auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Statement apply(final Statement statement, Description description) { CompatChange compatChange = description.getAnnotation(CompatChange.class); if (compatChange == null) { return statement; } return <START> new Statement() <END> { @Override public void evaluate() throws Throwable { try { Compatibility.setOverridesForTest(compatChange.enabled(), compatChange.disabled()); statement.evaluate(); } finally { Compatibility.unsetOverridesForTest(); } } }; }</code><technical_language>nit: consider extracting this a named static class (for example, avoids implicit "this" reference enclosing CompareChangeRule instance)</technical_language>

Target:
public Statement apply(final Statement statement, Description description) { Set<Long> enabled = new HashSet<>(); Set<Long> disabled = new HashSet<>(); EnableCompatChanges enableCompatChanges = description.getAnnotation(EnableCompatChanges.class); DisableCompatChanges disableCompatChanges = description.getAnnotation(DisableCompatChanges.class); if (enableCompatChanges != null) { for (long changeId: enableCompatChanges.value()) { enabled.add(changeId); } } if (disableCompatChanges != null) { for (long changeId: disableCompatChanges.value()) { disabled.add(changeId); } } if (enabled.isEmpty() && disabled.isEmpty()) { return statement; } return new CompatChangeStatement(statement, enabled, disabled); }
Source:
<code>public void run() throws OseeCoreException { TestUtil.setDemoDb(true); Branch atsBranch = AtsUtil.getAtsBranch(); SkynetTransaction transaction = TransactionManager.createTransaction(atsBranch, "Create ATS Folders"); Artifact headingArt = OseeSystemArtifacts.getOrCreateArtifact(AtsArtifactToken.HeadingFolder, atsBranch); Artifact oseeWebArt = ArtifactTypeManager.addArtifact(AtsArtifactToken.WebPrograms, AtsUtil.getAtsBranch()); oseeWebArt.persist(transaction); Artifact demoProgramsArt = ArtifactTypeManager.addArtifact(AtsArtifactToken.DemoPrograms, AtsUtil.getAtsBranch()); oseeWebArt.addRelation(CoreRelationTypes.Universal_Grouping__Members, demoProgramsArt); oseeWebArt.persist(transaction); <START> Artifact Sawteam = ArtifactQuery.getArtifactFromId("At2WHxFk5VVE2cafF5AA", AtsUtil.getAtsBranch()); <END> Sawteam.addRelation(CoreRelationTypes.SupportingInfo_SupportedBy, demoProgramsArt); Sawteam.persist(transaction); headingArt.addChild(oseeWebArt); headingArt.addChild(demoProgramsArt); headingArt.persist(transaction); transaction.execute(); }</code><technical_language>team capitalized. DemoArtifactToken.SAW_SW instead of hardcoded guid</technical_language>

Target:
public void run() throws OseeCoreException { TestUtil.setDemoDb(true); Branch atsBranch = AtsUtil.getAtsBranch(); SkynetTransaction transaction = TransactionManager.createTransaction(atsBranch, "Create ATS Folders"); Artifact headingArt = OseeSystemArtifacts.getOrCreateArtifact(AtsArtifactToken.HeadingFolder, atsBranch); Artifact oseeWebArt = ArtifactTypeManager.addArtifact(AtsArtifactToken.WebPrograms, atsBranch); oseeWebArt.persist(transaction); Artifact demoProgramsArt = ArtifactTypeManager.addArtifact(DemoArtifactToken.DemoPrograms, atsBranch); oseeWebArt.addRelation(CoreRelationTypes.Universal_Grouping__Members, demoProgramsArt); oseeWebArt.persist(transaction); Artifact sawTeam = ArtifactQuery.getArtifactFromToken(DemoArtifactToken.SAW_Bld_1, atsBranch); sawTeam.addRelation(CoreRelationTypes.SupportingInfo_SupportedBy, demoProgramsArt); sawTeam.persist(transaction); headingArt.addChild(oseeWebArt); headingArt.addChild(demoProgramsArt); headingArt.persist(transaction); transaction.execute(); }
Source:
<code>public void tearDown() { removeTempDatabase(props, database); <START> } <END></code><technical_language>delete users databases users a database in PostgreSQL</technical_language>

Target:
public void tearDown() { removeTempDatabase(props, database); removeRestrictedUser(props); }
Source:
<code>private void validateCountDistinct(Schema.Field inputField, FailureCollector collector, String validationFieldName) { if (inputField != null) { Schema.Type type = inputField.getSchema().isNullable() ? inputField.getSchema().getNonNullable().getType() : <START> inputField.getSchema().getType(); <END> if (type != Schema.Type.STRING && type != Schema.Type.INT && type != Schema.Type.LONG && type != Schema.Type.FLOAT && type != Schema.Type.DOUBLE && type != Schema.Type.BOOLEAN) { collector.addFailure( String.format("Distinct counting is not supported for the field %s of type %s.", inputField.getName(), type), "Please specify a string, integer, long, float, double or boolean field.") .withConfigElement("aggregates", validationFieldName); } } }</code><technical_language>sense allow float double? potentially out of memory easily, 0.000001 0.00000001, etc. In Java check equality of floats doubles IDEs flag a warning</technical_language>

Target:
private void validateCountDistinct(Schema.Field inputField, FailureCollector collector, String validationFieldName) { if (inputField != null) { Schema.Type type = inputField.getSchema().isNullable() ? inputField.getSchema().getNonNullable().getType() : inputField.getSchema().getType(); if (type != Schema.Type.STRING && type != Schema.Type.INT && type != Schema.Type.LONG && type != Schema.Type.BOOLEAN) { collector.addFailure( String.format("Distinct counting is not supported for the field %s of type %s.", inputField.getName(), type), "Please specify a string, integer, long or boolean field.") .withConfigElement("aggregates", validationFieldName); } } }
Source:
<code>public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Object object = method.invoke(producer, args); if (method.getName().equals("produce") && spiedClasses.contains(object.getClass())) { <START> object = spy(object); <END> } return object; }</code><technical_language>yea. A spy :)</technical_language>

Target:
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Object object = method.invoke(producer, args); if (object != null && method.getName().equals("produce") && spiedClasses.contains(object.getClass())) { object = spy(object); } return object; }
Source:
<code>public void pushSurveys(SurveyContainerWSObject surveyContainerWSObject, WSClientCallBack wsClientCallBack) { Response<SurveyWSResult> response = null; try { response = mSurveyApiClientRetrofit.pushSurveys( surveyContainerWSObject).execute(); } catch (UnrecognizedPropertyException e) { ConversionException conversionException = new ConversionException(e); wsClientCallBack.onError(conversionException); } catch (IOException e) { wsClientCallBack.onError(e); } if (response != null && response.code() == 401) { ConversionException conversionException = new ConversionException(null); wsClientCallBack.onError(conversionException); } else if (response != null && response.code() == 402) { <START> InvalidCreedentialsOnPushException invalidCredentialsException = <END> new InvalidCreedentialsOnPushException(); wsClientCallBack.onError(invalidCredentialsException); } else if (response != null && response.isSuccessful()) { wsClientCallBack.onSuccess(response.body()); } else { Log.e(TAG, "Failed response when pushing surveys"); wsClientCallBack.onError(new ConversionException(null)); } }</code><technical_language>is necessary create new InvalidCreedentialsOnPushException this error is HardCoded credentials, InvalidCredentialsException provoke Logout</technical_language>

Target:
public void pushSurveys(SurveyContainerWSObject surveyContainerWSObject, WSClientCallBack wsClientCallBack) { Response<SurveyWSResult> response = null; try { response = mSurveyApiClientRetrofit.pushSurveys( surveyContainerWSObject).execute(); } catch (UnrecognizedPropertyException e) { ConversionException conversionException = new ConversionException(e); wsClientCallBack.onError(conversionException); } catch (IOException e) { wsClientCallBack.onError(e); } if (response != null && response.code() == 401) { ConversionException conversionException = new ConversionException(null); wsClientCallBack.onError(conversionException); } else if (response != null && response.code() == 402) { InvalidCredentialsException invalidCredentialsException = new InvalidCredentialsException(); wsClientCallBack.onError(invalidCredentialsException); } else if (response != null && response.isSuccessful()) { wsClientCallBack.onSuccess(response.body()); } else { Log.e(TAG, "Failed response when pushing surveys"); wsClientCallBack.onError(new ConversionException(null)); } }
Source:
<code>public boolean downloadTemplate() { try { String mountSrcUuid = UUID.randomUUID().toString(); String mount = String.format(mountCommand, srcHost + ":" + srcPath, "/mnt/" + mountSrcUuid); Script.runSimpleBashScript(mount); String downloadDir = getDestPoolPath() + File.separator + getDirectDownloadTempPath(getTemplateId()); setDownloadedFilePath(downloadDir + File.separator + getFileNameFromUrl()); Script.runSimpleBashScript("cp /mnt/" + mountSrcUuid + srcPath + " " + getDownloadedFilePath()); Script.runSimpleBashScript("umount /mnt/" + mountSrcUuid); <START> } catch (Exception e) { <END> return false; } return true; }</code><technical_language>Do need this generic exception</technical_language>

Target:
public boolean downloadTemplate() { String mountSrcUuid = UUID.randomUUID().toString(); String mount = String.format(mountCommand, srcHost + ":" + srcPath, "/mnt/" + mountSrcUuid); Script.runSimpleBashScript(mount); String downloadDir = getDestPoolPath() + File.separator + getDirectDownloadTempPath(getTemplateId()); setDownloadedFilePath(downloadDir + File.separator + getFileNameFromUrl()); Script.runSimpleBashScript("cp /mnt/" + mountSrcUuid + srcPath + " " + getDownloadedFilePath()); Script.runSimpleBashScript("umount /mnt/" + mountSrcUuid); return true; }
Source:
<code>public float[] getIntensityValues(float[] intensityValues) { if (this.intensityValues == null) try { <START> parseScan(null, null); <END> } catch (IOException | InvalidRangeException e) { throw new MSDKRuntimeException(e); } return this.intensityValues; }</code><technical_language>This is wrong - intensity values saved this.intensityValues consume memory. idea is values parsed demand stored (unless Predicate set for scan). is enough memory data files, is point of on-demand parsing. Also, reference integrity - if return reference array, caller modifications array, modify parsed data. Instead copy data provided array (if data fit) create a new (if data fit)</technical_language>

Target:
public float[] getIntensityValues(float[] intensityValues) { if (preLoadedIntensityValues == null) { final Integer scanIndex = getScanIndex(); numOfDataPoints = getNumberOfDataPoints(); try { final int scanStartPosition[] = {scanStartPositions[scanIndex]}; final int scanLength[] = {scanStartPositions[scanIndex + 1] - scanStartPositions[scanIndex]}; final Array intensityValueArray = intensityValueVariable.read(scanStartPosition, scanLength); final Index intensityValuesIndex = intensityValueArray.getIndex(); if (intensityValues == null || intensityValues.length < numOfDataPoints) intensityValues = new float[numOfDataPoints]; for (int i = 0; i < numOfDataPoints; i++) { final Index intensityIndex0 = intensityValuesIndex.set0(i); intensityValues[i] = (float) (intensityValueArray.getDouble(intensityIndex0) * intensityValueScaleFactor); } } catch (IOException | InvalidRangeException e) { throw new MSDKRuntimeException(e); } } else { if (intensityValues == null || intensityValues.length < numOfDataPoints) intensityValues = new float[numOfDataPoints]; for (int i = 0; i < preLoadedIntensityValues.length; i++) intensityValues[i] = preLoadedIntensityValues[i]; } return intensityValues; }
Source:
<code><START> public IFolder getDestinationFolder() { <END> return fRelativeDestinationFolder; }</code><technical_language>this named getRelativeDestinationFolder then? in ImportHandler.java is relative field needs renamed</technical_language>

Target:
public IFolder getDestinationFolder() { return fDestinationFolder; }
Source:
<code>public void addNode(RepositoryTreeNode<?> treeNode, Object timeCarrier) { if (filtering) { int time = Integer.MIN_VALUE; if (timeCarrier instanceof RevCommit) { time = ((RevCommit) timeCarrier).getCommitTime(); } if (time >= thresholdTime) { TimedNode node = new TimedNode(treeNode, time); nodes.add(node); int size = nodes.size(); if (size > maxCount) { Collections.sort(nodes); nodes = nodes.subList(size - maxCount, size); <START> thresholdTime = nodes.get(0).time; <END> } } } else { allNodes.add(treeNode); } }</code><technical_language>maxCount elements, O(n * log(n)) for insert (sorting n elements, n == maxCount). Moreover, list is sorted for element. this is a job for a PriorityQueue, ordered oldest tag is front of queue. add, if size > maxCount, poll discard (it'll old), set thresholdTime = queue.peek().time; addNode O(log(n))</technical_language>

Target:
public void addNode(RepositoryTreeNode<?> treeNode, Object timeCarrier) { if (isFiltering()) { int time = Integer.MIN_VALUE; if (timeCarrier instanceof RevCommit) { time = ((RevCommit) timeCarrier).getCommitTime(); } if (time >= thresholdTime) { TimedNode node = new TimedNode(treeNode, time); nodes.add(node); int size = nodes.size(); if (size > maxCount) { Collections.sort(nodes); nodes = nodes.subList(size - maxCount, size); thresholdTime = nodes.get(0).time; } } } else { allNodes.add(treeNode); } }
Source:
<code>private ResponseEntity<?> doExecuteForReturnType(String url, Object requestData, Method method, RestTemplate restTemplate) { ResponseEntity<?> response = method.execute(restTemplate, url, requestData); <START> String body = (response.getBody() == null) ? "" : response.getBody().toString(); <END> sendAuditLog(url, requestData, body, response.getStatusCode().toString()); if (RestUtility.isError(response.getStatusCode())) { return null; } else { return response; } }</code><technical_language>Unnecessary parentheses</technical_language>

Target:
private ResponseEntity<?> doExecuteForReturnType(String url, Object requestData, Method method, RestTemplate restTemplate) { ResponseEntity<?> response = method.execute(restTemplate, url, requestData); String body = response.getBody() == null ? StringUtils.EMPTY : response.getBody().toString(); sendAuditLog(url, requestData, body, response.getStatusCode().toString()); if (RestUtility.isError(response.getStatusCode())) { return null; } else { return response; } }
Source:
<code>public String findMailAddressFor(User u) { if (disabled) return null; String username = u.getId(); for (JiraSite site : JiraGlobalConfiguration.getInstance().getSites()) { JiraSession session = site.getSession(); if (session == null) { continue; } com.atlassian.jira.rest.client.api.domain.User user = session.service <START> .getUser(username); <END> if (user != null) { String email = user.getEmailAddress(); if (email != null) { email = unmaskEmail(email); return email; } } } return null; }</code><technical_language>do partial reformatting part of a functional PR. In other words, current formatting for unrelated changes, if want change line lengths, do for source code in a separate PR</technical_language>

Target:
public String findMailAddressFor(User u) { if (disabled) return null; String username = u.getId(); for (JiraSite site : JiraGlobalConfiguration.get().getSites()) { JiraSession session = site.getSession(); if (session == null) { continue; } com.atlassian.jira.rest.client.api.domain.User user = session.service.getUser(username); if (user != null) { String email = user.getEmailAddress(); if (email != null) { email = unmaskEmail(email); return email; } } } return null; }
Source:
<code><START> public void testFrameworkProducerUpdate() throws Exception { <END> setupFrameworkProducer(false); Exchange mockExchange = mock(Exchange.class); Message message = mock(Message.class); when(mockExchange.getIn()).thenReturn(message); when(mockExchange.getOut()).thenReturn(message); when(mockExchange.getIn().getHeader(OPERATION_HEADER_KEY)).thenReturn(UPDATE_OPERATION); when(mockExchange.getIn().getHeader(TIMEOUT_HEADER_KEY)).thenReturn(1000L); when(mockExchange.getIn().getBody()).thenReturn(new MetacardImpl()); when(mockExchange.getIn().getBody(any())).thenReturn(new MetacardImpl()); frameworkProducer.process(mockExchange); }</code><technical_language>This test needs a verification</technical_language>

Target:
public void testFrameworkProducerUpdate() throws Exception { setupFrameworkProducer(false); Exchange mockExchange = mock(Exchange.class); Message message = mock(Message.class); when(mockExchange.getIn()).thenReturn(message); when(mockExchange.getOut()).thenReturn(message); when(mockExchange.getIn().getHeader(OPERATION_HEADER_KEY)).thenReturn(UPDATE_OPERATION); when(mockExchange.getIn().getHeader(TIMEOUT_HEADER_KEY)).thenReturn(1000L); when(mockExchange.getIn().getBody()).thenReturn(new MetacardImpl()); when(mockExchange.getIn().getBody(any())).thenReturn(new MetacardImpl()); frameworkProducer.process(mockExchange); verify(catalogFramework).update(any(UpdateRequest.class)); }
Source:
<code>public boolean isVersioningEnabled(IsVersioningEnabledArgs args) throws ErrorResponseException, IllegalArgumentException, InsufficientDataException, InternalException, InvalidBucketNameException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, XmlParserException { checkArgs(args); Map<String, String> queryParamMap = new HashMap<>(); queryParamMap.put("versioning", ""); try (Response response = executeGet(args.bucket(), null, null, queryParamMap)) { VersioningConfiguration result = Xml.unmarshal(VersioningConfiguration.class, response.body().charStream()); return result.status(); } catch (ErrorResponseException e) { <START> if (e.errorResponse().errorCode() != ErrorCode.ILLEGAL_VERSIONING_CONFIGURATION_EXCEPTION) { <END> throw e; } } return false; }</code><technical_language>do get this error</technical_language>

Target:
public boolean isVersioningEnabled(IsVersioningEnabledArgs args) throws ErrorResponseException, IllegalArgumentException, InsufficientDataException, InternalException, InvalidBucketNameException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, XmlParserException { checkArgs(args); Map<String, String> queryParamMap = new HashMap<>(); queryParamMap.put("versioning", ""); try (Response response = executeGet(args.bucket(), null, null, queryParamMap)) { VersioningConfiguration result = Xml.unmarshal(VersioningConfiguration.class, response.body().charStream()); return result.status(); } }
Source:
<code>public List<Sprite> getAllClonesOfSprite(Sprite sprite) { List<Sprite> clonesOfSprite = new ArrayList<Sprite>(); Pattern pattern = createCloneRegexPattern(sprite.getName()); for (Sprite spriteOfStage : sprites) { <START> Matcher matcher = pattern.matcher(spriteOfStage.getName()); <END> if (spriteOfStage.isClone && matcher.matches()) { clonesOfSprite.add(spriteOfStage); } } return clonesOfSprite; }</code><technical_language>skip this if spriteOfStage.isClone is false</technical_language>

Target:
public List<Sprite> getAllClonesOfSprite(Sprite sprite) { List<Sprite> clonesOfSprite = new ArrayList<>(); Pattern pattern = createCloneRegexPattern(sprite.getName()); for (Sprite spriteOfStage : sprites) { if (!spriteOfStage.isClone) { continue; } Matcher matcher = pattern.matcher(spriteOfStage.getName()); if (matcher.matches()) { clonesOfSprite.add(spriteOfStage); } } return clonesOfSprite; }
Source:
<code>public void shouldExecuteOnlyWhenNecessary() { DefaultFileSystem fileSystemPython = new DefaultFileSystem(); DefaultFileSystem fileSystemForeign = new DefaultFileSystem(); <START> DefaultInputFile inputFile1 = new DefaultInputFile("src/test/resources/example_project/example.swift").setLanguage(Python.KEY); <END> inputFile1.setAbsolutePath((new File("src/test/resources/example_project/example.swift")).getAbsolutePath()); fileSystemPython.add(inputFile1); Project pythonProject = mock(Project.class); Project foreignProject = mock(Project.class); RulesProfile emptyProfile = mock(RulesProfile.class); RulesProfile pylintProfile = createPylintProfile(); checkNecessityOfExecution(pythonProject, pylintProfile, fileSystemPython, true); checkNecessityOfExecution(pythonProject, emptyProfile, fileSystemPython, false); checkNecessityOfExecution(foreignProject, pylintProfile, fileSystemForeign, false); checkNecessityOfExecution(foreignProject, emptyProfile, fileSystemForeign, false); }</code><technical_language>strange example..</technical_language>

Target:
public void shouldExecuteOnlyWhenNecessary() { DefaultFileSystem fileSystemPython = new DefaultFileSystem(); DefaultFileSystem fileSystemForeign = new DefaultFileSystem(); DefaultInputFile inputFile1 = new DefaultInputFile("src/test/resources/example_project/example.py").setLanguage(Python.KEY); inputFile1.setAbsolutePath((new File("src/test/resources/example_project/example.py")).getAbsolutePath()); fileSystemPython.add(inputFile1); Project pythonProject = mock(Project.class); Project foreignProject = mock(Project.class); RulesProfile emptyProfile = mock(RulesProfile.class); RulesProfile pylintProfile = createPylintProfile(); checkNecessityOfExecution(pythonProject, pylintProfile, fileSystemPython, true); checkNecessityOfExecution(pythonProject, emptyProfile, fileSystemPython, false); checkNecessityOfExecution(foreignProject, pylintProfile, fileSystemForeign, false); checkNecessityOfExecution(foreignProject, emptyProfile, fileSystemForeign, false); }
Source:
<code>public List<EmailWrapper> generateFeedbackSessionClosedEmails(FeedbackSessionAttributes session) { <START> boolean isEmailNeeded = fsLogic.isFeedbackSessionForStudentsToAnswer(session); <END> CourseAttributes course = coursesLogic.getCourse(session.getCourseId()); List<InstructorAttributes> instructors = isEmailNeeded ? instructorsLogic.getInstructorsForCourse(session.getCourseId()) : new ArrayList<InstructorAttributes>(); List<EmailWrapper> emails = generateFeedbackSessionClosedEmail(course, session, instructors); return emails; }</code><technical_language>This means if session is for students, closed email sent. is a sufficient condition for email sent? A session questions for instructors</technical_language>

Target:
public List<EmailWrapper> generateFeedbackSessionClosedEmails(FeedbackSessionAttributes session) { if (session.isPrivateSession()) { return new ArrayList<EmailWrapper>(); } CourseAttributes course = coursesLogic.getCourse(session.getCourseId()); boolean isEmailNeededForStudents = false; try { isEmailNeededForStudents = fsLogic.isFeedbackSessionHasQuestionForStudents( session.getFeedbackSessionName(), session.getCourseId()); } catch (EntityDoesNotExistException e) { log.severe("Course " + session.getCourseId() + " does not exist or " + "session " + session.getFeedbackSessionName() + " does not exist"); } List<InstructorAttributes> instructors = instructorsLogic.getInstructorsForCourse(session.getCourseId()); List<StudentAttributes> students = isEmailNeededForStudents ? studentsLogic.getStudentsForCourse(session.getCourseId()) : new ArrayList<StudentAttributes>(); return generateFeedbackSessionClosedEmail(course, session, instructors, students); }
Source:
<code>protected List<SortInfo> getSortInfo(String sortBy, String sortOrder) { List<SortInfo> sortInfoList = null; if (!StringUtils.isBlank(sortBy)) { String[] sorts = sortBy.split(","); String[] orders = null; if (!StringUtils.isBlank(sortOrder)) { orders = sortOrder.split(","); } if (sorts.length > 0) { sortInfoList = new ArrayList<>(); } for (int i = 0; i < sorts.length; i++) { String sort = sorts[i]; <START> boolean sortAscending = (orders != null && orders.length > i && orders[i].equalsIgnoreCase("asc")); <END> sortInfoList.add(new SortInfo(sort, sortAscending)); } } return sortInfoList; }</code><technical_language>keeping "asc" object call equals method</technical_language>

Target:
protected List<SortInfo> getSortInfo(String sortBy, String sortOrder) { List<SortInfo> sortInfoList = null; if (!StringUtils.isBlank(sortBy)) { String[] sorts = sortBy.split(","); String[] orders = null; if (!StringUtils.isBlank(sortOrder)) { orders = sortOrder.split(","); } if (sorts.length > 0) { sortInfoList = new ArrayList<>(); } for (int i = 0; i < sorts.length; i++) { String sort = sorts[i]; boolean sortAscending = orders != null && orders.length > i && "asc".equalsIgnoreCase(orders[i]); sortInfoList.add(new SortInfo(sort, sortAscending)); } } return sortInfoList; }
Source:
<code>public String getLocalNameFromDelegate( AbstractLiteralIV<BigdataLiteral, ?> delegate) { final BigInteger bigintVal; if (delegate instanceof XSDIntegerIV) { bigintVal = ((XSDIntegerIV<?>)delegate).getInlineValue(); } else { final String intStr = super.getLocalNameFromDelegate(delegate); bigintVal = new BigInteger(intStr, 10); } <START> String localName = bigintVal.toString(16); if (localName.length() < fixedWidth) { localName = zeroPadding.substring(localName.length()) + localName; } <END> return localName; }</code><technical_language>Padding extracted in a separate method. (I argue int another method, I sense some opposition there)</technical_language>

Target:
public String getLocalNameFromDelegate( AbstractLiteralIV<BigdataLiteral, ?> delegate) { final BigInteger bigintVal; if (delegate instanceof XSDIntegerIV) { bigintVal = ((XSDIntegerIV<?>)delegate).getInlineValue(); } else { final String intStr = super.getLocalNameFromDelegate(delegate); bigintVal = new BigInteger(intStr, 10); } String localName = toFixedWidthHexString(bigintVal); return localName; }
Source:
<code>public Page getNextPage() { if (isFinished()) { close(); return null; } if (!isPinotDataFetched) { fetchPinotData(); } if (currentDataTable != null) { estimatedMemoryUsageInBytes -= currentDataTable.getEstimatedSizeInBytes(); } if (dataTableList.size() == 0) { close(); return null; } currentDataTable = dataTableList.pop(); List<PinotColumnHandle> expectedColumnHandles = split.getExpectedColumnHandles(); PageBuilder pageBuilder = new PageBuilder(columnTypes); pageBuilder.declarePositions(currentDataTable.getDataTable().getNumberOfRows()); for (int columnHandleIdx = 0; columnHandleIdx < columnHandles.size(); columnHandleIdx++) { BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(columnHandleIdx); Type columnType = columnTypes.get(columnHandleIdx); <START> PinotColumnHandle handle = columnHandles.get(columnHandleIdx); <END> int idxReturnedByPinot = expectedColumnHandles.indexOf(handle); if (idxReturnedByPinot < 0) { throw new PinotException(PinotErrorCode.PINOT_INVALID_PQL_GENERATED, split.getSegmentPql(), String.format("Expected column handle %s to be present in the handles %s corresponding to the segment PQL", handle, expectedColumnHandles)); } writeBlock(blockBuilder, columnType, idxReturnedByPinot); } return pageBuilder.build(); }</code><technical_language>s/columnHandleIdx/columnHandleIndex/g</technical_language>

Target:
public Page getNextPage() { if (isFinished()) { close(); return null; } if (!isPinotDataFetched) { fetchPinotData(); } if (currentDataTable != null) { estimatedMemoryUsageInBytes -= currentDataTable.getEstimatedSizeInBytes(); } if (dataTableList.size() == 0) { close(); return null; } currentDataTable = dataTableList.pop(); List<PinotColumnHandle> expectedColumnHandles = split.getExpectedColumnHandles(); PageBuilder pageBuilder = new PageBuilder(columnTypes); pageBuilder.declarePositions(currentDataTable.getDataTable().getNumberOfRows()); for (int columnHandleIndex = 0; columnHandleIndex < columnHandles.size(); columnHandleIndex++) { BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(columnHandleIndex); Type columnType = columnTypes.get(columnHandleIndex); PinotColumnHandle handle = columnHandles.get(columnHandleIndex); int indexReturnedByPinot = expectedColumnHandles.indexOf(handle); if (indexReturnedByPinot < 0) { throw new PinotException( PINOT_INVALID_PQL_GENERATED, split.getSegmentPql(), String.format("Expected column handle %s to be present in the handles %s corresponding to the segment PQL", handle, expectedColumnHandles)); } writeBlock(blockBuilder, columnType, indexReturnedByPinot); } return pageBuilder.build(); }
Source:
<code>protected void parseSplitSampleData(Variant variant, String fileId, String studyId, String[] fields, String[] alternateAlleles, String[] secondaryAlternates, int alternateAlleleIdx) throws NonStandardCompliantSampleField, NotAVariantException { String[] formatFields = variant.getSourceEntry(fileId, studyId).getFormat().split(":"); for (int i = 9; i < fields.length; i++) { Map<String, String> map = new TreeMap<>(); int countreferencegenotypes=0; String[] sampleFields = fields[i].split(":"); for (int j = 0; j < sampleFields.length; j++) { <START> if(sampleFields[j].equals("./.") || sampleFields.equals("0/0") || sampleFields.equals("0|0")){ <END> countreferencegenotypes++; } String formatField = formatFields[j]; String sampleField = processSampleField(alternateAlleleIdx, formatField, sampleFields[j]); map.put(formatField, sampleField); if(countreferencegenotypes == sampleFields.length){ throw new NotAVariantException("all the sample genotypes are non-variant"); }else{ variant.getSourceEntry(fileId, studyId).addSampleData(map); } } } }</code><technical_language>check this if sampleField is genotypes (formatFields[0] == "GT")</technical_language>

Target:
protected void parseSplitSampleData(Variant variant, String fileId, String studyId, String[] fields, String[] alternateAlleles, String[] secondaryAlternates, int alternateAlleleIdx) throws NonStandardCompliantSampleField, NotAVariantException { String[] formatFields = variant.getSourceEntry(fileId, studyId).getFormat().split(":"); for (int i = 9; i < fields.length; i++) { Map<String, String> map = new TreeMap<>(); int countReferenceGenotypes = 0; String[] sampleFields = fields[i].split(":"); for (int j = 0; j < sampleFields.length; j++) { if(formatFields[0].equals("GT")){ if(sampleFields[j].equals("./.") || sampleFields[j].equals("0/0") || sampleFields[j].equals("0|0")){ countReferenceGenotypes++; } } String formatField = formatFields[j]; String sampleField = processSampleField(alternateAlleleIdx, formatField, sampleFields[j]); map.put(formatField, sampleField); if(countReferenceGenotypes == sampleFields.length){ throw new NotAVariantException("all the sample genotypes are non-variant"); }else{ variant.getSourceEntry(fileId, studyId).addSampleData(map); } } } }
Source:
<code>TopologyMaster.MetricResponse getMetricsFromMetricsCache( String metric, String component, Instant start, Duration duration) { TopologyMaster.MetricRequest request = TopologyMaster.MetricRequest.newBuilder() .setComponentName(component) .setExplicitInterval( MetricInterval.newBuilder() .setStart(start.getEpochSecond()) .setEnd(start.plus(duration).getEpochSecond()) .build()) .addMetric(metric) .build(); <START> LOG.info("MetricsCache Query request: " + request.toString()); <END> NetworkUtils.sendHttpPostRequest(con, "X", request.toByteArray()); byte[] responseData = NetworkUtils.readHttpResponse(con); try { TopologyMaster.MetricResponse response = TopologyMaster.MetricResponse.parseFrom(responseData); LOG.info("MetricsCache Query response: " + response.toString()); return response; } catch (com.google.protobuf.InvalidProtocolBufferException e) { LOG.severe("protobuf cannot parse the reply from MetricsCache " + e); return null; } }</code><technical_language>Is info level logging required here</technical_language>

Target:
TopologyMaster.MetricResponse getMetricsFromMetricsCache( String metric, String component, Instant start, Duration duration) { TopologyMaster.MetricRequest request = TopologyMaster.MetricRequest.newBuilder() .setComponentName(component) .setExplicitInterval( MetricInterval.newBuilder() .setStart(start.getEpochSecond()) .setEnd(start.plus(duration).getEpochSecond()) .build()) .addMetric(metric) .build(); LOG.log(Level.FINE, "MetricsCache Query request: %s", request); NetworkUtils.sendHttpPostRequest(con, "X", request.toByteArray()); byte[] responseData = NetworkUtils.readHttpResponse(con); try { TopologyMaster.MetricResponse response = TopologyMaster.MetricResponse.parseFrom(responseData); LOG.log(Level.FINE, "MetricsCache Query response: %s", response); return response; } catch (com.google.protobuf.InvalidProtocolBufferException e) { LOG.severe("protobuf cannot parse the reply from MetricsCache " + e); return null; } }
Source:
<code>public static void notifyNodeCommandException(Project project) { Notification notification = new Notification(GROUP_ANALYSIS_PROBLEM, <START> "<b>SonarLint - Unmet Analysis Requirement</b>", <END> "Node.js >= 8.x is required to perform JavaScript or TypeScript analysis. Check the <a href='#'>SonarLint Log</a> for details.", NotificationType.WARNING, new ShowSonarLintLogListener(project)); notification.setImportant(true); notification.notify(project); }</code><technical_language>I title (at I seen). In SLE simply title: SonarLint - Node.js required</technical_language>

Target:
public static void notifyNodeCommandException(Project project) { Notification notification = new Notification(GROUP_ANALYSIS_PROBLEM, "<b>SonarLint - Node.js Required</b>", "Node.js >= 8.x is required to perform JavaScript or TypeScript analysis. Check the <a href='#'>SonarLint Log</a> for details.", NotificationType.WARNING, new ShowSonarLintLogListener(project)); notification.setImportant(true); notification.notify(project); }
Source:
<code>static Func1<ChangeNotification<InstanceInfo>, Observable<ChangeNotification<InstanceInfo>>> bufferStartEndDelineateFun(Interest<InstanceInfo> interest) { final ChangeNotification<InstanceInfo> bufferStartNotification = StreamStateNotification.bufferStartNotification(interest); final ChangeNotification<InstanceInfo> bufferEndNotification = StreamStateNotification.bufferEndNotification(interest); final List<ChangeNotification<InstanceInfo>> buffer = new ArrayList<>(); return new Func1<ChangeNotification<InstanceInfo>, Observable<ChangeNotification<InstanceInfo>>>() { @Override public Observable<ChangeNotification<InstanceInfo>> call(ChangeNotification<InstanceInfo> notification) { if (notification.getKind() != Kind.BufferSentinel) { buffer.add(notification); return Observable.empty(); } if (buffer.isEmpty()) { return Observable.empty(); } Observable<ChangeNotification<InstanceInfo>> result; if (buffer.size() == 1) { result = Observable.just(buffer.get(0)); } else { List<ChangeNotification<InstanceInfo>> batch = new ArrayList<>(2 + buffer.size()); batch.add(bufferStartNotification); <START> for (ChangeNotification<InstanceInfo> item : buffer) { <END> batch.add(item); } batch.add(bufferEndNotification); result = Observable.from(batch); } buffer.clear(); return result; } }; }</code><technical_language>do addAll(buffer)</technical_language>

Target:
static Func1<ChangeNotification<InstanceInfo>, Observable<ChangeNotification<InstanceInfo>>> bufferStartEndDelineateFun(Interest<InstanceInfo> interest) { final ChangeNotification<InstanceInfo> bufferStartNotification = StreamStateNotification.bufferStartNotification(interest); final ChangeNotification<InstanceInfo> bufferEndNotification = StreamStateNotification.bufferEndNotification(interest); final List<ChangeNotification<InstanceInfo>> buffer = new ArrayList<>(); return new Func1<ChangeNotification<InstanceInfo>, Observable<ChangeNotification<InstanceInfo>>>() { @Override public Observable<ChangeNotification<InstanceInfo>> call(ChangeNotification<InstanceInfo> notification) { if (notification.getKind() != Kind.BufferSentinel) { buffer.add(notification); return Observable.empty(); } if (buffer.isEmpty()) { return Observable.empty(); } Observable<ChangeNotification<InstanceInfo>> result; if (buffer.size() == 1) { result = Observable.just(buffer.get(0)); } else { List<ChangeNotification<InstanceInfo>> batch = new ArrayList<>(2 + buffer.size()); batch.add(bufferStartNotification); batch.addAll(buffer); batch.add(bufferEndNotification); result = Observable.from(batch); } buffer.clear(); return result; } }; }
Source:
<code>public void incrementGoalStats() throws MojoExecutionException { try { loadStatistics(); if(sdkStatistics.getStatsEnabled() && wizard.isInteractiveMode()){ String goal = getGoal(); if (StringUtils.isNotBlank(goal)) { sdkStatistics.incrementGoal(goal); sdkStatistics.setLastUsed(); sdkStatistics.save(); } sdkStatistics.sendReport(wizard); } } catch (Exception e) { <START> wizard.showMessage("Failed to send anonymous user statistics"); <END> } }</code><technical_language>append e.getMessage() give clue user why</technical_language>

Target:
public void incrementGoalStats() throws MojoExecutionException { try { loadStatistics(); if(sdkStatistics.getStatsEnabled() && wizard.isInteractiveMode()){ String goal = getGoal(); if (StringUtils.isNotBlank(goal)) { sdkStatistics.incrementGoal(goal); sdkStatistics.setLastUsed(); sdkStatistics.save(); } sdkStatistics.sendReport(wizard); } } catch (Exception e) { wizard.showMessage("Failed to send anonymous user statistics. " + e.getMessage()); } }
Source:
<code>public void testProcessingCatalog() { String variable = "%{translate}"; String translation = "Translate"; String catalog = "..." + variable + "..."; <START> MondrianProperties.instance().LocalePropFile.set( "resources.properties" ); <END> DynamicSchemaProcessor dsp = new LocalizingDynamicSchemaProcessor(); Util.PropertyList connectInfo = new Util.PropertyList(); try { String catalogProcessed = dsp.processCatalog(catalog, connectInfo); assertEquals( catalog.replace( variable, translation ), catalogProcessed ); } catch (Exception e) { assertEquals(0, 1); } }</code><technical_language>here: - Is a external files? I idea of external test file. refactor a method override in next line create LDSP. If not, put file in a proper folder, root of test resources. - property needs reset end of this test method. Normally, of test subclasses of FoodMartTest, exposes propSaver protected object. Setting properties propSaver automatically reset test. worth into</technical_language>

Target:
public void testProcessingCatalog() { String variable = "%{translate}"; String translation = "Translate"; String catalog = "..." + variable + "..."; MondrianProperties.instance().LocalePropFile.set("mondrian/i18n/LocalizingDynamicSchemaProcessor/resources.properties" ); DynamicSchemaProcessor dsp = new LocalizingDynamicSchemaProcessor(); Util.PropertyList connectInfo = new Util.PropertyList(); try { String catalogProcessed = dsp.processCatalog(catalog, connectInfo); assertEquals( catalog.replace( variable, translation ), catalogProcessed ); } catch (Exception e) { assertEquals(0, 1); } MondrianProperties.instance().LocalePropFile.set( "" ); }
Source:
<code>public static void closeView(String title, SWTWorkbenchBot bot) { <START> final List<SWTBotView> openViews = bot.views(); <END> for (SWTBotView view : openViews) { if (view.getTitle().toLowerCase().equals(title.toLowerCase())) { view.close(); bot.waitUntil(ConditionHelpers.ViewIsClosed(view)); } } }</code><technical_language>bot.viewByTitle instead of looping</technical_language>

Target:
public static void closeView(String title, SWTWorkbenchBot bot) { final List<SWTBotView> openViews = bot.views(); for (SWTBotView view : openViews) { if (view.getTitle().equalsIgnoreCase(title)) { view.close(); bot.waitUntil(ConditionHelpers.ViewIsClosed(view)); } } }
Source:
<code>private static Optional<List<Tree>> findIssueForOperand(Expression expr) { if (instantiatesFreshObject(expr)) { return Optional.of(Collections.emptyList()); } else if (expr.is(Tree.Kind.NAME)) { Name name = (Name) expr; Expression rhs = Expressions.singleAssignedValue((Name) expr); <START> if (rhs != null && instantiatesFreshObject(rhs) && cannotEscape(name.symbol())) { <END> return Optional.of(Collections.singletonList(rhs)); } } return Optional.empty(); }</code><technical_language>This is a bit nitpicky I if assign name.symbol() a variable test for null early return calling Expressions.singleAssignedValue remove null checks cannotEscape method achieve 100% coverage</technical_language>

Target:
private static Optional<List<Tree>> findIssueForOperand(Expression expr) { if (instantiatesFreshObject(expr)) { return Optional.of(Collections.emptyList()); } else if (expr.is(Tree.Kind.NAME)) { Name name = (Name) expr; Symbol symb = name.symbol(); if (symb != null) { Expression rhs = Expressions.singleAssignedValue((Name) expr); if (rhs != null && instantiatesFreshObject(rhs) && cannotEscape(symb)) { return Optional.of(Collections.singletonList(rhs)); } } } return Optional.empty(); }
Source:
<code>private Request startBlockwiseUpload(final Exchange exchange, final Request request) { final KeyUri key = getKey(exchange, request); synchronized (block1Transfers) { Block1BlockwiseStatus status = getBlock1Status(key); if (status != null) { status.cancelRequest(); clearBlock1Status(key); } status = getOutboundBlock1Status(key, exchange, request); final Request block = status.getNextRequestBlock(); block.addMessageObserver(new MessageObserverAdapter() { private void copyToken() { request.setToken(block.getToken()); } @Override public void onAcknowledgement() { copyToken(); } @Override public void onReject() { copyToken(); clearBlock1Status(key); } @Override public void onTimeout() { copyToken(); clearBlock1Status(key); } @Override public void onCancel() { <START> clearBlock1Status(key); <END> } @Override public void onSendError(Throwable error) { copyToken(); clearBlock1Status(key); } }); return block; } }</code><technical_language>copyToken() "onSent"</technical_language>

Target:
private Request startBlockwiseUpload(final Exchange exchange, final Request request) { final KeyUri key = getKey(exchange, request); synchronized (block1Transfers) { Block1BlockwiseStatus status = getBlock1Status(key); if (status != null) { status.cancelRequest(); clearBlock1Status(key); } status = getOutboundBlock1Status(key, exchange, request); final Request block = status.getNextRequestBlock(); block.addMessageObserver(new MessageObserverAdapter() { private void copyToken() { request.setToken(block.getToken()); } @Override public void onCancel() { failed(); } @Override public void onSent() { copyToken(); } @Override public void onSendError(Throwable error) { copyToken(); failed(); } @Override public void failed() { clearBlock1Status(key); } }); return block; } }
Source:
<code>private String getImageDaemonUri(String daemonHostname) { <START> String scheme = Config.<Boolean>getValue(ConfigValues.ImageDaemonSSLEnabled) ? "https" : "http"; <END> String port = Config.getValue(ConfigValues.ImageDaemonPort); return scheme + "://" + daemonHostname + ":" + port; }</code><technical_language>imageio-daemon configured http, I need this option. add http support if a requirement</technical_language>

Target:
private String getImageDaemonUri(String daemonHostname) { String port = Config.getValue(ConfigValues.ImageDaemonPort); return "https://" + daemonHostname + ":" + port; }
Source:
<code>protected void loadInterstitial(Context context, CustomEventInterstitialListener listener, Map<String, Object> localExtras, Map<String, String> serverExtras) { if (context == null) { Log.e(LOG_TAG, "Context cannot be null."); listener.onInterstitialFailed(ADAPTER_CONFIGURATION_ERROR); return; } if (listener == null) { Log.e(LOG_TAG, "CustomEventInterstitialListener cannot be null."); return; } if (!(context instanceof Activity)) { Log.e(LOG_TAG, "Ad can be rendered only in Activity context."); listener.onInterstitialFailed(ADAPTER_CONFIGURATION_ERROR); return; } if (!extrasAreValid(serverExtras)) { listener.onInterstitialFailed(ADAPTER_CONFIGURATION_ERROR); return; } mContext = context; mListener = listener; String apiKey = serverExtras.get(FlurryAgentWrapper.PARAM_API_KEY); <START> mAdSpaceName = serverExtras.get(FlurryAgentWrapper.PARAM_AD_SPACE_NAME); <END> FlurryAgentWrapper.getInstance().startSession(context, apiKey, null); Log.d(LOG_TAG, "Fetching Flurry ad, ad unit name:" + mAdSpaceName); mInterstitial = new FlurryAdInterstitial(mContext, mAdSpaceName); mInterstitial.setListener(new FlurryMopubInterstitialListener()); mInterstitial.fetchAd(); }</code><technical_language>assume a potential illegal argument exception here, too, if adSpaceName=""</technical_language>

Target:
protected void loadInterstitial(Context context, CustomEventInterstitialListener listener, Map<String, Object> localExtras, Map<String, String> serverExtras) { if (context == null) { Log.e(LOG_TAG, "Context cannot be null."); listener.onInterstitialFailed(ADAPTER_CONFIGURATION_ERROR); return; } if (listener == null) { Log.e(LOG_TAG, "CustomEventInterstitialListener cannot be null."); return; } if (!(context instanceof Activity)) { Log.e(LOG_TAG, "Ad can be rendered only in Activity context."); listener.onInterstitialFailed(ADAPTER_CONFIGURATION_ERROR); return; } if (!validateExtras(serverExtras)) { Log.e(LOG_TAG, "Failed interstitial ad fetch: Missing required server extras" + " [FLURRY_APIKEY and/or FLURRY_ADSPACE]."); listener.onInterstitialFailed(ADAPTER_CONFIGURATION_ERROR); return; } mContext = context; mListener = listener; String apiKey = serverExtras.get(FlurryAgentWrapper.PARAM_API_KEY); mAdSpaceName = serverExtras.get(FlurryAgentWrapper.PARAM_AD_SPACE_NAME); FlurryAgentWrapper.getInstance().startSession(context, apiKey, null); Log.d(LOG_TAG, "Fetching Flurry ad, ad unit name:" + mAdSpaceName); mInterstitial = new FlurryAdInterstitial(mContext, mAdSpaceName); mInterstitial.setListener(new FlurryMopubInterstitialListener()); mInterstitial.fetchAd(); }
Source:
<code>public boolean execute(MatchingFrame frame, ISearchContext context) throws LocalSearchException { if (it.hasNext()) { final Tuple next = it.next(); for (int i = 0; i < positions.length; i++) { <START> frame.setValue(positions[i], next.get(i)); <END> } return true; } else { return false; } }</code><technical_language>if bound a (e.g. in case of loop edge)? perform equality check for analogous pattern call extend</technical_language>

Target:
public boolean execute(MatchingFrame frame, ISearchContext context) throws LocalSearchException { if (it.hasNext()) { final Tuple next = it.next(); for (Integer position : unboundVariableIndex) { frame.setValue(position, null); } for (int i = 0; i < positions.length; i++) { Object newValue = next.get(i); Object oldValue = frame.getValue(positions[i]); if (oldValue != null && !Objects.equals(oldValue, newValue)) { return false; } frame.setValue(positions[i], newValue); } return true; } else { return false; } }
Source:
<code>public void testAboutDialog() throws IOException { solo.clickOnMenuItem("About"); <START> solo.sleep(2000); <END> assertTrue("Could not find the dialog!", solo.searchText("Musicdroid")); }</code><technical_language>solo.waitForDialogToOpen() instead of sleep</technical_language>

Target:
public void testAboutDialog() throws IOException { solo.clickOnMenuItem(getActivity().getResources().getString(R.string.action_project_about)); solo.waitForDialogToOpen(); assertTrue(solo.searchText(getActivity().getResources().getString(R.string.about_Dialog))); }
Source:
<code>private void moveResource(Resource resource, Path path, Notification notification) { if (resource.isProject()) { closeRelatedEditors(resource); } resource .move(path) .then( <START> arg -> { <END> if (arg.isFolder()) { return; } final List<EditorPartPresenter> openedEditors = editorAgent.getOpenedEditors(); for (EditorPartPresenter editor : openedEditors) { VirtualFile file = editor.getEditorInput().getFile(); if (arg.getLocation().equals(file.getLocation())) { eventBus.fireEvent(FileEvent.createFileOpenedEvent(file)); return; } } }) .catchError( arg -> { notification.setContent(arg.getMessage()); }); }</code><technical_language>arg is a good name</technical_language>

Target:
private void moveResource(Resource resource, Path path, Notification notification) { if (resource.isProject()) { closeRelatedEditors(resource); } resource .move(path) .then( movedResource -> { if (movedResource.isFolder()) { return; } final List<EditorPartPresenter> openedEditors = editorAgent.getOpenedEditors(); for (EditorPartPresenter editor : openedEditors) { VirtualFile file = editor.getEditorInput().getFile(); if (movedResource.getLocation().equals(file.getLocation())) { eventBus.fireEvent(FileEvent.createFileOpenedEvent(file)); return; } } }) .catchError( arg -> { notification.setContent(arg.getMessage()); }); }