auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public int compare(OrderByRowResult<T> r1, OrderByRowResult<T> r2) { try { List<QueryItem> result1 = r1.getOrderByItems(); List<QueryItem> result2 = r2.getOrderByItems(); if (result1.size() != result2.size()) { throw new IllegalStateException("OrderByItems cannot have different sizes."); } if (result1.size() != this.sortOrders.size()) { throw new IllegalStateException("OrderByItems cannot have a different size than sort orders."); } if (this.itemTypes == null) { synchronized (this) { if (this.itemTypes == null) { this.itemTypes = new ArrayList<ItemType>(result1.size()); for (QueryItem item : result1) { this.itemTypes.add(ItemTypeHelper.getOrderByItemType(item.getItem())); } } } } this.checkOrderByItemType(result1); this.checkOrderByItemType(result2); for (int i = 0; i < result1.size(); ++i) { int cmp = ItemComparator.getInstance().compare(result1.get(i).getItem(), result2.get(i).getItem()); if (cmp != 0) { switch (this.sortOrders.get(i)) { case Ascending: return cmp; case Descending: <START> return ItemComparator.getInstance().compare(result2.get(i).getItem(), result1.get(i).getItem()); <END> } } } return r1.getSourcePartitionKeyRange().getMinInclusive().compareTo(r2.getSourcePartitionKeyRange().getMinInclusive()); } catch (Exception e) { logger.error("Orderby Row comparision failed {}, {}", r1.toJson(), r2.toJson(), e); throw e; } }</code><technical_language>This recomputes cmp, instead signum</technical_language>

Target:
public int compare(OrderByRowResult<T> r1, OrderByRowResult<T> r2) { try { List<QueryItem> result1 = r1.getOrderByItems(); List<QueryItem> result2 = r2.getOrderByItems(); if (result1.size() != result2.size()) { throw new IllegalStateException("OrderByItems cannot have different sizes."); } if (result1.size() != this.sortOrders.size()) { throw new IllegalStateException("OrderByItems cannot have a different size than sort orders."); } if (this.itemTypes == null) { synchronized (this) { if (this.itemTypes == null) { this.itemTypes = new ArrayList<ItemType>(result1.size()); for (QueryItem item : result1) { this.itemTypes.add(ItemTypeHelper.getOrderByItemType(item.getItem())); } } } } this.checkOrderByItemType(result1); this.checkOrderByItemType(result2); for (int i = 0; i < result1.size(); ++i) { int cmp = ItemComparator.getInstance().compare(result1.get(i).getItem(), result2.get(i).getItem()); if (cmp != 0) { switch (this.sortOrders.get(i)) { case Ascending: return signum(cmp); case Descending: return -signum(cmp); } } } return r1.getSourcePartitionKeyRange().getMinInclusive().compareTo(r2.getSourcePartitionKeyRange().getMinInclusive()); } catch (Exception e) { logger.error("Orderby Row comparision failed {}, {}", r1.toJson(), r2.toJson(), e); throw e; } }
Source:
<code>public void testInvalidCursorExceptionOnNotExistentTimeline() throws Exception { <START> final Cursor cursor = new Cursor("1", "C000002012345"); <END> final String eventTypeName = "my_et"; final Timeline firstTimeline = mock(Timeline.class); when(firstTimeline.getOrder()).thenReturn(1); final EventType eventType = mock(EventType.class); when(eventTypeCache.getEventType(eq(eventTypeName))).thenReturn(eventType); when(eventTypeCache.getTimelines(eq(eventTypeName))).thenReturn(Collections.singletonList(firstTimeline)); try { converter.convert(eventTypeName, cursor); Assert.fail("Convert should throw exception on invalid cursor"); } catch (final InvalidCursorException ex) { Assert.assertEquals(CursorError.UNAVAILABLE, ex.getError()); } }</code><technical_language>I thought fancy dashes "C00-0002-012345" :(</technical_language>

Target:
public void testInvalidCursorExceptionOnNotExistentTimeline() throws Exception { final Cursor cursor = new Cursor("1", "001-0002-012345"); final String eventTypeName = "my_et"; final Timeline firstTimeline = mock(Timeline.class); when(firstTimeline.getOrder()).thenReturn(1); final EventType eventType = mock(EventType.class); when(eventTypeCache.getEventType(eq(eventTypeName))).thenReturn(eventType); when(eventTypeCache.getTimelinesOrdered(eq(eventTypeName))) .thenReturn(Collections.singletonList(firstTimeline)); try { converter.convert(eventTypeName, cursor); Assert.fail("Convert should throw exception on invalid cursor"); } catch (final InvalidCursorException ex) { Assert.assertEquals(CursorError.UNAVAILABLE, ex.getError()); } }
Source:
<code>public void newBatchNumberNull() { final CdmaMastSegment mastSegment = new CdmaMastSegment("200/1"); final CdmaBatchDevice cd1 = new CdmaBatchDevice("cd1", this.loopbackAddress); <START> mastSegment.addCdmaBatchDevice(null, cd1); <END> }</code><technical_language>is expected result of this test</technical_language>

Target:
public void newBatchNumberNull() { final CdmaMastSegment mastSegment = new CdmaMastSegment("200/1"); final CdmaBatchDevice cd1 = new CdmaBatchDevice("cd1", this.loopbackAddress); mastSegment.addCdmaBatchDevice(null, cd1); final CdmaBatch cdmaBatch = mastSegment.popCdmaBatch(); assertEquals("Batch should get maximum batch number", CdmaBatch.MAX_BATCH_NUMBER, cdmaBatch.getBatchNumber()); }
Source:
<code>public ISarosView sarosView() throws RemoteException { <START> if (Saros.useHtmlGui() && this.forceUseHtmlGui) { <END> IHTMLBot htmlBot = HTMLBotImpl.getInstance(); EclipseHTMLWorkbenchBot.getInstance().openSarosBrowserView(); htmlBot.view(View.MAIN_VIEW).open(); return SarosHTMLView.getInstance().setBot(htmlBot); } else { SWTWorkbenchBot bot = new SWTWorkbenchBot(); RemoteWorkbenchBot.getInstance().openViewById(VIEW_SAROS_ID); bot.viewByTitle(VIEW_SAROS).show(); return SarosView.getInstance().setView(bot.viewByTitle(VIEW_SAROS)); } }</code><technical_language>confusing a setter method underlying field name. private boolean shouldTestHtmlGui public void runTestsOnHtmlGui()? way: is supposed call forceUseHtmlGui()? If party calls sarosView(), introduce a field a new method instead of simply a boolean parameter for public ISarosView sarosView(boolean testHtmlGui)</technical_language>

Target:
public ISarosView sarosView() throws RemoteException { if (Saros.useHtmlGui() && this.shouldTestHtmlGui) { IHTMLBot htmlBot = HTMLBotImpl.getInstance(); EclipseHTMLWorkbenchBot.getInstance().openSarosBrowserView(); htmlBot.view(View.MAIN_VIEW).open(); return SarosHTMLView.getInstance().setBot(htmlBot); } else { SWTWorkbenchBot bot = new SWTWorkbenchBot(); RemoteWorkbenchBot.getInstance().openViewById(VIEW_SAROS_ID); bot.viewByTitle(VIEW_SAROS).show(); return SarosView.getInstance().setView(bot.viewByTitle(VIEW_SAROS)); } }
Source:
<code><START> public AddXAuthTokenToRequest(@Provider Supplier<Credentials> creds) { <END> this.creds = checkNotNull(creds, "creds"); }</code><technical_language>Remove public modifier</technical_language>

Target:
AddXAuthTokenToRequest(@Provider Supplier<Credentials> creds) { this.creds = creds; }
Source:
<code>private static BlockPos getValidPos(World world, int x, int z, ITree tree){ <START> if(Config.blacklistedTreeDims.contains(world.provider.getDimension())) <END> return null; final BlockPos topPos = world.getHeight(new BlockPos(x, 0, z)); if (topPos.getY() == 0) { return null; } final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(topPos); IBlockState blockState = world.getBlockState(pos); IBlockState downState = world.getBlockState(pos.down()); while (BlockUtil.canReplace(blockState, world, pos)) { pos.move(EnumFacing.DOWN); if (pos.getY() <= 0) { return null; } blockState = world.getBlockState(pos); downState = world.getBlockState(pos.down()); } if(tree instanceof IPlantable && blockState.getBlock().canSustainPlant(blockState, world, pos, EnumFacing.UP, (IPlantable) tree)){ return pos.up(); } return null; }</code><technical_language>Please move this check decorateTrees(World, Random, int, int). sense check time if world is time same</technical_language>

Target:
private static BlockPos getValidPos(World world, int x, int z, ITree tree){ final BlockPos topPos = world.getHeight(new BlockPos(x, 0, z)); if (topPos.getY() == 0) { return null; } final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(topPos); IBlockState blockState = world.getBlockState(pos); IBlockState downState = world.getBlockState(pos.down()); while (BlockUtil.canReplace(blockState, world, pos)) { pos.move(EnumFacing.DOWN); if (pos.getY() <= 0) { return null; } blockState = world.getBlockState(pos); downState = world.getBlockState(pos.down()); } if(tree instanceof IPlantable && blockState.getBlock().canSustainPlant(blockState, world, pos, EnumFacing.UP, (IPlantable) tree)){ return pos.up(); } return null; }
Source:
<code>private Set<String> getSourceIds(QueryRequest query) { Set<String> result; if (query.isEnterprise()) { <START> result = Collections.singleton("enterprise"); <END> } else if (query.getSourceIds() == null || query.getSourceIds().isEmpty()) { result = Collections.singleton(SystemInfo.getSiteName()); } else { result = query.getSourceIds(); } return result; }</code><technical_language>immediately return predicate is valid instead of assignment? if (query.isEnterprise()) return Collections.singleton("enterprise"); if (query.getSourceIds() == null || query.getSourceIds().isEmpty()) { return Collections.singleton(SystemInfo.getSiteName()); return query.getSourceIds();</technical_language>

Target:
private Set<String> getSourceIds(QueryRequest query) { if (query.isEnterprise()) { return Collections.singleton("enterprise"); } if (query.getSourceIds() == null || query.getSourceIds().isEmpty()) { return Collections.singleton(SystemInfo.getSiteName()); } return query.getSourceIds(); }
Source:
<code>public int lookupId(@Nullable String name) { if (name == null) { return 0; } else { IdLookup idLookup = baseSelector.idLookup(); <START> return (idLookup == null ? 0 : idLookup.lookupId(name)) + nullAdjustment; <END> } }</code><technical_language>fail if idLooup = null</technical_language>

Target:
public int lookupId(@Nullable String name) { if (name == null) { return 0; } else { IdLookup idLookup = baseSelector.idLookup(); assert idLookup != null; return idLookup.lookupId(name) + nullAdjustment; } }
Source:
<code>private int getUpdatedCaretPosition(StringBuilder currentCalculatedMessage, int currentCaretPosition, CommitMessageWithCaretPosition messageWithPosition, ICommitMessageProvider2 provider) { int pos = currentCaretPosition; if (currentCaretPosition == CommitMessageWithCaretPosition.NO_POSITION) { String providedMessage = messageWithPosition.getMessage(); if (providedMessage == null || providedMessage.trim().isEmpty()) { return pos; } int providedCaretPosition = messageWithPosition .getDesiredCaretPosition(); if (providedCaretPosition == CommitMessageWithCaretPosition.NO_POSITION) { return pos; } if (providedCaretPosition > providedMessage.length() || providedCaretPosition < 0) { Activator.logWarning( MessageFormat.format( UIText.CommitDialog_CaretPositionOutOfBounds, provider.getClass().getName(), providedCaretPosition), null); return CommitMessageWithCaretPosition.NO_POSITION; } else { pos = currentCalculatedMessage.length(); if (currentCalculatedMessage.length() > 0) { pos += MESSAGE_SEPARATOR.length(); } pos += providedCaretPosition; } } else { <START> Activator <END> .logWarning( MessageFormat.format( UIText.CommitDialog_MultipleCommitMessageProvider2Implementations, provider.getClass().getName()), null); } return pos; }</code><technical_language>formatting of this statement odd</technical_language>

Target:
private int getUpdatedCaretPosition(StringBuilder currentCalculatedMessage, int currentCaretPosition, CommitMessageWithCaretPosition messageWithPosition, ICommitMessageProvider2 provider) { int pos = currentCaretPosition; if (currentCaretPosition == CommitMessageWithCaretPosition.NO_POSITION) { String providedMessage = messageWithPosition.getMessage(); if (providedMessage == null || providedMessage.trim().isEmpty()) { return pos; } int providedCaretPosition = messageWithPosition .getDesiredCaretPosition(); if (providedCaretPosition == CommitMessageWithCaretPosition.NO_POSITION) { return pos; } if (providedCaretPosition > providedMessage.length() || providedCaretPosition < 0) { Activator.logWarning( MessageFormat.format( UIText.CommitDialog_CaretPositionOutOfBounds, provider.getClass().getName(), providedCaretPosition), null); return CommitMessageWithCaretPosition.NO_POSITION; } else { pos = currentCalculatedMessage.length(); if (currentCalculatedMessage.length() > 0) { pos += MESSAGE_SEPARATOR.length(); } pos += providedCaretPosition; } } else { Activator .logWarning( MessageFormat.format( UIText.CommitDialog_IgnoreCaretPosition, provider.getClass().getName()), null); } return pos; }
Source:
<code>public void initialize( SchemaIndexDescriptor descriptor, IndexProgressor progressor, IndexQuery[] query ) { assert query != null && query.length > 0; super.initialize( progressor ); this.query = query; IndexQuery firstPredicate = query[0]; switch ( firstPredicate.type() ) { case exact: seekQuery( descriptor, query ); break; case exists: scanQuery( descriptor ); break; case range: assert query.length == 1; rangeQuery( descriptor, (IndexQuery.RangePredicate) firstPredicate ); break; case stringPrefix: <START> prefixQuery( descriptor, (IndexQuery.StringPrefixPredicate) firstPredicate ); <END> break; case stringSuffix: case stringContains: assert query.length == 1; suffixOrContainsQuery( descriptor, firstPredicate ); break; default: throw new UnsupportedOperationException( "Query not supported: " + Arrays.toString( query ) ); } }</code><technical_language>assert query.length == 1; is missing</technical_language>

Target:
public void initialize( SchemaIndexDescriptor descriptor, IndexProgressor progressor, IndexQuery[] query ) { assert query != null && query.length > 0; super.initialize( progressor ); this.query = query; IndexQuery firstPredicate = query[0]; switch ( firstPredicate.type() ) { case exact: seekQuery( descriptor, query ); break; case exists: scanQuery( descriptor ); break; case range: assert query.length == 1; rangeQuery( descriptor, (IndexQuery.RangePredicate) firstPredicate ); break; case stringPrefix: assert query.length == 1; prefixQuery( descriptor, (IndexQuery.StringPrefixPredicate) firstPredicate ); break; case stringSuffix: case stringContains: assert query.length == 1; suffixOrContainsQuery( descriptor, firstPredicate ); break; default: throw new UnsupportedOperationException( "Query not supported: " + Arrays.toString( query ) ); } }
Source:
<code><START> public static Set<URI> parseAllowedCorsOrigins(String allowedCorsOrigins) throws Exception { <END> String[] stringOrigins = allowedCorsOrigins.split(","); Set<URI> parsedOrigins = new HashSet<>(); for (String origin : stringOrigins) { parsedOrigins.add(new URI(origin)); } return parsedOrigins; }</code><technical_language>Unnecessary wide throws clause</technical_language>

Target:
public static Set<URI> parseAllowedCorsOrigins(String allowedCorsOrigins) throws URISyntaxException { String[] stringOrigins = allowedCorsOrigins.split(","); Set<URI> parsedOrigins = new HashSet<>(); for (String origin : stringOrigins) { parsedOrigins.add(new URI(origin.trim())); } return parsedOrigins; }
Source:
<code><START> public static String countryCodeToEmoji(String countryCode) { <END> int char1 = Character.codePointAt(countryCode, 0) - 0x41 + 0x1F1E6; int char2 = Character.codePointAt(countryCode, 1) - 0x41 + 0x1F1E6; return new String(Character.toChars(char1)) + new String(Character.toChars(char2)); }</code><technical_language>Do some doc this routine? adding al link ok</technical_language>

Target:
public static String countryCodeToEmoji(String countryCode) { if (TextUtils.isEmpty(countryCode) || countryCode.length() != 2) { return ""; } int char1 = Character.codePointAt(countryCode, 0) - 0x41 + 0x1F1E6; int char2 = Character.codePointAt(countryCode, 1) - 0x41 + 0x1F1E6; return new String(Character.toChars(char1)) + new String(Character.toChars(char2)); }
Source:
<code>public void perform(Object... args) { if (args.length == 0) { controller.action(ChooseFile.class, true, this); } else { <START> fileChosen(args[0].toString(), null); <END> } }</code><technical_language>I Result.SUCCESS is more consistent instead of null</technical_language>

Target:
public void perform(Object... args) { if (args.length == 0) { controller.action(ChooseFile.class, true, this); } else { fileChosen(args[0].toString(), Result.SUCCESS); } }
Source:
<code>public EventType findByName(final String name) throws NoSuchEventTypeException { final String sql = "SELECT et_topic, et_event_type_object, et_deleted " + "FROM zn_data.event_type WHERE et_name = ?"; try { final EventType eventType = jdbcTemplate.queryForObject(sql, new Object[]{name}, new EventTypeMapper()); <START> if (eventType.isDeleted()) { <END> throw new NoSuchEventTypeException("EventType \"" + name + "\" does not exist."); } return eventType; } catch (EmptyResultDataAccessException e) { throw new NoSuchEventTypeException("EventType \"" + name + "\" does not exist.", e); } }</code><technical_language>I this done plain query. adding another condition et_deleted = false? return empty set</technical_language>

Target:
public EventType findByName(final String name) throws NoSuchEventTypeException { final String sql = "SELECT et_topic, et_event_type_object, et_archived " + "FROM zn_data.event_type WHERE et_name = ? AND et_archived = FALSE"; try { return jdbcTemplate.queryForObject(sql, new Object[]{name}, new EventTypeMapper()); } catch (EmptyResultDataAccessException e) { throw new NoSuchEventTypeException("EventType \"" + name + "\" does not exist.", e); } }
Source:
<code><START> private static IdentifierTree getIdentifier(ExpressionTree tree) { <END> if (isIdentifier(tree)) { return (IdentifierTree) tree; } return null; }</code><technical_language>this method, subsequently need Symbol identifier, more usefull return Symbol directly. annotate this method @CheckForNull</technical_language>

Target:
private static Symbol getIdentifier(ExpressionTree tree) { if (tree.is(Kind.IDENTIFIER)) { return ((IdentifierTree) tree).symbol(); } return null; }
Source:
<code>private View getSectionDividerView(View convertView, ViewGroup parent) { Activity context = activity.get(); if(context == null) { return null; } LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (UserPreferences.getFeedFilter() != UserPreferences.FEED_FILTER_NONE) { convertView = inflater.inflate(R.layout.nav_section_filter_divider, parent, false); convertView.setEnabled(true); convertView.setOnClickListener((l) -> FeedFilterDialog.showDialog(context)); } else { convertView = inflater.inflate(R.layout.nav_section_item, parent, false); convertView.setEnabled(false); <START> convertView.setOnClickListener(null); <END> } return convertView; }</code><technical_language>please move click handling NavDrawerFragment.onItemClick? other items of sidebar handled in file. a good practice displaying (adapter) behavior (click listener) separated. I admit this is case in code base in this case, pretty easy do</technical_language>

Target:
private View getSectionDividerView(View convertView, ViewGroup parent) { Activity context = activity.get(); if(context == null) { return null; } LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.nav_section_item, parent, false); TextView feedsFilteredMsg = convertView.findViewById(R.id.nav_feeds_filtered_message); if (UserPreferences.getFeedFilter() != UserPreferences.FEED_FILTER_NONE && showSubscriptionList) { convertView.setEnabled(true); feedsFilteredMsg.setText("{md-info-outline} " + context.getString(R.string.subscriptions_are_filtered)); Iconify.addIcons(feedsFilteredMsg); feedsFilteredMsg.setVisibility(View.VISIBLE); } else { convertView.setEnabled(false); feedsFilteredMsg.setVisibility(View.GONE); } return convertView; }
Source:
<code>protected void render0(FunctionRenderContext context) { context.addArgument(0); <START> context.addChunk("::json"); <END> context.addChunk("#>>'{"); addUnquotedArgument(context, 1); for (int i = 2; i < context.getArgumentsSize(); i++) { context.addChunk(","); addUnquotedArgument(context, i); } context.addChunk("}'"); }</code><technical_language>cast(... json) syntax instead avoid issues subqueries happen in older hibernate versions</technical_language>

Target:
protected void render0(FunctionRenderContext context) { context.addChunk("cast("); context.addArgument(0); context.addChunk(" as json)"); context.addChunk("#>>'{"); addUnquotedArgument(context, 1); for (int i = 2; i < context.getArgumentsSize(); i++) { context.addChunk(","); addUnquotedArgument(context, i); } context.addChunk("}'"); }
Source:
<code>public JSONObject changeLibraryIdBarcode(HttpSession session, JSONObject json) { Long libraryId = json.getLong("libraryId"); String idBarcode = json.getString("identificationBarcode"); try { User user = securityManager.getUserByLoginName(SecurityContextHolder.getContext().getAuthentication().getName()); if (!isStringEmptyOrNull(idBarcode)) { <START> Collection<Boxable> previouslyBarcodedItems = requestManager.getBoxablesFromBarcodeList(Arrays.asList(new String[] { idBarcode })); <END> if (!previouslyBarcodedItems.isEmpty()) { Boxable previouslyBarcodedItem = previouslyBarcodedItems.iterator().next(); String error = String.format( "Could not change library identification barcode to '%s'. This barcode is already in use by an item with the name '%s' and the alias '%s'.", idBarcode, previouslyBarcodedItem.getName(), previouslyBarcodedItem.getAlias()); log.debug(error); return JSONUtils.SimpleJSONError(error); } Library library = requestManager.getLibraryById(libraryId); library.setIdentificationBarcode(idBarcode); library.setLastModifier(user); requestManager.saveLibrary(library); } else { return JSONUtils.SimpleJSONError("New identification barcode not recognized"); } } catch (IOException e) { log.debug("Could not change Library identificationBarcode: " + e.getMessage()); return JSONUtils.SimpleJSONError(e.getMessage()); } return JSONUtils.SimpleJSONResponse("New identification barcode successfully assigned."); }</code><technical_language>Arrays.asList is variadic, write this Arrays.asList(idBarcode)</technical_language>

Target:
public JSONObject changeLibraryIdBarcode(HttpSession session, JSONObject json) { Long libraryId = json.getLong("libraryId"); String idBarcode = json.getString("identificationBarcode"); try { User user = securityManager.getUserByLoginName(SecurityContextHolder.getContext().getAuthentication().getName()); if (!isStringEmptyOrNull(idBarcode)) { List<Boxable> previouslyBarcodedItems = new ArrayList<Boxable>(requestManager.getBoxablesFromBarcodeList(Arrays.asList(idBarcode))); if (!previouslyBarcodedItems.isEmpty() && !(previouslyBarcodedItems.size() == 1 && previouslyBarcodedItems.get(0).getId() == libraryId)) { Boxable previouslyBarcodedItem = previouslyBarcodedItems.get(0); String error = String.format( "Could not change library identification barcode to '%s'. This barcode is already in use by an item with the name '%s' and the alias '%s'.", idBarcode, previouslyBarcodedItem.getName(), previouslyBarcodedItem.getAlias()); log.debug(error); return JSONUtils.SimpleJSONError(error); } Library library = requestManager.getLibraryById(libraryId); library.setIdentificationBarcode(idBarcode); library.setLastModifier(user); requestManager.saveLibrary(library); } else { return JSONUtils.SimpleJSONError("New identification barcode not recognized"); } } catch (IOException e) { log.debug("Could not change Library identificationBarcode: " + e.getMessage()); return JSONUtils.SimpleJSONError(e.getMessage()); } return JSONUtils.SimpleJSONResponse("New identification barcode successfully assigned."); }
Source:
<code>public static String format(Date date, boolean init) { SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.'000Z'"); <START> if (!init) <END> sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.'999Z'"); sdf.setTimeZone(TimeZone.getTimeZone("ZULU")); String ret = sdf.format(date); return ret; }</code><technical_language>If add a line break here, curly brackets well. else is error-prone</technical_language>

Target:
public static String format(Date date, boolean init) { SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.'000Z'"); if (!init) { sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.'999Z'"); } sdf.setTimeZone(TimeZone.getTimeZone("ZULU")); String ret = sdf.format(date); return ret; }
Source:
<code>public V get(Object key) { assertKeyNotNull(key); <START> checkCanRun(cache, componentRegistry); <END> InternalCacheEntry<K, V> ice = getDataContainer().get(key); if (ice != null) { return ice.getValue(); } return null; }</code><technical_language>componentRegistry removed (cache.getName())</technical_language>

Target:
public V get(Object key) { assertKeyNotNull(key); checkCanRun(cache, cache.getName()); InternalCacheEntry<K, V> ice = getDataContainer().get(key); if (ice != null) { return ice.getValue(); } return null; }
Source:
<code><START> public String getLineContent(Repository repository, int lineNumber) <END> throws IOException { Line line = getLine(lineNumber); if (line == null) return null; ObjectLoader loader = repository.open(blob, Constants.OBJ_BLOB); byte[] contents; if (loader.isLarge()) contents = IO.readWholeStream(loader.openStream(), (int) loader.getSize()).array(); else contents = loader.getCachedBytes(); return new RawText(contents).getString(lineNumber); }</code><technical_language>able a non-default encoding here</technical_language>

Target:
public String getLineContent(Repository repository, int lineNumber) throws IOException { return getLineContent(repository, lineNumber, Constants.CHARSET); }
Source:
<code>private static Map<String, String> buildParamsMap(String params) { if (params.startsWith("/")) { params = params.substring(1); } String[] pathParts = params.split("/"); Map<String, String> pathMap = new HashMap<String, String>(); for (int i=0; i < pathParts.length/2; i++) { String key = pathParts[2*i].toLowerCase(); String value = pathParts[2*i+1]; <START> if (!value.toLowerCase().equals("null")) { <END> pathMap.put(key, value); } } return pathMap; }</code><technical_language>if(!UtilMethods.isSet(value))</technical_language>

Target:
private static Map<String, String> buildParamsMap(String params) { if (params.startsWith("/")) { params = params.substring(1); } String[] pathParts = params.split("/"); Map<String, String> pathMap = new HashMap<String, String>(); for (int i=0; i < pathParts.length/2; i++) { String key = pathParts[2*i].toLowerCase(); String value = pathParts[2*i+1]; if (UtilMethods.isSet(value)) { pathMap.put(key, value); } } return pathMap; }
Source:
<code>public static void exit() { <START> SaveGameWriter.saveGame("firstActualGame.json"); <END> stage.close(); }</code><technical_language>This Writer save game "exit" button is pressed in main menu. red X of window is pressed, happens. <logic,review</technical_language>

Target:
public static void exit() { createSaveDirectory(); SaveGameWriter.saveGame("sav/save.json"); stage.close(); }
Source:
<code>public <T> Serializer<T> createKeySerializer(Class<T> clazz, ClassLoader classLoader, ServiceConfiguration<?>... configs) throws UnsupportedTypeException { <START> Serializer<T> serializer = (Serializer<T>) getUserProvidedSerializer(find(DefaultSerializerConfiguration.Type.KEY, configs)); <END> if (serializer == null) { DefaultSerializerConfiguration<T> conf = find(DefaultSerializerConfiguration.Type.KEY, configs); serializer = createSerializer(clazz, classLoader, conf, configs); instantiated.add(serializer); } updateProvidedInstanceCounts(serializer); return serializer; }</code><technical_language>Replacing this line with: java DefaultSerializerConfiguration<T> configuration = find(DefaultSerializerConfiguration.Type.KEY, configs); Serializer<T> serializer = getUserProvidedSerializer(configuration); resolve unchecked casts warning. applies createValueSerializer</technical_language>

Target:
public <T> Serializer<T> createKeySerializer(Class<T> clazz, ClassLoader classLoader, ServiceConfiguration<?>... configs) throws UnsupportedTypeException { DefaultSerializerConfiguration<T> configuration = find(DefaultSerializerConfiguration.Type.KEY, configs); Serializer<T> serializer = getUserProvidedSerializer(configuration); if (serializer == null) { serializer = createSerializer(clazz, classLoader, configuration, configs); instantiated.add(serializer); } updateProvidedInstanceCounts(serializer); return serializer; }
Source:
<code>public void category_001_openNavigate() { init(); category.toggle(); <START> category.openLink(0); <END> }</code><technical_language>rename openCategoryPage()</technical_language>

Target:
public void category_001_openNavigate() { init(); category.toggle(); category.openCategoryPage(0); }
Source:
<code>public ScriptEventsIterator getEventIterator(@Nullable ITmfTrace trace) { if (trace == null) { throw new NullPointerException("Trace should not be null"); } ScriptEventRequest scriptEventRequest = new ScriptEventRequest(); trace.sendRequest(scriptEventRequest); <START> getScriptEngine().addExecutionListener(new IExecutionListener() { <END> @Override public void notify(@Nullable IScriptEngine engine, @Nullable Script script, int status) { if (status == SCRIPT_END) { scriptEventRequest.done(); } } }); return scriptEventRequest.getEventIterator(); }</code><technical_language>This module, in unit tests for instance run script environment, I guess script engine null? But, TIL Nice approach! I asked EASE ml, Christian is helpful ;-)</technical_language>

Target:
public ScriptEventsIterator getEventIterator(@Nullable ITmfTrace trace) { if (trace == null) { throw new NullPointerException("Trace should not be null"); } ScriptEventRequest scriptEventRequest = new ScriptEventRequest(); trace.sendRequest(scriptEventRequest); setupEventIteratorExecutionListener(scriptEventRequest); return scriptEventRequest.getEventIterator(); }
Source:
<code>private void changeRegion(RateControlRegion region, long nowMs) { if (rateControlRegion == region) { return; } rateControlRegion = region; if (logger.isTraceEnabled()) { logger.trace(Logger.Category.BWE, diagnosticContext .makeTimeSeriesPoint("aimd_region", nowMs) .addKey("aimd", hashCode()) <START> .addField("value", region).toString()); <END> } }</code><technical_language>is toString needed? needed, passing extra argument</technical_language>

Target:
private void changeRegion(RateControlRegion region, long nowMs) { if (rateControlRegion == region) { return; } rateControlRegion = region; if (logger.isTraceEnabled()) { logger.trace(Logger.Category.BWE, diagnosticContext .makeTimeSeriesPoint("aimd_region", nowMs) .addKey("aimd", hashCode()) .addField("value", region)); } }
Source:
<code>public List<String> listAndVerifyDetectors(String host, InetSocketAddress sshAddr) throws Exception { try (final SshClient sshClient = new SshClient(sshAddr, "admin", "admin")) { PrintStream pipe = sshClient.openShell(); pipe.println("provision:list-detectors"); pipe.println("logout"); await().atMost(1, MINUTES).until(sshClient.isShellClosedCallable()); String shellOutput = sshClient.getStdout(); shellOutput = StringUtils.substringAfter(shellOutput, "provision:list-detectors"); LOG.info("Detectors output: {}", shellOutput); Map<String, String> detectorMap = new HashMap<String, String>(); for (String detector : shellOutput.split("\\r?\\n")) { if (StringUtils.isNotBlank(detector)) { String detectorSet[] = detector.split(":"); if (detectorSet.length >= 2) { detectorMap.put(detectorSet[0], detectorSet[1]); } } } LOG.info("Found detectors: {}", detectorMap); return expectedDetectors.keySet().stream().filter(e -> { <START> return detectorMap.keySet().stream().noneMatch(s -> s.contains(e)); <END> }).collect(Collectors.toList()); } }</code><technical_language>contains reliable since: "HTTPS".contains("HTTP") == true guessing extra white-space in output</technical_language>

Target:
public List<String> listAndVerifyDetectors(String host, InetSocketAddress sshAddr) throws Exception { List<String> unmatchedDetectors = new ArrayList<>(); try (final SshClient sshClient = new SshClient(sshAddr, "admin", "admin")) { PrintStream pipe = sshClient.openShell(); pipe.println("provision:list-detectors"); pipe.println("logout"); await().atMost(1, MINUTES).until(sshClient.isShellClosedCallable()); String shellOutput = CommandTestUtils.stripAnsiCodes(sshClient.getStdout()); shellOutput = StringUtils.substringAfter(shellOutput, "provision:list-detectors"); LOG.info("Detectors output: {}", shellOutput); Map<String, String> detectorMap = new HashMap<String, String>(); for (String detector : shellOutput.split("\\r?\\n")) { if (StringUtils.isNotBlank(detector)) { String detectorSet[] = detector.split(":"); if (detectorSet.length >= 2) { detectorMap.put(detectorSet[0], detectorSet[1]); } } } LOG.info("Found detectors: {}", detectorMap); for (String detectorName : expectedDetectors.keySet()) { if (!detectorMap.containsKey(detectorName)) { unmatchedDetectors.add(detectorName); } } } return unmatchedDetectors; }
Source:
<code>public ClientDriverRequest(HttpServletRequest request) { this.path = request.getPathInfo(); this.method = Enum.valueOf(Method.class, request.getMethod()); this.params = HashMultimap.create(); <START> String queryString = request.getQueryString(); <END> if (StringUtils.isNotEmpty(StringUtils.trimToEmpty(queryString))) { String[] splitQueryString = queryString.split("&"); for (int i = 0; i < splitQueryString.length; i++) { String[] queryPair = splitQueryString[i].split("="); this.params.put(queryPair[0], queryPair[1]); } } headers = new HashMap<String, Object>(); Enumeration<String> headerNames = request.getHeaderNames(); if (headerNames != null) { while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); headers.put(headerName, request.getHeader(headerName)); } } try { this.bodyContent = IOUtils.toString(request.getReader()); } catch (IOException e) { throw new RuntimeException("Failed to read body of request", e); } this.bodyContentType = request.getContentType(); }</code><technical_language>Previously used: java Map<String, String[]> actualParams = actualRequest.getParameterMap(); String[] actualParamValues = actualParams.get(expectedKey); // ... splitting string</technical_language>

Target:
public ClientDriverRequest(HttpServletRequest request) { this.path = request.getPathInfo(); this.method = Enum.valueOf(Method.class, request.getMethod()); this.params = HashMultimap.create(); Map<String, String[]> parameterMap = request.getParameterMap(); for (Entry<String, String[]> paramEntry : parameterMap.entrySet()) { String[] values = paramEntry.getValue(); for (String value : values) { this.params.put(paramEntry.getKey(), value); } } headers = new HashMap<String, Object>(); Enumeration<String> headerNames = request.getHeaderNames(); if (headerNames != null) { while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); headers.put(headerName, request.getHeader(headerName)); } } try { this.bodyContent = IOUtils.toString(request.getReader()); } catch (IOException e) { throw new RuntimeException("Failed to read body of request", e); } this.bodyContentType = request.getContentType(); }
Source:
<code>void setPictureSize(Size size) { if (size == null) { if (mAspectRatio == null) { return; } SortedSet<Size> sizes = mPictureSizes.sizes(mAspectRatio); if(sizes != null && !sizes.isEmpty()) { mPictureSize = sizes.last(); } } else { mPictureSize = size; } if (mCameraParameters != null && mCamera != null) { mCameraParameters.setPictureSize(mPictureSize.getWidth(), mPictureSize.getHeight()); try{ mCamera.setParameters(mCameraParameters); } catch(RuntimeException e ) { <START> Log.e("Camera1", "setParameters failed", e); <END> } } }</code><technical_language>tag for this log Log.e("RNCamera")</technical_language>

Target:
void setPictureSize(Size size) { if (size == null) { if (mAspectRatio == null) { return; } SortedSet<Size> sizes = mPictureSizes.sizes(mAspectRatio); if(sizes != null && !sizes.isEmpty()) { mPictureSize = sizes.last(); } } else { mPictureSize = size; } if (mCameraParameters != null && mCamera != null) { mCameraParameters.setPictureSize(mPictureSize.getWidth(), mPictureSize.getHeight()); try{ mCamera.setParameters(mCameraParameters); } catch(RuntimeException e ) { Log.e("CAMERA_1::", "setParameters failed", e); } } }
Source:
<code>protected String cleanStringValue( Class<? extends PersistableBusinessObject> businessObjectClass, String propertyName, String propertyValue) { <START> String cleanedValue = StringUtils.defaultIfBlank(propertyValue, null); <END> Integer maxLength = dataDictionaryService.getAttributeMaxLength(businessObjectClass, propertyName); if (maxLength != null && maxLength > 0 && StringUtils.length(cleanedValue) > maxLength) { LOG.info("cleanStringValue, Truncating value for business object " + businessObjectClass.getName() + " and property " + propertyName); cleanedValue = StringUtils.left(cleanedValue, maxLength); } return cleanedValue; }</code><technical_language>Do want do a trim String this point eliminate leading trailing spaces</technical_language>

Target:
protected String cleanStringValue( Class<? extends PersistableBusinessObject> businessObjectClass, String propertyName, String propertyValue) { String cleanedValue = StringUtils.defaultIfBlank(propertyValue, null); if (ObjectUtils.isNotNull(cleanedValue)) { cleanedValue = cleanedValue.trim(); } Integer maxLength = dataDictionaryService.getAttributeMaxLength(businessObjectClass, propertyName); if (maxLength != null && maxLength > 0 && StringUtils.length(cleanedValue) > maxLength) { LOG.info("cleanStringValue, Truncating value for business object " + businessObjectClass.getName() + " and property " + propertyName); cleanedValue = StringUtils.left(cleanedValue, maxLength); } return cleanedValue; }
Source:
<code>public void setUpExecutor() throws Exception { sqlExecutor = SQLExecutor.builder(clusterService) .addTable("CREATE TABLE t (" + " id int," + " qty int," + " sentinel boolean CONSTRAINT sentinel CHECK(sentinel)," + " CONSTRAINT id_is_even CHECK(id % 2 = 0))") .build(); docTableInfo = sqlExecutor.resolveTableInfo("t"); <START> txnCtx = CoordinatorTxnCtx.systemTransactionContext(); <END> checkConstraints = new CheckConstraints( txnCtx, new InputFactory(sqlExecutor.functions()), FromSourceRefResolver.WITHOUT_PARTITIONED_BY_REFS, docTableInfo); }</code><technical_language>sqlExecutor, docTableInfo tnxCtx a local variables</technical_language>

Target:
public void setUpExecutor() throws Exception { SQLExecutor sqlExecutor = SQLExecutor.builder(clusterService) .addTable("CREATE TABLE t (" + " id int," + " qty int," + " sentinel boolean CONSTRAINT sentinel CHECK(sentinel)," + " CONSTRAINT id_is_even CHECK(id % 2 = 0))") .build(); DocTableInfo docTableInfo = sqlExecutor.resolveTableInfo("t"); TransactionContext txnCtx = CoordinatorTxnCtx.systemTransactionContext(); checkConstraints = new CheckConstraints( txnCtx, new InputFactory(sqlExecutor.functions()), FromSourceRefResolver.WITHOUT_PARTITIONED_BY_REFS, docTableInfo); }
Source:
<code>public void mousePressed(MouseEvent e) { <START> if (e.isPopupTrigger()) <END> doPop(e); }</code><technical_language>Please add for if blocks statement</technical_language>

Target:
public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { doPop(e); } }
Source:
<code>public String generatePageActionLogMessage(String url, Map<String, String[]> params, UserType currUser, AccountAttributes userAccount, StudentAttributes unregisteredStudent, String logMessage) { <START> Builder builder = generateBasicActivityLogEntry(url, params, currUser); <END> boolean isUnregisteredStudent = unregisteredStudent != null; boolean isAccountWithGoogleId = userAccount != null && userAccount.googleId != null; if (isUnregisteredStudent) { updateInfoForUnregisteredStudent(builder, unregisteredStudent); } else if (isAccountWithGoogleId) { updateInfoForNormalUser(builder, currUser, userAccount); } builder.withLogMessage(logMessage); return builder.build().generateLogMessage(); }</code><technical_language>builder a class variable for generator class</technical_language>

Target:
public String generatePageActionLogMessage(String url, Map<String, String[]> params, UserType currUser, AccountAttributes userAccount, StudentAttributes unregisteredStudent, String logMessage) { Builder builder = generateBasicLogEntryBuilder(url, params, currUser); boolean isUnregisteredStudent = unregisteredStudent != null; boolean isAccountWithGoogleId = userAccount != null && userAccount.googleId != null; if (isUnregisteredStudent) { updateInfoForUnregisteredStudent(builder, unregisteredStudent); } else if (isAccountWithGoogleId) { updateInfoForNormalUser(builder, currUser, userAccount); } builder.withLogMessage(logMessage); return builder.build().generateLogMessage(); }
Source:
<code>boolean connect() throws IOException { if (isConnected) { return true; } try { socket = new Socket(inetAddress, port); if (socket.isConnected()) { isConnected = true; return true; } } catch (Exception e) { <START> logger.error("Bind Exception Already Connected ", e); <END> } return false; }</code><technical_language>Catch specific exception(s) log consistently are. Also, is, this method throw IOException</technical_language>

Target:
boolean connect() throws IOException { if (isConnected) { return true; } socket = new Socket(inetAddress, port); if (socket.isConnected()) { isConnected = true; return true; } return false; }
Source:
<code>@Test public void testWriter() { String s = Frameworks.withPlanner((cluster, relOptSchema, rootSchema) -> { rootSchema.add("hr", new ReflectiveSchema(new JdbcTest.HrSchema())); LogicalTableScan scan = LogicalTableScan.create(cluster, relOptSchema.getTableForMember( <START> asList("hr", "emps")), <END> ImmutableList.of()); final RexBuilder rexBuilder = cluster.getRexBuilder(); LogicalFilter filter = LogicalFilter.create(scan, rexBuilder.makeCall( SqlStdOperatorTable.EQUALS, rexBuilder.makeFieldAccess( rexBuilder.makeRangeReference(scan), "deptno", true), rexBuilder.makeExactLiteral(BigDecimal.TEN))); final RelJsonWriter writer = new RelJsonWriter(); final RelDataType bigIntType = cluster.getTypeFactory().createSqlType(SqlTypeName.BIGINT); LogicalAggregate aggregate = LogicalAggregate.create(filter, ImmutableList.of(), ImmutableBitSet.of(0), null, ImmutableList.of( AggregateCall.create(SqlStdOperatorTable.COUNT, true, false, false, ImmutableList.of(1), -1, RelCollations.EMPTY, bigIntType, "c"), AggregateCall.create(SqlStdOperatorTable.COUNT, false, false, false, ImmutableList.of(), -1, RelCollations.EMPTY, bigIntType, "d"))); aggregate.explain(writer); return writer.asString(); }); assertThat(s, is(XX)); }</code><technical_language>changes needed</technical_language>

Target:
@Test public void testWriter() { String s = Frameworks.withPlanner((cluster, relOptSchema, rootSchema) -> { rootSchema.add("hr", new ReflectiveSchema(new JdbcTest.HrSchema())); LogicalTableScan scan = LogicalTableScan.create(cluster, relOptSchema.getTableForMember( Arrays.asList("hr", "emps")), ImmutableList.of()); final RexBuilder rexBuilder = cluster.getRexBuilder(); LogicalFilter filter = LogicalFilter.create(scan, rexBuilder.makeCall( SqlStdOperatorTable.EQUALS, rexBuilder.makeFieldAccess( rexBuilder.makeRangeReference(scan), "deptno", true), rexBuilder.makeExactLiteral(BigDecimal.TEN))); final RelJsonWriter writer = new RelJsonWriter(); final RelDataType bigIntType = cluster.getTypeFactory().createSqlType(SqlTypeName.BIGINT); LogicalAggregate aggregate = LogicalAggregate.create(filter, ImmutableList.of(), ImmutableBitSet.of(0), null, ImmutableList.of( AggregateCall.create(SqlStdOperatorTable.COUNT, true, false, false, ImmutableList.of(1), -1, RelCollations.EMPTY, bigIntType, "c"), AggregateCall.create(SqlStdOperatorTable.COUNT, false, false, false, ImmutableList.of(), -1, RelCollations.EMPTY, bigIntType, "d"))); aggregate.explain(writer); return writer.asString(); }); assertThat(s, is(XX)); }
Source:
<code>public static void input( <START> @AggregationState DigestAndPercentileState state, <END> @SqlType(StandardTypes.BIGINT) long value, @SqlType(StandardTypes.DOUBLE) double percentile) { initializeDigest(state); QuantileDigest digest = state.getDigest(); state.addMemoryUsage(-digest.estimatedInMemorySizeInBytes()); digest.add(value); state.addMemoryUsage(digest.estimatedInMemorySizeInBytes()); state.setPercentile(percentile); }</code><technical_language>input functions call weightedInput a weight of 1.0? in QuantileDigest add a weight is add a weight of 1. a lot of duplicated code removed</technical_language>

Target:
public static void input( @AggregationState DigestAndPercentileState state, @SqlType(StandardTypes.BIGINT) long value, @SqlType(StandardTypes.DOUBLE) double percentile) { addInput(state, value, DEFAULT_WEIGHT, percentile, DEFAULT_ACCURACY); }
Source:
<code>private MessageDigest initCopyPack(PackOutputStream out, boolean validate, DfsReader ctx) throws IOException { if (length == -1) ctx.pin(this, 0); if (!validate) { ctx.unpin(); <START> return null; <END> } int hdrlen = 12; byte[] buf = out.getCopyBuffer(); int n = ctx.copy(this, 0, buf, 0, hdrlen); ctx.unpin(); if (n != hdrlen) { setInvalid(); throw new IOException(MessageFormat.format( JGitText.get().packfileIsTruncated, getPackName())); } MessageDigest md = Constants.newMessageDigest(); md.update(buf, 0, hdrlen); return md; }</code><technical_language>is confusing header is copied buffer validation is disabled. I understand needing create MessageDigest, is OK copy header? If header get copied, a name for this method processHeader()</technical_language>

Target:
private MessageDigest initCopyPack(PackOutputStream out, boolean validate, DfsReader ctx) throws IOException { if (length == -1) ctx.pin(this, 0); if (!validate) { ctx.unpin(); return null; } int hdrlen = 12; byte[] buf = out.getCopyBuffer(); int n = ctx.copy(this, 0, buf, 0, hdrlen); ctx.unpin(); if (n != hdrlen) throw packfileIsTruncated(); MessageDigest md = Constants.newMessageDigest(); md.update(buf, 0, hdrlen); return md; }
Source:
<code>public boolean valueContains(String value) { if (this.getType().equals(String.class.getName()) || this.getType().equals("java.lang.LargeString")) { return value == null ? this.getValue() == null : value.equals(this.getValue()); <START> } else if (this.getType().equals(ArrayList.class.getName()) || this.getType().equals("java.util.LargeArrayList")) { <END> return this.getValue() == null ? value == null : ((ArrayList<String>) this.getValue()).contains(value); } else if (this.getType().equals(LinkedHashMap.class.getName())) { return this.getValue() == null ? value == null : (((LinkedHashMap<String, String>) this.getValue()).containsKey(value) || ((LinkedHashMap<String, String>) this.getValue()).containsValue(value)); } else return false; }</code><technical_language>Strings (LargeString LargeArray) in constant somewhere</technical_language>

Target:
public boolean valueContains(String value) { if (this.getType().equals(String.class.getName()) || this.getType().equals(BeansUtils.largeStringClassName)) { return value == null ? this.getValue() == null : value.equals(this.getValue()); } else if (this.getType().equals(ArrayList.class.getName()) || this.getType().equals(BeansUtils.largeArrayListClassName)) { return this.getValue() == null ? value == null : ((ArrayList<String>) this.getValue()).contains(value); } else if (this.getType().equals(LinkedHashMap.class.getName())) { return this.getValue() == null ? value == null : (((LinkedHashMap<String, String>) this.getValue()).containsKey(value) || ((LinkedHashMap<String, String>) this.getValue()).containsValue(value)); } else return false; }