auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void shouldGenerateUpdatesForLabelAdditionWithExistingProperties() { NodeUpdates updates = NodeUpdates.forNode( nodeId, empty, labels ) .existing( propertyKeyId1, Values.of( "Neo" ) ) .existing( propertyKeyId2, Values.of( 100L ) ) <START> .existing( propertyKeyId3, Values.of( Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 ) ) ) <END> .build(); assertThat( updates.forIndexKeys( indexes, propertyLoader( property1, property2, property3 ) ), containsInAnyOrder( IndexEntryUpdate.add( nodeId, index1, property1.value() ), IndexEntryUpdate.add( nodeId, index2, property2.value() ), IndexEntryUpdate.add( nodeId, index3, property3.value() ), IndexEntryUpdate.add( nodeId, index123, values123 ) ) ); }</code><technical_language>need extra Values.of wrap</technical_language>

Target:
public void shouldGenerateUpdatesForLabelAdditionWithExistingProperties() { NodeUpdates updates = NodeUpdates.forNode( nodeId, empty, labels ) .existing( propertyKeyId1, Values.of( "Neo" ) ) .existing( propertyKeyId2, Values.of( 100L ) ) .existing( propertyKeyId3, Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 ) ) .build(); assertThat( updates.forIndexKeys( indexes, propertyLoader( property1, property2, property3 ) ), containsInAnyOrder( IndexEntryUpdate.add( nodeId, index1, property1.value() ), IndexEntryUpdate.add( nodeId, index2, property2.value() ), IndexEntryUpdate.add( nodeId, index3, property3.value() ), IndexEntryUpdate.add( nodeId, index123, values123 ) ) ); }
Source:
<code>private List<Person> getOverviewPersonsForUser(Person signedInUser, List<Department> departments, String selectedDepartmentName) { if (departments.isEmpty() && (signedInUser.hasRole(BOSS) || signedInUser.hasRole(OFFICE))) { return personService.getActivePersons(); } return departments.stream() <START> .filter(d -> d.getName().equals(selectedDepartmentName)) <END> .map(Department::getMembers) .flatMap(List::stream) .sorted(comparing(Person::getFirstName)) .collect(toList()); }</code><technical_language>d -> department</technical_language>

Target:
private List<Person> getOverviewPersonsForUser(Person signedInUser, List<Department> departments, String selectedDepartmentName) { if (departments.isEmpty() && (signedInUser.hasRole(BOSS) || signedInUser.hasRole(OFFICE))) { return personService.getActivePersons(); } return departments.stream() .filter(department -> department.getName().equals(selectedDepartmentName)) .map(Department::getMembers) .flatMap(List::stream) .sorted(comparing(Person::getFirstName)) .collect(toList()); }
Source:
<code>public static File createAppPackageFile() { buildOperators(); final String version = System.getProperty("apex.version"); final List<String> params = new LinkedList<>(); params.add("clean"); <START> params.add("install"); <END> params.add("-DskipTests"); if (version != null && version.length() > 0) { params.add("-Dapex.version=" + version); } Assert.assertEquals(0, mavenCli.doMain(params.toArray(new String[params.size()]), workingDirectory, System.out, System.err)); return new File(workingDirectory, "target/mydtapp-1.0-SNAPSHOT.apa"); }</code><technical_language>this change</technical_language>

Target:
public static File createAppPackageFile() { final String version = System.getProperty("apex.version"); final List<String> params = new LinkedList<>(); params.add("clean"); params.add("package"); params.add("-DskipTests"); if (version != null && version.length() > 0) { params.add("-Dapex.version=" + version); } Assert.assertEquals(0, mavenCli.doMain(params.toArray(new String[params.size()]), workingDirectory, System.out, System.err)); return new File(workingDirectory, "target/mydtapp-1.0-SNAPSHOT.apa"); }
Source:
<code>public void testWriteAndPublisher(Method method) { String key = TestingUtil.k(method); String value = TestingUtil.v(method); IracMetadata metadata = createMetadata(); cacheStore.write(createEntry(key, value, metadata)); MarshallableEntrySubscriber<V> subscriber = new MarshallableEntrySubscriber<>(); cacheStore.entryPublisher(key::equals, true, true).subscribe(subscriber); <START> <END> List<MarshallableEntry<String, V>> entries = subscriber.cf.join(); AssertJUnit.assertEquals(1, entries.size()); assertCorrectEntry(entries.get(0), key, value, metadata); }</code><technical_language>Unnecessary whitespace</technical_language>

Target:
public void testWriteAndPublisher(Method method) { String key = TestingUtil.k(method); String value = TestingUtil.v(method); IracMetadata metadata = createMetadata(); cacheStore.write(createEntry(key, value, metadata)); MarshallableEntrySubscriber<V> subscriber = new MarshallableEntrySubscriber<>(); cacheStore.entryPublisher(key::equals, true, true).subscribe(subscriber); List<MarshallableEntry<String, V>> entries = subscriber.cf.join(); assertEquals(1, entries.size()); assertCorrectEntry(entries.get(0), key, value, metadata); }
Source:
<code><START> public static List<SetupAction> getSetupActions(DeploymentUnit deploymentUnit) { <END> final List<SetupAction> setupActions = new ArrayList<SetupAction>(); JavaNamespaceSetup naming = deploymentUnit.getAttachment(org.jboss.as.ee.naming.Attachments.JAVA_NAMESPACE_SETUP_ACTION); if (naming != null) { setupActions.add(naming); } final ConcurrentContextSetupAction concurrentContext = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.CONCURRENT_CONTEXT_SETUP_ACTION); if (concurrentContext != null) { setupActions.add(concurrentContext); } return setupActions; }</code><technical_language>I digested important part of this yet, AFAICT this visibility change is needed</technical_language>

Target:
static List<SetupAction> getSetupActions(DeploymentUnit deploymentUnit) { final List<SetupAction> setupActions = new ArrayList<SetupAction>(); JavaNamespaceSetup naming = deploymentUnit.getAttachment(org.jboss.as.ee.naming.Attachments.JAVA_NAMESPACE_SETUP_ACTION); if (naming != null) { setupActions.add(naming); } final ConcurrentContextSetupAction concurrentContext = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.CONCURRENT_CONTEXT_SETUP_ACTION); if (concurrentContext != null) { setupActions.add(concurrentContext); } return setupActions; }
Source:
<code>private void run() { assignConsumer(); try { while (true) { ConsumerRecords<String, String> records = kafkaConsumer.poll(pollingTimeout); processRecords(records); updateConsumerLag(); } } catch (WakeupException e) { LOG.info("Received shutdown signal."); <START> } catch (Exception e) { <END> LOG.error("An error occurred while processing feature states.", e); } finally { shutdown(); } }</code><technical_language>RuntimeException sufficient here</technical_language>

Target:
private void run() { assignConsumer(); running = true; try { while (true) { ConsumerRecords<String, String> records = kafkaConsumer.poll(pollingTimeout); processRecords(records); updateConsumerLag(); } } catch (WakeupException e) { LOG.info("Received shutdown signal."); } catch (RuntimeException e) { LOG.error("An error occurred while processing feature states: KafkaConsumer will be closed.", e); } finally { running = false; shutdown(); } }
Source:
<code>public void verify(VerificationData data) { try { mode.verify(data); for (VerificationListener listener : listeners) { listener.onVerificationSucceeded(new VerificationSucceededEvent(mock, mode, data)); } } catch (MockitoAssertionError e) { for (VerificationListener listener : listeners) { <START> listener.onVerificationException(mock, mode, e); <END> } throw e; } }</code><technical_language>onVerificationFailed(new VerificationFailedEvent(mock,mode,data,e))</technical_language>

Target:
public void verify(VerificationData data) { try { mode.verify(data); notifyListeners(new VerificationEventImpl(mock, mode, data, null)); } catch (RuntimeException e) { notifyListeners(new VerificationEventImpl(mock, mode, data, e)); throw e; } catch (Error e) { notifyListeners(new VerificationEventImpl(mock, mode, data, e)); throw e; } }
Source:
<code>void testAddStorageResourceWhenNameIsLongerThan24Chars() { String name = "thishasmorethan24characters"; DeploymentTemplateBuilder builder = getMockDeploymentTemplateBuilderWithEmptyOptions(name); DeploymentBody deploymentBody = builder.getDeploymentTemplate(); assertTrue(Iterables.contains(deploymentBody.template().variables().keySet(), "storageAccountName")); String storageAccountName = deploymentBody.template().variables().get("storageAccountName"); assertEquals(storageAccountName.length(), 24); assertEquals(storageAccountName.substring(0, 10), name.replaceAll("[^a-z0-9]", "").substring(0, 10)); <START> assertEquals(storageAccountName.substring(storageAccountName.length() - 10, storageAccountName.length()), name.replaceAll("[^a-z0-9]", "").substring(name.length() - 10, name.length())); <END> }</code><technical_language>Tests replicate business logic (or testing produces expected value; if business logic is broken, test is broken too). Instead, assertions concrete values. Assert is a concrete one, starts expected String N prefix N suffix characters, etc</technical_language>

Target:
void testAddStorageResourceWhenNameIsLongerThan24Chars() { String name = "thishasmorethan24characters"; DeploymentTemplateBuilder builder = getMockDeploymentTemplateBuilderWithEmptyOptions(name); DeploymentBody deploymentBody = builder.getDeploymentTemplate(); assertTrue(Iterables.contains(deploymentBody.template().variables().keySet(), "storageAccountName")); String storageAccountName = deploymentBody.template().variables().get("storageAccountName"); assertEquals(storageAccountName.length(), 24); assertEquals(storageAccountName.substring(0, 10), "thishasmor"); assertEquals(storageAccountName.substring(storageAccountName.length() - 10, storageAccountName.length()), "characters"); }
Source:
<code>public Attachment addAttachment(String assetId, AttachmentSummary attSummary) throws IOException, BadVersionException, RequestFailureException, SecurityException { <START> return null; <END> }</code><technical_language>Worth throwing exception here</technical_language>

Target:
public Attachment addAttachment(String assetId, AttachmentSummary attSummary) throws IOException, BadVersionException, RequestFailureException, SecurityException { throw new UnsupportedOperationException("Attachment methods should not be invoked for Loose Repositories"); }
Source:
<code>@Test public void sendSMSTest() { try { driver.sendSMS("11111111", "call"); } catch (Exception e) { <START> assertFalse( "method works only in emulators", true); <END> } }</code><technical_language>fail call instead</technical_language>

Target:
@Test public void sendSMSTest() { try { driver.sendSMS("11111111", "call"); } catch (Exception e) { fail("method works only in emulators"); } }
Source:
<code>public void execute(IProgressMonitor m) throws CoreException { if (!results.isEmpty()) throw new CoreException(new Status(IStatus.ERROR, Activator .getPluginId(), CoreText.OperationAlreadyExecuted)); IProgressMonitor monitor; if (m == null) monitor = new NullProgressMonitor(); else monitor = m; monitor.beginTask(NLS.bind(CoreText.PullOperation_TaskName, Integer .valueOf(repositories.length)), repositories.length); IWorkspaceRunnable action = new IWorkspaceRunnable() { public void run(IProgressMonitor mymonitor) throws CoreException { for (int i = 0; i < repositories.length; i++) { Repository repository = repositories[i]; if (mymonitor.isCanceled()) throw new CoreException(Status.CANCEL_STATUS); PullCommand pull = new Git(repository).pull(); try { pull .setProgressMonitor(new EclipseGitProgressTransformer( new SubProgressMonitor(mymonitor, 1))); pull.setTimeout(timeout); results.put(repository, pull.call()); } catch (DetachedHeadException e) { results.put(repository, Activator.error( CoreText.PullOperation_DetachedHeadMessage, e)); } catch (InvalidConfigurationException e) { results .put( repository, Activator .error( CoreText.PullOperation_PullNotConfiguredMessage, <START> e)); <END> } catch (GitAPIException e) { results.put(repository, Activator.error(e.getMessage(), e)); } catch (JGitInternalException e) { results.put(repository, Activator.error(e.getMessage(), e)); } finally { mymonitor.worked(1); } } } }; ResourcesPlugin.getWorkspace().run(action, monitor); }</code><technical_language>extract some local variables code is indented this</technical_language>

Target:
public void execute(IProgressMonitor m) throws CoreException { if (!results.isEmpty()) throw new CoreException(new Status(IStatus.ERROR, Activator .getPluginId(), CoreText.OperationAlreadyExecuted)); IProgressMonitor monitor; if (m == null) monitor = new NullProgressMonitor(); else monitor = m; monitor.beginTask(NLS.bind(CoreText.PullOperation_TaskName, Integer .valueOf(repositories.length)), repositories.length); IWorkspaceRunnable action = new IWorkspaceRunnable() { public void run(IProgressMonitor mymonitor) throws CoreException { for (int i = 0; i < repositories.length; i++) { Repository repository = repositories[i]; if (mymonitor.isCanceled()) throw new CoreException(Status.CANCEL_STATUS); PullCommand pull = new Git(repository).pull(); try { pull.setProgressMonitor(new EclipseGitProgressTransformer( new SubProgressMonitor(mymonitor, 1))); pull.setTimeout(timeout); results.put(repository, pull.call()); } catch (DetachedHeadException e) { results.put(repository, Activator.error( CoreText.PullOperation_DetachedHeadMessage, e)); } catch (InvalidConfigurationException e) { IStatus error = Activator .error(CoreText.PullOperation_PullNotConfiguredMessage, e); results.put(repository, error); } catch (GitAPIException e) { results.put(repository, Activator.error(e.getMessage(), e)); } catch (JGitInternalException e) { results.put(repository, Activator.error(e.getMessage(), e)); } finally { mymonitor.worked(1); } } } }; ResourcesPlugin.getWorkspace().run(action, monitor); }
Source:
<code>public Action<?, ?> databaseBackupFailedAction() { return new AbstractBackupRestoreActions<>(DatabaseBackupFailedEvent.class) { @Override protected BackupRestoreContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatabaseBackupFailedEvent payload) { Flow flow = getFlow(flowParameters.getFlowId()); flow.setFlowFailed(payload.getException()); <START> return BackupRestoreContext.from(flowParameters, payload, null, null, null); <END> } @Override protected void doExecute(BackupRestoreContext context, DatabaseBackupFailedEvent payload, Map<Object, Object> variables) { backupRestoreStatusService.handleDatabaseBackupFailure(context.getStackId(), payload.getException().getMessage(), payload.getDetailedStatus()); sendEvent(context, DATABASE_BACKUP_FAIL_HANDLED_EVENT.event(), payload); } }; }</code><technical_language>**suggestion:** For Database backup failed state, passing null values in, reusing this BackupRestoreContext for active failed backups restores, want create a new context type</technical_language>

Target:
public Action<?, ?> databaseBackupFailedAction() { return new AbstractBackupRestoreActions<>(DatabaseBackupFailedEvent.class) { @Override protected BackupRestoreContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatabaseBackupFailedEvent payload) { Flow flow = getFlow(flowParameters.getFlowId()); flow.setFlowFailed(payload.getException()); return BackupRestoreContext.from(flowParameters, payload, null, null); } @Override protected void doExecute(BackupRestoreContext context, DatabaseBackupFailedEvent payload, Map<Object, Object> variables) { backupRestoreStatusService.handleDatabaseBackupFailure(context.getStackId(), payload.getException().getMessage(), payload.getDetailedStatus()); sendEvent(context, DATABASE_BACKUP_FAIL_HANDLED_EVENT.event(), payload); } }; }
Source:
<code>public FormValidation doCheckMaxDaysOld(@QueryParameter int maxDaysOld) { if (maxDaysOld <= 0) { <START> return FormValidation.warning("The maximum age of a commit should be greater than 0. Otherwise no branches are found"); <END> } return FormValidation.ok(); }</code><technical_language>suggestion return FormValidation.warning("Setting maximum age 0 negative turns this filter.");</technical_language>

Target:
public FormValidation doCheckMaxDaysOld(@QueryParameter int maxDaysOld) { if (maxDaysOld <= 0) { return FormValidation.warning("Setting maximum age to 0 or negative turns off this filter."); } return FormValidation.ok(); }
Source:
<code><START> public boolean equals(Object o) { <END> if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } UnregisteredDisk that = (UnregisteredDisk) o; if (!diskImage.equals(that.diskImage)) { return false; } return vms.equals(that.vms); }</code><technical_language>I this re-generated added id</technical_language>

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } UnregisteredDisk that = (UnregisteredDisk) o; return Objects.equals(diskImage, that.diskImage) && Objects.equals(vms, that.vms) && Objects.equals(id, that.id); }
Source:
<code>private void markEdit(CodeMirror cm, JsArrayString lines, JsArray<Span> edits, int startLine) { int pos = 0; LineIterator iter = new LineIterator(lines, startLine); Configuration diffOpt = Configuration.create() .set("className", diffTable.style.diff()) .set("readOnly", true); Configuration editOpt = Configuration.create() .set("className", diffTable.style.intraline()) .set("readOnly", true); LineCharacter last = LineCharacter.create(0, 0); for (int i = 0; i < edits.length(); i++) { Span span = edits.get(i); LineCharacter from = iter.advance(span.begin() - pos); LineCharacter to = iter.advance(span.length()); int fromLine = from.getLine(); <START> pos = span.begin() + span.length(); <END> if (last.getLine() == fromLine) { cm.markText(last, from, diffOpt); } else { cm.markText(LineCharacter.create(fromLine, 0), from, diffOpt); } cm.markText(from, to, editOpt); last = to; for (int line = fromLine; line < to.getLine(); line++) { cm.addLineClass(line, LineClassWhere.BACKGROUND, diffTable.style.intraline()); } } }</code><technical_language>span.end()</technical_language>

Target:
private void markEdit(CodeMirror cm, JsArrayString lines, JsArray<Span> edits, int startLine) { int pos = 0; EditIterator iter = new EditIterator(lines, startLine); Configuration diffOpt = Configuration.create() .set("className", diffTable.style.diff()) .set("readOnly", true); Configuration editOpt = Configuration.create() .set("className", diffTable.style.intraline()) .set("readOnly", true); LineCharacter last = LineCharacter.create(0, 0); for (int i = 0; i < edits.length(); i++) { Span span = edits.get(i); LineCharacter from = iter.advance(span.begin() - pos); LineCharacter to = iter.advance(span.length()); int fromLine = from.getLine(); pos = span.end(); if (last.getLine() == fromLine) { cm.markText(last, from, diffOpt); } else { cm.markText(LineCharacter.create(fromLine, 0), from, diffOpt); } cm.markText(from, to, editOpt); last = to; for (int line = fromLine; line < to.getLine(); line++) { cm.addLineClass(line, LineClassWhere.BACKGROUND, diffTable.style.intraline()); } } }
Source:
<code>public void updateNumberOfShards(int newNumber) { Preconditions.checkArgument(newNumber <= 128); <START> increaseValue(NUMBER_OF_SHARDS_INDEX, true, newNumber); <END> }</code><technical_language>Ideally a constant for boolean / key (if follow suggestion in #3104), _must_ match for this work properly</technical_language>

Target:
public void updateNumberOfShards(int newNumber) { Preconditions.checkArgument(newNumber <= 128); increaseValueToAtLeast(ShardAndStrategy.conservative(SHARD_COUNT_INDEX), newNumber); }
Source:
<code>private PositionalBufferedStream initStream(final File inputFile, final long skip) { try { final FileInputStream fileStream = new FileInputStream(inputFile); final InputStream is; if (AbstractFeatureReader.hasBlockCompressedExtension(inputFile)) { final int bufferSize = Math.max(Defaults.BUFFER_SIZE, BlockCompressedStreamConstants.MAX_COMPRESSED_BLOCK_SIZE); final BufferedInputStream bufferedStream = new BufferedInputStream(fileStream, bufferSize); if (!BlockCompressedInputStream.isValidFile(bufferedStream)) { throw new TribbleException.MalformedFeatureFile("Input file is not in valid block compressed format.", inputFile.getAbsolutePath()); } final SeekableStream seekableStream = <START> SeekableStreamFactory.getInstance().getBufferedStream( <END> SeekableStreamFactory.getInstance().getStreamFor(inputFile.getAbsolutePath())); is = new BlockCompressedInputStream(seekableStream); } else { is = fileStream; } final PositionalBufferedStream pbs = new PositionalBufferedStream(is); if ( skip > 0 ) pbs.skip(skip); return pbs; } catch (final FileNotFoundException e) { throw new TribbleException.FeatureFileDoesntExist("Unable to open the input file, most likely the file doesn't exist.", inputFile.getAbsolutePath()); } catch (final IOException e) { throw new TribbleException.MalformedFeatureFile("Error initializing stream", inputFile.getAbsolutePath(), e); } }</code><technical_language>I save a local reference SeekableStreamFactory instance here, a more readable. personal preference, ignore if disagree</technical_language>

Target:
private PositionalBufferedStream initStream(final File inputFile, final long skip) { try { final FileInputStream fileStream = new FileInputStream(inputFile); final InputStream is; if (AbstractFeatureReader.hasBlockCompressedExtension(inputFile)) { final int bufferSize = Math.max(Defaults.BUFFER_SIZE, BlockCompressedStreamConstants.MAX_COMPRESSED_BLOCK_SIZE); final BufferedInputStream bufferedStream = new BufferedInputStream(fileStream, bufferSize); if (!BlockCompressedInputStream.isValidFile(bufferedStream)) { throw new TribbleException.MalformedFeatureFile("Input file is not in valid block compressed format.", inputFile.getAbsolutePath()); } final ISeekableStreamFactory ssf = SeekableStreamFactory.getInstance(); final SeekableStream seekableStream = ssf.getBufferedStream(ssf.getStreamFor(inputFile.getAbsolutePath())); is = new BlockCompressedInputStream(seekableStream); } else { is = fileStream; } final PositionalBufferedStream pbs = new PositionalBufferedStream(is); if ( skip > 0 ) pbs.skip(skip); return pbs; } catch (final FileNotFoundException e) { throw new TribbleException.FeatureFileDoesntExist("Unable to open the input file, most likely the file doesn't exist.", inputFile.getAbsolutePath()); } catch (final IOException e) { throw new TribbleException.MalformedFeatureFile("Error initializing stream", inputFile.getAbsolutePath(), e); } }
Source:
<code>default void setHelperComponent(Component component) { getElement().getChildren() .filter(child -> "helper".equals(child.getAttribute("slot"))) <START> .collect(Collectors.toList()) <END> .forEach(getElement()::removeChild); if (component != null) { component.getElement().setAttribute("slot", "helper"); getElement().appendChild(component.getElement()); } }</code><technical_language>Unnecessary collecting a list child slot=helper, findAny().ifPresent(...) instead</technical_language>

Target:
default void setHelperComponent(Component component) { getElement().getChildren() .filter(child -> "helper".equals(child.getAttribute("slot"))) .findAny() .ifPresent(getElement()::removeChild); if (component != null) { component.getElement().setAttribute("slot", "helper"); getElement().appendChild(component.getElement()); } }
Source:
<code>public TransferObserver upload(String key, InputStream inputStream, UploadOptions options) throws IOException { File file = writeInputStreamToFile(inputStream); TransferObserver observer = upload( options.getBucket() != null ? options.getBucket() : getDefaultBucketOrThrow(), key, file, options.getMetadata() != null ? options.getMetadata() : new ObjectMetadata(), options.getCannedAcl(), options.getTransferListener() ); <START> deleteTempFile(observer); <END> return observer; }</code><technical_language>delete File upload completed, File is read upload process. I suggest putting this code removeTransferRecordFromDB method</technical_language>

Target:
public TransferObserver upload(String key, InputStream inputStream, UploadOptions options) throws IOException { File file = writeInputStreamToFile(inputStream); return upload( options.getBucket() != null ? options.getBucket() : getDefaultBucketOrThrow(), key, file, options.getMetadata() != null ? options.getMetadata() : new ObjectMetadata(), options.getCannedAcl(), options.getTransferListener() ); }
Source:
<code>public Promise<Map<String, String>> loadPreferences() { <START> if (!service.hasJDTLSInstallerAdded()) { <END> return promiseProvider.resolve(newHashMap()); } List<String> options = new ArrayList<>(); for (ErrorWarningsOptions option : ErrorWarningsOptions.values()) { options.add(option.toString()); } return service .getJavaCoreOptions(options) .then( (Function<JavaCoreOptions, Map<String, String>>) javaCoreOptions -> { persistedPreferences.putAll(javaCoreOptions.getOptions()); return javaCoreOptions.getOptions(); }); }</code><technical_language>If follow call hierarachy here, this is called early populate CurrentUser#getPreferences(). method is called all. remove method</technical_language>

Target:
public Promise<Map<String, String>> loadPreferences() { List<String> options = new ArrayList<>(); for (ErrorWarningsOptions option : ErrorWarningsOptions.values()) { options.add(option.toString()); } return service .getJavaCoreOptions(options) .then( (Function<JavaCoreOptions, Map<String, String>>) javaCoreOptions -> { persistedPreferences.putAll(javaCoreOptions.getOptions()); return javaCoreOptions.getOptions(); }); }
Source:
<code>public String toString() { <START> final StringBuilder sb = new StringBuilder("LocalBias{"); <END> sb.append("acq=").append(acquisitionTimestamp); sb.append(", last=").append(lastAccessTimestamp); sb.append('}'); return sb.toString(); }</code><technical_language>is advantage of StringBuilder in toString()</technical_language>

Target:
public String toString() { return "LocalBias{acq=" + acquisitionTimestamp + ", last=" + lastAccessTimestamp + '}'; }
Source:
<code>private static void updateForTabletDataFile(ServerContext context, KeyExtent extent, FileRef path, FileRef mergeFile, DataFileValue dfv, String time, Set<FileRef> filesInUseByScans, String address, ZooLock zooLock, Set<String> unusedWalLogs, TServerInstance lastLocation, long flushId) { TabletMutator tablet = context.getAmple().mutateTablet(extent); if (dfv.getNumEntries() > 0) { tablet.putFile(path, dfv); tablet.putTime(time); TServerInstance self = getTServerInstance(address, zooLock); tablet.putLocation(self, LocationType.LAST); if (lastLocation != null && !lastLocation.equals(self)) { tablet.deleteLocation(lastLocation, LocationType.LAST); } } <START> tablet.putFlushId(flushId); <END> if (mergeFile != null) { tablet.deleteFile(mergeFile); } if (unusedWalLogs != null) { unusedWalLogs.forEach(tablet::deleteWal); } filesInUseByScans.forEach(tablet::putScan); tablet.mutate(); }</code><technical_language>Eventually this clearLastLocation method dead code removed</technical_language>

Target:
private static void updateForTabletDataFile(ServerContext context, KeyExtent extent, FileRef path, FileRef mergeFile, DataFileValue dfv, String time, Set<FileRef> filesInUseByScans, String address, ZooLock zooLock, Set<String> unusedWalLogs, TServerInstance lastLocation, long flushId) { TabletMutator tablet = context.getAmple().mutateTablet(extent); if (dfv.getNumEntries() > 0) { tablet.putFile(path, dfv); tablet.putTime(time); TServerInstance self = getTServerInstance(address, zooLock); tablet.putLocation(self, LocationType.LAST); if (lastLocation != null && !lastLocation.equals(self)) { tablet.deleteLocation(lastLocation, LocationType.LAST); } } tablet.putFlushId(flushId); if (mergeFile != null) { tablet.deleteFile(mergeFile); } unusedWalLogs.forEach(tablet::deleteWal); filesInUseByScans.forEach(tablet::putScan); tablet.putZooLock(zooLock); tablet.mutate(); }
Source:
<code>public MobileArticlePageObject openCategory(String wikiURL){ getUrl(wikiURL+ categoryPmg); waitForElementByElement(showAllButton); <START> PageObjectLogging.log("openCategory", "category page was opened", true, driver); <END> return new MobileArticlePageObject(driver); }</code><technical_language>move log(...) end of method. (again, i improve piece of code :) )</technical_language>

Target:
public MobileArticlePageObject openCategory(String wikiURL) { getUrl(wikiURL + URLsContent.categoryPmg); waitForElementByElement(showAllButton); PageObjectLogging.log("openCategory", "category page was opened", true, driver); return new MobileArticlePageObject(driver); }
Source:
<code>public URI getServiceUri() throws URISyntaxException { <START> return new URI("http://localhost:8087/mmx/merger/v1/action"); <END> }</code><technical_language>This remote..</technical_language>

Target:
private URI getServiceUri() throws Exception { final ServiceInstance instance = serviceProvider.getInstance(); final String scheme; final String host; final int port; final String path = "/mmx/merger/v1/action"; host = instance.getAddress(); if (instance.getSslPort() != null && instance.getSslPort() > 0) { scheme = "https"; port = instance.getSslPort(); } else { scheme = "http"; port = instance.getPort(); } return new URI(scheme, null, host, port, path, null, null); }
Source:
<code>public ByteBuf getCommandLineBytes() throws ImapAsyncClientException { final ByteBuf sb = Unpooled.buffer(ENABLE_BUF_LEN); sb.writeBytes(ENABLE_SP_B); <START> for (int i = 0, len = capabilities.length; i < len; i++) { <END> sb.writeBytes(capabilities[i].getBytes(StandardCharsets.US_ASCII)); if (i < len - 1) { sb.writeByte(ImapClientConstants.SPACE); } } sb.writeBytes(CRLF_B); return sb; }</code><technical_language>Remove len capabilities.length</technical_language>

Target:
public ByteBuf getCommandLineBytes() throws ImapAsyncClientException { final ByteBuf sb = Unpooled.buffer(ENABLE_BUF_LEN); sb.writeBytes(ENABLE_B); for (int i = 0; i < capabilities.length; i++) { sb.writeByte(ImapClientConstants.SPACE); sb.writeBytes(capabilities[i].getBytes(StandardCharsets.US_ASCII)); } sb.writeBytes(CRLF_B); return sb; }
Source:
<code>public String getTokenValue() { String value = tokenValue.toString(); if ( isEL ) { <START> value = value.replace( "\\{", "{" ); <END> value = value.replace( "\\}", "}" ); } return value; }</code><technical_language>I sense pre-compile re-use patterns</technical_language>

Target:
public String getTokenValue() { if ( !terminated ) { throw new IllegalStateException( "Trying to retrieve token value for unterminated token" ); } return value; }
Source:
<code>public long getCurrentSize() { long size = -1; try { this.putCountsLock.readLock().lock(); try { this.takeCountsLock.readLock().lock(); size = this.elementsAdded - this.elementsRemoved; <START> } finally { <END> this.takeCountsLock.readLock().unlock(); } } finally { this.putCountsLock.readLock().unlock(); } return size; }</code><technical_language>If get exception here, bubble get reported</technical_language>

Target:
public long getCurrentSize() { return this.elementsAdded.get() - this.elementsRemoved.get(); }
Source:
<code>public boolean quotaExceeded(IOException e) { ErrorInfo errorInfo = getErrorInfo(e); <START> if (errorInfo != null) { return QUOTA_EXCEEDED_REASON.equals(errorInfo.getReason()); } return false; <END> }</code><technical_language>Replace one-liner: java return errorInfo != null && QUOTA_EXCEEDED_REASON.equals(errorInfo.getReason());</technical_language>

Target:
public boolean quotaExceeded(IOException e) { ErrorInfo errorInfo = getErrorInfo(e); return errorInfo != null && QUOTA_EXCEEDED_REASON.equals(errorInfo.getReason()); }
Source:
<code>private IStatus handleWorkspaceRootDrop(DropTargetEvent event) { if (event.data instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) event.data; if (onlyRepositoryNodesSelected(selection)) { <START> List<String> reposToRemove <END> = new ArrayList<>(); for (Object treeNode : selection.toList()) { RepositoryNode repo = (RepositoryNode) treeNode; reposToRemove.add( repo.getRepository().getDirectory().toString()); } RepositoryGroups groups = new RepositoryGroups(); groups.removeFromGroups(reposToRemove); refreshRepositoriesView(); return Status.OK_STATUS; } } return Status.CANCEL_STATUS; }</code><technical_language>File</technical_language>

Target:
private IStatus handleWorkspaceRootDrop(DropTargetEvent event) { if (event.data instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) event.data; if (onlyRepositoryNodesSelected(selection)) { List<File> reposToRemove = new ArrayList<>(); for (Object treeNode : selection.toList()) { RepositoryNode repo = (RepositoryNode) treeNode; reposToRemove.add(repo.getRepository().getDirectory()); } RepositoryGroups.getInstance().removeFromGroups(reposToRemove); refreshRepositoriesView(); return Status.OK_STATUS; } } return Status.CANCEL_STATUS; }
Source:
<code>public RuleResult validate(final PasswordData passwordData) { final String matchingChars = PasswordUtils.getMatchingCharacters( String.valueOf(characterData.getCharacters()), passwordData.getPassword(), numCharacters); if (matchingChars.length() < numCharacters) { return new RuleResult( false, new RuleResultDetail(characterData.getErrorCode(), createRuleResultDetailParameters(matchingChars))); <START> } else { <END> return new RuleResult(true); } }</code><technical_language>else block is required is return other case. Simply return it</technical_language>

Target:
public RuleResult validate(final PasswordData passwordData) { final String matchingChars = PasswordUtils.getMatchingCharacters( String.valueOf(characterData.getCharacters()), passwordData.getPassword(), numCharacters); if (matchingChars.length() < numCharacters) { return new RuleResult( false, new RuleResultDetail(characterData.getErrorCode(), createRuleResultDetailParameters(matchingChars))); } return new RuleResult(true); }
Source:
<code>public InternalThreadExecutor() { <START> super(Config.<Integer> GetValue(ConfigValues.DefaultThreadPoolSize), <END> Config.<Integer> GetValue(ConfigValues.DefaultThreadPoolSize), 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); }</code><technical_language>This is forcing a minimal size (corePoolSize) identical max size. choose do it? This threads alive if needed. I suggest put this in a configvalue</technical_language>

Target:
public InternalThreadExecutor() { super(Config.<Integer> GetValue(ConfigValues.DefaultMinThreadPoolSize), Config.<Integer> GetValue(ConfigValues.DefaultMaxThreadPoolSize), 60L, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(Config.<Integer> GetValue(ConfigValues.DefaultMaxSizeOfWaitingTasks))); }
Source:
<code>public static void readFileMetaData(InputStream from, FileMetaDataConsumer consumer) throws IOException { <START> readFileMetaData(from, consumer, (BlockCipher.Decryptor) null, (byte[]) null); <END> }</code><technical_language>I omit casting add value</technical_language>

Target:
public static void readFileMetaData(InputStream from, FileMetaDataConsumer consumer) throws IOException { readFileMetaData(from, consumer, null, null); }
Source:
<code><START> public void startClose() { <END> close = true; }</code><technical_language>this method public</technical_language>

Target:
void startClose() { stateMachine.setState(STATE_CLOSING); }
Source:
<code>public GatewayBranch getBranch(String id) { <START> for(GatewayBranch branch : branchList) { <END> if(id.equals(branch.getId())) { return branch; } } return null; }</code><technical_language>Please adhere code conventions. A space for if</technical_language>

Target:
public Optional<GatewayBranch> getBranch(String id) { for (GatewayBranch branch : branchList) { if (id.equals(branch.getId())) { return Optional.of(branch); } } return Optional.empty(); }
Source:
<code>public SliceSampler(final RandomGenerator rng, final Function<Double, Double> logPDF, final double xMin, final double xMax, final double width) { Utils.nonNull(rng); Utils.nonNull(logPDF); <START> if (xMin > xMax) { <END> throw new IllegalArgumentException("Maximum bound must be larger than minimum bound."); } ParamUtils.isPositive(width, "Slice-sampling width must be positive."); this.rng = rng; this.logPDF = logPDF; this.xMin = xMin; this.xMax = xMax; this.width = width; this.exponentialDistribution = new ExponentialDistribution(rng, 1.); }</code><technical_language>Utils.validateArg(xMin <= xMax. . .)</technical_language>

Target:
public SliceSampler(final RandomGenerator rng, final Function<Double, Double> logPDF, final double xMin, final double xMax, final double width) { Utils.nonNull(rng); Utils.nonNull(logPDF); Utils.validateArg(xMin <= xMax, "Maximum bound must be greater than or equal to minimum bound."); ParamUtils.isPositive(width, "Slice-sampling width must be positive."); this.rng = rng; this.logPDF = logPDF; this.xMin = xMin; this.xMax = xMax; this.width = width; this.exponentialDistribution = new ExponentialDistribution(rng, 1.); }
Source:
<code>public List<BackPackedListData> getBackPackedListData() { <START> return backPackedListData != null ? backPackedListData : new ArrayList<BackPackedListData>(); <END> }</code><technical_language>initialise member variable point of declaration (i.e. List<BackpackedListData> backPackedListData = new ArrayList<>(); instead of checking here. overwrite list other points save this (unnecessary) check</technical_language>

Target:
public List<BackPackedListData> getBackPackedListData() { return backPackedListData; }
Source:
<code>public int read(WritableByteChannel channel) throws IOException { <START> int bytesWritten = streamEnded.get() ? -1 : 0; <END> if (!channelOpen.get()) { throw new ClosedChannelException(); } else if (!streamEnded.get()) { try { contentLock.lock(); int currentBytesWritten = requestContents.size() > 0 ? requestContents.get(0).read(channel) : 0; while (currentBytesWritten != 0) { if (currentBytesWritten == -1) { NettyContent nettyContent = requestContents.remove(0); nettyContent.release(); streamEnded.set(nettyContent.isLast()); } else { bytesWritten += currentBytesWritten; } currentBytesWritten = 0; if (!streamEnded.get() && requestContents.size() > 0) { currentBytesWritten = requestContents.get(0).read(channel); } } } finally { contentLock.unlock(); } } return bytesWritten; }</code><technical_language>This is confusing for me. I suggest if channel open throw exception else if stream is ended bytesWritten = -1 else logic read</technical_language>

Target:
public int read(WritableByteChannel channel) throws IOException { int bytesWritten; if (!channelOpen.get()) { throw new ClosedChannelException(); } else if (streamEnded.get()) { bytesWritten = -1; } else { bytesWritten = 0; contentLock.lock(); try { int currentBytesWritten = requestContents.size() > 0 ? requestContents.get(0).read(channel) : 0; while (currentBytesWritten != 0) { if (currentBytesWritten == -1) { NettyContent nettyContent = requestContents.remove(0); nettyContent.release(); streamEnded.set(nettyContent.isLast()); } else { bytesWritten += currentBytesWritten; } currentBytesWritten = 0; if (!streamEnded.get() && requestContents.size() > 0) { currentBytesWritten = requestContents.get(0).read(channel); } } } finally { contentLock.unlock(); } } return bytesWritten; }
Source:
<code>protected ResourceConverter getResourceConverter() { <START> DataCleanerConfiguration configuration = getAnalysisJobBuilder().getConfiguration(); <END> return new ResourceConverter(configuration); }</code><technical_language>final</technical_language>

Target:
protected ResourceConverter getResourceConverter() { final DataCleanerConfiguration configuration = getAnalysisJobBuilder().getConfiguration(); return new ResourceConverter(configuration); }
Source:
<code>public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); if (bundle == null || "google.com/iid".equals(bundle.getString("from"))) return; OneSignal.setAppContext(context); ProcessedBundleResult processedResult = processOrderBroadcast(context, intent, bundle); if (processedResult == null) { setSuccessfulResultCode(); return; } if (processedResult.isDup || processedResult.hasExtenderService <START> || processedResult.isOneSignalPayload) { <END> setAbort(); return; } setSuccessfulResultCode(); }</code><technical_language>original checked processedResult.isOneSignalPayload && OneSignal.getFilterOtherGCMReceivers(context) this means remove rocessedResult.isOneSignalPayload</technical_language>

Target:
public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); if (bundle == null || "google.com/iid".equals(bundle.getString("from"))) return; OneSignal.setAppContext(context); ProcessedBundleResult processedResult = processOrderBroadcast(context, intent, bundle); if (processedResult == null) { setSuccessfulResultCode(); return; } if (processedResult.isDup || processedResult.hasExtenderService) { setAbort(); return; } setSuccessfulResultCode(); }
Source:
<code>public ButtonBase(ComponentContainer container) { super(container); <START> view = (T)(new android.widget.Button(container.$context())); <END> defaultButtonDrawable = view.getBackground(); defaultColorStateList = view.getTextColors(); defaultButtonMinWidth = KitkatUtil.getMinWidth(view); defaultButtonMinHeight = KitkatUtil.getMinHeight(view); container.$add(this); view.setOnClickListener(this); view.setOnFocusChangeListener(this); view.setOnLongClickListener(this); view.setOnTouchListener(this); IceCreamSandwichUtil.setAllCaps(view, false); TextAlignment(Component.ALIGNMENT_CENTER); BackgroundColor(Component.COLOR_DEFAULT); Image(""); Enabled(true); fontTypeface = Component.TYPEFACE_DEFAULT; TextViewUtil.setFontTypeface(view, fontTypeface, bold, italic); FontSize(Component.FONT_DEFAULT_SIZE); Text(""); TextColor(Component.COLOR_DEFAULT); Shape(Component.BUTTON_SHAPE_DEFAULT); }</code><technical_language>This works technically correct T android.widget.Button, is true of ToggleBase subclasses. alternative approach this constructor additional argument T view set this.view = view. Then, introduce another constructor takes single argument calls this constructor this(container, new android.widget.Button(container.$context()). Then, ToggleBase pass right instance of view. This is a minor memory optimization right CheckBox Switch components result in a Button created (which is immediately discarded) actual widget</technical_language>

Target:
public ButtonBase(ComponentContainer container) { this(container, (T) (new android.widget.Button(container.$context()))); }
Source:
<code>public void logAuditMessage(final Guid clusterId, final GlusterVolumeEntity volume, final VDS server, final AuditLogType logType, final Map<String, String> customValues) { AuditLogableBase logable = Injector.injectMembers(new AuditLogableBase()); logable.setVds(server); logable.setGlusterVolume(volume); logable.setClusterId(clusterId); if (customValues != null) { <START> customValues.entrySet().stream().forEach(e <END> -> logable.addCustomValue(e.getKey(), e.getValue())); } auditLogDirector.log(logable, logType); }</code><technical_language>need stream() - a collection a forEach method</technical_language>

Target:
public void logAuditMessage(final Guid clusterId, final GlusterVolumeEntity volume, final VDS server, final AuditLogType logType, final Map<String, String> customValues) { AuditLogableBase logable = Injector.injectMembers(new AuditLogableBase()); logable.setVds(server); logable.setGlusterVolume(volume); logable.setClusterId(clusterId); if (customValues != null) { customValues.entrySet().forEach(e -> logable.addCustomValue(e.getKey(), e.getValue())); } auditLogDirector.log(logable, logType); }
Source:
<code>private void enable() { if (fEditor != null) { if (fReconciler != null) { <START> fReconciler.uninstall(); <END> } fReconciler= new JavaCodeMiningReconciler(); fReconciler.install(fEditor, fSourceViewer); } }</code><technical_language>I desinstall reconcilier. Remind is this necessary</technical_language>

Target:
private void enable() { if (fEditor != null) { if (fReconciler != null) { fReconciler.updateCodeMinings(); } else { fReconciler= new JavaCodeMiningReconciler(); fReconciler.install(fEditor, fSourceViewer); } } }
Source:
<code>public void onServerTemplateDeleted(@Observes ServerTemplateDeleted serverTemplateDeleted) { <START> serverTemplatesClients.computeIfPresent(serverTemplateDeleted.getServerTemplateId(), <END> (serverTemplateId, clients) -> { logger.debug("KieServerClient removed and closed for server template {}", serverTemplateId.equals("") ? serverTemplateDeleted.getServerTemplateId() : serverTemplateId); return null; }); adminClients.remove(serverTemplateDeleted.getServerTemplateId()); removeServerInstancesFromIndex(serverTemplateDeleted.getServerTemplateId()); }</code><technical_language>reason of putting null map for server template id instead of removing it</technical_language>

Target:
public void onServerTemplateDeleted(@Observes ServerTemplateDeleted serverTemplateDeleted) { final Map<String, KieServicesClient> clients = serverTemplatesClients.remove(serverTemplateDeleted.getServerTemplateId()); if (clients != null) { logger.debug("KieServerClient removed and closed for server template {}", serverTemplateDeleted.getServerTemplateId()); } adminClients.remove(serverTemplateDeleted.getServerTemplateId()); removeServerInstancesFromIndex(serverTemplateDeleted.getServerTemplateId()); }
Source:
<code>private void addCategoriesAsTags(Set<TestTag> tags) { Category annotation = description.getAnnotation(Category.class); if (annotation != null) { <START> Stream.of(annotation.value()) <END> .map(ReflectionUtils::getAllAssignmentCompatibleClasses) .flatMap(Collection::stream) .distinct() .map(Class::getName) .map(TestTag::create) .forEachOrdered(tags::add); } }</code><technical_language>please change this stream() java.util.Arrays.stream is/was statically imported</technical_language>

Target:
private void addCategoriesAsTags(Set<TestTag> tags) { Category annotation = description.getAnnotation(Category.class); if (annotation != null) { stream(annotation.value()) .map(ReflectionUtils::getAllAssignmentCompatibleClasses) .flatMap(Collection::stream) .distinct() .map(Class::getName) .map(TestTag::create) .forEachOrdered(tags::add); } }
Source:
<code>protected Query newTermQuery(final Term term, float boost) { if (term.text().contains(identifier)) { SuggesterPrefixQuery q = new SuggesterPrefixQuery(replaceIdentifier(term, identifier)); <START> this.suggesterQuery = q; <END> return q; } return super.newTermQuery(term, boost); }</code><technical_language>boost checked if applicable here: if (boost != DEFAULT_BOOST) { q = new BoostQuery(q, boost); }</technical_language>

Target:
protected Query newTermQuery(final Term term, float boost) { if (term.text().contains(identifier)) { Query q = new SuggesterPrefixQuery(replaceIdentifier(term, identifier)); this.suggesterQuery = (SuggesterPrefixQuery) q; if (boost != DEFAULT_BOOST) { q = new BoostQuery(q, boost); } return q; } return super.newTermQuery(term, boost); }
Source:
<code><START> private void disableMenuItem(Menu menu, int rID) { <END> MenuItem item = menu.findItem(rID); item.setEnabled(false); item.setVisible(false); }</code><technical_language>need add a null check for safety. layouts dynamic need able handle case try disable a MenuItem exist. I in previous example a null check. piece of code in optionsmenyoncreate call assert existence of items. In summary for disabling a menu item check if null. means is gone</technical_language>

Target:
private void disableMenuItem(Menu menu, int rID) { MenuItem item = menu.findItem(rID); if(item != null) { item.setEnabled(false); item.setVisible(false); } }