auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static int indexOfChangeId(String message, String delimiter) { String[] lines = message.split(delimiter); int indexOfChangeIdLine = 0; boolean inFooter = false; for (int i = lines.length - 1; i >= 0; --i) { if (!inFooter && isEmptyLine(lines[i])) continue; inFooter = true; <START> if (changeIdPattern.matcher(lines[i].trim()).matches()) { <END> indexOfChangeIdLine = i; break; } else if (isEmptyLine(lines[i]) || i == 0) return -1; } int indexOfChangeIdLineinString = 0; for (int i = 0; i < indexOfChangeIdLine; ++i) indexOfChangeIdLineinString += lines[i].length() + delimiter.length(); return indexOfChangeIdLineinString + lines[indexOfChangeIdLine].indexOf(CHANGE_ID); }</code><technical_language>amending removes lines indented Change-Id, trimming right side fixes this</technical_language>

Target:
public static int indexOfChangeId(String message, String delimiter) { String[] lines = message.split(delimiter); int indexOfChangeIdLine = 0; boolean inFooter = false; for (int i = lines.length - 1; i >= 0; --i) { if (!inFooter && isEmptyLine(lines[i])) continue; inFooter = true; if (changeIdPattern.matcher(trimRight(lines[i])).matches()) { indexOfChangeIdLine = i; break; } else if (isEmptyLine(lines[i]) || i == 0) return -1; } int indexOfChangeIdLineinString = 0; for (int i = 0; i < indexOfChangeIdLine; ++i) indexOfChangeIdLineinString += lines[i].length() + delimiter.length(); return indexOfChangeIdLineinString + lines[indexOfChangeIdLine].indexOf(CHANGE_ID); }
Source:
<code>public void save(final Map<?, ?> options) throws IOException { TransactionalEditingDomain domain = ((ModelSet) getResourceSet()).getTransactionalEditingDomain(); CompoundCommand compoundCommand = new CompoundCommandNonDirty("Modify top <START> tables"); <END> for (final EObject top : getContents()) { if (top instanceof Table) { compoundCommand.append(getDisposeTableCommand(domain, (Table) top)); } } domain.getCommandStack().execute(compoundCommand); super.save(options); }</code><technical_language>add tag for string please</technical_language>

Target:
public void save(final Map<?, ?> options) throws IOException { final TransactionalEditingDomain domain = ((ModelSet) getResourceSet()).getTransactionalEditingDomain(); final CompoundCommand compoundCommand = new CompoundCommand("Modify top tables"); for (final EObject top : getContents()) { if (top instanceof Table) { compoundCommand.append(getDisposeTableCommand(domain, (Table) top)); } } try { GMFUnsafe.write(domain, compoundCommand); } catch (InterruptedException e) { Activator.log.error(e); } catch (RollbackException e) { Activator.log.error(e); } finally { super.save(options); } }
Source:
<code>private long countMapWithAtleastOneQueryCache(Node node) { return maps.stream().filter(distributedObject -> { MapConfig config = node.getConfig().getMapConfig(distributedObject.getName()); if (config != null) { <START> return config.getQueryCacheConfigs().size() >= 1; <END> } return false; }).count(); }</code><technical_language>Please write !config.getQueryCacheConfigs().isEmpty() instead of checking size</technical_language>

Target:
private long countMapWithAtleastOneQueryCache(Node node) { return maps.stream().filter(distributedObject -> { MapConfig config = node.getConfig().getMapConfig(distributedObject.getName()); if (config != null) { return !config.getQueryCacheConfigs().isEmpty(); } return false; }).count(); }
Source:
<code>public void loadDashboards(RuntimeModel runtimeModel) { NavTree navTree = runtimeModel.getNavTree(); Menus menus = menusHelper.buildMenusFromNavTree(navTree).build(); view.addMenus(menus); <START> goToIndex(runtimeModel.getLayoutTemplates()); <END> }</code><technical_language>move this call RouterScreen.java? loadDashboards more responsibilities implies. more sense RouterScreen call loadDashboards goToIndex</technical_language>

Target:
public void loadDashboards(RuntimeModel runtimeModel) { NavTree navTree = runtimeModel.getNavTree(); Menus menus = menusHelper.buildMenusFromNavTree(navTree).build(); view.addMenus(menus); }
Source:
<code>private String createFxmlPath(Class<?> viewType) { String emptyPath = ""; final StringBuilder pathBuilder = new StringBuilder(); FxmlPath annotation = viewType.getDeclaredAnnotation(FxmlPath.class); String path = annotation != null ? annotation.value() : emptyPath; <START> if (!emptyPath.equalsIgnoreCase(path)) { <END> pathBuilder.append(path); } else { pathBuilder.append("/"); if (viewType.getPackage() != null) { pathBuilder.append(viewType.getPackage().getName().replaceAll("\\.", "/")); pathBuilder.append("/"); } pathBuilder.append(viewType.getSimpleName()); pathBuilder.append(".fxml"); } return pathBuilder.toString(); }</code><technical_language>In oppinion "emptyPath" variable code more difficult understand. I empty string literal "" in assignment line 132 check for path != null && path.trim().isEmpty() in conditional line 135 This takes account annotation null. Another (in oppinion more readable) approach is java.util.Optional: java final FxmlPath pathAnnotation = viewType.getDeclaredAnnotation(FxmlPath.class); final String fxmlPath = Optional.ofNullable(pathAnnotation) .map(annotation -> annotation.value()) .map(path -> path.trim()) .orElse(""); if(fxmlPath.isEmpty()) { ..</technical_language>

Target:
private String createFxmlPath(Class<?> viewType) { final StringBuilder pathBuilder = new StringBuilder(); final FxmlPath pathAnnotation = viewType.getDeclaredAnnotation(FxmlPath.class); final String fxmlPath = Optional.ofNullable(pathAnnotation) .map(FxmlPath::value) .map(String::trim) .orElse(""); if (fxmlPath.isEmpty()) { pathBuilder.append("/"); if (viewType.getPackage() != null) { pathBuilder.append(viewType.getPackage().getName().replaceAll("\\.", "/")); pathBuilder.append("/"); } pathBuilder.append(viewType.getSimpleName()); pathBuilder.append(".fxml"); } else { pathBuilder.append(fxmlPath); } return pathBuilder.toString(); }
Source:
<code>public IntervalListTest() { <START> fileHeader = IntervalList.fromFile(new File(TEST_DIR, "/IntervalListchr123_empty.interval_list")).getHeader(); <END> fileHeader.setSortOrder(SAMFileHeader.SortOrder.unsorted); list1 = new IntervalList(fileHeader); list2 = new IntervalList(fileHeader); list3 = new IntervalList(fileHeader); list1.add(new Interval("1", 1, 100)); list1.add(new Interval("1", 101, 200)); list1.add(new Interval("1", 202, 300)); list1.add(new Interval("2", 200, 300)); list1.add(new Interval("2", 100, 150)); list2.add(new Interval("1", 50, 150)); list2.add(new Interval("1", 301, 500)); list2.add(new Interval("2", 1, 150)); list2.add(new Interval("2", 250, 270)); list2.add(new Interval("2", 290, 400)); list3.add(new Interval("1", 25, 400)); list3.add(new Interval("2", 200, 600)); list3.add(new Interval("3", 50, 470)); }</code><technical_language>nice migrate this Path, e.g. TEST_DIR Path TEST_DIR.resolve("/xxx/xxx/") suggestion fileHeader = IntervalList.fromPath(TEST_DIR.resolve("/IntervalListchr123_empty.interval_list")).getHeader();</technical_language>

Target:
public IntervalListTest() { fileHeader = IntervalList.fromPath(TEST_DIR.resolve("IntervalListchr123_empty.interval_list")).getHeader(); fileHeader.setSortOrder(SAMFileHeader.SortOrder.unsorted); list1 = new IntervalList(fileHeader); list2 = new IntervalList(fileHeader); list3 = new IntervalList(fileHeader); list1.add(new Interval("1", 1, 100)); list1.add(new Interval("1", 101, 200)); list1.add(new Interval("1", 202, 300)); list1.add(new Interval("2", 200, 300)); list1.add(new Interval("2", 100, 150)); list2.add(new Interval("1", 50, 150)); list2.add(new Interval("1", 301, 500)); list2.add(new Interval("2", 1, 150)); list2.add(new Interval("2", 250, 270)); list2.add(new Interval("2", 290, 400)); list3.add(new Interval("1", 25, 400)); list3.add(new Interval("2", 200, 600)); list3.add(new Interval("3", 50, 470)); }
Source:
<code>public SResolver normalResolution(final VirtualFrame frame, final SResolver resolver, final Object result, final boolean haltOnResolver, final boolean haltOnResolution) { SPromise promise = resolver.getPromise(); if (haltOnResolver || promise.haltOnResolver()) { haltNode.executeEvaluated(frame, result); } resolvePromise(Resolution.SUCCESSFUL, resolver, result, <START> haltOnResolution || promise.haltOnResolution()); <END> return resolver; }</code><technical_language>I understand a promiseResolutionBreakpoint is set a createPromisePair primitive for triggering breakpoint, implementation idea is same: check a flag promise. new changes, reused flag for triggering a promise resolution breakpoint, call haltOnResolution. I sense, I variant in moment</technical_language>

Target:
public SResolver normalResolution(final VirtualFrame frame, final SResolver resolver, final Object result, final boolean haltOnResolver, final boolean haltOnResolution) { SPromise promise = resolver.getPromise(); if (haltOnResolver || promise.getHaltOnResolver()) { haltNode.executeEvaluated(frame, result); } resolvePromise(Resolution.SUCCESSFUL, resolver, result, haltOnResolution || promise.getHaltOnResolution()); return resolver; }
Source:
<code><START> String getPluginName() { <END> return pluginName; }</code><technical_language>this protected</technical_language>

Target:
protected String getPluginName() { return pluginName; }
Source:
<code>protected ComplianceReasonTranslator initObjectTranslator() { <START> return this.ComplianceReasonTranslator; <END> }</code><technical_language>I a bit petty, reading this a while realize a variable starting capital letter triggered a bit :D</technical_language>

Target:
protected ComplianceReasonTranslator initObjectTranslator() { this.translator = new ComplianceReasonTranslator(); return this.translator; }
Source:
<code>public void test_setAttribute_empty_array() { final SAMFileHeader header = new SAMFileHeader(); final String arrayTag = "XA"; final SAMRecord record = new SAMRecord(header); Assert.assertNull(record.getStringAttribute(arrayTag)); record.setAttribute(arrayTag, new int[0]); Assert.assertNotNull(record.getSignedIntArrayAttribute(arrayTag)); Assert.assertEquals(record.getSignedIntArrayAttribute(arrayTag),new int[0]); record.getSAMString(); Assert.assertEquals(record.getAttribute(arrayTag), new char[0]); record.setAttribute(arrayTag, null); Assert.assertNull(record.getStringAttribute(arrayTag)); <START> <END> }</code><technical_language>remove excess nls</technical_language>

Target:
public void test_setAttribute_empty_array() { final SAMFileHeader header = new SAMFileHeader(); final SAMRecord record = new SAMRecord(header); Assert.assertNull(record.getStringAttribute(ARRAY_TAG)); record.setAttribute(ARRAY_TAG, new int[0]); Assert.assertNotNull(record.getSignedIntArrayAttribute(ARRAY_TAG)); Assert.assertEquals(record.getSignedIntArrayAttribute(ARRAY_TAG), new int[0]); Assert.assertEquals(record.getAttribute(ARRAY_TAG), new char[0]); record.setAttribute(ARRAY_TAG, null); Assert.assertNull(record.getStringAttribute(ARRAY_TAG)); }
Source:
<code>public void testCopy() { final String definition = "Human lives in \"{city}\""; final String drl = "Human(city==\"{city}\")"; final DSLSentence original = makeDslSentence(definition, drl); final DSLSentence copy = original.copy(); assertEquals(copy.getDefinition(), original.getDefinition()); assertEquals(copy.getDrl(), original.getDrl()); <START> assertEquals(copy.getValues().size(), <END> original.getValues().size()); }</code><technical_language>Please assert sizes equals this test pass if size is zero. getValues() return DSLVariableValue - city. Please enhance assertion</technical_language>

Target:
public void testCopy() { final String definition = "Human lives in \"{city}\""; final String drl = "Human(city==\"{city}\")"; final DSLSentence original = makeDslSentence(definition, drl); final DSLSentence copy = original.copy(); assertEquals(original.getDefinition(), copy.getDefinition()); assertEquals(original.getDrl(), copy.getDrl()); assertEquals(original.getValues(), copy.getValues()); assertEquals(firstValue(original), firstValue(copy)); assertNotSame(firstValue(original), firstValue(copy)); }
Source:
<code>protected boolean deleteAndVerifyContainerGone(String container) { <START> return this.api.deleteContainerMetadata(this.getUserWorkspace(), container); <END> }</code><technical_language>Is this verifying container gone? be</technical_language>

Target:
protected boolean deleteAndVerifyContainerGone(String container) { this.api.deleteContainerViaWorkspaceApi(this.getUserWorkspace(), container); return !containerExists(container); }
Source:
<code>public Cohort removePatientFromCohort(Cohort cohort, Patient patient) { <START> if (cohort.contains(patient)) { <END> cohort.removeMember(patient); Context.getCohortService().saveCohort(cohort); } return cohort; }</code><technical_language>Based implementation of equals, this correct thing, a patient multiple memberships in cohort technically active one. want remove active membership for this patient membership</technical_language>

Target:
public Cohort removePatientFromCohort(Cohort cohort, Patient patient) { if (cohort.contains(patient.getPatientId())) { cohort.removeMember(patient); Context.getCohortService().saveCohort(cohort); } return cohort; }
Source:
<code>private String resolveEnvParams(String content) { Pattern pattern = Pattern.compile("\\$\\{(\\w+(:-.+)?)\\}"); Matcher m = pattern.matcher(content); while (m.find()) { String[] parts = m.group(1).split(":-"); <START> String v = env.get(parts[0]); <END> if (v != null) { content = content.replace(m.group(), v); } else if (parts.length == 2) { content = content.replace(m.group(), parts[1]); } } return content; }</code><technical_language>Please extract invocation of System.getenv separate provider object</technical_language>

Target:
private String resolveEnvParams(String content) { Pattern pattern = Pattern.compile("\\$\\{(\\w+(:-.+)?)\\}"); Matcher m = pattern.matcher(content); while (m.find()) { String[] parts = m.group(1).split(":-"); String v = System.getenv(parts[0]); if (v != null) { content = content.replace(m.group(), v); } else if (parts.length == 2) { content = content.replace(m.group(), parts[1]); } } return content; }
Source:
<code>public VoltDBPSerialAggregate( RelOptCluster cluster, RelTraitSet traitSet, RelNode child, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls, RexNode postPredicate, int splitCount, boolean isCoordinatorAggr) { <START> this(cluster, <END> traitSet, child, indicator, groupSet, groupSets, aggCalls, postPredicate, splitCount, isCoordinatorAggr, null, null); }</code><technical_language>prefer super(cluster, traitSet, child, ..., isCoordinatorAggr); (is this valid syntax? need declare m_offset/m_limit null L37-38?): slightly more straightforward</technical_language>

Target:
public VoltDBPSerialAggregate( RelOptCluster cluster, RelTraitSet traitSet, RelNode child, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls, RexNode postPredicate, int splitCount, boolean isCoordinatorAggr) { super(cluster, traitSet, child, indicator, groupSet, groupSets, aggCalls, postPredicate, splitCount, isCoordinatorAggr); m_offset = null; m_limit = null; }
Source:
<code>public void visitBinaryExpression(BinaryExpressionTree tree) { Tree.Kind peek = stack.peek(); Tree.Kind kind = getKind(tree); if (requiresParenthesis(peek, kind)) { <START> raiseIssue(); <END> } stack.push(kind); super.visitBinaryExpression(tree); stack.pop(); }</code><technical_language>Raise issue line of operator, accessed tree.operatorToken().line()</technical_language>

Target:
public void visitBinaryExpression(BinaryExpressionTree tree) { Tree.Kind peek = stack.peek(); Tree.Kind kind = getKind(tree); if (requiresParenthesis(peek, kind)) { raiseIssue(tree.operatorToken().line(), tree); } stack.push(kind); super.visitBinaryExpression(tree); stack.pop(); }
Source:
<code>public Proc launch(ProcStarter ps) throws IOException { if (!ps.quiet) { maskedPrintCommandLine(ps.commands, ps.masks, ps.pwd); } EnvVars jobEnv = inherit(ps.envs); String[] jobCmd = new String[ps.commands.size()]; for ( int idx = 0 ; idx < jobCmd.length; idx++ ) jobCmd[idx] = jobEnv.expand(ps.commands.get(idx)); if (Functions.isWindows()) { <START> jobCmd = new ArgumentListBuilder(jobCmd).toWindowsCommand().toCommandArray(); <END> } return new LocalProc(jobCmd, Util.mapToEnv(jobEnv), ps.reverseStdin ?LocalProc.SELFPUMP_INPUT:ps.stdin, ps.reverseStdout?LocalProc.SELFPUMP_OUTPUT:ps.stdout, ps.reverseStderr?LocalProc.SELFPUMP_OUTPUT:ps.stderr, toFile(ps.pwd)); }</code><technical_language>if this windows box is running POSIX subsystem - cygwin? pass this break installations</technical_language>

Target:
public Proc launch(ProcStarter ps) throws IOException { if (!ps.quiet) { maskedPrintCommandLine(ps.commands, ps.masks, ps.pwd); } EnvVars jobEnv = inherit(ps.envs); String[] jobCmd = new String[ps.commands.size()]; for ( int idx = 0 ; idx < jobCmd.length; idx++ ) jobCmd[idx] = jobEnv.expand(ps.commands.get(idx)); if (!isUnix()) { jobCmd = escapeForWindows(jobCmd); } return new LocalProc(jobCmd, Util.mapToEnv(jobEnv), ps.reverseStdin ?LocalProc.SELFPUMP_INPUT:ps.stdin, ps.reverseStdout?LocalProc.SELFPUMP_OUTPUT:ps.stdout, ps.reverseStderr?LocalProc.SELFPUMP_OUTPUT:ps.stderr, toFile(ps.pwd)); }
Source:
<code>public Opt<Identity> enter(final Request req) throws IOException { final Iterator<String> headers = new RqHeaders.Base(req) .header(this.header).iterator(); Opt<Identity> user = new Opt.Empty<>(); String head = ""; while (headers.hasNext()) { final String nexthead = headers.next(); if (nexthead.trim().startsWith("Bearer")) { head = nexthead; break; } } final String dot = "\\."; if (head.length() > 0) { final String jwt = head.trim().split(" ", 2)[1].trim(); final byte[] jwtheader = jwt.split(dot)[0].getBytes(); final byte[] jwtpayload = jwt.split(dot)[1].getBytes(); <START> final byte[] jwtsign = jwt.split(dot)[2].getBytes(); <END> final ByteBuffer tocheck = ByteBuffer.allocate( jwtheader.length + jwtpayload.length + 1 ); tocheck.put(jwtheader).put(".".getBytes()).put(jwtpayload); final byte[] checked = this.signature.sign(tocheck.array()); if (Arrays.equals(jwtsign, checked)) { final JsonObject jsonv = Json.createReader( new StringReader( new String(new Base64().decode(jwtpayload)) ) ) .readObject(); user = new Opt.Single<Identity>( new Identity.Simple( jsonv.getString(Token.Jwt.SUBJECT) ) ); } } return user; }</code><technical_language>@semantosoph this code a bit weird. do: final String[] parts = jwt.split(dot); final byte[] jwtheader = parts[0].getBytes(); final byte[] jwtpayload = parts[1].getBytes(); final byte[] jwtsign = parts[2].getBytes();</technical_language>

Target:
public Opt<Identity> enter(final Request req) throws IOException { final Iterator<String> headers = new RqHeaders.Base(req) .header(this.header).iterator(); Opt<Identity> user = new Opt.Empty<>(); String head = ""; while (headers.hasNext()) { final String nexthead = headers.next(); if (nexthead.trim().startsWith("Bearer")) { head = nexthead; break; } } final String dot = "\\."; if (head.length() > 0) { final String jwt = head.split(" ", 2)[1].trim(); final String[] parts = jwt.split(dot); final byte[] jwtheader = parts[0].getBytes(); final byte[] jwtpayload = parts[1].getBytes(); final byte[] jwtsign = parts[2].getBytes(); final ByteBuffer tocheck = ByteBuffer.allocate( jwtheader.length + jwtpayload.length + 1 ); tocheck.put(jwtheader).put(".".getBytes()).put(jwtpayload); final byte[] checked = this.signature.sign(tocheck.array()); if (Arrays.equals(jwtsign, checked)) { final JsonObject jsonv = Json.createReader( new StringReader( new String(new Base64().decode(jwtpayload)) ) ) .readObject(); user = new Opt.Single<Identity>( new Identity.Simple( jsonv.getString(Token.Jwt.SUBJECT) ) ); } } return user; }
Source:
<code>public Object fromMessage(Message message) throws MessageConversionException { Object result = this.delegate.fromMessage(message); if (result instanceof RemoteInvocationResult) { try { result = ((RemoteInvocationResult) result).recreate(); } catch (Throwable e) { <START> throw new AmqpException(e); <END> } } return result; }</code><technical_language>pointers throw recreate() exceptions is? other places care exception wrapping</technical_language>

Target:
public Object fromMessage(Message message) throws MessageConversionException { Object result = this.delegate.fromMessage(message); if (result instanceof RemoteInvocationResult) { try { result = ((RemoteInvocationResult) result).recreate(); } catch (Throwable e) { throw new AmqpRemoteException(e); } } return result; }
Source:
<code>private void testMiniMesosReportsFrameworkRole(String role) throws UnirestException, JsonParseException, JsonMappingException { LOGGER.info("Starting Elasticsearch scheduler with framework role: " + role); ElasticsearchSchedulerContainer scheduler = new ElasticsearchSchedulerContainer( clusterArchitecture.dockerClient, CLUSTER.getZkContainer().getIpAddress(), role, CLUSTER); CLUSTER.addAndStartContainer(scheduler); LOGGER.info("Started Elasticsearch scheduler on " + scheduler.getIpAddress() + ":" + getTestConfig().getSchedulerGuiPort()); ESTasks esTasks = new ESTasks(TEST_CONFIG, scheduler.getIpAddress()); new TasksResponse(esTasks, 3); <START> new ElasticsearchNodesResponse(esTasks, 3); <END> Awaitility.await().atMost(30, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS).until(() -> CLUSTER.getStateInfo().getFramework("elasticsearch") != null); Assert.assertEquals(role, CLUSTER.getStateInfo().getFramework("elasticsearch").getRole()); }</code><technical_language>3 difficult understand. replaced cluster.getSlaves().length</technical_language>

Target:
private void testMiniMesosReportsFrameworkRole(String role) throws UnirestException, JsonParseException, JsonMappingException { LOGGER.info("Starting Elasticsearch scheduler with framework role: " + role); ElasticsearchSchedulerContainer scheduler = new ElasticsearchSchedulerContainer( clusterArchitecture.dockerClient, CLUSTER.getZkContainer().getIpAddress(), role, CLUSTER); CLUSTER.addAndStartContainer(scheduler); LOGGER.info("Started Elasticsearch scheduler on " + scheduler.getIpAddress() + ":" + getTestConfig().getSchedulerGuiPort()); ESTasks esTasks = new ESTasks(TEST_CONFIG, scheduler.getIpAddress()); new TasksResponse(esTasks, TEST_CONFIG.getElasticsearchNodesCount()); new ElasticsearchNodesResponse(esTasks, TEST_CONFIG.getElasticsearchNodesCount()); Awaitility.await().atMost(30, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS).until(() -> CLUSTER.getStateInfo().getFramework("elasticsearch") != null); Assert.assertEquals(role, CLUSTER.getStateInfo().getFramework("elasticsearch").getRole()); }
Source:
<code>protected void setUp() throws Exception { super.setUp(); initAccessToServer(getContext()); Log.v(LOG_TAG, "Setting up the remote fixture..."); mFullPath2FileToShare = mBaseFolderPath + FILE_TO_SHARE; File textFile = getActivity().extractAsset(TestActivity.ASSETS__TEXT_FILE_NAME); RemoteOperationResult result = getActivity().uploadFile( textFile.getAbsolutePath(), mFullPath2FileToShare, "txt/plain"); if (!result.isSuccess()) { Utils.logAndThrow(LOG_TAG, result); } result = getActivity().createShare( mFullPath2FileToShare, ShareType.PUBLIC_LINK, "", false, "", OCShare.READ_PERMISSION_FLAG); if (result.isSuccess()){ mShare = (OCShare) result.getData().get(0); } else{ mShare = null; } mFullPath2FolderToShare = mBaseFolderPath + FOLDER_TO_SHARE; result = getActivity().createFolder( mFullPath2FolderToShare, true); if (!result.isSuccess()) { Utils.logAndThrow(LOG_TAG, result); } result = getActivity().createShare( mFullPath2FolderToShare, ShareType.PUBLIC_LINK, "", false, "", OCShare.READ_PERMISSION_FLAG); if (result.isSuccess()){ mFolderShare = (OCShare) result.getData().get(0); } else{ <START> mFolderShare = null; <END> } Log.v(LOG_TAG, "Remote fixtures created."); }</code><technical_language>In case of fail, throw exception Utils.logAndThrow</technical_language>

Target:
protected void setUp() throws Exception { super.setUp(); initAccessToServer(getContext()); Log.v(LOG_TAG, "Setting up the remote fixture..."); mFullPath2FileToShare = mBaseFolderPath + FILE_TO_SHARE; File textFile = getActivity().extractAsset(TestActivity.ASSETS__TEXT_FILE_NAME); RemoteOperationResult result = getActivity().uploadFile( textFile.getAbsolutePath(), mFullPath2FileToShare, "txt/plain"); if (!result.isSuccess()) { Utils.logAndThrow(LOG_TAG, result); } result = getActivity().createShare( mFullPath2FileToShare, ShareType.PUBLIC_LINK, "", false, "", OCShare.READ_PERMISSION_FLAG); if (result.isSuccess()){ mShare = (OCShare) result.getData().get(0); } else{ Utils.logAndThrow(LOG_TAG, result); } mFullPath2FolderToShare = mBaseFolderPath + FOLDER_TO_SHARE; result = getActivity().createFolder( mFullPath2FolderToShare, true); if (!result.isSuccess()) { Utils.logAndThrow(LOG_TAG, result); } result = getActivity().createShare( mFullPath2FolderToShare, ShareType.PUBLIC_LINK, "", false, "", OCShare.READ_PERMISSION_FLAG); if (result.isSuccess()){ mFolderShare = (OCShare) result.getData().get(0); } else{ Utils.logAndThrow(LOG_TAG, result); } Log.v(LOG_TAG, "Remote fixtures created."); }
Source:
<code>public void inputChanged(@Nullable Viewer viewer, @Nullable Object oldInput, @Nullable Object newInput) { fTableViewer = (TableViewer) viewer; if (newInput instanceof ISegmentStore<?>) { ISegmentStore<?> segmentStore = (ISegmentStore<?>) newInput; fSegmentArray = Iterables.toArray(segmentStore, ISegment.class); if (fComparator != null) { Arrays.sort(fSegmentArray, fComparator); } } else if (newInput instanceof ISegment[]) { <START> fSegmentArray = ((ISegment[]) newInput).clone(); <END> if (fComparator != null) { Arrays.sort(fSegmentArray, fComparator); } } else { fSegmentArray = null; } }</code><technical_language>do Arrays.copy() ? need clone segments. need a copy of array. Similar segment store</technical_language>

Target:
public void inputChanged(@Nullable Viewer viewer, @Nullable Object oldInput, @Nullable Object newInput) { fTableViewer = (TableViewer) viewer; if (newInput instanceof ISegmentStore) { ISegmentStore<ISegment> segmentStore = (ISegmentStore<ISegment>) newInput; fSegmentArray = Iterables.toArray(segmentStore, ISegment.class); if (fComparator != null) { Arrays.sort(fSegmentArray, fComparator); } } else if (newInput instanceof ISegment[]) { fSegmentArray = ((ISegment[]) newInput).clone(); if (fComparator != null) { Arrays.sort(fSegmentArray, fComparator); } } else { fSegmentArray = null; } }
Source:
<code>default Optional<PaxosValue> getLearnedValueAtSeqIfExists(long seq) { <START> return learnerRecords().containsKey(seq) ? Optional.of(learnerRecords().get(seq)) : Optional.empty(); <END> }</code><technical_language>this Optional.ofNullable()</technical_language>

Target:
default Optional<PaxosValue> getLearnedValueAtSeqIfExists(long seq) { return Optional.ofNullable(learnerRecords().getOrDefault(seq, null)); }
Source:
<code>protected abstract void initialize() throws ResourceManagerException; <START> protected abstract void terminate() throws Throwable; <END> protected CompletableFuture<Void> prepareLeadershipAsync() { return CompletableFuture.completedFuture(null); }</code><technical_language>weaken signature throws Exception</technical_language>

Target:
protected abstract void initialize() throws ResourceManagerException; protected abstract void terminate() throws Exception; protected CompletableFuture<Void> prepareLeadershipAsync() { return CompletableFuture.completedFuture(null); }
Source:
<code>public void start(Collection<? extends Location> locations) { super.start(locations); <START> subscribeToMembers(this, Startable.SERVICE_UP, new SensorEventListener<Boolean>() { <END> public void onEvent(SensorEvent<Boolean> event) { setAnyRouter(); } }); AbstractMembershipTrackingPolicy policy = new AbstractMembershipTrackingPolicy(MutableMap.of("name", "Router cluster membership tracker")) { @Override protected void onEntityAdded(Entity member) { setAnyRouter(); } protected void onEntityRemoved(Entity member) { setAnyRouter(); } }; addPolicy(policy); policy.setGroup(this); }</code><technical_language>get rid of this listener - AbstractMembershipTrackingPolicy listen serviceUp. need a protected void onEntityChanged in policy below</technical_language>

Target:
public void start(Collection<? extends Location> locations) { super.start(locations); AbstractMembershipTrackingPolicy policy = new AbstractMembershipTrackingPolicy(MutableMap.of("name", "Router cluster membership tracker")) { @Override protected void onEntityAdded(Entity member) { setAnyRouter(); } protected void onEntityRemoved(Entity member) { setAnyRouter(); } @Override protected void onEntityChange(Entity member) { setAnyRouter(); } }; addPolicy(policy); policy.setGroup(this); }
Source:
<code>private boolean isPlayerHit(Entity source) { if (source instanceof GlowPlayer) { return true; } else if (source instanceof GlowTntPrimed) { return <START> ((GlowTntPrimed)source).getPlayer() != null <END> && (((GlowTntPrimed)source).getPlayer().getGameMode() == GameMode.SURVIVAL || ((GlowTntPrimed)source).getPlayer().getGameMode() == GameMode.ADVENTURE); } else if (source instanceof GlowWolf) { return ((GlowWolf)source).isTamed(); } return false; }</code><technical_language>Casts a space closing parentheses. a couple fix here. Ex.: ((GlowTntPrimed) source).getPlayer() != null store GlowTntPrimed instance returning casting multiple times: java GlowTntPrimed tnt = (GlowTntPrimed) source; return tnt.getPlayer() != null [...]</technical_language>

Target:
private boolean isPlayerHit(Entity source) { if (source instanceof GlowPlayer) { return true; } if (source instanceof GlowTntPrimed) { GlowPlayer player = (GlowPlayer)((GlowTntPrimed) source).getSource(); return player != null && (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE); } if (source instanceof GlowWolf) { return ((GlowWolf) source).isTamed(); } return false; }
Source:
<code>public void testItalicWithWhitespace() { String html; Pattern expectedPattern = Pattern.compile("<body><p>normal\\s*<i>\\s*italic text\\s*</i>\\s*normal</p></body>"); html = parser.parseToHtml("normal '' italic text'' normal"); TestUtil.println(html); <START> assertTrue(expectedPattern.matcher(html).find()); <END> html = parser.parseToHtml("normal ''italic text '' normal"); TestUtil.println(html); assertTrue(expectedPattern.matcher(html).find()); html = parser.parseToHtml("normal '' italic text '' normal"); TestUtil.println(html); assertTrue(expectedPattern.matcher(html).find()); }</code><technical_language>bold, assert html.contains("<p>normal <i> italic text</i> normal</p>") more obvious for whitespace behaviour is included in assert</technical_language>

Target:
public void testItalicWithWhitespace() { String html; html = parser.parseToHtml("normal '' italic text'' normal"); TestUtil.println(html); assertTrue(html.contains("<body><p>normal <i> italic text</i> normal</p></body>")); html = parser.parseToHtml("normal ''italic text '' normal"); TestUtil.println(html); assertTrue(html.contains("<body><p>normal <i>italic text </i> normal</p></body>")); html = parser.parseToHtml("normal '' italic text '' normal"); TestUtil.println(html); assertTrue(html.contains("<body><p>normal <i> italic text </i> normal</p></body>")); }
Source:
<code>public void testRotationWithNoData() throws InterruptedException { GenericFileOutputOperator writer = new GenericFileOutputOperator(); File dir = new File(testMeta.getDir()); writer.setFilePath(testMeta.getDir()); writer.setOutputFileName("output.txt"); writer.setMaxIdleWindows(5); writer.setAlwaysWriteToTmp(true); writer.setup(testMeta.testOperatorContext); for (int i = 0; i < 30; ++i) { writer.beginWindow(i); <START> Thread.sleep(100L); <END> writer.endWindow(); } writer.committed(29); Collection<File> files = FileUtils.listFiles(dir, null, false); Assert.assertEquals("Number of part files", 0, files.size()); }</code><technical_language>reduce this sleep? get rid of if sense for test? If check is data is in windows, work</technical_language>

Target:
public void testRotationWithNoData() throws InterruptedException { GenericFileOutputOperator writer = new GenericFileOutputOperator(); File dir = new File(testMeta.getDir()); writer.setFilePath(testMeta.getDir()); writer.setOutputFileName("output.txt"); writer.setMaxIdleWindows(5); writer.setAlwaysWriteToTmp(true); writer.setup(testMeta.testOperatorContext); for (int i = 0; i < 30; ++i) { writer.beginWindow(i); writer.endWindow(); } writer.committed(29); Collection<File> files = FileUtils.listFiles(dir, null, false); Assert.assertEquals("Number of part files", 0, files.size()); }
Source:
<code>public Properties generate(SourceOfRandomness random, GenerationStatus status) { int size = status.size(); Properties properties = new Properties(); for (int i = 0; i < size; ++i) { properties.setProperty( <START> stringGenerator.generate(random, status), <END> stringGenerator.generate(random, status)); } return properties; }</code><technical_language>@brentvukmer Yeah, prefer keeping scope indent long-line indent spaces. Thanks</technical_language>

Target:
@Override public Properties generate(SourceOfRandomness random, GenerationStatus status) { int size = status.size(); Properties properties = new Properties(); for (int i = 0; i < size; ++i) { properties.setProperty( stringGenerator.generate(random, status), stringGenerator.generate(random, status)); } return properties; }
Source:
<code>public void testSendingInvokesEndpointContextMatcher() throws Exception { TestEndpointContextMatcher endpointMatcher = new TestEndpointContextMatcher(3); client.setEndpointContextMatcher(endpointMatcher); LatchDecrementingRawDataChannel channel = serverHelper.givenAnEstablishedSession(client, false); EndpointContext endpointContext = endpointMatcher.getConnectionEndpointContext(1); RawData outboundMessage = RawData.outbound(new byte[] { 0x01 }, endpointContext, null, false); CountDownLatch latch = new CountDownLatch(1); channel.setLatch(latch); client.send(outboundMessage); assertThat(endpointMatcher.await(TIMEOUT_IN_MILLIS, TimeUnit.MILLISECONDS), is(true)); assertThat(endpointMatcher.getConnectionEndpointContext(2), is(endpointContext)); assertThat(endpointMatcher.getMessageEndpointContext(2), is(endpointContext)); <START> assertTrue("DTLS client timed out after " + MAX_TIME_TO_WAIT_SECS + " seconds waitng for response!", latch.await(MAX_TIME_TO_WAIT_SECS, TimeUnit.SECONDS)); <END> }</code><technical_language>typo : waitng</technical_language>

Target:
public void testSendingInvokesEndpointContextMatcher() throws Exception { TestEndpointContextMatcher endpointMatcher = new TestEndpointContextMatcher(3); client.setEndpointContextMatcher(endpointMatcher); LatchDecrementingRawDataChannel channel = serverHelper.givenAnEstablishedSession(client, false); EndpointContext endpointContext = endpointMatcher.getConnectionEndpointContext(1); RawData outboundMessage = RawData.outbound(new byte[] { 0x01 }, endpointContext, null, false); CountDownLatch latch = new CountDownLatch(1); channel.setLatch(latch); client.send(outboundMessage); assertThat(endpointMatcher.await(TIMEOUT_IN_MILLIS, TimeUnit.MILLISECONDS), is(true)); assertThat(endpointMatcher.getConnectionEndpointContext(2), is(endpointContext)); assertThat(endpointMatcher.getMessageEndpointContext(2), is(endpointContext)); assertTrue("DTLS client timed out after " + MAX_TIME_TO_WAIT_SECS + " seconds waiting for response!", latch.await(MAX_TIME_TO_WAIT_SECS, TimeUnit.SECONDS)); }
Source:
<code>void writeReport() throws IOException { StringBuilder builder = new StringBuilder(); for (DumpProcessingAction action : this.clientConfiguration .getActions()) { if (this.clientConfiguration.getReportFilename() != null) { builder.append(action.getActionName() + ": "); builder.append(action.getReport()); builder.append(System.getProperty("line.separator")); } else { logger.info(action.getActionName() + ": " + action.getReport()); } } if (this.clientConfiguration.getReportFilename() != null) { Path outputDirectory = Paths.get( this.clientConfiguration.getReportFilename()).getParent(); if (outputDirectory == null) { outputDirectory = Paths.get("."); } DirectoryManager dm = DirectoryManagerFactory .createDirectoryManager(outputDirectory); OutputStream out = dm.getOutputStreamForFile(Paths .get(this.clientConfiguration.getReportFilename()) .getFileName().toString()); OutputStream bufferedFileOutputStream = new BufferedOutputStream( <START> out, 1024 * 1024 * 5); <END> bufferedFileOutputStream.write(builder.toString().getBytes( StandardCharsets.UTF_8)); bufferedFileOutputStream.close(); } }</code><technical_language>a big buffer for lines of report have. default</technical_language>

Target:
void writeReport() throws IOException { StringBuilder builder = new StringBuilder(); for (DumpProcessingAction action : this.clientConfiguration .getActions()) { if (this.clientConfiguration.getReportFilename() != null) { builder.append(action.getActionName() + ": "); builder.append(action.getReport()); builder.append(System.getProperty("line.separator")); } else { logger.info(action.getActionName() + ": " + action.getReport()); } } if (this.clientConfiguration.getReportFilename() != null) { Path outputDirectory = Paths.get( this.clientConfiguration.getReportFilename()).getParent(); if (outputDirectory == null) { outputDirectory = Paths.get("."); } DirectoryManager dm = DirectoryManagerFactory .createDirectoryManager(outputDirectory); OutputStream out = dm.getOutputStreamForFile(Paths .get(this.clientConfiguration.getReportFilename()) .getFileName().toString()); out.write(builder.toString().getBytes(StandardCharsets.UTF_8)); out.close(); } }
Source:
<code><START> private static Object convertValue( <END> String name, Serializable value, AttributeType.AttributeFormat format) { if (value == null) { return null; } switch (format) { case DATE: if (!(value instanceof Date)) { LOGGER.debug( "Dropping attribute date value for because it isn't a Date object.", value, name); return null; } SimpleDateFormat dateFormat = new SimpleDateFormat(ISO_8601_DATE_FORMAT); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); return dateFormat.format((Date) value); case BINARY: byte[] bytes = (byte[]) value; return DatatypeConverter.printBase64Binary(bytes); case BOOLEAN: case DOUBLE: case LONG: case INTEGER: case SHORT: return value; case STRING: case XML: case FLOAT: case GEOMETRY: return value.toString(); case OBJECT: default: return null; } }</code><technical_language>I returning a Serializable is more appropriate</technical_language>

Target:
private Serializable convertValue( String name, Serializable value, AttributeType.AttributeFormat format) { if (value == null) { return null; } switch (format) { case DATE: if (!(value instanceof Date)) { LOGGER.debug( "Dropping attribute date value for because it isn't a Date object.", value, name); return null; } Instant instant = ((Date) value).toInstant(); ZoneId zoneId = ZoneId.of("UTC"); ZonedDateTime zonedDateTime = instant.atZone(zoneId); return zonedDateTime.format(formatter); case BINARY: byte[] bytes = (byte[]) value; return DatatypeConverter.printBase64Binary(bytes); case BOOLEAN: case DOUBLE: case LONG: case INTEGER: case SHORT: case STRING: case XML: case FLOAT: case GEOMETRY: return value; case OBJECT: default: return null; } }
Source:
<code>public static Object getDefaultValue(Property swaggerProperty) { if (swaggerProperty instanceof IntegerProperty) { return ((IntegerProperty) swaggerProperty).getDefault(); } else if (swaggerProperty instanceof LongProperty) { return ((LongProperty) swaggerProperty).getDefault(); } else if (swaggerProperty instanceof FloatProperty) { return ((FloatProperty) swaggerProperty).getDefault(); } else if (swaggerProperty instanceof DoubleProperty) { return ((DoubleProperty) swaggerProperty).getDefault(); } else if (swaggerProperty instanceof UUIDProperty) { return ((UUIDProperty) swaggerProperty).getDefault(); } else if (swaggerProperty instanceof StringProperty) { return ((StringProperty) swaggerProperty).getDefault(); } <START> return null; <END> }</code><technical_language>A log (level: warning) nice prevent forgetting add new types update Swagger version</technical_language>

Target:
public static Object getDefaultValue(Property swaggerProperty) { if (swaggerProperty instanceof IntegerProperty) { return ((IntegerProperty) swaggerProperty).getDefault(); } else if (swaggerProperty instanceof LongProperty) { return ((LongProperty) swaggerProperty).getDefault(); } else if (swaggerProperty instanceof FloatProperty) { return ((FloatProperty) swaggerProperty).getDefault(); } else if (swaggerProperty instanceof DoubleProperty) { return ((DoubleProperty) swaggerProperty).getDefault(); } else if (swaggerProperty instanceof UUIDProperty) { return ((UUIDProperty) swaggerProperty).getDefault(); } else if (swaggerProperty instanceof StringProperty) { return ((StringProperty) swaggerProperty).getDefault(); } LOGGER.warning("Cannot get the default value " + "from a swagger property of unknown type '" + swaggerProperty.getType() + "'"); return null; }
Source:
<code>public Set<Language> whitelistedLanguages() { if (isCdtPresent()) { <START> return Collections.singleton(Language.CPP); <END> } return Collections.emptySet(); }</code><technical_language>whitelist C</technical_language>

Target:
public Set<Language> whitelistedLanguages() { if (isCdtPresent()) { return EnumSet.of(Language.CPP, Language.C); } return Collections.emptySet(); }
Source:
<code>public void setDebugStatus( Reporter reporter, String message ) { <START> if ( debug ) { <END> log.setLogLevel(LogLevel.DEBUG); log.logDebug( message ); reporter.setStatus( message ); } }</code><technical_language>This is be. This be: if (log.isDebugEnabled()) { log.logDebug( message ); } Do "if (debug)" this is hardcoded enabled. Do "setLogLevel()" overriding system administrator's configuration</technical_language>

Target:
public void setDebugStatus( Reporter reporter, String message ) { if ( log.isDebug() ) { log.logDebug( message ); reporter.setStatus( message ); } }
Source:
<code>protected Map<String, Pair<String, String>> getExclusiveLocks() { <START> Set<Guid> directLunsToLock = getParameters().getAttachedDirectLunDisksIds() == null ? getDiskToLunIdsOfDirectLunsAttachedToVmsInPool().keySet() : getParameters().getAttachedDirectLunDisksIds(); <END> return directLunsToLock.stream() .collect(Collectors.toMap(Guid::toString, diskId -> LockMessagesMatchUtil.makeLockingPair( LockingGroup.DISK, EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED))); }</code><technical_language>Optional.ofNullable(getParameters().getAttachedDirectLunDisksIds()).orElse(getDiskToLunIdsOfDirectLunsAttachedToVmsInPool().keySet()) pretty issue of taste</technical_language>

Target:
protected Map<String, Pair<String, String>> getExclusiveLocks() { Set<Guid> directLunsToLock = Optional.ofNullable(getParameters().getAttachedDirectLunDisksIds()) .orElse(getDiskToLunIdsOfDirectLunsAttachedToVmsInPool().keySet()); return directLunsToLock.stream() .collect(Collectors.toMap(Guid::toString, diskId -> LockMessagesMatchUtil.makeLockingPair( LockingGroup.DISK, EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED))); }
Source:
<code>public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { if (config.getHstsMaxAge() != null && requestContext.getSecurityContext().isSecure()) { StringBuilder headerValue = new StringBuilder(String.format("%s=%d", MAX_AGE, config.getHstsMaxAge().roundTo(TimeUnit.SECONDS))); if (config.isIncludeSubDomains()) { headerValue.append(INCLUDE_SUB_DOMAINS); } if (config.isPreload()) { headerValue.append(PRELOAD); <START> } <END> responseContext.getHeaders().putSingle(HSTS, headerValue); } }</code><technical_language>A potentially useful micro-optimization calculate header construction</technical_language>

Target:
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { if (headerValue != null && requestContext.getSecurityContext().isSecure()) { responseContext.getHeaders().putSingle(HSTS, headerValue); } }
Source:
<code>public Response removePhraseFromPackage(@HeaderParam("Authorization") String authorization, @PathParam("package") String packageCode, @PathParam("pageName") String pageName, @PathParam("id") UUID phraseId) { logger.info(String.format("Adding phrase w/ authorization %s", authorization)); AuthorizationRecord.checkAdminAccess(authorizationService.getAuthorizationRecord(null, authorization), clock.currentDateTime()); <START> logger.info(String.format("Adding phrase, admin validated. Adding phrase for %s-%s", packageCode, pageName)); <END> Optional<GodToolsTranslation> translationOptional = draftTranslation.retrieve(BASE_LANGUAGE_CODE, packageCode, false); if(!translationOptional.isPresent()) { translationOptional = publishedTranslation.retrieve(BASE_LANGUAGE_CODE, packageCode, false); if(!translationOptional.isPresent()) { logger.warn("Something weird... no published English translation for: " + packageCode); return Response.status(Response.Status.BAD_REQUEST).build(); } } Optional<PageStructure> pageOptional = translationOptional.get().getPage(pageName); if(!pageOptional.isPresent()) { logger.warn(String.format("Listing phrases, Page %s not found English translation for %s", pageName, packageCode)); return Response.status(Response.Status.NOT_FOUND).build(); } Package gtPackage = packageService.selectByCode(packageCode); translationElementService.delete(phraseId); translationUpload.doUpload(gtPackage.getTranslationProjectId(), BASE_LANGUAGE_CODE, pageName, true); return Response .noContent() .build(); }</code><technical_language>Log messages incorrect too</technical_language>

Target:
public Response removePhraseFromPackage(@HeaderParam("Authorization") String authorization, @PathParam("package") String packageCode, @PathParam("pageName") String pageName, @PathParam("id") UUID phraseId) { logger.info(String.format("Removing phrase w/ authorization %s", authorization)); AuthorizationRecord.checkAdminAccess(authorizationService.getAuthorizationRecord(null, authorization), clock.currentDateTime()); logger.info(String.format("Removing phrase, admin validated. Adding phrase for %s-%s", packageCode, pageName)); Optional<GodToolsTranslation> translationOptional = getGodToolsTranslationOptional(packageCode); Optional<PageStructure> pageOptional = translationOptional.get().getPage(pageName); if(!pageOptional.isPresent()) { logger.warn(String.format("Removing phrases, Page %s not found English translation for %s", pageName, packageCode)); return Response.status(Response.Status.NOT_FOUND).build(); } Package gtPackage = packageService.selectByCode(packageCode); translationElementService.delete(phraseId); translationUpload.doUpload(gtPackage.getTranslationProjectId(), BASE_LANGUAGE_CODE, pageName, true); return Response .noContent() .build(); }