auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void generatePage_onJenkinsConfiguration_generatesSummaryTableWithBuildNumber() { setUpWithJson(SAMPLE_JSON); configuration.setRunWithJenkins(true); configuration.setBuildNumber("123"); page = new StepsOverviewPage(); <START> initPageGeneartor().generatePage(page); <END> DocumentAssertion document = documentFrom(page.getWebPage()); BuildInfoAssertion buildInfo = document.getBuildInfo(); TableRowAssertion headValues = buildInfo.getHeaderRow(); headValues.hasExactValues("Project", "Number", "Date"); assertThat(buildInfo.getProjectName()).isEqualTo(configuration.getProjectName()); assertThat(buildInfo.getBuildNumber()).isEqualTo(configuration.getBuildNumber()); buildInfo.hasBuildDate(true); }</code><technical_language>I this convention is clear is tested exactly: initPageGenerator generatePage method. happy stay previous clear convention</technical_language>

Target:
public void generatePage_onJenkinsConfiguration_generatesSummaryTableWithBuildNumber() { setUpWithJson(SAMPLE_JSON); configuration.setRunWithJenkins(true); configuration.setBuildNumber("123"); page = new StepsOverviewPage(); generatePage(page); DocumentAssertion document = documentFrom(page.getWebPage()); BuildInfoAssertion buildInfo = document.getBuildInfo(); TableRowAssertion headValues = buildInfo.getHeaderRow(); headValues.hasExactValues("Project", "Number", "Date"); assertThat(buildInfo.getProjectName()).isEqualTo(configuration.getProjectName()); assertThat(buildInfo.getBuildNumber()).isEqualTo(configuration.getBuildNumber()); buildInfo.hasBuildDate(true); }
Source:
<code>public boolean applies(GameEvent event, Ability source, Game game) { CavernOfSoulsWatcher watcher = game.getState().getWatcher(CavernOfSoulsWatcher.class, source.getSourceId()); Spell spell = game.getStack().getSpell(event.getTargetId()); Integer currentZCC = game.getObject(event.getTargetId()).getZoneChangeCounter(game); <START> return spell != null && watcher != null && watcher.spellCantBeCountered(spell.getId(), currentZCC); <END> }</code><technical_language>a special MageObjectReference object ZCC code. Store card ref in Set<MageObjectReference> call getCard ref get actual card null (if zcc changed). Example: ![shot_200612_215449](<LINK_0></technical_language>

Target:
public boolean applies(GameEvent event, Ability source, Game game) { CavernOfSoulsWatcher watcher = game.getState().getWatcher(CavernOfSoulsWatcher.class, source.getSourceId()); Spell spell = game.getStack().getSpell(event.getTargetId()); return spell != null && watcher != null && watcher.spellCantBeCountered(new MageObjectReference(spell, game)); }
Source:
<code>private static ProductExpr fromXtext(final org.abs_models.xtext.abs.ProductExpression xtext_exp) { ProductExpr result = null; <START> if (xtext_exp == null) { <END> result = new ProductFeatureSet(); } if (xtext_exp instanceof org.abs_models.xtext.abs.ProductExprDifference) { result = new ProductDifference(fromXtext(xtext_exp.getLeft()), fromXtext(xtext_exp.getRight())); } else if (xtext_exp instanceof org.abs_models.xtext.abs.ProductExprUnion) { result = new ProductUnion(fromXtext(xtext_exp.getLeft()), fromXtext(xtext_exp.getRight())); } else if (xtext_exp instanceof org.abs_models.xtext.abs.ProductExprIntersect) { result = new ProductIntersect(fromXtext(xtext_exp.getLeft()), fromXtext(xtext_exp.getRight())); } else { if (xtext_exp.getProdname() != null) { result = new ProductName(xtext_exp.getProdname()); } else if (xtext_exp.getParen() != null) { return fromXtext(xtext_exp.getParen()); } else { result = new ProductFeatureSet(); for (final org.abs_models.xtext.abs.ProductFeature feat : xtext_exp.getFeatures()) { ((ProductFeatureSet)result).addFeature(fromXtext(feat)); } } } return nodeWithLocation(result, xtext_exp); }</code><technical_language>I caller check for null, call fromXtext in case</technical_language>

Target:
private static ProductExpr fromXtext(final org.abs_models.xtext.abs.ProductExpression xtext_exp) { ProductExpr result = null; if (xtext_exp instanceof org.abs_models.xtext.abs.ProductExprDifference) { result = new ProductDifference(fromXtext(xtext_exp.getLeft()), fromXtext(xtext_exp.getRight())); } else if (xtext_exp instanceof org.abs_models.xtext.abs.ProductExprUnion) { result = new ProductUnion(fromXtext(xtext_exp.getLeft()), fromXtext(xtext_exp.getRight())); } else if (xtext_exp instanceof org.abs_models.xtext.abs.ProductExprIntersect) { result = new ProductIntersect(fromXtext(xtext_exp.getLeft()), fromXtext(xtext_exp.getRight())); } else { if (xtext_exp.getProdname() != null) { result = new ProductName(xtext_exp.getProdname()); } else if (xtext_exp.getParen() != null) { return fromXtext(xtext_exp.getParen()); } else { result = new ProductFeatureSet(); for (final org.abs_models.xtext.abs.ProductFeature feat : xtext_exp.getFeatures()) { ((ProductFeatureSet)result).addFeature(fromXtext(feat)); } } } return nodeWithLocation(result, xtext_exp); }
Source:
<code>private static void assertFilterIfNotMIssingMatches( byte[] family, byte[] qualifier, byte[] value, boolean latestOnly, Filters.Filter adaptedFilter) throws IOException { <START> Condition cellSetCondition = adaptedFilter.toProto().getInterleave().getFilters(0).getCondition(); <END> Condition cellUnsetCondition = adaptedFilter.toProto().getInterleave().getFilters(1).getCondition(); assertColumnSpecification( family, qualifier, latestOnly, cellSetCondition.getPredicateFilter()); ByteString valueBS = ByteString.copyFrom(value); Assert.assertEquals( FILTERS.value().range() .startClosed(valueBS) .endClosed(valueBS) .toProto(), getValueRangeFilter(cellSetCondition.getPredicateFilter().getChain())); assertColumnSpecification( family, qualifier, latestOnly, cellUnsetCondition.getPredicateFilter()); Assert.assertEquals( FILTERS.pass().toProto(), cellSetCondition.getTrueFilter()); Assert.assertFalse(cellSetCondition.hasFalseFilter()); Assert.assertEquals( FILTERS.pass().toProto(), cellUnsetCondition.getFalseFilter()); Assert.assertFalse(cellUnsetCondition.hasTrueFilter()); }</code><technical_language>please call toProto().getInterleave() once</technical_language>

Target:
private static void assertFilterIfNotMIssingMatches( byte[] family, byte[] qualifier, byte[] value, boolean latestOnly, Filters.Filter adaptedFilter) throws IOException { Interleave interleaveFilter = adaptedFilter.toProto().getInterleave(); Condition cellSetCondition = interleaveFilter.getFilters(0).getCondition(); Condition cellUnsetCondition = interleaveFilter.getFilters(1).getCondition(); assertColumnSpecification( family, qualifier, latestOnly, cellSetCondition.getPredicateFilter()); ByteString valueBS = ByteString.copyFrom(value); Assert.assertEquals( FILTERS.value().range() .startClosed(valueBS) .endClosed(valueBS) .toProto(), getValueRangeFilter(cellSetCondition.getPredicateFilter().getChain())); assertColumnSpecification( family, qualifier, latestOnly, cellUnsetCondition.getPredicateFilter()); Assert.assertEquals( FILTERS.pass().toProto(), cellSetCondition.getTrueFilter()); Assert.assertFalse(cellSetCondition.hasFalseFilter()); Assert.assertEquals( FILTERS.pass().toProto(), cellUnsetCondition.getFalseFilter()); Assert.assertFalse(cellUnsetCondition.hasTrueFilter()); }
Source:
<code>protected void updateCursor(final PatchLineComment newComment) { if (newComment.getLine() == R_HEAD) { final PatchSet.Id psId = newComment.getKey().getParentKey().getParentKey(); switch (newComment.getSide()) { case FILE_SIDE_A: if (idSideA == null && idSideB.equals(psId)) { rowOfTableHeaderB++; borderRowOfFileComment++; return; } break; case FILE_SIDE_B: if (idSideA != null && idSideA.equals(psId)) { rowOfTableHeaderB++; borderRowOfFileComment++; <START> return; <END> } if (idSideB.equals(psId)) { borderRowOfFileComment++; } } } }</code><technical_language>Remove this too, change next if else if</technical_language>

Target:
protected void updateCursor(final PatchLineComment newComment) { if (newComment.getLine() == R_HEAD) { final PatchSet.Id psId = newComment.getKey().getParentKey().getParentKey(); switch (newComment.getSide()) { case FILE_SIDE_A: if (idSideA == null && idSideB.equals(psId)) { rowOfTableHeaderB++; borderRowOfFileComment++; return; } break; case FILE_SIDE_B: if (idSideA != null && idSideA.equals(psId)) { rowOfTableHeaderB++; borderRowOfFileComment++; } else if (idSideB.equals(psId)) { borderRowOfFileComment++; } } } }
Source:
<code>public void restartTask(final ConnectorTaskId id, final Callback<Void> callback) { addRequest(new Callable<Void>() { @Override public Void call() throws Exception { if (checkRebalanceNeeded(callback)) return null; if (!configState.connectors().contains(id.connector())) { callback.onCompletion(new NotFoundException("Unknown connector: " + id.connector()), null); return null; } if (configState.taskConfig(id) == null) { callback.onCompletion(new NotFoundException("Unknown task: " + id), null); return null; } if (assignment.tasks().contains(id)) { try { worker.stopAndAwaitTask(id); if (startTask(id)) callback.onCompletion(null, null); else callback.onCompletion(new ConnectException("Failed to start task: " + id), null); } catch (Throwable t) { callback.onCompletion(t, null); } } else if (isLeader()) { callback.onCompletion(new NotAssignedException("Cannot restart task since it is not assigned to this member", member.ownerUrl(id)), null); } else { <START> callback.onCompletion(new NotLeaderException("Cannot restart task since it is not leader", leaderUrl()), null); <END> } return null; } }, forwardErrorCallback(callback)); }</code><technical_language>I this change is clear. Workers (members of cluster) leaders, while connectors tasks assigned workers. connectors/tasks workers (members), incorrect "Cannot restart task [the task] is a leader". improvement original message adds is change "member" "worker", is debatable do "member" in other log messages (including in this class!)</technical_language>

Target:
public void restartTask(final ConnectorTaskId id, final Callback<Void> callback) { addRequest(new Callable<Void>() { @Override public Void call() throws Exception { if (checkRebalanceNeeded(callback)) return null; if (!configState.connectors().contains(id.connector())) { callback.onCompletion(new NotFoundException("Unknown connector: " + id.connector()), null); return null; } if (configState.taskConfig(id) == null) { callback.onCompletion(new NotFoundException("Unknown task: " + id), null); return null; } if (assignment.tasks().contains(id)) { try { worker.stopAndAwaitTask(id); if (startTask(id)) callback.onCompletion(null, null); else callback.onCompletion(new ConnectException("Failed to start task: " + id), null); } catch (Throwable t) { callback.onCompletion(t, null); } } else if (isLeader()) { callback.onCompletion(new NotAssignedException("Cannot restart task since it is not assigned to this member", member.ownerUrl(id)), null); } else { callback.onCompletion(new NotLeaderException("Cannot restart task since it is not assigned to this member", leaderUrl()), null); } return null; } }, forwardErrorCallback(callback)); }
Source:
<code>public final void setupAbstractTest() { DesiredCapabilities capabilities = new DesiredCapabilities(); <START> capabilities.setCapability("takesScreenshot", false); <END> driver = new PhantomJSDriver(capabilities); driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS); driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); driver.manage().window().setSize(new Dimension(2560, 1440)); }</code><technical_language>please remove commit changes</technical_language>

Target:
public final void setupAbstractTest() { ChromeOptions opts = new ChromeOptions(); opts.addArguments("--headless", "--disable-gpu", "--window-size=2560x1440"); DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability(ChromeOptions.CAPABILITY, opts); driver = new ChromeDriver(caps); driver.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS); driver.manage().timeouts().setScriptTimeout(15, TimeUnit.SECONDS); }
Source:
<code>public void authenticate(String user, String password) { String adminUser = ((Properties)context.get(ExtensionProperties.CONFIGURATION)).getProperty("config.authn.user.name"); <START> String adminPassword = ((Properties)context.get(ExtensionProperties.CONFIGURATION)).getProperty("config.authn.user.password"); <END> if (!ObjectUtils.equals(user, adminUser) || !ObjectUtils.equals(password, adminPassword)) { throw new AAAExtensionException(AAAExtensionException.AAAExtensionError.INCORRECT_CREDENTIALS, ""); } }</code><technical_language>store member init? important, is good is</technical_language>

Target:
public void authenticate(String user, String password) { String adminUser = ((Properties)context.get(ExtensionProperties.CONFIGURATION)).getProperty("config.authn.user.name"); String adminPassword = ((Properties)context.get(ExtensionProperties.CONFIGURATION)).getProperty("config.authn.user.password"); if (!user.equals(adminUser) || !password.equals(adminPassword)) { throw new AAAExtensionException(AAAExtensionException.AAAExtensionError.INCORRECT_CREDENTIALS, ""); } }
Source:
<code>public Set<SecurityGroup> listSecurityGroupsInLocation(final Location location) { String region = AWSUtils.getRegionFromLocationOrNull(location); if (region != null) { return listSecurityGroupsInLocation(region); } else { return ImmutableSet.of(); <START> } <END> }</code><technical_language>Quick style question (also applies below): do feel making "exceptional case" (region == null, guessing?) bit handle in if... clause, e.g. if (region == null) { return ImmutableSet.of(); // handle special case } return listSecurityGroupsInLocation(region);</technical_language>

Target:
public Set<SecurityGroup> listSecurityGroupsInLocation(final Location location) { String region = AWSUtils.getRegionFromLocationOrNull(location); if (region == null) { return ImmutableSet.of(); } return listSecurityGroupsInLocation(region); }
Source:
<code>public void shouldGetActiveDiagnoses() { <START> Patient patient = new Patient(2); <END> List<Diagnosis> activeDiagnosis = diagnosisDAO.getActiveDiagnoses(patient); assertEquals(2, activeDiagnosis.size()); }</code><technical_language>get rid of variable</technical_language>

Target:
public void shouldGetActiveDiagnoses() { assertEquals(2, diagnosisDAO.getActiveDiagnoses(new Patient(2)).size()); }
Source:
<code>public static boolean hasAnyPermission(Object object, Permission[] permissions) throws IOException, ServletException { if (permissions == null || permissions.length == 0) { return true; } if (object instanceof AccessControlled) return hasAnyPermission((AccessControlled) object, permissions); else { <START> List<Ancestor> ancs = Stapler.getCurrentRequest().getAncestors(); <END> for (Ancestor anc : Iterators.reverse(ancs)) { Object o = anc.getObject(); if (o instanceof AccessControlled) { return hasAnyPermission((AccessControlled) o, permissions); } } return hasAnyPermission(Jenkins.get(), permissions); } }</code><technical_language>suggestion AccessControlled ac = Stapler.getCurrentRequest().findAncestorObject(AccessControlled.class); etc</technical_language>

Target:
public static boolean hasAnyPermission(Object object, Permission[] permissions) throws IOException, ServletException { if (permissions == null || permissions.length == 0) { return true; } if (object instanceof AccessControlled) return hasAnyPermission((AccessControlled) object, permissions); else { AccessControlled ac = Stapler.getCurrentRequest().findAncestorObject(AccessControlled.class); if (ac != null) { return hasAnyPermission(ac, permissions); } return hasAnyPermission(Jenkins.get(), permissions); } }
Source:
<code>protected void executeCommand() { <START> DbUser dbUser = getDbUser(); <END> setCurrentUser(dbUser); String engineSessionId = loginOnBehalf(dbUser); if (StringUtils.isNotEmpty(engineSessionId)) { getReturnValue().setActionReturnValue(engineSessionId); } setSucceeded(true); }</code><technical_language>this is interactive command, I suggest do call getDbUser twice, drop canDoAction entirely</technical_language>

Target:
protected void executeCommand() { try { getReturnValue().setActionReturnValue(loginOnBehalf()); } catch (Exception ex) { log.error("Unable to create engine session: {}", ex.getMessage()); log.debug("Unable to create engine session", ex); } setSucceeded(true); }
Source:
<code>private void updateDiskImageDynamic() { <START> VDSReturnValue ret = Backend.getInstance().getResourceManager().RunVdsCommand( <END> VDSCommandType.GetImageInfo, new GetImageInfoVDSCommandParameters(getDestinationDiskImage().getStoragePoolId().getValue(), getDestinationDiskImage().getStorageIds().get(0), getDestinationDiskImage().getId(), getDestinationDiskImage().getImageId())); DiskImage imageFromIRS = (DiskImage) ret.getReturnValue(); DiskImageDynamic diskImageDynamic = getDiskImageDynamicDAO().get(getDestinationDiskImage().getImageId()); if (imageFromIRS != null && diskImageDynamic != null) { diskImageDynamic.setactual_size(imageFromIRS.getActualSizeFromDiskImage()); getDiskImageDynamicDAO().update(diskImageDynamic); } }</code><technical_language>runVdsCommand</technical_language>

Target:
private void updateDiskImageDynamic() { VDSReturnValue ret = runVdsCommand( VDSCommandType.GetImageInfo, new GetImageInfoVDSCommandParameters(getDestinationDiskImage().getStoragePoolId().getValue(), getDestinationDiskImage().getStorageIds().get(0), getDestinationDiskImage().getId(), getDestinationDiskImage().getImageId())); DiskImage imageFromIRS = (DiskImage) ret.getReturnValue(); DiskImageDynamic diskImageDynamic = getDiskImageDynamicDAO().get(getDestinationDiskImage().getImageId()); if (imageFromIRS != null && diskImageDynamic != null) { diskImageDynamic.setactual_size(imageFromIRS.getActualSizeFromDiskImage()); getDiskImageDynamicDAO().update(diskImageDynamic); } }
Source:
<code>public void mustEvaluateTrueEquality() throws Exception { new Assertion<>( "Must evaluate true equality", new RsPrettyJson( <START> new RsWithBody("{\"person\":{\"name\":\"John\"}}") <END> ), new IsEqual<>( new RsPrettyJson( new RsWithBody("{\"person\":{\"name\":\"John\"}}") ) ) ).affirm(); }</code><technical_language>@fanifieiev refactor this string put in a variable</technical_language>

Target:
public void mustEvaluateTrueEquality() throws Exception { final String body = "{\"person\":{\"name\":\"John\"}}"; new Assertion<>( "Must evaluate true equality", new RsPrettyJson( new RsWithBody(body) ), new IsEqual<>( new RsPrettyJson( new RsWithBody(body) ) ) ).affirm(); }
Source:
<code>public void testReadListViaFluentAPI() { List<PGobject> result = handle.createQuery("SELECT get_foo_bars()") .map(new PGObjectColumnMapper()) .list(); <START> List<FooBarPGType> fooBars = (List<FooBarPGType>) (List<?>) result; <END> assertThat(fooBars).isEqualTo(ImmutableList.of( new FooBarPGType(1, "foo1", "bar1"), new FooBarPGType(2, "foo2", "bar2") )); }</code><technical_language>this triple cast (result is cast a lines up)</technical_language>

Target:
public void testReadListViaFluentAPI() { List<FooBarPGType> result = handle.createQuery("SELECT get_foo_bars()") .mapTo(FooBarPGType.class) .list(); assertThat(result).containsExactlyInAnyOrder( new FooBarPGType(1, "foo1", "bar1"), new FooBarPGType(2, "foo2", "bar2") ); }
Source:
<code>public void testBuilderWithDefaultValues() { FeedbackResponseCommentAttributes feedbackAttributes = FeedbackResponseCommentAttributes .builder("course", "name", "questionId", <START> "responseId", "email") <END> .build(); assertEquals(feedbackAttributes.giverSection, "None"); assertEquals(feedbackAttributes.receiverSection, "None"); assertEquals(feedbackAttributes.showCommentTo, new ArrayList<>()); assertEquals(feedbackAttributes.showGiverNameTo, new ArrayList<>()); assertEquals(feedbackAttributes.commentText, new Text("")); assertTrue(feedbackAttributes.isVisibilityFollowingFeedbackQuestion); }</code><technical_language>This fine previous line</technical_language>

Target:
public void testBuilderWithDefaultValues() { FeedbackResponseCommentAttributes feedbackAttributes = FeedbackResponseCommentAttributes .builder("course", "name", "email", new Text("")) .build(); assertEquals(feedbackAttributes.giverSection, "None"); assertEquals(feedbackAttributes.receiverSection, "None"); assertEquals(feedbackAttributes.showCommentTo, new ArrayList<>()); assertEquals(feedbackAttributes.showGiverNameTo, new ArrayList<>()); assertTrue(feedbackAttributes.isVisibilityFollowingFeedbackQuestion); }
Source:
<code>public void interruptedExecution(CheckerContext context) { <START> reportIssues(); <END> }</code><technical_language>that. If reach end of execution paths exploration is interrupted, issue? explored a branch another return statement</technical_language>

Target:
public void interruptedExecution(CheckerContext context) { methodInvariantContexts.pop(); }
Source:
<code>public String identify() { <START> return "bigdoor@" + door.getDoorUID() + PropertyParser.getPropertiesString(this); <END> }</code><technical_language>This propertyparser call belong</technical_language>

Target:
public String identify() { return "bigdoor@" + door.getDoorUID(); }
Source:
<code>final void markCommitStateDirty() { <START> if (isAutoCommit || isReadOnly) { <END> lastAccess = clockSource.currentTime(); } else { isCommitStateDirty = true; } }</code><technical_language>This is more expensive. markCommitStateDirty() called dozens hundreds of times in a single connection use, isReadOnly is evaluated times. However, close() is called connection use, checking isReadOnly flag (where is currently), is more efficient</technical_language>

Target:
final void markCommitStateDirty() { isCommitStateDirty = true; }
Source:
<code>private void removeOffendingMprHashFragment(JsonObject uidl) { if (!uidl.hasKey(EXECUTE)) { return; } JsonArray exec = uidl.getArray(EXECUTE); String hash = null; int idx = -1; for (int i = 0; i < exec.length(); i++) { JsonArray arr = exec.get(i); for (int j = 0; j < arr.length(); j++) { <START> if (!arr.get(j).getType().equals(JsonType.STRING)) { <END> continue; } String script = arr.getString(j); if (script.contains("history.pushState")) { idx = i; continue; } if (!script.startsWith(SYNC_ID)) { continue; } JsonObject json = JsonUtil.parse("{" + script + "}"); hash = replaceHashFragment(json); if (hash != null) { script = JsonUtil.stringify(json); script = script.substring(1, script.length() - 1); arr.set(j, script); } } } if (hash != null) { idx = idx >= 0 ? idx : exec.length(); JsonArray arr = Json.createArray(); arr.set(0, ""); arr.set(1, String.format(PUSH_STATE, hash)); exec.set(idx, arr); } }</code><technical_language>![MAJOR](<LINK_0> 'Severity: MAJOR') Reduce total number of break continue statements in this loop one. [![rule](<LINK_1>](<LINK_2></technical_language>

Target:
private void removeOffendingMprHashFragment(JsonObject uidl) { if (!uidl.hasKey(EXECUTE)) { return; } JsonArray exec = uidl.getArray(EXECUTE); String hash = null; int idx = -1; for (int i = 0; i < exec.length(); i++) { JsonArray arr = exec.get(i); for (int j = 0; j < arr.length(); j++) { if (!arr.get(j).getType().equals(JsonType.STRING)) { continue; } String script = arr.getString(j); if (script.contains("history.pushState")) { idx = i; continue; } if (!script.startsWith(SYNC_ID)) { continue; } JsonObject json = JsonUtil.parse("{" + script + "}"); hash = removeHashInV7Uidl(json); if (hash != null) { script = JsonUtil.stringify(json); script = script.substring(1, script.length() - 1); arr.set(j, script); } } } if (hash != null) { idx = idx >= 0 ? idx : exec.length(); JsonArray arr = Json.createArray(); arr.set(0, ""); arr.set(1, String.format(PUSH_STATE, hash)); exec.set(idx, arr); } }
Source:
<code>public void closesAllParts() throws Exception { final String body = "RqMtFakeTest.closesAllParts"; final RqMultipart request = new RqMtFake( new RqFake(), new RqWithHeaders( new RqFake("", "", body), RqMtFakeTest.contentLengthHeader( (long) body.getBytes().length ), RqMtFakeTest.contentDispositionHeader( "form-data; name=\"name\"" ) ), new RqWithHeaders( new RqFake("", "", body), RqMtFakeTest.contentLengthHeader(0L), RqMtFakeTest.contentDispositionHeader( "form-data; name=\"content\"; filename=\"a.bin\"" ) ) ); final String exmessage = "An IOException was expected since the Stream is closed"; final String name = "name"; final String content = "content"; final RqMtBase multi = new RqMtBase(request); multi.part(name).iterator().next().body().read(); multi.part(content).iterator().next().body().read(); multi.body().close(); MatcherAssert.assertThat( multi.part(name).iterator().next(), Matchers.notNullValue() ); try { multi.part(name).iterator().next().body().read(); Assert.fail(exmessage); } catch (final IOException ex) { MatcherAssert.assertThat( ex, Matchers.instanceOf(ClosedChannelException.class) <START> ); <END> } MatcherAssert.assertThat( multi.part(content).iterator().next(), Matchers.notNullValue() ); try { multi.part(content).iterator().next().body().read(); Assert.fail(exmessage); } catch (final IOException ex) { MatcherAssert.assertThat( ex, Matchers.instanceOf(ClosedChannelException.class) ); } }</code><technical_language>@victornoel lots of assertions in method, break this method in parts assertion each</technical_language>

Target:
public void closesAllParts() throws Exception { final String body = "RqMtFakeTest.closesAllParts"; final RqMultipart request = new RqMtFake( new RqFake(), new RqWithHeaders( new RqFake("", "", body), RqMtFakeTest.contentLengthHeader( (long) body.getBytes().length ), RqMtFakeTest.contentDispositionHeader( "form-data; name=\"name\"" ) ), new RqWithHeaders( new RqFake("", "", body), RqMtFakeTest.contentLengthHeader(0L), RqMtFakeTest.contentDispositionHeader( "form-data; name=\"content\"; filename=\"a.bin\"" ) ) ); final String exmessage = "An IOException was expected since the Stream is closed"; final String name = "name"; final String content = "content"; final RqMtBase multi = new RqMtBase(request); multi.part(name).iterator().next().body().read(); multi.part(content).iterator().next().body().read(); multi.body().close(); MatcherAssert.assertThat( multi.part(name).iterator().next(), Matchers.notNullValue() ); try { multi.part(name).iterator().next().body().read(); Assert.fail(exmessage); } catch (final IOException ex) { MatcherAssert.assertThat( ex, new IsInstanceOf(ClosedChannelException.class) ); } MatcherAssert.assertThat( multi.part(content).iterator().next(), Matchers.notNullValue() ); try { multi.part(content).iterator().next().body().read(); Assert.fail(exmessage); } catch (final IOException ex) { MatcherAssert.assertThat( ex, new IsInstanceOf(ClosedChannelException.class) ); } }
Source:
<code><START> public Optional<NorthAmericaRegion> getState(String normalisedZipCode) { <END> var wellFormedZipCodeAndOptionalPlusFourMatcher = WELL_FORMED_STATE_WITH_ZIP_CODE_AND_OPTIONAL_PLUS_FOUR.matcher(normalisedZipCode); var wellFormedStateWithZipAndOptionalPlusFourMatcher = WELL_FORMED_ZIP_CODE_AND_OPTIONAL_PLUS_FOUR.matcher(normalisedZipCode); if (wellFormedStateWithZipAndOptionalPlusFourMatcher.matches()) { String stateAbbreviation = wellFormedStateWithZipAndOptionalPlusFourMatcher.group(1); return Optional.ofNullable(UsZipCodeToStateMap.ZIP_CODE_TO_US_STATE_ABBREVIATIONS.get(stateAbbreviation)); } else if (wellFormedZipCodeAndOptionalPlusFourMatcher.matches()) { String firstThreeCharacters = wellFormedZipCodeAndOptionalPlusFourMatcher.group(1); return Optional.ofNullable(US_STATE_ABBREVIATIONS_MAPPING.get(firstThreeCharacters)); } return Optional.empty(); }</code><technical_language>I this stay UsState</technical_language>

Target:
public Optional<UsState> getState(String normalisedZipCode) { var wellFormedZipCodeAndOptionalPlusFourMatcher = WELL_FORMED_STATE_WITH_ZIP_CODE_AND_OPTIONAL_PLUS_FOUR.matcher(normalisedZipCode); var wellFormedStateWithZipAndOptionalPlusFourMatcher = WELL_FORMED_ZIP_CODE_AND_OPTIONAL_PLUS_FOUR.matcher(normalisedZipCode); if (wellFormedStateWithZipAndOptionalPlusFourMatcher.matches()) { String stateAbbreviation = wellFormedStateWithZipAndOptionalPlusFourMatcher.group(1); return Optional.ofNullable(UsZipCodeToStateMap.ZIP_CODE_TO_US_STATE_ABBREVIATIONS.get(stateAbbreviation)); } else if (wellFormedZipCodeAndOptionalPlusFourMatcher.matches()) { String firstThreeCharacters = wellFormedZipCodeAndOptionalPlusFourMatcher.group(1); return Optional.ofNullable(US_STATE_ABBREVIATIONS_MAPPING.get(firstThreeCharacters)); } return Optional.empty(); }
Source:
<code>private Charts createCharts(List<Metric> metrics) { Charts charts = new Flotr2Charts(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); String displayFormat = "MMM dd"; if(metrics.size() > 0 && metrics.get(0).name.length() == 7){ df = new SimpleDateFormat("yyyy-MM"); <START> displayFormat = "MMM"; <END> } df.setTimeZone(getTimeZone()); Chart chart = charts.createLineChart("commitsChart", getString("gb.activity"), "day", getString("gb.commits")); chart.setDateFormat(displayFormat); for (Metric metric : metrics) { Date date; try { date = df.parse(metric.name); } catch (ParseException e) { logger.error("Unable to parse date: " + metric.name); return charts; } chart.addValue(date, (int)metric.count); } charts.addChart(chart); return charts; }</code><technical_language>change this displayFormat = "yyyy MMM";</technical_language>

Target:
private Charts createCharts(List<Metric> metrics) { Charts charts = new Flotr2Charts(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); String displayFormat = "MMM dd"; if(metrics.size() > 0 && metrics.get(0).name.length() == 7){ df = new SimpleDateFormat("yyyy-MM"); displayFormat = "yyyy MMM"; } df.setTimeZone(getTimeZone()); Chart chart = charts.createLineChart("commitsChart", getString("gb.activity"), "day", getString("gb.commits")); chart.setDateFormat(displayFormat); for (Metric metric : metrics) { Date date; try { date = df.parse(metric.name); } catch (ParseException e) { logger.error("Unable to parse date: " + metric.name); return charts; } chart.addValue(date, (int)metric.count); if(metric.tag > 0 ){ chart.addHighlight(date, (int)metric.count); } } charts.addChart(chart); return charts; }
Source:
<code>public static void setBundlesLevels(Q7Target target, Map<String, String> levelMap) { final ProfileBundleContainer profileBundleContainer = target.getInstall().container; if (profileBundleContainer != null) { for (TargetBundle bundle : target.getInstall().getBundles()) { String bundleLevels = levelMap.get(bundle.getBundleInfo().getSymbolicName()); if (bundleLevels != null) { <START> String[] strings = bundleLevels.split(":"); <END> int level = Integer.parseInt(strings[0]); boolean started = Boolean.parseBoolean(strings[1]); bundle.getBundleInfo().setStartLevel(level); bundle.getBundleInfo().setMarkedAsStarted(started); } } } else { log(status("Profile Bundle Container is EMPTY.")); } }</code><technical_language>Please add exception checking fail</technical_language>

Target:
public static void setBundlesLevels(Q7Target target, Map<String, String> levelMap) { final ProfileBundleContainer profileBundleContainer = target.getInstall().container; if (profileBundleContainer != null) { for (TargetBundle bundle : target.getInstall().getBundles()) { String bundleLevels = levelMap.get(bundle.getBundleInfo().getSymbolicName()); if (bundleLevels != null) { try { String[] strings = bundleLevels.split(":"); int level = Integer.parseInt(strings[0]); boolean started = Boolean.parseBoolean(strings[1]); bundle.getBundleInfo().setStartLevel(level); bundle.getBundleInfo().setMarkedAsStarted(started); } catch (Exception e) { } } } } else { log(status("Profile Bundle Container is EMPTY.")); } }
Source:
<code>public void checkDocuments() throws XWikiException { LOGGER.info("executing XWikiRecycleBinIndexes"); <START> if (queryExecService.existsConstraint("prefix_db", "xwikirecyclebin", "dateIDX")) { <END> queryExecService.executeWriteSQL(getSQLIndexToRecycleBin()); } }</code><technical_language>a ! (NOT) is missing - I prefix_db placeholder, fill actual database prefix</technical_language>

Target:
public void checkDocuments() throws XWikiException { LOGGER.info("executing XWikiRecycleBinIndexes"); String prefixAndDb = modelContext.getXWikiContext().getWiki().Param("xwiki.db.prefix") + modelContext.getWikiRef().getName(); if (!queryExecService.existsIndex(prefixAndDb, "xwikirecyclebin", "dateIDX")) { queryExecService.executeWriteSQL(getSQLIndexToRecycleBin()); } }
Source:
<code>public String getName() { <START> return this.key.replace("options.mainHand.", ""); <END> }</code><technical_language>set a field this</technical_language>

Target:
public String getName() { return this.name; }
Source:
<code>private void initChartMenu() { List<Chart> charts = mController.getCharts(); String[] menuArray = new String[charts.size()]; int i = 0; for (Chart chart : charts) { menuArray[i] = chart.name; i++; } mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menuArray); mDrawerList.setAdapter(mAdapter); <START> final Activity that = this; <END> mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mController.updatePatientObsUi(position); mDrawerLayout.closeDrawer(mDrawerList); } }); }</code><technical_language>I this is used. But, for future, if need access outer class class, OuterClass.this class</technical_language>

Target:
private void initChartMenu() { final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ActionBar.TabListener tabListener = new ActionBar.TabListener() { @Override public void onTabSelected(ActionBar.Tab tab, android.app.FragmentTransaction ft) { mController.updatePatientObsUi(tab.getPosition()); } @Override public void onTabUnselected(ActionBar.Tab tab, android.app.FragmentTransaction ft) @Override public void onTabReselected(ActionBar.Tab tab, android.app.FragmentTransaction ft) }; List<Chart> charts = mController.getCharts(); String[] menuArray = new String[charts.size()]; for (int i = 0; i < charts.size(); i++) { menuArray[i] = charts.get(i).name; actionBar.addTab( actionBar.newTab() .setText(charts.get(i).name) .setTabListener(tabListener)); } }
Source:
<code><START> public ArrayInterface setInt(int index, int value) { <END> return setObject(index, value); }</code><technical_language>I return Array here</technical_language>

Target:
public Array setInt(int index, int value) { return setObject(index, value); }
Source:
<code>private void submitFeedback() { PreferenceUtils.saveBoolean(NavigationServiceProvider.FIRST_FEEDBACK, false); Log.d(TAG, "First Feedback : " + String.valueOf(Application.getPrefs() .getBoolean(NavigationServiceProvider.FIRST_FEEDBACK, true))); String feedback = ((EditText) this.findViewById(R.id.editFeedbackText)).getText().toString(); if (Application.getPrefs() .getBoolean(getString(R.string.preferences_key_user_share_logs), true)) { moveLog(feedback); <START> } <END> else { deleteLog(); } Log.d(TAG,"Feedback send : " + feedback); Toast.makeText(FeedbackActivity.this, getString(R.string.feedback_notify_confirmation), Toast.LENGTH_SHORT).show(); }</code><technical_language>For of IF statements, please move else line preceding bracket? } else {</technical_language>

Target:
private void submitFeedback() { PreferenceUtils.saveBoolean(NavigationService.FIRST_FEEDBACK, false); Log.d(TAG, "First Feedback : " + String.valueOf(Application.getPrefs() .getBoolean(NavigationService.FIRST_FEEDBACK, true))); String feedback = ((EditText) this.findViewById(R.id.editFeedbackText)).getText().toString(); if (Application.getPrefs() .getBoolean(getString(R.string.preferences_key_user_share_logs), true)) { moveLog(feedback); } else { deleteLog(); } Log.d(TAG,"Feedback send : " + feedback); Toast.makeText(FeedbackActivity.this, getString(R.string.feedback_notify_confirmation), Toast.LENGTH_SHORT).show(); }
Source:
<code>public void testValidationInvalidPassword() throws Exception { <START> EditRepositoryWizard wizard = new EditRepositoryWizard(repository, <END> TasksUiPlugin.getConnectorUi(repository.getConnectorKind())); WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard); dialog.create(); BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage(); page.setPassword("bogus"); try { BugzillaClient client = createClient(page.getRepositoryUrl(), page.getUserName(), page.getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(), page.getCharacterEncoding()); client.validate(null); } catch (CoreException e) { return; } fail("LoginException didn't occur!"); }</code><technical_language>test includes this I move setup</technical_language>

Target:
public void testValidationInvalidPassword() throws Exception { WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard); dialog.create(); BugzillaRepositorySettingsPage page = (BugzillaRepositorySettingsPage) wizard.getSettingsPage(); page.setPassword("bogus"); try { BugzillaClient client = createClient(page.getRepositoryUrl(), page.getUserName(), page.getPassword(), page.getHttpAuthUserId(), page.getHttpAuthPassword(), page.getCharacterEncoding()); client.validate(null); } catch (CoreException e) { return; } fail("LoginException didn't occur!"); }
Source:
<code>private void writeHostSpec(HostSpecificationImpl host, DataOutputStream out, boolean force) throws IOException { if (host != null && force && !forcedWrite.contains(host)) { int index = addToObjectTable(host); out.writeByte(StateReader.OBJECT); out.writeInt(index); forcedWrite.add(host); } else if (writePrefix(host, out)) return; writeVersionConstraint(host, out); BundleDescription[] hosts = host.getHosts(); if (hosts == null) { out.writeInt(0); return; } out.writeInt(hosts.length); for (BundleDescription <START> host1 : <END> hosts) { writeBundleDescription(host1, out, force); } writeMap(out, host.getAttributes()); writeMap(out, host.getArbitraryDirectives()); }</code><technical_language>rename h, creative now</technical_language>

Target:
private void writeHostSpec(HostSpecificationImpl host, DataOutputStream out, boolean force) throws IOException { if (host != null && force && !forcedWrite.contains(host)) { int index = addToObjectTable(host); out.writeByte(StateReader.OBJECT); out.writeInt(index); forcedWrite.add(host); } else if (writePrefix(host, out)) return; writeVersionConstraint(host, out); BundleDescription[] hosts = host.getHosts(); if (hosts == null) { out.writeInt(0); return; } out.writeInt(hosts.length); for (BundleDescription h : hosts) { writeBundleDescription(h, out, force); } writeMap(out, host.getAttributes()); writeMap(out, host.getArbitraryDirectives()); }
Source:
<code>private static Credential.UserCredential buildUserCredentialFromEnterpriseConfig( WifiEnterpriseConfig config) { Credential.UserCredential userCredential = new Credential.UserCredential(); userCredential.setEapType(EAPConstants.EAP_TTLS); if (TextUtils.isEmpty(config.getIdentity())) { Log.e(TAG, "Missing username for user credential"); return null; } userCredential.setUsername(config.getIdentity()); if (TextUtils.isEmpty(config.getPassword())) { Log.e(TAG, "Missing password for user credential"); return null; } String encodedPassword = new String(Base64.encode(config.getPassword().getBytes(StandardCharsets.UTF_8), Base64.DEFAULT), StandardCharsets.UTF_8); userCredential.setPassword(encodedPassword); switch(config.getPhase2Method()) { <START> case WifiEnterpriseConfig.Phase2.PAP: userCredential.setNonEapInnerMethod("PAP"); break; case WifiEnterpriseConfig.Phase2.MSCHAP: userCredential.setNonEapInnerMethod("MS-CHAP"); break; case WifiEnterpriseConfig.Phase2.MSCHAPV2: userCredential.setNonEapInnerMethod("MS-CHAP-V2"); <END> break; default: Log.e(TAG, "Unsupported phase2 method for TTLS: " + config.getPhase2Method()); return null; } return userCredential; }</code><technical_language>Missed these</technical_language>

Target:
private static Credential.UserCredential buildUserCredentialFromEnterpriseConfig( WifiEnterpriseConfig config) { Credential.UserCredential userCredential = new Credential.UserCredential(); userCredential.setEapType(EAPConstants.EAP_TTLS); if (TextUtils.isEmpty(config.getIdentity())) { Log.e(TAG, "Missing username for user credential"); return null; } userCredential.setUsername(config.getIdentity()); if (TextUtils.isEmpty(config.getPassword())) { Log.e(TAG, "Missing password for user credential"); return null; } String encodedPassword = new String(Base64.encode(config.getPassword().getBytes(StandardCharsets.UTF_8), Base64.DEFAULT), StandardCharsets.UTF_8); userCredential.setPassword(encodedPassword); switch(config.getPhase2Method()) { case WifiEnterpriseConfig.Phase2.PAP: userCredential.setNonEapInnerMethod(Credential.UserCredential.AUTH_METHOD_PAP); break; case WifiEnterpriseConfig.Phase2.MSCHAP: userCredential.setNonEapInnerMethod(Credential.UserCredential.AUTH_METHOD_MSCHAP); break; case WifiEnterpriseConfig.Phase2.MSCHAPV2: userCredential.setNonEapInnerMethod(Credential.UserCredential.AUTH_METHOD_MSCHAPV2); break; default: Log.e(TAG, "Unsupported phase2 method for TTLS: " + config.getPhase2Method()); return null; } return userCredential; }
Source:
<code>public void parseData() throws BasicModel.FieldNotDefinedException { mDataToBind.clear(); <START> for (StoredNotification notification : mAPIData) { <END> mDataToBind.add(new RecentNotificationListItem(notification.getTitle(), notification.getBody(), notification.getIntent())); } }</code><technical_language>regular for</technical_language>

Target:
public void parseData() throws BasicModel.FieldNotDefinedException { mDataToBind.clear(); for (int i = 0; i < mAPIData.size(); i++) { StoredNotification notification = mAPIData.get(i); mDataToBind.add(new RecentNotificationListItem(notification.getTitle(), notification.getBody(), notification.getIntent())); } }
Source:
<code>public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append(operator == null ? "" : operator.toString()); <START> buffer.append(" " + super.toString()); END> buffer.append(":" + value == null ? "" : value); buffer.append(" " + type == null ? "" : type.toString()); buffer.append("^" + boost); return buffer.toString(); }</code><technical_language>FieldAwareQuery return empty string, consider moving colon super.toString(), empty</technical_language>

Target:
public String toString() { StringBuilder builder = new StringBuilder(); builder.append(operator == null ? "" : operator.toString()); builder.append(" ").append(super.toString()); builder.append(value == null ? "" : value); builder.append(" ").append(type == null ? "" : type.toString()); builder.append("^").append(boost); return builder.toString(); }
Source:
<code>public ListBoxModel doFillTokenCredentialIdItems(@AncestorInPath Item context) { <START> Jenkins j = Jenkins.getInstance(); <END> if (j == null) { throw new IllegalStateException(); } if(context == null && !j.hasPermission(Jenkins.ADMINISTER) || context != null && !context.hasPermission(Item.EXTENDED_READ)) { return new StandardListBoxModel(); } return new StandardListBoxModel() .withEmptySelection() .withAll(lookupCredentials( StringCredentials.class, context, ACL.SYSTEM, new HostnameRequirement("*.slack.com")) ); }</code><technical_language>getActiveInstance maybe? deprecated in newer jenkins core, replacement 2.98 <LINK_0></technical_language>

Target:
public ListBoxModel doFillTokenCredentialIdItems(@AncestorInPath Item context) { Jenkins jenkins = Jenkins.getActiveInstance(); if(context == null && !jenkins.hasPermission(Jenkins.ADMINISTER) || context != null && !context.hasPermission(Item.EXTENDED_READ)) { return new StandardListBoxModel(); } return new StandardListBoxModel() .withEmptySelection() .withAll(lookupCredentials( StringCredentials.class, context, ACL.SYSTEM, new HostnameRequirement("*.slack.com")) ); }
Source:
<code>public void run(IAction action) { Job job = new Job(CodanUIMessages.Job_TitleRunningAnalysis) { @SuppressWarnings("unchecked") @Override protected IStatus run(final IProgressMonitor monitor) { <START> if (sel instanceof IStructuredSelection) { <END> IStructuredSelection ss = (IStructuredSelection) sel; int count = ss.size(); monitor.beginTask(getName(), count * 100); if (monitor.isCanceled()) return Status.CANCEL_STATUS; for (Iterator iterator = ss.iterator(); iterator.hasNext();) { Object o = iterator.next(); if (o instanceof IAdaptable) { o = ((IAdaptable) o).getAdapter(IResource.class); } if (o instanceof IResource) { IResource res = (IResource) o; SubProgressMonitor subMon = new SubProgressMonitor(monitor, 100); CodanRuntime.getInstance().getBuilder().processResource(res, subMon, CheckerLaunchMode.RUN_ON_DEMAND); if (subMon.isCanceled()) return Status.CANCEL_STATUS; } if (monitor.isCanceled()) return Status.CANCEL_STATUS; } } return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); }</code><technical_language>bail out starting job</technical_language>

Target:
public void run(IAction action) { if (sel instanceof IStructuredSelection) { final IStructuredSelection ss = (IStructuredSelection) sel; Job job = new Job(CodanUIMessages.Job_TitleRunningAnalysis) { @Override protected IStatus run(final IProgressMonitor monitor) { int count = ss.size(); monitor.beginTask(getName(), count * 100); if (monitor.isCanceled()) return Status.CANCEL_STATUS; for (Iterator iterator = ss.iterator(); iterator.hasNext();) { Object o = iterator.next(); if (o instanceof IAdaptable) { o = ((IAdaptable) o).getAdapter(IResource.class); } if (o instanceof IResource) { IResource res = (IResource) o; SubProgressMonitor subMon = new SubProgressMonitor(monitor, 100); CodanRuntime.getInstance().getBuilder().processResource(res, subMon, CheckerLaunchMode.RUN_ON_DEMAND); if (subMon.isCanceled()) return Status.CANCEL_STATUS; } if (monitor.isCanceled()) return Status.CANCEL_STATUS; } return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); } }
Source:
<code>public void validate() { <START> if (!file.exists() && overwriteFile == true) { <END> throw new IllegalStateException("The file can not be overwritten because the file does not exist"); } }</code><technical_language>I care this situation (neither in Excel) - if file exist running risks of overwriting existing data. name configured property - instead of "overwriteFile" "overwriteFileIfExists"</technical_language>

Target:
public void validate() { if (file.exists() && !overwriteFileIfExists) { throw new IllegalStateException("The file already exists. Please configure the job to overwrite the existing file."); } }