auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Optional<ChargeResponse> create(ChargeCreateRequest chargeRequest, Long accountId, UriInfo uriInfo) { return gatewayAccountDao.findById(accountId).map(gatewayAccount -> { if (gatewayAccount.isLive() && !chargeRequest.getReturnUrl().startsWith("https://")) { logger.info(String.format("Gateway account %d is LIVE, but is configured to use a non-https return_url", accountId)); } SupportedLanguage language = chargeRequest.getLanguage() != null ? chargeRequest.getLanguage() : SupportedLanguage.ENGLISH; ChargeEntity chargeEntity = new ChargeEntity( chargeRequest.getAmount(), chargeRequest.getReturnUrl(), chargeRequest.getDescription(), ServicePaymentReference.of(chargeRequest.getReference()), gatewayAccount, chargeRequest.getEmail(), language, chargeRequest.isDelayedCapture(), <START> chargeRequest.getExternalMetadata().orElse(null)); <END> if (chargeRequest.getPrefilledCardHolderDetails().isPresent()) { PrefilledCardHolderDetails cardHolderDetails = chargeRequest.getPrefilledCardHolderDetails().get(); CardDetailsEntity cardDetailsEntity = new CardDetailsEntity(); if (cardHolderDetails.getCardHolderName().isPresent()) { cardDetailsEntity.setCardHolderName(cardHolderDetails.getCardHolderName().get()); } if (cardHolderDetails.getAddress().isPresent()) { AddressEntity addressEntity = new AddressEntity(cardHolderDetails.getAddress().get()); cardDetailsEntity.setBillingAddress(addressEntity); } chargeEntity.setCardDetails(cardDetailsEntity); } chargeDao.persist(chargeEntity); chargeEventDao.persistChargeEventOf(chargeEntity); return Optional.of(populateResponseBuilderWith(aChargeResponseBuilder(), uriInfo, chargeEntity).build()); }).orElseGet(Optional::empty); }</code><technical_language>If bother, I good constructors: external metadata without)</technical_language>

Target:
public Optional<ChargeResponse> create(ChargeCreateRequest chargeRequest, Long accountId, UriInfo uriInfo) { return gatewayAccountDao.findById(accountId).map(gatewayAccount -> { if (gatewayAccount.isLive() && !chargeRequest.getReturnUrl().startsWith("https://")) { logger.info(String.format("Gateway account %d is LIVE, but is configured to use a non-https return_url", accountId)); } SupportedLanguage language = chargeRequest.getLanguage() != null ? chargeRequest.getLanguage() : SupportedLanguage.ENGLISH; ChargeEntity chargeEntity = new ChargeEntity( chargeRequest.getAmount(), chargeRequest.getReturnUrl(), chargeRequest.getDescription(), ServicePaymentReference.of(chargeRequest.getReference()), gatewayAccount, chargeRequest.getEmail(), language, chargeRequest.isDelayedCapture(), chargeRequest.getExternalMetadata().orElse(null)); chargeRequest.getPrefilledCardHolderDetails() .map(this::createCardDetailsEntity) .ifPresent(chargeEntity::setCardDetails); chargeDao.persist(chargeEntity); chargeEventDao.persistChargeEventOf(chargeEntity); return populateResponseBuilderWith(aChargeResponseBuilder(), uriInfo, chargeEntity).build(); }); }
Source:
<code>public void configure() { setName(NAME); <START> setDescription("Performs incremental processing with MapReduce job"); <END> addMapReduce(mapReduce); }</code><technical_language>"Performs incremental processing ETL MapReduce". longer term 'MapReduce job'. 'MapReduce program' 'MapReduce'</technical_language>

Target:
public void configure() { setName(NAME); setDescription("Performs incremental processing with ETL MapReduce"); addMapReduce(mapReduce); }
Source:
<code>public void eventDispatched(final MIRunningEvent e) { if (fDisableNextRunningEvent) { super.eventDispatched(e); return; } if (fRunToLineActiveOperation == null && fStepInToSelectionActiveOperation == null) { super.eventDispatched(e); } else { <START> if (fLatestEvent instanceof SuspendedEvent) { <END> super.eventDispatched(e); } } }</code><technical_language>Please change ISuspendedDMEvent, is generic interface. BTW, great idea check fLatestEvent for this</technical_language>

Target:
public void eventDispatched(final MIRunningEvent e) { if (fDisableNextRunningEvent) { super.eventDispatched(e); return; } if (fRunToLineActiveOperation == null && fStepInToSelectionActiveOperation == null) { super.eventDispatched(e); } else { if (fLatestEvent instanceof ISuspendedDMEvent) { super.eventDispatched(e); } } }
Source:
<code>public void getDosingInstructionsAsString_shouldInferCorrectly() { ChemoDosingInstructions chemoDosingInstructions = new ChemoDosingInstructions(); <START> chemoDosingInstructions.setDosageAdjustmentPercentage(20.04); <END> chemoDosingInstructions.setDosageDilutionInstructions("10% diluted"); chemoDosingInstructions.setDosageDeliveredTiming("once in 2 hours"); String shouldBeResult = "Dosage Adjustment Percentage : 20.04\nDosage Delivered Timing : once in 2 hours" + "\nDosage Dilution Instructions : 10% diluted\n"; String dosingInstructions = chemoDosingInstructions.getDosingInstructionsAsString(Locale.getDefault()); Assert.assertEquals(dosingInstructions, shouldBeResult); }</code><technical_language>values passed params methods multiple times, if global constants class</technical_language>

Target:
public void getDosingInstructionsAsString_shouldInferCorrectly() { ChemoDosingInstructions chemoDosingInstructions = new ChemoDosingInstructions(); chemoDosingInstructions.setDosageAdjustmentPercentage(ADJUSTMENT_PERCENTAGE_CONSTANT); chemoDosingInstructions.setDosageDilutionInstructions(DILUTION_INSTRUCTIONS_CONSTANT); chemoDosingInstructions.setDosageDeliveredTiming(DELIVERED_TIMING_CONSTANT); String shouldBeResult = ADJUSTMENT_PERCENTAGE + ADJUSTMENT_PERCENTAGE_CONSTANT + "\n" + DELIVERED_TIMING + DELIVERED_TIMING_CONSTANT + "\n" + DILUTION_INSTRUCTIONS + DILUTION_INSTRUCTIONS_CONSTANT + "\n"; String dosingInstructions = chemoDosingInstructions.getDosingInstructionsAsString(Locale.getDefault()); Assert.assertEquals(dosingInstructions, shouldBeResult); }
Source:
<code>private AdminClient brokerAdminClient(KafkaProperties kafkaProperties) { Properties props = new Properties(); props.put(BOOTSTRAP_SERVERS_CONFIG, kafkaProperties.getBootstrapKafkaServer()); props.put(SECURITY_PROTOCOL_CONFIG, DEFAULT_SECURITY_PROTOCOL); props.put(REQUEST_TIMEOUT_MS_CONFIG, kafkaProperties.getKafkaServerRequestTimeoutMillis()); if (kafkaProperties.isSaslEnabled()) { props.put("sasl.mechanism", "PLAIN"); <START> props.put("security.protocol", "SASL_PLAINTEXT"); <END> props.put("sasl.jaas.config", kafkaProperties.getSaslJaasConfig()); } return AdminClient.create(props); }</code><technical_language>In Frontend & Consumers parameters configured hardcoded</technical_language>

Target:
private AdminClient brokerAdminClient(KafkaProperties kafkaProperties) { Properties props = new Properties(); props.put(BOOTSTRAP_SERVERS_CONFIG, kafkaProperties.getBootstrapKafkaServer()); props.put(SECURITY_PROTOCOL_CONFIG, DEFAULT_SECURITY_PROTOCOL); props.put(REQUEST_TIMEOUT_MS_CONFIG, kafkaProperties.getKafkaServerRequestTimeoutMillis()); if (kafkaProperties.isSaslEnabled()) { props.put(SASL_MECHANISM, kafkaProperties.getSaslMechanism()); props.put(SECURITY_PROTOCOL_CONFIG, kafkaProperties.getSaslProtocol()); props.put(SASL_JAAS_CONFIG, kafkaProperties.getSaslJaasConfig()); } return AdminClient.create(props); }
Source:
<code>public void waitSignInDialogToClose() { info("Waiting for sign in dialog to be closed..."); <START> (new WebDriverWait(driver, 10)).until(ExpectedConditions.invisibilityOfElementLocated(By.id(signInDialogFormSel))); <END> info("Sign in dialog is closed"); }</code><technical_language>need constant instead of explicit number. able change globally for of timeouts. This constant exists in SeleniumcConfig class is called.</technical_language>

Target:
public void waitSignInDialogToClose() { info("Waiting for sign in dialog to be closed..."); (new WebDriverWait(driver, SELENIUM_TIMEOUT_SEC)).until(ExpectedConditions.invisibilityOfElementLocated(By.id(signInDialogFormSel))); info("Sign in dialog is closed"); }
Source:
<code>protected String[] getLocations() { String[] locations = StringUtils.commaDelimitedListToStringArray(getExtensionsLocations()); for (int i = 0; i < locations.length; i++) { if (!locations[i].contains(":")) { locations[i] = "classpath*:" + locations[i]; } <START> locations[i] = locations[i] + " *.*"; <END> } return locations; }</code><technical_language>this ensure provided path end a slash</technical_language>

Target:
protected String[] getLocations() { String[] locations = StringUtils.commaDelimitedListToStringArray(getExtensionsLocations()); for (int i = 0; i < locations.length; i++) { if (!prefix.matcher(locations[i]).find()) { locations[i] = "classpath*:" + locations[i]; } if (!locations[i].endsWith("/")) { locations[i] = locations[i] + "/"; } locations[i] = locations[i] + "**/*.*"; } return locations; }
Source:
<code>private void handleRepositoryChange( GitResourceVariantTreeSubscriber subscriber, RepositoryMapping which) { for (GitSynchronizeData gsd : gsds) { if (which.getRepository().equals(gsd.getRepository())) { try { gsd.updateRevs(); } catch (IOException e) { Activator <START> .error(CoreText.GitSubscriberMergeContext_FailedUpdateRevs, <END> e); return; } subscriber.reset(this.gsds); } } }</code><technical_language>error(String, Throwable) returns IStatus. log error</technical_language>

Target:
private void handleRepositoryChange( GitResourceVariantTreeSubscriber subscriber, RepositoryMapping which) { for (GitSynchronizeData gsd : gsds) { if (which.getRepository().equals(gsd.getRepository())) { try { gsd.updateRevs(); } catch (IOException e) { Activator .logError( CoreText.GitSubscriberMergeContext_FailedUpdateRevs, e); return; } subscriber.reset(this.gsds); } } }
Source:
<code>public void destroy() { <START> reactorClient.close(); <END> }</code><technical_language>do need setup-destroy client test</technical_language>

Target:
public void destroy() throws Exception { reactorClient.close(); eventLoops.close(); proxy.close(); }
Source:
<code>private List<AnnotationSpec> list(Class<?>... types) { <START> if (types.length == 0) { <END> return Collections.emptyList(); } List<AnnotationSpec> annotations = new ArrayList<>(); for (Class<?> type : types) { annotations.add(AnnotationSpec.builder(type).build()); } return annotations; }</code><technical_language>this optimization necessary</technical_language>

Target:
private AnnotationSpec[] list(Class<?>... types) { AnnotationSpec[] annotations = new AnnotationSpec[types.length]; for (int i = 0; i < types.length; i++) { annotations[i] = AnnotationSpec.builder(types[i]).build(); } return annotations; }
Source:
<code>public Block getRegion(int positionOffset, int length) { checkValidRegion(positionCount, positionOffset, length); <START> return new DictionaryBlock(idsOffset + positionOffset, length, getDictionary(), ids, false, getDictionarySourceId()); <END> }</code><technical_language>access variables instead of calling methods</technical_language>

Target:
public Block getRegion(int positionOffset, int length) { checkValidRegion(positionCount, positionOffset, length); return new DictionaryBlock(idsOffset + positionOffset, length, dictionary, ids, false, dictionarySourceId); }
Source:
<code>@Nullable @Override protected Map<ClusterNode, VisorTxTaskResult> reduce0(List<ComputeJobResult> results) throws IgniteException { Map<ClusterNode, VisorTxTaskResult> mapRes = new TreeMap<>(); Map<UUID, ClusterNode> nodeMap = new HashMap<>(); for (ComputeJobResult result : results) { VisorTxTaskResult data = result.getData(); if (data == null || data.getInfos().isEmpty()) continue; mapRes.put(result.getNode(), data); nodeMap.put(result.getNode().id(), result.getNode()); } <START> if (taskArg.txInfoArgument() == null) { <END> for (VisorTxTaskResult result : mapRes.values()) { List<VisorTxInfo> infos = result.getInfos(); Iterator<VisorTxInfo> it = infos.iterator(); while (it.hasNext()) { VisorTxInfo info = it.next(); if (!info.getXid().equals(info.getNearXid())) { UUID nearNodeId = info.getMasterNodeIds().iterator().next(); ClusterNode node = nodeMap.get(nearNodeId); if (node == null) continue; VisorTxTaskResult res0 = mapRes.get(node); if (res0 == null) continue; boolean exists = false; for (VisorTxInfo txInfo : res0.getInfos()) { if (txInfo.getXid().equals(info.getNearXid())) { exists = true; break; } } if (exists) it.remove(); } } } } return mapRes; }</code><technical_language>Please, add verboseMode taskArg</technical_language>

Target:
@Nullable @Override protected Map<ClusterNode, VisorTxTaskResult> reduce0(List<ComputeJobResult> results) throws IgniteException { Map<ClusterNode, VisorTxTaskResult> mapRes = new TreeMap<>(); Map<UUID, ClusterNode> nodeMap = new HashMap<>(); for (ComputeJobResult result : results) { VisorTxTaskResult data = result.getData(); if (data == null || data.getInfos().isEmpty()) continue; mapRes.put(result.getNode(), data); nodeMap.put(result.getNode().id(), result.getNode()); } if (!taskArg.verboseMode()) { for (VisorTxTaskResult result : mapRes.values()) { List<VisorTxInfo> infos = result.getInfos(); Iterator<VisorTxInfo> it = infos.iterator(); while (it.hasNext()) { VisorTxInfo info = it.next(); if (!info.getXid().equals(info.getNearXid())) { UUID nearNodeId = info.getMasterNodeIds().iterator().next(); ClusterNode node = nodeMap.get(nearNodeId); if (node == null) continue; VisorTxTaskResult res0 = mapRes.get(node); if (res0 == null) continue; boolean exists = false; for (VisorTxInfo txInfo : res0.getInfos()) { if (txInfo.getXid().equals(info.getNearXid())) { exists = true; break; } } if (exists) it.remove(); } } } } return mapRes; }
Source:
<code>public ItemStack createStack() { net.minecraft.item.ItemStack itemStack = (net.minecraft.item.ItemStack) this.privateStack.copy(); itemStack.setTagCompound(this.compound); <START> return (ItemStack) itemStack; <END> }</code><technical_language>ItemStackUtil.fromNative(itemStack)</technical_language>

Target:
public ItemStack createStack() { net.minecraft.item.ItemStack nativeStack = ItemStackUtil.cloneDefensiveNative(ItemStackUtil.toNative(this.privateStack.copy())); if(this.compound != null) { nativeStack.setTagCompound((NBTTagCompound) this.compound.copy()); } return ItemStackUtil.fromNative(nativeStack); }
Source:
<code>public <R extends OlapResult> R execute(@Nonnull DistributedJob jobRequest) throws IOException,TimeoutException{ jobRequest.markSubmitted(); try{ <START> Future<OlapResult> submit=networkLayerMap.get("default").submit(jobRequest); <END> return (R)submit.get(timeoutMillis,TimeUnit.MILLISECONDS); }catch(InterruptedException e){ Thread.currentThread().interrupt(); throw new IOException(e); }catch(ExecutionException e){ throw Exceptions.rawIOException(e.getCause()); } }</code><technical_language>Is this default a queue name</technical_language>

Target:
public <R extends OlapResult> R execute(@Nonnull DistributedJob jobRequest) throws IOException,TimeoutException{ jobRequest.markSubmitted(); try{ Future<OlapResult> submit=networkLayerMap.get(SIConstants.OLAP_DEFAULT_QUEUE_NAME).submit(jobRequest); return (R)submit.get(timeoutMillis,TimeUnit.MILLISECONDS); }catch(InterruptedException e){ Thread.currentThread().interrupt(); throw new IOException(e); }catch(ExecutionException e){ throw Exceptions.rawIOException(e.getCause()); } }
Source:
<code>public void test() throws IOException { TreeMap<Key,Value> sourceMap = new TreeMap<>(); Value emptyValue = new Value("".getBytes()); IteratorSetting iteratorSetting = new IteratorSetting(1, FirstEntryInRowIterator.class); FirstEntryInRowIterator.setNumScansBeforeSeek(iteratorSetting, 10); <START> sourceMap.put(new Key("r1", "cf", "cq"), emptyValue); <END> sourceMap.put(new Key("r2", "cf", "cq"), emptyValue); sourceMap.put(new Key("r3", "cf", "cq"), emptyValue); TreeMap<Key,Value> resultMap = new TreeMap<>(); long numSourceEntries = sourceMap.size(); long numNexts = process(sourceMap, resultMap, new Range(), iteratorSetting); assertEquals(numNexts, numSourceEntries); assertEquals(sourceMap.size(), resultMap.size()); for (int i = 0; i < 20; i++) { sourceMap.put(new Key("r2", "cf", "cq" + i), emptyValue); } resultMap.clear(); numNexts = process(sourceMap, resultMap, new Range(new Key("r1"), (new Key("r2")).followingKey(PartialKey.ROW)), iteratorSetting); assertEquals(numNexts, resultMap.size() + 10); assertEquals(resultMap.size(), 2); resultMap.clear(); numNexts = process(sourceMap, resultMap, new Range(new Key("r1"), new Key("r2", "cf2")), iteratorSetting); assertEquals(numNexts, resultMap.size() + 10); assertEquals(resultMap.size(), 2); resultMap.clear(); numNexts = process(sourceMap, resultMap, new Range(new Key("r1"), new Key("r4")), iteratorSetting); assertEquals(numNexts, resultMap.size() + 10); assertEquals(resultMap.size(), 3); }</code><technical_language>test fail if this is set properly? If not, call iteratorSetting.getOptions() this check if set</technical_language>

Target:
public void test() throws IOException { TreeMap<Key,Value> sourceMap = new TreeMap<>(); Value emptyValue = new Value("".getBytes()); IteratorSetting iteratorSetting = new IteratorSetting(1, FirstEntryInRowIterator.class); FirstEntryInRowIterator.setNumScansBeforeSeek(iteratorSetting, 10); assertTrue(iteratorSetting.getOptions().containsKey(FirstEntryInRowIterator.NUM_SCANS_STRING_NAME)); sourceMap.put(new Key("r1", "cf", "cq"), emptyValue); sourceMap.put(new Key("r2", "cf", "cq"), emptyValue); sourceMap.put(new Key("r3", "cf", "cq"), emptyValue); TreeMap<Key,Value> resultMap = new TreeMap<>(); long numSourceEntries = sourceMap.size(); long numNexts = process(sourceMap, resultMap, new Range(), iteratorSetting); assertEquals(numNexts, numSourceEntries); assertEquals(sourceMap.size(), resultMap.size()); for (int i = 0; i < 20; i++) { sourceMap.put(new Key("r2", "cf", "cq" + i), emptyValue); } resultMap.clear(); numNexts = process(sourceMap, resultMap, new Range(new Key("r1"), (new Key("r2")).followingKey(PartialKey.ROW)), iteratorSetting); assertEquals(numNexts, resultMap.size() + 10); assertEquals(resultMap.size(), 2); resultMap.clear(); numNexts = process(sourceMap, resultMap, new Range(new Key("r1"), new Key("r2", "cf2")), iteratorSetting); assertEquals(numNexts, resultMap.size() + 10); assertEquals(resultMap.size(), 2); resultMap.clear(); numNexts = process(sourceMap, resultMap, new Range(new Key("r1"), new Key("r4")), iteratorSetting); assertEquals(numNexts, resultMap.size() + 10); assertEquals(resultMap.size(), 3); }
Source:
<code><START> public static String getPath(String filename) { <END> return "src/test/resources/com/puppycrawl/tools/checkstyle/gui/" + filename; }</code><technical_language>public</technical_language>

Target:
private static String getPath(String filename) { return "src/test/resources/com/puppycrawl/tools/checkstyle/gui/" + filename; }
Source:
<code>public AlluxioCachingHdfsFileInputStream( FileInStream inputStream, Optional<FSDataInputStream> dataTierInputStream, boolean cacheValidationEnabled) { <START> this.inputStream = requireNonNull(inputStream); this.dataTierInputStream = requireNonNull(dataTierInputStream); <END> verify(!cacheValidationEnabled || dataTierInputStream.isPresent(), "data tier input need to be non-null for data validation."); this.cacheValidationEnabled = cacheValidationEnabled; }</code><technical_language>this.inputStream = requireNonNull(inputStream, "inputStream is null"); for other</technical_language>

Target:
public AlluxioCachingHdfsFileInputStream( FileInStream inputStream, Optional<FSDataInputStream> dataTierInputStream, boolean cacheValidationEnabled) { this.inputStream = requireNonNull(inputStream, "InputStream is null"); this.dataTierInputStream = requireNonNull(dataTierInputStream, "DataTierInputStream is null"); verify(!cacheValidationEnabled || dataTierInputStream.isPresent(), "data tier input need to be non-null for data validation."); this.cacheValidationEnabled = cacheValidationEnabled; }
Source:
<code>private String indent(int spaces) { <START> String indent = ""; <END> for (int i = 0; i < spaces; i++) { indent += " "; } return indent; }</code><technical_language>I realise original implementation similar this, places character in output stream, constantly copying strings this implementation is. a StringBuffer better, Formatter ("$" + spaces + "s", "") work</technical_language>

Target:
private String indent(int spaces) { if (spaces == 0) { return ""; } else { return String.format("%" + spaces + "s", " "); } }
Source:
<code>public PusherOptions setProxy(Proxy proxy){ <START> this.proxy = proxy; <END> return this; }</code><technical_language>pretty exception raised if set null here, reject early</technical_language>

Target:
public PusherOptions setProxy(Proxy proxy){ if (proxy == null) { throw new IllegalArgumentException("proxy must not be null (instead use Proxy.NO_PROXY)"); } this.proxy = proxy; return this; }
Source:
<code>public String toString() { <START> StringBuilder s = new StringBuilder("BrowserExt: " + getId() + ", " + getName() + ", " + getOS() END> + ", " + getExecutable() + ", " + getParameters() + ", "); String[] locations = getDefaultLocations(); if (locations != null) { int size = locations.length; for (int i = 0; i < size; i++) { s.append(locations[i] + ";"); } } return s.toString(); }</code><technical_language>append instead of +</technical_language>

Target:
public String toString() { StringBuilder s = new StringBuilder("BrowserExt: ").append(getId()).append(", " + getName()).append(", ") .append(getOS()).append(", ").append(getExecutable()).append(", ").append(getParameters()).append(", "); String[] locations = getDefaultLocations(); if (locations != null) { int size = locations.length; for (int i = 0; i < size; i++) { s.append(locations[i]).append(";"); } } return s.toString(); }
Source:
<code>public void write(byte b) { try { m_out.write(b); } catch (IOException e) { while (!reconnect()) { try { Thread.sleep(10000); <START> } catch (InterruptedException ie) { <END> } } } }</code><technical_language>please add logging in TRACE level miss</technical_language>

Target:
public void write(byte b) { try { m_out.write(b); } catch (IOException e) { logger.trace("got exception while writing: {}", e.getMessage()); while (!reconnect()) { try { logger.trace("sleeping before reconnecting"); Thread.sleep(10000); } catch (InterruptedException ie) { logger.warn("interrupted while sleeping on write reconnect"); } } } }
Source:
<code>public final Disposable subscribe(final Action onComplete) { ObjectHelper.requireNonNull(onComplete, "onComplete is null"); <START> return subscribe(onComplete, Functions.ON_ERROR_MISSING); <END> }</code><technical_language>need for null checks. subscribe delegates a method, call indirection avoided call new method directly</technical_language>

Target:
public final Disposable subscribe(final Action onComplete) { return subscribe(onComplete, Functions.ON_ERROR_MISSING); }
Source:
<code>protected Element getUpdatedReferenceDataSubSection(final DocumentBuilder documentBuilder) { final Resource resource = getWizardContext().getTenantContext().getConfigurationFile().toResource(); final DomConfigurationWriter writer = new DomConfigurationWriter(resource); <START> final Element stringPatternsElement = writer.getStringPatternsElement(); <END> final StringPattern stringPattern = new SimpleStringPattern(_name, _expression); stringPatternsElement.appendChild(writer.externalize(stringPattern)); return stringPatternsElement; }</code><technical_language>lines of code retrieve stringPatternsElement copy/pasted RegexSwapStringPatternReferenceDataWizardSession class. extract a separate method AbstractReferenceDataWizardSession called getStringPatternsElement() invoked classes</technical_language>

Target:
protected Element getUpdatedReferenceDataSubSection(final DocumentBuilder documentBuilder) { final Element stringPatternsElement = _writer.getStringPatternsElement(); final StringPattern stringPattern = new SimpleStringPattern(_name, _expression); stringPatternsElement.appendChild(_writer.externalize(stringPattern)); return stringPatternsElement; }
Source:
<code>public void warmup() throws Exception { CacheConfig<Integer, Long> config = new CacheConfig<Integer, Long>(); config.setName(basename); config.setTypes(Integer.class, Long.class); cacheManager.createCache(basename, config); <START> ICache cache = cacheManager.getCache(basename, Integer.class, Long.class); <END> for (int k = 0; k < keyCount; k++) { cache.put(k, 0l); } }</code><technical_language>Get cache in setup</technical_language>

Target:
public void warmup() throws Exception { CacheConfig<Integer, Long> config = new CacheConfig<Integer, Long>(); config.setName(basename); config.setTypes(Integer.class, Long.class); cacheManager.createCache(basename, config); cache = cacheManager.getCache(basename, Integer.class, Long.class); for (int k = 0; k < keyCount; k++) { cache.put(k, 0l); } }
Source:
<code>private List<ITmfEventAspect<?>> <START> getAspectsFromColumnsId(List<Long> <END> desiredColumns) { if (!desiredColumns.isEmpty()) { List<ITmfEventAspect<?>> aspects = new ArrayList<>(); for (Long columnsId : desiredColumns) { ITmfEventAspect<?> aspect = fAspectMap.get(columnsId); if (aspect != null) { aspects.add(aspect); } } return aspects; } return new ArrayList<>(fAspectMap.values()); }</code><technical_language>return a linkedHashMap avoid some forths this getColumnsIdFromAspects</technical_language>

Target:
private static Map<Long, ITmfEventAspect<?>> getAspectsFromColumnsId(List<Long> desiredColumns) { Map<Long, ITmfEventAspect<?>> aspects = new LinkedHashMap<>(); if (!desiredColumns.isEmpty()) { for (Long columnsId : desiredColumns) { ITmfEventAspect<?> aspect = fAspectMap.get(columnsId); if (aspect != null) { aspects.put(columnsId, aspect); } } return aspects; } return fAspectMap; }
Source:
<code>public byte[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { String text = jp.getText(); if (text != null) { return BASE64.decode(text); } <START> return new byte[0]; <END> }</code><technical_language>Discuss @g2vinay - this suppressed</technical_language>

Target:
public byte[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { String text = jp.getText(); if (text != null) { return BASE64.decode(text); } return null; }
Source:
<code>public View getView(int position, View convertView, ViewGroup parent) { TextView tv = (TextView) convertView; if (null == tv) { tv = new TextView(context, null); tv.setPadding(20, 30, 20, 30); tv.setCompoundDrawablePadding(10); tv.setTextAppearance(context, android.R.style.TextAppearance_DeviceDefault_Large); } DialogMenuItem menu = menus[position]; tv.setText(menu.text); <START> tv.setTypeface(Settings.iconFont); <END> if (menu.icon > 0) { tv.setCompoundDrawablesWithIntrinsicBounds(menu.icon, 0, 0, 0); } return tv; }</code><technical_language>need move line 53 54. need setTypeface creation of tv</technical_language>

Target:
public View getView(int position, View convertView, ViewGroup parent) { TextView tv = (TextView) convertView; if (null == tv) { tv = new TextView(context, null); tv.setPadding(20, 30, 20, 30); tv.setCompoundDrawablePadding(10); tv.setTextAppearance(context, android.R.style.TextAppearance_DeviceDefault_Large); tv.setTypeface(Settings.iconFont); } DialogMenuItem menu = menus[position]; tv.setText(menu.text); if (menu.icon > 0) { tv.setCompoundDrawablesWithIntrinsicBounds(menu.icon, 0, 0, 0); } return tv; }
Source:
<code>public void onDestroy() { super.onDestroy(); if (mLoadingDialog != null) { mLoadingDialog.dismiss(); mLoadingDialog = null; } <START> mDisabledDialog = null; <END> mIsDestroyed = true; }</code><technical_language>This useless</technical_language>

Target:
public void onDestroy() { super.onDestroy(); if (mLoadingDialog != null) { mLoadingDialog.dismiss(); } mIsDestroyed = true; }
Source:
<code>public void putTicket(ImageTicket ticket) { BasicHttpEntityEnclosingRequest request = (BasicHttpEntityEnclosingRequest) getRequest("PUT", TICKETS_URI + ticket.getId()); StringEntity entity = new StringEntity(ImageTicketHelper.toJson(ticket).toString(), StandardCharsets.UTF_8); request.setEntity(entity); request.setHeader("content-length", <START> String.valueOf(request.getEntity().getContentLength())); <END> HttpEntity response = sendRequest(request); consumeEntity(response); }</code><technical_language>entity</technical_language>

Target:
public void putTicket(ImageTicket ticket) { BasicHttpEntityEnclosingRequest request = (BasicHttpEntityEnclosingRequest) getRequest("PUT", TICKETS_URI + ticket.getId()); StringEntity entity = new StringEntity(ImageTicketHelper.toJson(ticket).toString(), StandardCharsets.UTF_8); request.setEntity(entity); request.setHeader("content-length", String.valueOf(request.getEntity().getContentLength())); HttpEntity response = executeRequest(request); consumeEntity(response); }
Source:
<code>public void onPlayerWalks(final PlayerMoveEvent event) { if (event.getFrom().getY() > 255 || event.getFrom().getY() < 0 || event.getTo().getY() > 255 || event.getTo().getY() < 0) { return; } Location from = event.getFrom().getBlock().getLocation(); Location to = event.getTo().getBlock().getLocation(); if (from.equals(to)) { return; } <START> if (!from.getWorld().getName().equalsIgnoreCase(to.getWorld().getName())) { <END> return; } int maxRad = 50 * 50; for (final NPC npc: getAllNPCs()) { if (npc.isSpawned() && npc.getEntity().getType() == EntityType.PLAYER) { if (from.getWorld().getName().equalsIgnoreCase(npc.getEntity().getLocation().getWorld().getName()) && npc.getEntity().getLocation().distanceSquared(to) < maxRad && npc.getEntity().getLocation().distanceSquared(from) > maxRad) { showNPCReset(event.getPlayer(), npc); } } } }</code><technical_language>==</technical_language>

Target:
public void onPlayerWalks(final PlayerMoveEvent event) { Location from = roundLocation(event.getFrom()); Location to = roundLocation(event.getTo()); if (from.equals(to)) { return; } if (from.getWorld() != to.getWorld()) { return; } int maxRad = 50 * 50; for (final NPC npc: getAllNPCs()) { if (npc.isSpawned() && npc.getEntity().getType() == EntityType.PLAYER) { if (from.getWorld().getName().equalsIgnoreCase(npc.getEntity().getLocation().getWorld().getName()) && npc.getEntity().getLocation().distanceSquared(to) < maxRad && npc.getEntity().getLocation().distanceSquared(from) > maxRad) { showNPCReset(event.getPlayer(), npc); } } } }
Source:
<code>public static double argmax(final Function<Double, Double> function, final double min, final double max, final double guess) { <START> final UnivariateObjectiveFunction objective = new UnivariateObjectiveFunction(x -> function.apply(x)); <END> final SearchInterval interval= new SearchInterval(min, max, guess); return DEFAULT_OPTIMIZER.optimize(objective, GoalType.MAXIMIZE, interval, DEFAULT_MAX_EVAL).getPoint(); }</code><technical_language>function::apply</technical_language>

Target:
public static double argmax(final Function<Double, Double> function, final double min, final double max, final double guess) { final SearchInterval interval = new SearchInterval(min, max, guess); return DEFAULT_OPTIMIZER.optimize(new UnivariateObjectiveFunction(function::apply), GoalType.MAXIMIZE, interval, DEFAULT_MAX_EVAL).getPoint(); }
Source:
<code>public <T extends Node> T getNode(String nodeNameSuffix) { String fullNodeName = params.getFullNodeName(nodeNameSuffix); Node node = nodes.get(fullNodeName); <START> if (node == null) { <END> throw new NodeException(String.format( "Node not found. Node name: %s, cluster: %s, cluster nodes: %s", fullNodeName, params.getName(), nodes.keySet()) ); } return ClassUtils.cast(node); }</code><technical_language>please Optional</technical_language>

Target:
public <T extends Node> T getNode(String nodeNameSuffix) { String fullNodeName = params.getFullNodeName(nodeNameSuffix); Optional<Node> node = Optional.ofNullable(nodes.get(fullNodeName)); if (!node.isPresent()) { throw new NodeException(String.format( "Node not found. Node name: %s, cluster: %s, cluster nodes: %s", fullNodeName, params.getName(), nodes.keySet()) ); } return ClassUtils.cast(node.get()); }
Source:
<code>protected void inserted(Object[] elements, int index) { List<Object> kids = null; boolean changed = false; synchronized (this) { ModelNode[] childrenNodes = getRootNode().getChildrenNodes(); if (childrenNodes == null) { kids = new ArrayList<>(elements.length); } else { kids = new ArrayList<>(elements.length + childrenNodes.length); for (ModelNode <START> childrenNode : <END> childrenNodes) { kids.add(childrenNode.getElement()); } } for (Object element : elements) { if (!kids.contains(element)) { kids.add(index, element); index++; changed = true; } } } if (changed) { setChildren(getRootNode(), kids); } }</code><technical_language>rename childNode</technical_language>

Target:
protected void inserted(Object[] elements, int index) { List<Object> kids = null; boolean changed = false; synchronized (this) { ModelNode[] childrenNodes = getRootNode().getChildrenNodes(); if (childrenNodes == null) { kids = new ArrayList<>(elements.length); } else { kids = new ArrayList<>(elements.length + childrenNodes.length); for (ModelNode childNode : childrenNodes) { kids.add(childNode.getElement()); } } for (Object element : elements) { if (!kids.contains(element)) { kids.add(index, element); index++; changed = true; } } } if (changed) { setChildren(getRootNode(), kids); } }
Source:
<code>public static Jenkins getInstance() { Jenkins instance = HOLDER.getInstance(); if (instance == null) { if(!Boolean.getBoolean(Jenkins.class.getName()+".disableExceptionOnNullInstance")) { <START> throw new IllegalStateException(); <END> } } return instance; }</code><technical_language>useful restore original text</technical_language>

Target:
public static Jenkins getInstance() { Jenkins instance = HOLDER.getInstance(); if (instance == null) { if(!Boolean.getBoolean(Jenkins.class.getName()+".disableExceptionOnNullInstance")) { throw new IllegalStateException("Jenkins has not been started, or was already shut down"); } } return instance; }
Source:
<code>void stop(int reason) { int uid = Binder.getCallingUid(); if (uid != mUid && uid != Process.SYSTEM_UID) { if (DBG) { Log.e(TAG, "Cannot stop unowned keepalive " + mSlot + " on " + mNai.network); } } if (NOT_STARTED != mStartedState) { Log.d(TAG, "Stopping keepalive " + mSlot + " on " + mNai.name()); if (mType == TYPE_NATT) { mNai.asyncChannel.sendMessage(CMD_STOP_SOCKET_KEEPALIVE, mSlot); } else if (mType == TYPE_TCP) { mNai.asyncChannel.sendMessage(CMD_STOP_SOCKET_KEEPALIVE, mSlot); <START> mNai.asyncChannel.sendMessage(CMD_REMOVE_KEEPALIVE_PACKET_FILTER, <END> mSlot, mInterval, mPacket); mTcpController.stopSocketMonitor(mSlot); } else { Log.wtf(TAG, "Stoping keepalive with unknown type: " + mType); } } notifyMessenger(mSlot, reason); unlinkDeathRecipient(); }</code><technical_language>FWIW do bugs filed drop incoming NAT-T keepalives</technical_language>

Target:
void stop(int reason) { int uid = Binder.getCallingUid(); if (uid != mUid && uid != Process.SYSTEM_UID) { if (DBG) { Log.e(TAG, "Cannot stop unowned keepalive " + mSlot + " on " + mNai.network); } } if (NOT_STARTED != mStartedState) { Log.d(TAG, "Stopping keepalive " + mSlot + " on " + mNai.name()); if (mType == TYPE_NATT) { mNai.asyncChannel.sendMessage(CMD_STOP_SOCKET_KEEPALIVE, mSlot); } else if (mType == TYPE_TCP) { mNai.asyncChannel.sendMessage(CMD_STOP_SOCKET_KEEPALIVE, mSlot); mNai.asyncChannel.sendMessage(CMD_REMOVE_KEEPALIVE_PACKET_FILTER, mSlot); mTcpController.stopSocketMonitor(mSlot); } else { Log.wtf(TAG, "Stopping keepalive with unknown type: " + mType); } } notifyMessenger(mSlot, reason); unlinkDeathRecipient(); }
Source:
<code>public final void doFilter( ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { final HttpServletRequest httpRequest = (HttpServletRequest) request; final HttpSession session = httpRequest.getSession(false); if (session != null) { <START> Subject subject = (Subject) session.getAttribute("che_subject"); <END> if (subject != null && subject.getUserId() != null) { MDC.put(IDENTITY_ID_MDC_KEY, subject.getUserId()); } } try { filterChain.doFilter(request, response); } finally { MDC.remove(IDENTITY_ID_MDC_KEY); } }</code><technical_language>Subject EnvironmentContext</technical_language>

Target:
public final void doFilter( ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { Subject subject = EnvironmentContext.getCurrent().getSubject(); if (subject != null && subject.getUserId() != null) { MDC.put(IDENTITY_ID_MDC_KEY, subject.getUserId()); } try { filterChain.doFilter(request, response); } finally { MDC.remove(IDENTITY_ID_MDC_KEY); } }
Source:
<code>private static boolean assertSameHtml(String expected, String actual, boolean isPart, boolean isDifferenceToBeShown) { <START> String processedExpected = expected.replace("\r", ""); <END> String processedActual = convertToStandardHtml(actual, isPart); if (areDifferentHtmls(processedExpected, processedActual)) { processedExpected = convertToStandardHtml(expected, isPart); if (areDifferentHtmls(processedExpected, processedActual)) { if (isDifferenceToBeShown) { assertEquals("<expected>\n" + processedExpected + "</expected>", "<actual>\n" + processedActual + "</actual>"); } return false; } } return true; }</code><technical_language>@wkurniawan07 if this _only_ for CR+LF case, try more specific using: replace("\r\n", "\n");</technical_language>

Target:
private static boolean assertSameHtml(String expected, String actual, boolean isPart, boolean isDifferenceToBeShown) { String processedExpected = standardizeLineBreaks(expected); String processedActual = convertToStandardHtml(actual, isPart); if (areSameHtmls(processedExpected, processedActual)) { return true; } processedExpected = convertToStandardHtml(expected, isPart); if (areSameHtmls(processedExpected, processedActual)) { return true; } else { if (isDifferenceToBeShown) { assertEquals("<expected>\n" + processedExpected + "</expected>", "<actual>\n" + processedActual + "</actual>"); } return false; } }
Source:
<code>void jul() { logger.finest("Unable to open file " + csvPath); logger.finer("Unable to open file " + csvPath); logger.fine("Unable to open file " + csvPath); logger.config("Unable to open file " + csvPath); logger.info("Unable to open file " + csvPath); logger.warning("Unable to open file " + csvPath); logger.severe("Unable to open file " + csvPath); <START> if (logger.isFinestEnabled()) { <END> logger.finest("Unable to open file " + csvPath); } if (logger.isFinerEnabled()) { logger.finer("Unable to open file " + csvPath); } if (logger.isFineEnabled()) { logger.fine("Unable to open file " + csvPath); } if (logger.isFinestEnabled()) { logger.finest("Unable to open file " + csvPath); } if (logger.isConfigEnabled()) { logger.config("Unable to open file " + csvPath); } if (logger.isInfoEnabled()) { logger.info("Unable to open file " + csvPath); } if (logger.isWarningEnabled()) { logger.warning("Unable to open file " + csvPath); } if (logger.isSevereEnabled()) { logger.severe("Unable to open file " + csvPath); } }</code><technical_language>is fishy implementation, in if-condition visitor (especially name is matching). code raise issue, I expect (you test this case...): void foo(boolean b) { if (b) { logger.finest("Unable open file " + csvPath); // Noncompliant } }</technical_language>

Target:
void jul() { logger.finest("Unable to open file " + csvPath); logger.finer("Unable to open file " + csvPath); logger.fine("Unable to open file " + csvPath); logger.config("Unable to open file " + csvPath); logger.info("Unable to open file " + csvPath); logger.warning("Unable to open file " + csvPath); logger.severe("Unable to open file " + csvPath); if (logger.isLoggable(Level.FINEST)) { logger.finest("Unable to open file " + csvPath); } if (logger.isLoggable(Level.INFO)) { logger.trace("Unable to open file " + csvPath); logger.info("Unable to open file " + csvPath); } }
Source:
<code>public static boolean checkPerm(EntityPlayer player, String node, Map<String, IContext> contextInfo) { if (player instanceof FakePlayer) <START> throw new IllegalArgumentException("You cannot check permissions with a fake player. Use PermManager.getPerm(username, node)"); <END> return FACTORY.checkPerm(player, node, contextInfo); }</code><technical_language>Obnoxious buggy. FACTORY determine permissions fake players have</technical_language>

Target:
public static boolean checkPerm(EntityPlayer player, String node, Map<String, IContext> contextInfo) { return FACTORY.checkPerm(player, node, contextInfo); }
Source:
<code>public String getCollectionInput() { MultiInstanceLoopCharacteristics loopCharacteristics = getMultiInstanceLoopCharacteristics(); ItemAwareElement ieDataInput = loopCharacteristics.getLoopDataInputRef(); return process.getDataInputAssociations().stream() .filter(dia -> dia.getTargetRef().equals(ieDataInput)) .map(dia -> dia.getSourceRef().get(0).getId()) .findFirst() <START> .get(); <END> }</code><technical_language>Is safe call get() isPresent() there</technical_language>

Target:
public String getCollectionInput() { ItemAwareElement ieDataInput = getMultiInstanceLoopCharacteristics() .map(MultiInstanceLoopCharacteristics::getLoopDataInputRef) .orElse(null); return process.getDataInputAssociations().stream() .filter(dia -> dia.getTargetRef().getId().equals(ieDataInput.getId())) .map(dia -> ProcessVariableReader.getProcessVariableName((Property) dia.getSourceRef().get(0))) .findFirst() .orElse(null); }
Source:
<code>public static String randomAllocateIpv4Address(Long startIp, Long endIp, List<Long> allocatedIps) { int total = (int)(endIp - startIp + 1); if (total == allocatedIps.size()) { return null; } <START> if (startIp == endIp){ <END> return longToIpv4String(startIp); } BitSet full = new BitSet(total); for (long alloc : allocatedIps) { full.set((int) (alloc-startIp)); } Random random = new Random(); int next = random.nextInt(total); int a = full.nextClearBit(next); if (a >= total) { a = full.nextClearBit(0); } return longToIpv4String(a + startIp); }</code><technical_language>need update</technical_language>

Target:
public static String randomAllocateIpv4Address(Long startIp, Long endIp, List<Long> allocatedIps) { int total = (int)(endIp - startIp + 1); if (total == allocatedIps.size()) { return null; } if (startIp.equals(endIp) && allocatedIps.size() == 0){ return longToIpv4String(startIp); } BitSet full = new BitSet(total); for (long alloc : allocatedIps) { full.set((int) (alloc-startIp)); } Random random = new Random(); int next = random.nextInt(total); int a = full.nextClearBit(next); if (a >= total) { a = full.nextClearBit(0); } return longToIpv4String(a + startIp); }
Source:
<code><START> public WriterTarget getTarget() <END> { return target; }</code><technical_language>Add @JsonIgnore</technical_language>

Target:
public Optional<WriterTarget> getTarget() { return target; }
Source:
<code>public void select(final MenuItem item) { Boolean enabled = Display.syncExec(new ResultRunnable<Boolean>() { @Override public Boolean run() { return isMenuItemEnabled(item); } }); if (!enabled) { throw new CoreLayerException("Menu item is not enabled"); } else { Display.syncExec(new Runnable() { @Override public void run() { if (((item.getStyle() & SWT.RADIO) != 0) || ((item.getStyle() & SWT.CHECK) != 0)) { item.setSelection(!item.getSelection()); } } }); Display.asyncExec(new Runnable() { @Override public void run() { final Event event = new Event(); event.time = (int) System.currentTimeMillis(); event.widget = item; event.item = item; event.display = item.getDisplay(); event.type = SWT.Selection; <START> log.info("Click on menu item: " + item.getText()); <END> item.notifyListeners(SWT.Selection, event); } }); Display.syncExec(new Runnable() { @Override public void run() { } }); } }</code><technical_language>log info "Selecting menu item" "Select menu item", bcs send selection event, mouse down/up</technical_language>

Target:
public void select(final MenuItem item) { if (!isEnabled(item)) { throw new CoreLayerException("Menu item is not enabled"); } else { Display.syncExec(new Runnable() { @Override public void run() { if (((item.getStyle() & SWT.RADIO) != 0) || ((item.getStyle() & SWT.CHECK) != 0)) { item.setSelection(!item.getSelection()); } } }); Display.asyncExec(new Runnable() { @Override public void run() { final Event event = createSelectionEvent(item); log.info("Select menu item: " + item.getText()); item.notifyListeners(SWT.Selection, event); } }); Display.syncExec(new Runnable() { @Override public void run() { } }); } }
Source:
<code>private void closeViewer() { if (getRoot() != null) <START> BagsManager.instance().unwatch(getRoot()); <END> tryNavigate(_history.empty()); treeSnapshots.clear(); try { SwingUtilities.getWindowAncestor(this).dispose(); } catch (Exception ex) { LOG.log(Level.WARNING, "Couldn't close viewer window", ex); } _orderedInstances.remove(this); PluginRegistry.unregisterConsumer(this); OT.removeEditableStateListener(_editableStateListener); _actions.close(); ViewerService.instance().get().unregisterView(this); }</code><technical_language>open more a single program in a viewer. viewer is closed, cleanup include programs in viewer. confirm this is happening required? working fine this removing active program in view</technical_language>

Target:
private void closeViewer() { if (getRoot() != null) { BagsManager.instance().unwatch(getRoot()); } tryNavigate(_history.empty()); treeSnapshots.clear(); try { SwingUtilities.getWindowAncestor(this).dispose(); } catch (Exception ex) { LOG.log(Level.WARNING, "Couldn't close viewer window", ex); } _orderedInstances.remove(this); PluginRegistry.unregisterConsumer(this); OT.removeEditableStateListener(_editableStateListener); _actions.close(); ViewerService.instance().get().unregisterView(this); }
Source:
<code>public String getNextID(Class<? extends OWLEntity> type) throws AutoIDException { String id = nextId; try { nextId = Util.randomProlong(); } catch (Exception e) { <START> e.printStackTrace(); <END> } return getPrefix(type) + id.toString().replace("-", "_") + getSuffix(type); }</code><technical_language>Please remove e.printStackTrace() a logger (slf4j) log exceptions</technical_language>

Target:
public String getNextID(Class<? extends OWLEntity> type) throws AutoIDException { try { nextId = Util.randomProlong(); } catch (Exception e) { logger.error("An error occurred whilst attempting to get the next ID", e); } return getPrefix(type) + nextId.toString() + getSuffix(type); }