auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void canDoubleClickOnStyledText() throws Exception { bot.checkBox("Listen").select(); styledText = bot.styledTextInGroup("StyledText"); styledText.setText("This is sample text"); bot.button("Clear").click(); SWTBotText text = bot.textInGroup("Listeners"); styledText.doubleClick(0, 1); verifyNotifyClick(); assertEventMatches(text, "MouseDown [3]: MouseEvent{StyledText time=0 data=null button=1 stateMask=" + toStateMask(SWT.NONE, styledText.widget) + " x=0 y=0 count=2"); assertEventMatches(text, "MouseDoubleClick [8]: MouseEvent{StyledText time=0 data=null button=1 stateMask=" + toStateMask(SWT.NONE, styledText.widget) + " x=0 y=0 count=2}"); assertEventMatches(text, "MouseUp [4]: MouseEvent{StyledText time=0 data=null button=1 stateMask=" <START> + toStateMask(SWT.BUTTON1, styledText.widget) + " x=0 y=0 count=2"); <END> }</code><technical_language>Verify cursor position double-click</technical_language>

Target:
public void canDoubleClickOnStyledText() throws Exception { final int line = 0, column = 6; bot.checkBox("Listen").select(); styledText = bot.styledTextInGroup("StyledText"); styledText.setText("This is sample text"); bot.button("Clear").click(); styledText.doubleClick(line, column); assertEquals(new Position(line, column - 1), styledText.cursorPosition(true)); assertEquals(styledText.getSelection(), "is"); verifyNotifyClick(0); SWTBotText text = bot.textInGroup("Listeners"); assertEventMatches(text, "MouseDown [3]: MouseEvent{StyledText time=0 data=null button=1 stateMask=" + toStateMask(SWT.NONE, styledText.widget) + " x=0 y=0 count=2"); assertEventMatches(text, "MouseDoubleClick [8]: MouseEvent{StyledText time=0 data=null button=1 stateMask=" + toStateMask(SWT.NONE, styledText.widget) + " x=0 y=0 count=2}"); assertEventMatches(text, "MouseUp [4]: MouseEvent{StyledText time=0 data=null button=1 stateMask=" + toStateMask(SWT.BUTTON1, styledText.widget) + " x=0 y=0 count=2"); }
Source:
<code>public PlanNode visitProject(ProjectNode node, RewriteContext<Set<Symbol>> context) { ImmutableSet.Builder<Symbol> expectedInputs = ImmutableSet.builder(); Assignments.Builder builder = Assignments.builder(); <START> for (Map.Entry<Symbol, Expression> entry : node.getAssignments().entrySet()) { <END> Symbol output = entry.getKey(); Expression expression = entry.getValue(); if (context.get().contains(output)) { expectedInputs.addAll(SymbolsExtractor.extractUnique(expression)); builder.put(output, expression); } } PlanNode source = context.rewrite(node.getSource(), expectedInputs.build()); return new ProjectNode(node.getId(), source, builder.build()); }</code><technical_language>I simplify this java node.getAssignments().forEach((output, expression) -> { ... });</technical_language>

Target:
public PlanNode visitProject(ProjectNode node, RewriteContext<Set<Symbol>> context) { ImmutableSet.Builder<Symbol> expectedInputs = ImmutableSet.builder(); Assignments.Builder builder = Assignments.builder(); node.getAssignments().forEach((symbol, expression) -> { if (context.get().contains(symbol)) { expectedInputs.addAll(SymbolsExtractor.extractUnique(expression)); builder.put(symbol, expression); } }); PlanNode source = context.rewrite(node.getSource(), expectedInputs.build()); return new ProjectNode(node.getId(), source, builder.build()); }
Source:
<code>public byte[] readRound(long seq) { <START> return executeStatement(String.format("SELECT val FROM paxosLog WHERE seq = %s;", seq)) <END> .map(SqlitePaxosStateLog::getByteArrayUnchecked) .orElse(null); }</code><technical_language>suggestion return executeStatement(String.format("SELECT val paxosLog seq = %s", seq))</technical_language>

Target:
public byte[] readRound(long seq) { return executeStatement(String.format("SELECT val FROM paxosLog WHERE seq = %s", seq)) .map(SqlitePaxosStateLog::getByteArrayUnchecked) .orElse(null); }
Source:
<code>public boolean isToPrivateCloudTabOpened() { return seleniumWebDriverHelper <START> .waitVisibilityAndGetAttribute( <END> By.xpath(To_PRIVATE_CLOUD_BUTTON_XPATH + "/parent::md-tab-item"), "aria-selected") .equals("true"); }</code><technical_language>method seleniumWebDriverHelper::waitAttributeEqualsTo() is more suitable here, IMHO</technical_language>

Target:
public boolean isToPrivateCloudTabOpened() { final String privateCloudButtonParentContainer = PRIVATE_CLOUD_BUTTON_XPATH + "/parent::md-tab-item"; return seleniumWebDriverHelper .waitVisibilityAndGetAttribute(By.xpath(privateCloudButtonParentContainer), "aria-selected") .equals("true"); }
Source:
<code>public org.activiti.client.model.ProcessInstance from(ProcessInstance source) { org.activiti.client.model.ProcessInstance processInstance = null; if (source != null) { processInstance = new org.activiti.client.model.ProcessInstance(source.getId(), source.getName(), source.getDescription(), source.getProcessDefinitionId(), source.getStartUserId(), source.getStartTime(), source.getBusinessKey(), calculateStatus(source), <START> source.getStartUserId()); <END> } return processInstance; }</code><technical_language>This is done initiator field</technical_language>

Target:
public org.activiti.client.model.ProcessInstance from(ProcessInstance source) { org.activiti.client.model.ProcessInstance processInstance = null; if (source != null) { processInstance = new org.activiti.client.model.ProcessInstance(source.getId(), source.getName(), source.getDescription(), source.getProcessDefinitionId(), source.getStartUserId(), source.getStartTime(), source.getBusinessKey(), calculateStatus(source)); } return processInstance; }
Source:
<code>private static CloseableHttpClient createInsecureSslHttpClient() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException { final SSLContext sslContext = new SSLContextBuilder() <START> .useProtocol("TLSv1.2") <END> .loadTrustMaterial(null, new TrustStrategy() { @Override public boolean isTrusted(final X509Certificate[] chain, final String authType) throws CertificateException { return true; } }).build(); final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier()); final Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create() .register("http", PlainConnectionSocketFactory.getSocketFactory()) .register("https", sslsf) .build(); final HttpClientConnectionManager connectionManager = createConnectionManager(socketFactoryRegistry); return HttpClients.custom() .setConnectionManager(connectionManager) .setSSLSocketFactory( sslsf).build(); }</code><technical_language>fit style define this final static strings</technical_language>

Target:
private static CloseableHttpClient createInsecureSslHttpClient() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException { final SSLContext sslContext = new SSLContextBuilder() .useProtocol(INSECURE_SSL_PROTOCOL) .loadTrustMaterial(null, new TrustStrategy() { @Override public boolean isTrusted(final X509Certificate[] chain, final String authType) throws CertificateException { return true; } }).build(); final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier()); final Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create() .register("http", PlainConnectionSocketFactory.getSocketFactory()) .register("https", sslsf) .build(); final HttpClientConnectionManager connectionManager = createConnectionManager(socketFactoryRegistry); return HttpClients.custom() .setConnectionManager(connectionManager) .setSSLSocketFactory( sslsf).build(); }
Source:
<code>@Test public void parseMessageAndOneOf() throws Exception { String proto = "" + "message SearchRequest {\n" + " required string query = 1;\n" + " oneof page_info {\n" + " int32 page_number = 2;\n" + " int32 result_per_page = 3;\n" + " }\n" + "}"; <START> ProtoFile expected = ProtoFile.builder("search.proto") <END> .addType(MessageElement.builder() .setName("SearchRequest") .addField(FieldElement.builder() .setLabel(REQUIRED) .setType("string") .setName("query") .setTag(1) .build()) .addOneOf(OneOfElement.builder() .setName("page_info") .addField(FieldElement.builder() .setLabel(ONE_OF) .setType("int32") .setName("page_number") .setTag(2) .build()) .addField(FieldElement.builder() .setLabel(ONE_OF) .setType("int32") .setName("result_per_page") .setTag(3) .build()) .build()) .build()) .build(); assertThat(ProtoParser.parse("search.proto", proto)).isEqualTo(expected); }</code><technical_language>more legible</technical_language>

Target:
@Test public void parseMessageAndOneOf() throws Exception { String proto = "" + "message SearchRequest {\n" + " required string query = 1;\n" + " oneof page_info {\n" + " int32 page_number = 2;\n" + " int32 result_per_page = 3;\n" + " }\n" + "}"; ProtoFile expected = ProtoFile.builder("search.proto") .addType(MessageElement.builder() .name("SearchRequest") .addField(FieldElement.builder() .label(REQUIRED) .type("string") .name("query") .tag(1) .build()) .addOneOf(OneOfElement.builder() .name("page_info") .addField(FieldElement.builder() .label(ONE_OF) .type("int32") .name("page_number") .tag(2) .build()) .addField(FieldElement.builder() .label(ONE_OF) .type("int32") .name("result_per_page") .tag(3) .build()) .build()) .build()) .build(); assertThat(ProtoParser.parse("search.proto", proto)).isEqualTo(expected); }
Source:
<code>public void testGetNestedPath() { Class clazzRoot = UMLFactory.eINSTANCE.createClass(); Class clazzType1 = UMLFactory.eINSTANCE.createClass(); Class clazzType2 = UMLFactory.eINSTANCE.createClass(); Class clazzType3 = UMLFactory.eINSTANCE.createClass(); Property p1 = clazzRoot.createOwnedAttribute("P1", clazzType1); Property p2 = clazzType1.createOwnedAttribute("P2", clazzType2); Property p3 = clazzType2.createOwnedAttribute("P3", clazzType3); Property p4 = clazzType3.createOwnedAttribute("P4", clazzType1); Node p4View = NotationFactory.eINSTANCE.createNode(); p4View.setElement(p4); Node p3View = NotationFactory.eINSTANCE.createNode(); p3View.setElement(p3); p3View.insertChild(p4View); Node p2View = NotationFactory.eINSTANCE.createNode(); p2View.setElement(p2); p2View.insertChild(p3View); Node p1View = NotationFactory.eINSTANCE.createNode(); p1View.setElement(p1); p1View.insertChild(p2View); Node clazzRootViewNode = NotationFactory.eINSTANCE.createNode(); clazzRootViewNode.setElement(clazzRoot); clazzRootViewNode.insertChild(p1View); List<Property> nestedPath = ConnectorUtil.getNestedPath(clazzRoot, p4View); assertTrue("Wrong nested path, <START> expexted {P1, <END> P2, P3}", nestedPath.size() == 3 && nestedPath.get(0) == p1 && nestedPath.get(1) == p2 && nestedPath.get(2) == p3); nestedPath = ConnectorUtil.getNestedPath(clazzRoot, p2View); assertTrue("Wrong nested path, expexted {P1}", nestedPath.size() == 1 && nestedPath.get(0) == p1); }</code><technical_language>expected</technical_language>

Target:
public void testGetNestedPath() { Class clazzRoot = UMLFactory.eINSTANCE.createClass(); Class clazzType1 = UMLFactory.eINSTANCE.createClass(); Class clazzType2 = UMLFactory.eINSTANCE.createClass(); Class clazzType3 = UMLFactory.eINSTANCE.createClass(); Property p1 = clazzRoot.createOwnedAttribute("P1", clazzType1); Property p2 = clazzType1.createOwnedAttribute("P2", clazzType2); Property p3 = clazzType2.createOwnedAttribute("P3", clazzType3); Property p4 = clazzType3.createOwnedAttribute("P4", clazzType1); Node p4View = NotationFactory.eINSTANCE.createNode(); p4View.setElement(p4); Node p3View = NotationFactory.eINSTANCE.createNode(); p3View.setElement(p3); p3View.insertChild(p4View); Node p2View = NotationFactory.eINSTANCE.createNode(); p2View.setElement(p2); p2View.insertChild(p3View); Node p1View = NotationFactory.eINSTANCE.createNode(); p1View.setElement(p1); p1View.insertChild(p2View); Node clazzRootViewNode = NotationFactory.eINSTANCE.createNode(); clazzRootViewNode.setElement(clazzRoot); clazzRootViewNode.insertChild(p1View); List<Property> nestedPath = ConnectorUtil.getNestedPath(clazzRoot, p4View); assertEquals("Wrong nested path, expected {P1, P2, P3}", Arrays.asList(p1, p2, p3), nestedPath); nestedPath = ConnectorUtil.getNestedPath(clazzRoot, p2View); assertTrue("Wrong nested path, expected {P1}", nestedPath.size() == 1 && nestedPath.get(0) == p1); }
Source:
<code><START> public NewPartitionReassignment(List<Integer> targetReplicas) { <END> this.targetReplicas = Collections.unmodifiableList(new ArrayList<>(targetReplicas)); }</code><technical_language>this need public? Making private forces of of method, I is good</technical_language>

Target:
private NewPartitionReassignment(List<Integer> targetReplicas) { this.targetReplicas = Collections.unmodifiableList(new ArrayList<>(targetReplicas)); }
Source:
<code>public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { if (needFiltering(name)) { synchronized(this) { Class<?> cl = findLoadedClass(name); if (cl == null && delegatingClassLoader != null) { InputStream inputStream = delegatingClassLoader.getResourceAsStream(name.replace('.','/')+".class"); if (inputStream != null) { ByteArrayOutputStream targetBuffer = new ByteArrayOutputStream(); try { try { byte[] buffer = new byte[1024]; for(int r = inputStream.read(buffer, 0, buffer.length); r > 0; r = inputStream.read(buffer, 0, buffer.length)) { targetBuffer.write(buffer, 0, r); } } finally { inputStream.close(); } } catch (IOException e) { throw new ClassNotFoundException("Cannot load class with name '"+name+"' from delegating classloader", e); } byte[] classBytes = targetBuffer.toByteArray(); cl = defineClass(name, classBytes, 0, classBytes.length); if (resolve) { resolveClass(cl); } } } if (cl != null) { return cl; } else { throw new ClassNotFoundException("Class with name '"+name+"' should not be loaded from parent classloader and is not found in delegating classloader"); } } } else { <START> return super.loadClass(name, resolve); <END> } }</code><technical_language>sense reorder if branch avoid if (...) { long code ... long code} else {return} pattern</technical_language>

Target:
public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { if (!needFiltering(name)) { return super.loadClass(name, resolve); } synchronized(this) { Class<?> cl = findLoadedClass(name); if (cl == null && delegatingClassLoader != null) { InputStream inputStream = delegatingClassLoader.getResourceAsStream(name.replace('.','/')+".class"); if (inputStream != null) { ByteArrayOutputStream targetBuffer = new ByteArrayOutputStream(); try { try { byte[] buffer = new byte[1024]; for(int r = inputStream.read(buffer, 0, buffer.length); r > 0; r = inputStream.read(buffer, 0, buffer.length)) { targetBuffer.write(buffer, 0, r); } } finally { inputStream.close(); } } catch (IOException e) { throw new ClassNotFoundException("Cannot load class with name '"+name+"' from delegating classloader", e); } byte[] classBytes = targetBuffer.toByteArray(); cl = defineClass(name, classBytes, 0, classBytes.length); if (resolve) { resolveClass(cl); } } } if (cl != null) { return cl; } else { throw new ClassNotFoundException("Class with name '"+name+"' should not be loaded from parent classloader and is not found in delegating classloader"); } } }
Source:
<code>private void handleSubquery(FilterContext filter, List<IndexSegment> indexSegments, TimerContext timerContext, ExecutorService executorService, long endTimeMs) throws Exception { Predicate predicate = filter.getPredicate(); <START> if (predicate != null) { <END> handleSubquery(predicate.getLhs(), indexSegments, timerContext, executorService, endTimeMs); } else { for (FilterContext child : filter.getChildren()) { handleSubquery(child, indexSegments, timerContext, executorService, endTimeMs); } } }</code><technical_language>docs, check for filter.getChildren invert if statement</technical_language>

Target:
private void handleSubquery(FilterContext filter, List<IndexSegment> indexSegments, TimerContext timerContext, ExecutorService executorService, long endTimeMs) throws Exception { List<FilterContext> children = filter.getChildren(); if (children != null) { for (FilterContext child : children) { handleSubquery(child, indexSegments, timerContext, executorService, endTimeMs); } } else { handleSubquery(filter.getPredicate().getLhs(), indexSegments, timerContext, executorService, endTimeMs); } }
Source:
<code>Map<String, Long> getExternalResourcesUnSafe(Object resource) { if (!isYarnResourceTypesAvailable) { return Collections.emptyMap(); } final Map<String, Long> externalResources = new HashMap<>(); final Object[] externalResourcesInfo; try { externalResourcesInfo = (Object[]) resourceGetResourcesMethod.invoke(resource); for (int i = 2; i < externalResourcesInfo.length; i++) { final String name = (String) resourceInformationGetNameMethod.invoke(externalResourcesInfo[i]); final long value = (long) resourceInformationGetValueMethod.invoke(externalResourcesInfo[i]); <START> if (value > 0) { externalResources.put(name, value); } <END> } } catch (Exception e) { LOG.warn("Could not obtain the external resources supported by the given Resource.", e); return Collections.emptyMap(); } return externalResources; }</code><technical_language>I proper solution is enforce this invariant in InternalContainerResource constructor (filtering out entries a of 0 adapt equals method check entries a of 0). run situation in future user GPU constraints operator sets 0 resources match</technical_language>

Target:
Map<String, Long> getExternalResourcesUnSafe(Object resource) { if (!isYarnResourceTypesAvailable) { return Collections.emptyMap(); } final Map<String, Long> externalResources = new HashMap<>(); final Object[] externalResourcesInfo; try { externalResourcesInfo = (Object[]) resourceGetResourcesMethod.invoke(resource); for (int i = 2; i < externalResourcesInfo.length; i++) { final String name = (String) resourceInformationGetNameMethod.invoke(externalResourcesInfo[i]); final long value = (long) resourceInformationGetValueMethod.invoke(externalResourcesInfo[i]); externalResources.put(name, value); } } catch (Exception e) { LOG.warn("Could not obtain the external resources supported by the given Resource.", e); return Collections.emptyMap(); } return externalResources; }
Source:
<code>private static JsonElement createErrorJson(String message, Response.Status status, Object entity, Exception ex) { JsonObject ret = new JsonObject(); JsonObject err = new JsonObject(); ret.add(JSON_KEY_ERROR, err); err.addProperty(JSON_KEY_ERROR_MESSAGE, message); if (null != status) { err.addProperty(JSON_KEY_HTTPCODE, status.getStatusCode()); } if (null != entity) { ret.add("entity", GSON.toJsonTree(entity)); } if (null != ex) { JsonObject exc = new JsonObject(); err.add("exception", exc); { exc.addProperty("class", ex.getClass().getName()); exc.addProperty("message", ex.getMessage()); exc.addProperty("localized-message", ex.getLocalizedMessage()); exc.addProperty("cause", null != ex.getCause() ? ex.getCause().getClass().getName() : null); if (WITH_STACKTRACE) <START> exc.add("stacktrace", GSON.toJsonTree(ex.getStackTrace())); <END> } } return ret; }</code><technical_language>please add curly brackets</technical_language>

Target:
private static JsonElement createErrorJson(String message, Response.Status status, Object entity, Exception ex) { JsonObject ret = new JsonObject(); JsonObject err = new JsonObject(); ret.add(JSON_KEY_ERROR, err); err.addProperty(JSON_KEY_ERROR_MESSAGE, message); if (null != status) { err.addProperty(JSON_KEY_HTTPCODE, status.getStatusCode()); } if (null != entity) { ret.add("entity", GSON.toJsonTree(entity)); } if (null != ex) { JsonObject exc = new JsonObject(); err.add("exception", exc); { exc.addProperty("class", ex.getClass().getName()); exc.addProperty("message", ex.getMessage()); exc.addProperty("localized-message", ex.getLocalizedMessage()); exc.addProperty("cause", null != ex.getCause() ? ex.getCause().getClass().getName() : null); if (WITH_STACKTRACE) { exc.add("stacktrace", GSON.toJsonTree(ex.getStackTrace())); } } } return ret; }
Source:
<code>public int getMax() { <START> return getSeaPickle().getMinimumPickles(); <END> }</code><technical_language>^ Nope. Copypasta spaghetti that</technical_language>

Target:
public int getMax() { return getSeaPickle().getMaximumPickles(); }
Source:
<code>public void focusLost() { <START> assertFalse(new BooleanTextBox(true).isValidValue("-", true)); <END> assertTrue(new BooleanTextBox(false).isValidValue("-", false)); }</code><technical_language>miss new BooleanTextBox(true).isValidValue("-", false);</technical_language>

Target:
public void focusLost() { assertFalse(new BooleanTextBox(true).isValidValue("-", true)); assertFalse(new BooleanTextBox(false).isValidValue("-", true)); assertTrue(new BooleanTextBox(false).isValidValue("-", false)); assertTrue(new BooleanTextBox(true).isValidValue("-", false)); }
Source:
<code>public void testOverSizedBitImageExplicitStorageArray() { final int numLongs = ( int ) Math.ceil( 1000 * 1000 / 64 ); <START> final ArrayImg< BitType, LongArray > img = ArrayImgs.bits( new LongArray( new long[ numLongs ] ), 1000, 1000 ); <END> final Random r = new Random( 42l ); img.forEach( p -> { p.set( r.nextBoolean() ); } ); final long[] storage = ( long[] ) ( ( ArrayDataAccess< ? > ) img.update( null ) ).getCurrentStorageArray(); final long[] sizes = new long[ img.numDimensions() ]; img.dimensions( sizes ); assertEquals( storage.length, numLongs ); }</code><technical_language>sense test image sizes divisible 64? is, 1000 * 1000 / 64 == 15625, test "partially filled" longs. a 100 * 100 image (100 * 100 / 64 == 156.25)</technical_language>

Target:
public void testOverSizedBitImageExplicitStorageArray() { final int numLongs = ( int ) Math.ceil( 100 * 100 / 64d ); final ArrayImg< BitType, LongArray > img = ArrayImgs.bits( new LongArray( new long[ numLongs ] ), 100, 100 ); final Random r = new Random( 42l ); img.forEach( p -> { p.set( r.nextBoolean() ); } ); final long[] storage = ( long[] ) ( ( ArrayDataAccess< ? > ) img.update( null ) ).getCurrentStorageArray(); final long[] sizes = new long[ img.numDimensions() ]; img.dimensions( sizes ); assertEquals( storage.length, numLongs ); }
Source:
<code>public void getBrand(final String brand, final int page, final OnBrandCallback onBrandCallback) { <START> String fields = "brands,product_name_fr,product_name,image_small_url,image_front_thumb_url,quantity,nutrition_grades_tags"; <END> apiService.getProductByBrands(brand, page, fields).enqueue(new Callback<Search>() { @Override public void onResponse(Call<Search> call, Response<Search> response) { onBrandCallback.onBrandResponse(true, response.body()); } @Override public void onFailure(Call<Search> call, Throwable t) { onBrandCallback.onBrandResponse(false, null); } }); }</code><technical_language>final. suggestion final String fields = "brands,product_name_fr,product_name,image_small_url,image_front_thumb_url,quantity,nutrition_grades_tags";</technical_language>

Target:
public void getBrand(final String brand, final int page, final OnBrandCallback onBrandCallback) { apiService.getProductByBrands(brand, page, FIELDS_TO_FETCH_FACETS).enqueue(new Callback<Search>() { @Override public void onResponse(@NonNull Call<Search> call, @NonNull Response<Search> response) { onBrandCallback.onBrandResponse(true, response.body()); } @Override public void onFailure(@NonNull Call<Search> call, @NonNull Throwable t) { onBrandCallback.onBrandResponse(false, null); } }); }
Source:
<code>private boolean isLogNumFieldValid() { String count = logFileCount.getText(); logNumAlert.setText(""); if (count.length() == 0) { logNumAlert.setText(Bundle.AutopsyOptionsPanel_logNumAlert_noValueEntered_text()); return false; } if (count.replaceAll("[^\\d]", "").length() != count.length() || count.replaceFirst("^0+", "").length() == 0) { logNumAlert.setText(Bundle.AutopsyOptionsPanel_logNumAlert_invalidInput_text()); return false; } <START> return true; <END> }</code><technical_language>do want a pop a message, try parsing int catching exception. I int parsing code throwing exception catch , please put code this show pop is happening, thanks</technical_language>

Target:
private boolean isLogNumFieldValid() { String count = logFileCount.getText(); logNumAlert.setText(""); try { int count_num = Integer.parseInt(count); if (count_num < 1) { logNumAlert.setText(Bundle.AutopsyOptionsPanel_logNumAlert_invalidInput_text()); return false; } } catch (NumberFormatException e) { logNumAlert.setText(Bundle.AutopsyOptionsPanel_logNumAlert_invalidInput_text()); return false; } return true; }
Source:
<code>private void updateView(BoxIteratorCollaborations boxIteratorCollaborations) { mCollaborations = boxIteratorCollaborations; <START> if (mCollaborations != null) { <END> if (mCollaborations.size() == 0) { this.setVisibility(GONE); } else { this.setVisibility(View.VISIBLE); mInitialsListHeader.setVisibility(View.VISIBLE); final int totalCollaborators = mCollaborations.fullSize().intValue(); final int remainingWidth = mInitialsListView.getWidth(); final ArrayList<BoxCollaboration> collaborations = mCollaborations.getEntries(); clearInitialsView(); mInitialsListView.post(new Runnable() { @Override public void run() { final View initialsView = addInitialsToList(collaborations.get(0).getAccessibleBy()); initialsView.post(new Runnable() { @Override public void run() { int viewWidth = initialsView.getWidth(); int viewsCount = remainingWidth/viewWidth; for (int i = 1; i < viewsCount && i < collaborations.size(); i++) { View viewAdded = addInitialsToList(collaborations.get(i).getAccessibleBy()); if (i == viewsCount - 1) { int remaining = totalCollaborators - viewsCount; if (remaining > 0) { BoxAvatarView initials = (BoxAvatarView) viewAdded.findViewById(R.id.collaborator_initials); JsonObject jsonObject = new JsonObject(); jsonObject.set(BoxCollaborator.FIELD_NAME, Integer.toString(remaining + 1)); BoxUser numberUser = new BoxUser(jsonObject); initials.loadUser(numberUser, mController.getAvatarController()); } } } } }); } }); } } }</code><technical_language>In case this mCollaborations is null, setVisibility "GONE" ? I feel check: if(mCollaborations == null || mCollaborations.size() == 0) --> view.GONE view VISIBLE continue processing</technical_language>

Target:
private void updateView(BoxIteratorCollaborations boxIteratorCollaborations) { mCollaborations = boxIteratorCollaborations; if (mCollaborations == null) { this.setVisibility(GONE); return; } if (mCollaborations.size() == 0) { this.setVisibility(GONE); } else { this.setVisibility(View.VISIBLE); mInitialsListHeader.setVisibility(View.VISIBLE); final int totalCollaborators = mCollaborations.fullSize().intValue(); final int remainingWidth = mInitialsListView.getWidth(); final ArrayList<BoxCollaboration> collaborations = mCollaborations.getEntries(); clearInitialsView(); mInitialsListView.post(new Runnable() { @Override public void run() { final View initialsView = addInitialsToList(collaborations.get(0).getAccessibleBy()); initialsView.post(new Runnable() { @Override public void run() { int viewWidth = initialsView.getWidth(); int viewsCount = remainingWidth/viewWidth; for (int i = 1; i < viewsCount && i < collaborations.size(); i++) { View viewAdded = addInitialsToList(collaborations.get(i).getAccessibleBy()); if (i == viewsCount - 1) { int remaining = totalCollaborators - viewsCount; if (remaining > 0) { BoxAvatarView initials = (BoxAvatarView) viewAdded.findViewById(R.id.collaborator_initials); JsonObject jsonObject = new JsonObject(); jsonObject.set(BoxCollaborator.FIELD_NAME, Integer.toString(remaining + 1)); BoxUser numberUser = new BoxUser(jsonObject); initials.loadUser(numberUser, mController.getAvatarController()); } } } } }); } }); } }
Source:
<code>public void bootstrapOnHost(Stack stack) throws CloudbreakException { Set<Node> nodes = collectNodesForBootstrap(stack); try { List<GatewayConfig> allGatewayConfig = collectAndCheckGateways(stack); saveSaltComponent(stack); BootstrapParams params = createBootstrapParams(stack); <START> hostOrchestrator.bootstrap(allGatewayConfig, nodes, params, clusterDeletionBasedModel(stack.getId(), null)); <END> InstanceMetaData primaryGateway = stack.getPrimaryGatewayInstance(); saveOrchestrator(stack, primaryGateway); checkIfAllNodesAvailable(stack, nodes, primaryGateway); } catch (Exception e) { throw new CloudbreakException(e); } }</code><technical_language>bootstrap reBootstrap for save update. this refactored a common method</technical_language>

Target:
public void bootstrapOnHost(Stack stack) throws CloudbreakException { bootstrapOnHostInternal(stack, this::saveSaltComponent); }
Source:
<code>NameMatcher(String pattern, Character pathSeparator, boolean dirOnly){ super(pattern, dirOnly); slash = getPathSeparator(pathSeparator); beginning = pattern.length() == 0 ? false : pattern.charAt(0) == slash; <START> if(!beginning) { <END> this.subPattern = pattern; } else { this.subPattern = pattern.substring(1, pattern.length()); } }</code><technical_language>nit-pick: braces single line statements</technical_language>

Target:
NameMatcher(String pattern, Character pathSeparator, boolean dirOnly) { super(pattern, dirOnly); slash = getPathSeparator(pathSeparator); beginning = pattern.length() == 0 ? false : pattern.charAt(0) == slash; if (!beginning) this.subPattern = pattern; else this.subPattern = pattern.substring(1); }
Source:
<code>public Iterable<EdgeInfo> getEdgeInfos(Direction direction, final String[] labels, Authorizations authorizations) { <START> if (!getFetchHints().isIncludeEdgeRefs()) { <END> throw new VertexiumException("getEdgeInfos called without including any edge infos"); } Iterable<EdgeInfo> results = internalGetEdgeInfo(direction, authorizations); results = new FilterIterable<EdgeInfo>(results) { @Override protected boolean isIncluded(EdgeInfo o) { if (!getFetchHints().isIncludeEdgeRefLabel(o.getLabel())) { return false; } if (labels == null) { return true; } else { for (String label : labels) { if (o.getLabel().equals(label)) { return true; } } return false; } } }; return results; }</code><technical_language>this getFetchHints().validateHasEdgeFetchHints(direction) instead? If so, checking labels too</technical_language>

Target:
public Iterable<EdgeInfo> getEdgeInfos(Direction direction, final String[] labels, Authorizations authorizations) { getFetchHints().validateHasEdgeFetchHints(direction, labels); Iterable<EdgeInfo> results = internalGetEdgeInfo(direction, authorizations); results = new FilterIterable<EdgeInfo>(results) { @Override protected boolean isIncluded(EdgeInfo o) { if (!getFetchHints().isIncludeEdgeRefLabel(o.getLabel())) { return false; } if (labels == null) { return true; } else { for (String label : labels) { if (o.getLabel().equals(label)) { return true; } } return false; } } }; return results; }
Source:
<code>public String[] updateTranslationNames(String[] translationNames) { <START> <END> List<String> transList = new ArrayList<>(); for (String translation : translationNames) { transList.add(translation); } transList.add(getContext().getString(R.string.more_translations)); translationNames = transList.toArray(new String[transList.size()]); return translationNames; }</code><technical_language>Unnecessary empty line</technical_language>

Target:
private String[] updateTranslationNames(String[] translationNames) { List<String> translationsList = new ArrayList<>(); for (String translation : translationNames) { translationsList.add(translation); } translationsList.add(getContext().getString(R.string.more_translations)); translationNames = translationsList.toArray(new String[translationsList.size()]); return translationNames; }
Source:
<code>Observer<List<Location>> getLocationList() { return new Observer<List<Location>>() { @Override public void onCompleted() { new AlertDialog.Builder(ACBaseActivity.this) .setSingleChoiceItems( new ArrayAdapter<>(ACBaseActivity.this, android.R.layout.simple_list_item_single_choice, locationList), locationList.indexOf(mOpenMRS.getLocation()), (dialog, which) -> { mOpenMRS.setLocation(locationList.get(which)); dialog.dismiss(); }) .show(); } @Override public void onError(Throwable e) { e.printStackTrace(); } @Override public void onNext(List<Location> locations) { <START> locationList = new ArrayList<>(); <END> for (Location locationItem : locations) { locationList.add(locationItem.getName()); } } }; }</code><technical_language>instantiate this variable is initialized in onNext function is guarantee onNext is called time</technical_language>

Target:
private Observer<List<Location>> getLocationList() { return new Observer<List<Location>>() { @Override public void onCompleted() { showLocationDialog(locationList); } @Override public void onError(Throwable e) { e.printStackTrace(); } @Override public void onNext(List<Location> locations) { for (Location locationItem : locations) { locationList.add(locationItem.getName()); } } }; }
Source:
<code>void testCloserClosingState() throws InterruptedException { <START> Injector i = createInjector(); <END> final Closer closer = i.getInstance(Closer.class); assert closer.getState() == Closer.State.OPEN; final AtomicBoolean flag = new AtomicBoolean(true); closer.addToClose(new Closeable() { @Override public void close() throws IOException { while (flag.get()) { } assert closer.getState() == Closer.State.CLOSING; } }); Thread thread = new Thread(new Runnable() { @Override public void run() { try { closer.close(); } catch (IOException e) { assert false; } } }); thread.start(); while (closer.getState() == Closer.State.OPEN) { } assert closer.getState() == Closer.State.CLOSING; flag.set(false); thread.join(); assert closer.getState() == Closer.State.CLOSED; }</code><technical_language>is this test supposed test? Simply sequence of states some multi-threaded stuff? If so, exactly? a [CountDownLatch](<LINK_0> is suited handoff AtomicBoolean empty loops</technical_language>

Target:
void testCloserClosingState() throws InterruptedException { Injector i = createInjector(); final Closer closer = i.getInstance(Closer.class); final CountDownLatch closeDone = new CountDownLatch(1); final CountDownLatch closeStart = new CountDownLatch(1); closer.addToClose(new Closeable() { @Override public void close() throws IOException { try { closeStart.countDown(); assert closer.getState() == Closer.State.PROCESSING; closeDone.await(); } catch (InterruptedException e) { assert false : e.getMessage(); } } }); Thread thread = new Thread(new Runnable() { @Override public void run() { try { closer.close(); } catch (IOException e) { assert false : e.getMessage(); } } }); thread.start(); closeStart.await(); assert closer.getState() == Closer.State.PROCESSING; closeDone.countDown(); thread.join(); assert closer.getState() == Closer.State.DONE; }
Source:
<code>protected static Object getTraceTypeElement(IResource resource, String element) { try { if (resource != null) { String traceType = resource.getPersistentProperty(TmfCommonConstants.TRACETYPE); for (IConfigurationElement ce : TmfTraceType.getTypeElements()) { if (ce.getAttribute(TmfTraceType.ID_ATTR).equals(traceType)) { IConfigurationElement[] viewerCE = ce.getChildren(element); if (viewerCE.length != 1) { break; } <START> return viewerCE[0].createExecutableExtension(TmfTraceType.CLASS_ATTR); <END> } } } } catch (CoreException e) { Activator.getDefault().logError("Error creating statistics viewer", e); } return null; }</code><technical_language>..and is a TmfTraceType returned here? Merge artifact maybe</technical_language>

Target:
public static Object getTraceTypeElement(IResource resource, String element) { try { if (resource != null) { String traceType = resource.getPersistentProperty(TmfCommonConstants.TRACETYPE); for (IConfigurationElement ce : TmfTraceType.getTypeElements()) { if (ce.getAttribute(TmfTraceType.ID_ATTR).equals(traceType)) { IConfigurationElement[] viewerCE = ce.getChildren(element); if (viewerCE.length != 1) { break; } return viewerCE[0].createExecutableExtension(TmfTraceType.CLASS_ATTR); } } } } catch (CoreException e) { Activator.getDefault().logError("Error creating statistics viewer", e); } return null; }
Source:
<code>public void close() { final List<Throwable> suppressed = new ArrayList<>(); if (closed) { return; } boolean wasInTransaction = forceEndTransactions && config.get().get(Handles.class).isForceEndTransactions(); <START> <END> if (wasInTransaction) { try { wasInTransaction &= isInTransaction(); } catch (Exception e) { suppressed.add(e); } } extensionMethod.remove(); config.remove(); if (wasInTransaction) { try { rollback(); } catch (Exception e) { suppressed.add(e); } } try { statementBuilder.close(getConnection()); } catch (Exception e) { suppressed.add(e); } try { closer.close(connection); if (!suppressed.isEmpty()) { final Throwable original = suppressed.remove(0); suppressed.forEach(original::addSuppressed); throw new CloseException("Failed to clear transaction status on close", original); } if (wasInTransaction) { TransactionException txe = new TransactionException("Improper transaction handling detected: A Handle with an open " + "transaction was closed. Transactions must be explicitly committed or rolled back " + "before closing the Handle. " + "Jdbi has rolled back this transaction automatically. " + "This check may be disabled by calling getConfig(Handles.class).setForceEndTransactions(false)."); suppressed.forEach(txe::addSuppressed); throw txe; } } catch (SQLException e) { CloseException ce = new CloseException("Unable to close Connection", e); suppressed.forEach(ce::addSuppressed); throw ce; } finally { LOG.trace("Handle released", this); closed = true; } }</code><technical_language>isInTransaction() part get removed</technical_language>

Target:
public void close() { final List<Throwable> suppressed = new ArrayList<>(); if (closed) { return; } boolean wasInTransaction = false; if (forceEndTransactions && config.get().get(Handles.class).isForceEndTransactions()) { try { wasInTransaction = isInTransaction(); } catch (Exception e) { suppressed.add(e); } } extensionMethod.remove(); config.remove(); if (wasInTransaction) { try { rollback(); } catch (Exception e) { suppressed.add(e); } } try { statementBuilder.close(getConnection()); } catch (Exception e) { suppressed.add(e); } try { closer.close(connection); if (!suppressed.isEmpty()) { final Throwable original = suppressed.remove(0); suppressed.forEach(original::addSuppressed); throw new CloseException("Failed to clear transaction status on close", original); } if (wasInTransaction) { throw new TransactionException("Improper transaction handling detected: A Handle with an open " + "transaction was closed. Transactions must be explicitly committed or rolled back " + "before closing the Handle. " + "Jdbi has rolled back this transaction automatically. " + "This check may be disabled by calling getConfig(Handles.class).setForceEndTransactions(false)."); } } catch (SQLException e) { CloseException ce = new CloseException("Unable to close Connection", e); suppressed.forEach(ce::addSuppressed); throw ce; } finally { LOG.trace("Handle released", this); closed = true; } }
Source:
<code>private boolean proceedCommandExecutionFailed() { if (getParameters().getCommandStep() == RemoveSnapshotSingleDiskLiveStep.MERGE) { log.warn("Merge failed, <START> retrying to <END> recover from MERGE_STATUS step"); getParameters().setCommandStep(RemoveSnapshotSingleDiskLiveStep.MERGE_STATUS); return true; } if (getParameters().getCommandStep() == RemoveSnapshotSingleDiskLiveStep.DESTROY_IMAGE) { log.warn("Child command '{}' failed, proceeding to verify", getParameters().getCommandStep()); getParameters().setCommandStep(getParameters().getNextCommandStep()); return true; } log.error("Failed child command status for step '{}'", getParameters().getCommandStep()); setCommandStatus(CommandStatus.FAILED); return false; }</code><technical_language>s/retrying/attempting/</technical_language>

Target:
private boolean proceedCommandExecutionFailed() { if (getParameters().getCommandStep() == RemoveSnapshotSingleDiskLiveStep.MERGE) { log.warn("Merge failed, attempting to recover from MERGE_STATUS step"); getParameters().setCommandStep(RemoveSnapshotSingleDiskLiveStep.MERGE_STATUS); return true; } if (getParameters().getCommandStep() == RemoveSnapshotSingleDiskLiveStep.DESTROY_IMAGE) { log.warn("Child command '{}' failed, proceeding to verify", getParameters().getCommandStep()); getParameters().setCommandStep(getParameters().getNextCommandStep()); return true; } log.error("Failed child command status for step '{}'", getParameters().getCommandStep()); setCommandStatus(CommandStatus.FAILED); return false; }
Source:
<code>private List<TermResource> executeSearch(QueryBuilder qb, int limit, Boolean thinFilter) { List<TermResource> termList = new ArrayList<>(); SearchHits hits = client.prepareSearch(index).setQuery(qb).setSize(limit).execute().actionGet().getHits(); ObjectMapper mapper = new ObjectMapper(); if (thinFilter) { SimpleModule module = new SimpleModule(); module.addDeserializer(TermResource.class, new TermResourceMinimalDeserializer()); mapper.registerModule(module); } for (SearchHit hit : hits.getHits()) { String jsonString = hit.getSourceAsString(); try { TermResource resource = mapper.readValue(jsonString, TermResource.class); termList.add(resource); } catch (IOException e) { logger.error("Exception mapping value: '" + jsonString + "' to TermResource: " + e.getMessage()); } <START> } <END> return termList; }</code><technical_language>consider alternate approach removes need for TermResourceMinimalDeserializer altogether. if, instead of conditionally applying a json deserializer, full/built-in deserializer, add of blocks here: if (thinFilter) { List<TermResource> thinList = new ArrayList<TermResource>(); for (TermResource thick : termList) { TermResource thin = new TermResource(); thin.setId(thick.id); thin.setLabel(thick.label); thin.setDefinition(thick.definition); thin.setSynonyms(thick.synonyms); thinList.add(thin); } termList = thinList; } even: if (thinFilter) { for (TermResource thick : termList) { thick.setParents(null); thick.setOntology(null); thick.setUsable(null); } } I waffling is approach. a deserializer is efficient runtime, in deserialize fields need ES, create Java objects use. However, managing deserializers is heavier code maintenance, massaging Java objects is more readable/accessible code</technical_language>

Target:
private List<TermResource> executeSearch(QueryBuilder qb, int limit, Boolean thinFilter) { List<TermResource> termList = new ArrayList<>(); SearchHits hits = client.prepareSearch(index).setQuery(qb).setSize(limit).execute().actionGet().getHits(); ObjectMapper mapper = new ObjectMapper(); for (SearchHit hit : hits.getHits()) { String jsonString = hit.getSourceAsString(); try { TermResource resource = mapper.readValue(jsonString, TermResource.class); if (thinFilter) { resource.setOntology(null); resource.setUsable(null); resource.setParents(null); } termList.add(resource); } catch (IOException e) { logger.error("Exception mapping value: '" + jsonString + "' to TermResource: " + e.getMessage()); } } return termList; }
Source:
<code>protected final void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { drawForegroundLayer(); GlStateManager.translate(-guiLeft, -guiTop, 0); mouse.setMousePosition(mouseX, mouseY); <START> <END> for (IGuiElement element : guiElements) { element.drawForeground(); } tooltips.drawForeground(); GlStateManager.translate(guiLeft, guiTop, 0); }</code><technical_language>Swapping breaks other GUI's</technical_language>

Target:
protected final void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { GlStateManager.translate(-guiLeft, -guiTop, 0); mouse.setMousePosition(mouseX, mouseY); drawForegroundLayer(); for (IGuiElement element : guiElements) { element.drawForeground(); } tooltips.drawForeground(); GlStateManager.translate(guiLeft, guiTop, 0); }
Source:
<code><START> public void setLocked(boolean locked) { isLocked = locked; } <END></code><technical_language>Please follow style guide in CONTRIBUTING.md add this field access. turn > save action</technical_language>

Target:
public void setLocked(boolean locked) { this.isLocked = locked; }
Source:
<code>public List<Map<String, String>> replace(String input) { List<Map<String, String>> parsed = Lists.newArrayList(); Matcher m = pattern.matcher(input); int last = 0; while (m.find()) { addText(parsed, input.substring(last, m.start())); if (link != null) { <START> String builder = new String(link); for (int i = 0; i < m.groupCount(); i++) { builder = builder.replaceAll("\\$" + Integer.toString(i), m.group(i + 1)); } addLink(parsed, m.group(0), builder); <END> } last = m.end(); } addText(parsed, input.substring(last)); return parsed; }</code><technical_language>this replaced String s = pattern.matcher(m.group(0)).replaceAll(link); addLink(parsed, m.group(0), s);</technical_language>

Target:
public List<Map<String, String>> replace(String input) { List<Map<String, String>> parsed = Lists.newArrayList(); Matcher m = pattern.matcher(input); int last = 0; while (m.find()) { addText(parsed, input.substring(last, m.start())); if (link != null) { String s = pattern.matcher(m.group(0)).replaceAll(link); addLink(parsed, m.group(0), s); } last = m.end(); } addText(parsed, input.substring(last)); return parsed; }
Source:
<code>public JPanel getReopenPanel(){ if(reopenPanel == null){ reopenPanel = new JPanel(); reopenPanel.setLayout(new GridBagLayout()); <START> reopenPanel.setPreferredSize(new Dimension(100, 160)); <END> int y = 0; reopenPanel.add(wsUiHelper.getRedirectionCheckBox(),wsUiHelper.getFieldConstraints(0,y++)); reopenPanel.add(wsUiHelper.getTrackingSessionCheckBox(),wsUiHelper.getFieldConstraints(0,y++)); reopenPanel.add(wsUiHelper.createVerticalSeparator(),wsUiHelper.getFieldConstraints(0,y++)); reopenPanel.add(wsUiHelper.getWebSocketKeyLabel(),wsUiHelper.getLabelConstraints(0,y++)); reopenPanel.add(wsUiHelper.getSecWebsocketKeyField(),wsUiHelper.getFieldConstraints(0,y++)); reopenPanel.add(wsUiHelper.getAlwaysGenerateCheckBox(),wsUiHelper.getFieldConstraints(0,y++)); reopenPanel.add(wsUiHelper.getGenerateWebSocketKeyButton(),wsUiHelper.getFieldConstraints(0,y++)); } return reopenPanel; }</code><technical_language>Is this necessary pack()ed later</technical_language>

Target:
private JPanel getReopenPanel(){ if(reopenPanel == null){ reopenPanel = new JPanel(); reopenPanel.setLayout(new GridBagLayout()); int y = 0; reopenPanel.add(wsUiHelper.getRedirectionCheckBox(),wsUiHelper.getFieldConstraints(0,y++)); reopenPanel.add(wsUiHelper.getTrackingSessionCheckBox(),wsUiHelper.getFieldConstraints(0,y++)); reopenPanel.add(wsUiHelper.createVerticalSeparator(),wsUiHelper.getFieldConstraints(0,y++)); reopenPanel.add(wsUiHelper.getWebSocketKeyLabel(),wsUiHelper.getLabelConstraints(0,y++)); reopenPanel.add(wsUiHelper.getWebSocketKeyField(),wsUiHelper.getFieldConstraints(0,y++)); reopenPanel.add(wsUiHelper.getAlwaysGenerateCheckBox(),wsUiHelper.getFieldConstraints(0,y++)); reopenPanel.add(wsUiHelper.getGenerateWebSocketKeyButton(),wsUiHelper.getFieldConstraints(0,y++)); } return reopenPanel; }
Source:
<code><START> public Void setTier(AccessTier tier) { <END> return setTierWithResponse(tier, null, null, Context.NONE).value(); }</code><technical_language>This void, correct</technical_language>

Target:
public void setTier(AccessTier tier) { setTierWithResponse(tier, null, null, Context.NONE); }