auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Object getElementToHighlightAtPosition(Window element, int x, int y, Rect bounds) { <START> final Descriptor.Host host = getHost(); <END> if (host instanceof AndroidDescriptorHost) { final View view = element.peekDecorView(); final HighlightableDescriptor descriptor = ((AndroidDescriptorHost) host).getHighlightableDescriptor(view); return descriptor == null ? null : descriptor.getElementToHighlightAtPosition(view, x, y, bounds); } return null; }</code><technical_language>this pattern this diff. Consider a slightly simplified pattern lets 1 consolidated return statement: @Nullable @Override public Object getElementToHighlightAtPosition(Window element, int x, int y, Rect bounds) { final Descriptor.Host host = getHost(); HighlightableDescriptor descriptor = null; if (host instanceof AndroidDescriptorHost) { final View view = element.peekDecorView(); descriptor = ((AndroidDescriptorHost) host).getHighlightableDescriptor(view); } return descriptor == null ? null : descriptor.getElementToHighlightAtPosition(view, x, y, bounds); } This breaks algorithm orthogonal pieces: 1) do find HighlightableDescriptor, 2) do do</technical_language>

Target:
public Object getElementToHighlightAtPosition(Window element, int x, int y, Rect bounds) { final Descriptor.Host host = getHost(); View view = null; HighlightableDescriptor descriptor = null; if (host instanceof AndroidDescriptorHost) { view = element.peekDecorView(); descriptor = ((AndroidDescriptorHost) host).getHighlightableDescriptor(view); } return descriptor == null ? null : descriptor.getElementToHighlightAtPosition(view, x, y, bounds); }
Source:
<code>public TkText(final byte[] body) { super( new Take() { @Override @SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes") public Response act(final Request req) { try { new RqPrint(req).printBody(); } catch (final IOException exc) { <START> throw new RuntimeException(exc); <END> } return new RsText(body); } } ); }</code><technical_language>@exper0 above, IllegalStateException remove suppress</technical_language>

Target:
public TkText(final byte[] body) { super( new Take() { @Override public Response act(final Request req) { try { new RqPrint(req).printBody(); } catch (final IOException exc) { throw new IllegalStateException(exc); } return new RsText(body); } } ); }
Source:
<code><START> private List<String> extractSinkIdentifierNames(List<ModifyOperation> operations) { <END> List<ObjectIdentifier> identifiers = new ArrayList<>(operations.size()); Map<String, List<String>> tableName2DatabaseNames = new HashMap<>(); for (ModifyOperation operation : operations) { if (operation instanceof CatalogSinkModifyOperation) { ObjectIdentifier identifier = ((CatalogSinkModifyOperation) operation).getTableIdentifier(); identifiers.add(identifier); String tableName = identifier.getObjectName(); if (!tableName2DatabaseNames.containsKey(tableName)) { tableName2DatabaseNames.put(tableName, new ArrayList<>()); } tableName2DatabaseNames.get(tableName).add(identifier.getDatabaseName()); } else { throw new UnsupportedOperationException("Unsupported operation: " + operation); } } List<String> tableNames = new ArrayList<>(identifiers.size()); for (ObjectIdentifier i : identifiers) { List<String> databaseNames = tableName2DatabaseNames.get(i.getObjectName()); if (databaseNames.size() == 1) { tableNames.add(i.getObjectName()); } else if (databaseNames.size() == new HashSet<>(databaseNames).size()) { tableNames.add(String.join(".", i.getDatabaseName(), i.getObjectName())); } else { tableNames.add(String.join(".", i.getCatalogName(), i.getDatabaseName(),i.getObjectName())); } } return tableNames; }</code><technical_language>I prefer simple for now, full identify is enough</technical_language>

Target:
private List<String> extractSinkIdentifierNames(List<ModifyOperation> operations) { List<String> tableNames = new ArrayList<>(operations.size()); for (ModifyOperation operation : operations) { if (operation instanceof CatalogSinkModifyOperation) { ObjectIdentifier identifier = ((CatalogSinkModifyOperation) operation).getTableIdentifier(); tableNames.add(identifier.asSummaryString()); } else { throw new UnsupportedOperationException("Unsupported operation: " + operation); } } return tableNames; }
Source:
<code>public String getIdValue(Object object, int index) { switch ((StyleType) object) { case GENERIC: <START> return "Generic"; <END> case LINE: return "Line"; case POINT: return "Point"; case POLYGON: return "Polygon"; case RASTER: return "Raster"; default: return ""; } }</code><technical_language>Consider moving Enum, a bit confused this - is "id" for wicket communication - is human readable (in case translatable)</technical_language>

Target:
public String getIdValue(Object object, int index) { return object.toString(); }
Source:
<code>public void testMemoryNodeCanBeCreatedWithMemoryNodeReferenceAsType() { MemoryNode mets = new MemoryNode(Mets.METS); assertThat(mets.getType(), is(equalTo(Mets.METS.getIdentifier()))); <START> } <END></code><technical_language>testing here</technical_language>

Target:
public void testMemoryNodeCanBeCreatedWithMemoryNodeReferenceAsType() { MemoryNode mets = new MemoryNode(METS_METS); assertThat(mets.getType(), is(equalTo(METS_METS.getIdentifier()))); }
Source:
<code><START> public void updateZoomedEvent(ITimeEvent event) { <END> int index = Collections.binarySearch(fZoomedEventList, event, (e1, e2) -> Long.compare(e1.getTime(), e2.getTime())); if (index >= 0) { ITimeEvent current = fZoomedEventList.get(index); if (!(current instanceof NullTimeEvent)) { Activator.getDefault().logWarning("The time event should be an instance of NullTimeEvent"); return; } if (current.getTime() == event.getTime()) { fZoomedEventList.set(index++, event); } else if (current.getTime() < event.getTime()) { fZoomedEventList.set(index++, new NullTimeEvent(this, current.getTime(), event.getTime() - current.getTime())); fZoomedEventList.add(index++, event); } long eventEndTime = (event.getTime() + event.getDuration()); long currentEndTime = (current.getTime() + current.getDuration()); if (eventEndTime < currentEndTime) { fZoomedEventList.add(index, new NullTimeEvent(this, eventEndTime + 1, currentEndTime - eventEndTime)); } } else { index = -index + 1; if (index < fZoomedEventList.size()) { fZoomedEventList.add(index, event); } else { fZoomedEventList.add(event); } } updateEntryBounds(event); }</code><technical_language>trace</technical_language>

Target:
public void updateZoomedEvent(ITimeEvent event) { try (TraceCompassLogUtils.ScopeLog poc = new TraceCompassLogUtils.ScopeLog(LOGGER, Level.INFO, "UpdateZoomedEvent")) { int index = Collections.binarySearch(fZoomedEventList, event, (e1, e2) -> Long.compare(e1.getTime(), e2.getTime())); if (index >= 0) { ITimeEvent current = fZoomedEventList.get(index); if (!(current instanceof NullTimeEvent)) { return; } if (current.getTime() == event.getTime()) { fZoomedEventList.set(index++, event); } else if (current.getTime() < event.getTime()) { fZoomedEventList.set(index++, new NullTimeEvent(this, current.getTime(), event.getTime() - current.getTime())); fZoomedEventList.add(index++, event); } long eventEndTime = (event.getTime() + event.getDuration()); long currentEndTime = (current.getTime() + current.getDuration()); if (eventEndTime < currentEndTime) { fZoomedEventList.add(index, new NullTimeEvent(this, eventEndTime + 1, currentEndTime - eventEndTime)); } } else { index = -index + 1; if (index < fZoomedEventList.size()) { fZoomedEventList.add(index, event); } else { fZoomedEventList.add(event); } } updateEntryBounds(event); } }
Source:
<code>public void bindingChanged(BindingProvider provider, String itemName) { if (provider instanceof MCP23017BindingProvider) { if (provider.getItemNames().contains(itemName)) { bindGpioPin((MCP23017BindingProvider) provider, itemName); <START> logger.debug("bindingChanged item bound " + itemName + " - " + Arrays.toString(provider.getItemNames().toArray())); <END> } else { unBindGpioPin((MCP23017BindingProvider) provider, itemName); logger.debug("bindingChanged item unbound " + itemName + " - " + Arrays.toString(provider.getItemNames().toArray())); } } super.bindingChanged(provider, itemName); }</code><technical_language>parameterized logging instead of string concatenation</technical_language>

Target:
public void bindingChanged(BindingProvider provider, String itemName) { if (provider instanceof MCP23017BindingProvider) { String allItemNames = Arrays.toString(provider.getItemNames().toArray()); if (provider.getItemNames().contains(itemName)) { bindGpioPin((MCP23017BindingProvider) provider, itemName); logger.debug("bindingChanged item bound - {}", itemName, allItemNames); } else { unBindGpioPin((MCP23017BindingProvider) provider, itemName); logger.debug("bindingChanged item unbound - {}", itemName, allItemNames); } } super.bindingChanged(provider, itemName); }
Source:
<code>public RebalanceProtocol rebalanceProtocol() { final String upgradeFrom = streamsConfig.getString(StreamsConfig.UPGRADE_FROM_CONFIG); if (upgradeFrom != null) { switch (upgradeFrom) { case StreamsConfig.UPGRADE_FROM_0100: case StreamsConfig.UPGRADE_FROM_0101: case StreamsConfig.UPGRADE_FROM_0102: case StreamsConfig.UPGRADE_FROM_0110: case StreamsConfig.UPGRADE_FROM_10: case StreamsConfig.UPGRADE_FROM_11: case StreamsConfig.UPGRADE_FROM_20: case StreamsConfig.UPGRADE_FROM_21: case StreamsConfig.UPGRADE_FROM_22: case StreamsConfig.UPGRADE_FROM_23: log.info("Turning off cooperative rebalancing for upgrade from {}.x", upgradeFrom); return RebalanceProtocol.EAGER; default: throw new IllegalArgumentException("Unknown configuration value for parameter 'upgrade.from': " + upgradeFrom); } } <START> log.info("Cooperative rebalancing enabled now"); <END> return RebalanceProtocol.COOPERATIVE; }</code><technical_language>+1 this: thinking nice log message symmetric, log.info("Eager rebalancing enabled for upgrade {}.x", upgradeFrom); grep for "eager" "cooperative" figure out on</technical_language>

Target:
public RebalanceProtocol rebalanceProtocol() { final String upgradeFrom = streamsConfig.getString(StreamsConfig.UPGRADE_FROM_CONFIG); if (upgradeFrom != null) { switch (upgradeFrom) { case StreamsConfig.UPGRADE_FROM_0100: case StreamsConfig.UPGRADE_FROM_0101: case StreamsConfig.UPGRADE_FROM_0102: case StreamsConfig.UPGRADE_FROM_0110: case StreamsConfig.UPGRADE_FROM_10: case StreamsConfig.UPGRADE_FROM_11: case StreamsConfig.UPGRADE_FROM_20: case StreamsConfig.UPGRADE_FROM_21: case StreamsConfig.UPGRADE_FROM_22: case StreamsConfig.UPGRADE_FROM_23: log.info("Eager rebalancing enabled now for upgrade from {}.x", upgradeFrom); return RebalanceProtocol.EAGER; default: throw new IllegalArgumentException("Unknown configuration value for parameter 'upgrade.from': " + upgradeFrom); } } log.info("Cooperative rebalancing enabled now"); return RebalanceProtocol.COOPERATIVE; }
Source:
<code>public static UID from(UUID v) { <START> requireNonNull(v); <END> return new UID(v); }</code><technical_language>This line merge next line, making next line return new UID(requireNonNull(v));</technical_language>

Target:
public static UID from(UUID v) { return new UID(v); }
Source:
<code>private Response createResponse(Status status, Object entity) { ResponseBuilder rp = responseBuilder(status); if (entity == null) { return rp.build(); } PipedOutputStream out = new PipedOutputStream(); try { PipedInputStream in = new PipedInputStream(out); rp.entity(in); } catch (IOException e) { <START> throw new IllegalStateException("I/O error occurred"+e); <END> } Thread writerThread = new Thread(() -> { try (JsonWriter jsonWriter = new JsonWriter(new BufferedWriter(new OutputStreamWriter(out)))) { if (entity != null) { gson.toJson(entity, entity.getClass(), jsonWriter); jsonWriter.flush(); } } catch (IOException | JsonIOException e) { logger.error("Error streaming JSON through PipedInpuStream/PipedOutputStream: ", e); } }); writerThread.setDaemon(true); writerThread.start(); return rp.build(); }</code><technical_language>please add original exception a parameter here</technical_language>

Target:
private Response createResponse(Status status, Object entity) { ResponseBuilder rp = responseBuilder(status); if (entity == null) { return rp.build(); } PipedOutputStream out = new PipedOutputStream(); try { PipedInputStream in = new PipedInputStream(out); rp.entity(in); } catch (IOException e) { throw new IllegalStateException(e); } Thread writerThread = new Thread(() -> { try (JsonWriter jsonWriter = new JsonWriter(new BufferedWriter(new OutputStreamWriter(out)))) { if (entity != null) { gson.toJson(entity, entity.getClass(), jsonWriter); jsonWriter.flush(); } } catch (IOException | JsonIOException e) { logger.error("Error streaming JSON through PipedInpuStream/PipedOutputStream: ", e); } }); writerThread.setDaemon(true); writerThread.start(); return rp.build(); }
Source:
<code>public double adjust(double baseValue, double modifyingValue) { <START> return (baseValue + baseValue * modifyingValue); <END> }</code><technical_language>parentheses return statenents add clarity</technical_language>

Target:
public double adjust(double baseValue, double modifyingValue) { return modifyingValue; }
Source:
<code>protected ConfigNodeRoot setValue(String desiredPath, AbstractConfigNodeValue value, ConfigSyntax flavor) { ArrayList<AbstractConfigNode> childrenCopy = new ArrayList(children); for (int i = 0; i < childrenCopy.size(); i++) { AbstractConfigNode node = childrenCopy.get(i); if (node instanceof ConfigNodeComplexValue) { if (node instanceof ConfigNodeArray) { <START> throw new ConfigException.Generic("The ConfigDocument had an array at the root level, and values cannot be replaced inside an array."); <END> } else if (node instanceof ConfigNodeObject) { childrenCopy.set(i, ((ConfigNodeObject) node).setValueOnPath(desiredPath, value, flavor)); return new ConfigNodeRoot(childrenCopy); } } } throw new ConfigException.BugOrBroken("ConfigNodeRoot did not contain a value"); }</code><technical_language>ConfigException.WrongType sense here? mention this case in API docs</technical_language>

Target:
protected ConfigNodeRoot setValue(String desiredPath, AbstractConfigNodeValue value, ConfigSyntax flavor) { ArrayList<AbstractConfigNode> childrenCopy = new ArrayList<AbstractConfigNode>(children); for (int i = 0; i < childrenCopy.size(); i++) { AbstractConfigNode node = childrenCopy.get(i); if (node instanceof ConfigNodeComplexValue) { if (node instanceof ConfigNodeArray) { throw new ConfigException.WrongType(origin, "The ConfigDocument had an array at the root level, and values cannot be replaced inside an array."); } else if (node instanceof ConfigNodeObject) { childrenCopy.set(i, ((ConfigNodeObject) node).setValueOnPath(desiredPath, value, flavor)); return new ConfigNodeRoot(childrenCopy, origin); } } } throw new ConfigException.BugOrBroken("ConfigNodeRoot did not contain a value"); }
Source:
<code>public TextCsvConverter() { <START> enhanceMode = new HashSet<NetcdfDataset.Enhance>(); <END> enhanceMode.add(NetcdfDataset.Enhance.ScaleMissing); enhanceMode.add(NetcdfDataset.Enhance.ConvertEnums); enhanceMode.add(NetcdfDataset.Enhance.CoordSystems); }</code><technical_language>Explicit type argument NetcdfDataset.Enhance replaced <> for line 162 Map<Variable, NetcdfReader> variableReaders = new LinkedHashMap<Variable, NetcdfReader>();</technical_language>

Target:
public TextCsvConverter() { enhanceMode = new HashSet<>(); enhanceMode.add(NetcdfDataset.Enhance.ScaleMissing); enhanceMode.add(NetcdfDataset.Enhance.ConvertEnums); enhanceMode.add(NetcdfDataset.Enhance.CoordSystems); }
Source:
<code>public void visitMethodInvocation(MethodInvocationTree tree) { if (MAP_GET_METHOD.matches(tree)) { Tree firstArgument = Iterables.getOnlyElement(tree.arguments()); if (mapSymbol.equals(getMapSymbol(tree)) && firstArgument.is(Tree.Kind.IDENTIFIER) && ((IdentifierTree) firstArgument).symbol().equals(variable)) { <START> result = true; <END> } } super.visitMethodInvocation(tree); }</code><technical_language>interrupt exploration this point empty return;</technical_language>

Target:
public void visitMethodInvocation(MethodInvocationTree tree) { if (MAP_GET_METHOD.matches(tree)) { Tree firstArgument = Iterables.getOnlyElement(tree.arguments()); if (mapSymbol.equals(getOwnerSymbol(tree)) && firstArgument.is(Tree.Kind.IDENTIFIER) && ((IdentifierTree) firstArgument).symbol().equals(variable)) { result = true; return; } } super.visitMethodInvocation(tree); }
Source:
<code>public Type getAggColumnType(Type input, AggregationOp op) { switch (op) { case MIN: case MAX: return input; case COUNT: return Type.LONG_TYPE; case SUM: case SUM_SQUARED: if (input == Type.INT_TYPE || input == Type.LONG_TYPE) { return Type.LONG_TYPE; } if (input == Type.FLOAT_TYPE || input == Type.DOUBLE_TYPE) { return Type.DOUBLE_TYPE; } <START> throw new IllegalArgumentException("SUM_SQUARED on " + op + " is invalid"); <END> case AVG: case STDEV: return Type.DOUBLE_TYPE; default: throw new IllegalArgumentException(op + " is invalid"); } }</code><technical_language>I meant include input in message, op. Also, message needs account for SUM well: throw new IllegalArgumentException(op + " " + input + " is invalid");</technical_language>

Target:
public Type getAggColumnType(Type input, AggregationOp op) { switch (op) { case MIN: case MAX: return input; case COUNT: return Type.LONG_TYPE; case SUM: case SUM_SQUARED: if (input == Type.INT_TYPE || input == Type.LONG_TYPE) { return Type.LONG_TYPE; } if (input == Type.FLOAT_TYPE || input == Type.DOUBLE_TYPE) { return Type.DOUBLE_TYPE; } throw new IllegalArgumentException(op + " on " + input + " is invalid"); case AVG: case STDEV: return Type.DOUBLE_TYPE; default: throw new IllegalArgumentException(op + " on " + input + " is invalid"); } }
Source:
<code>public boolean offer(E e) { checkNotNull(e); boolean added = false; putLock.lock(); try { <START> if (currentSize.get() >= capacity) { <END> return false; } else { added = delegate.add(e); if (added) { elementAdded(e); } } } finally { putLock.unlock(); } if (added) { signalNotEmpty(); } return added; }</code><technical_language>here, room fit new element</technical_language>

Target:
public boolean offer(E e) { checkNotNull(e); checkSize(e); boolean added = false; putLock.lock(); try { if (currentSize.get() + getBytesSize(e) > capacity) { return false; } else { added = delegate.add(e); if (added) { elementAdded(e); } } } finally { putLock.unlock(); } if (added) { signalNotEmpty(); } return added; }
Source:
<code>public static void tearDownEnvironment() { <START> checkCredentials(); <END> log.info("Deleting Container Development Environment server adapter"); ServersView servers = new ServersView(); servers.open(); servers.getServer(SERVER_ADAPTER).delete(true); }</code><technical_language>checking credentials in AfterClass, checked in BeforeClass</technical_language>

Target:
public static void tearDownEnvironment() { log.info("Deleting Container Development Environment server adapter"); ServersView servers = new ServersView(); servers.open(); try { servers.getServer(SERVER_ADAPTER).delete(true); } catch (EclipseLayerException exc) { exc.printStackTrace(); } }
Source:
<code>public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ProgressImpl other = (ProgressImpl) obj; <START> if (creationTime == null) { <END> if (other.creationTime != null) return false; } else if (!creationTime.equals(other.creationTime)) return false; if (lastModified == null) { if (other.lastModified != null) return false; } else if (!lastModified.equals(other.lastModified)) return false; if (steps == null) { if (other.steps != null) return false; } else if (!steps.equals(other.steps)) return false; if (user == null) { if (other.user != null) return false; } else if (!user.equals(other.user)) return false; if (workflowProgressId != other.workflowProgressId) return false; if (workflowType != other.workflowType) return false; return true; }</code><technical_language>![CRITICAL](<LINK_1> 'Severity: CRITICAL') Refactor this method reduce Cognitive Complexity 17 15 allowed. [![rule](<LINK_2>](<LINK_0></technical_language>

Target:
public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ProgressImpl other = (ProgressImpl) obj; if (creationTime == null) { if (other.creationTime != null) return false; } else if (!creationTime.equals(other.creationTime)) return false; if (lastModified == null) { if (other.lastModified != null) return false; } else if (!lastModified.equals(other.lastModified)) return false; if (user == null) { if (other.user != null) return false; } else if (!user.equals(other.user)) return false; if (workflowProgressId != other.workflowProgressId) return false; if (workflowName != other.workflowName) return false; return true; }
Source:
<code>public int getattrCallback(String path, ByteBuffer buf) { try { return getattr(path, FileStat.wrap(buf)); } catch (Exception e) { <START> e.printStackTrace(); <END> return -ErrorCodes.EIO(); } }</code><technical_language>LOG.error("Failed getattr {}: ", path, e)</technical_language>

Target:
public int getattrCallback(String path, ByteBuffer buf) { try { return getattr(path, FileStat.wrap(buf)); } catch (Exception e) { LOG.error("Failed to getattr {}: ", path, e); return -ErrorCodes.EIO(); } }
Source:
<code>public SamzaContainerController( Object taskFactory, long containerShutdownMs, Map<String, MetricsReporter> metricsReporterMap) { this.executorService = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder() <START> .setNameFormat("container-thread-%d").build()); <END> this.taskFactory = taskFactory; this.metricsReporterMap = metricsReporterMap; if (containerShutdownMs == -1) { this.containerShutdownMs = TaskConfigJava.DEFAULT_TASK_SHUTDOWN_MS; } else { this.containerShutdownMs = containerShutdownMs; } }</code><technical_language>differentiate thread names if multiple StreamProcessors in a single JVM process</technical_language>

Target:
public SamzaContainerController( Object taskFactory, long containerShutdownMs, Map<String, MetricsReporter> metricsReporterMap) { this.taskFactory = taskFactory; this.metricsReporterMap = metricsReporterMap; if (containerShutdownMs == -1) { this.containerShutdownMs = TaskConfigJava.DEFAULT_TASK_SHUTDOWN_MS; } else { this.containerShutdownMs = containerShutdownMs; } }
Source:
<code>public byte[] toBytes(String charset) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try (FoldingWriter f = new FoldingWriter(new OutputStreamWriter(bos, charset))) { for (Property p : getProperties()) { f.write(p); } f.flush(); } catch (IOException io) { <START> throw new ProcessingException("Failed to convert ical to bytes"); <END> } return bos.toByteArray(); }</code><technical_language>add e thrown exception</technical_language>

Target:
public byte[] toBytes(String charset) { return BEANS.get(ICalVCardHelper.class).toBytes(this, charset); }
Source:
<code>public Integer call() throws Exception { <START> Thread.sleep(timeout); <END> return 1; }</code><technical_language>test quicker if waited a CountDownLatch instead of sleeping for a fixed time</technical_language>

Target:
public Integer call() throws Exception { latch.await(); return 1; }
Source:
<code>public void setLocationErrorOccurred(boolean errorOccurred) { this.loginValidatorWatcher.setLocationErrorOccurred(errorOccurred); <START> mDropdownLocation.setVisibility(View.GONE); <END> }</code><technical_language>supposed depend of errorOccurred</technical_language>

Target:
public void setLocationErrorOccurred(boolean errorOccurred) { this.loginValidatorWatcher.setLocationErrorOccurred(errorOccurred); mDropdownLocation.setVisibility(View.GONE); mLoginButton.setEnabled(!errorOccurred); }
Source:
<code>public void exitFunctionExpr(ExprParser.FunctionExprContext ctx) { String fnName = ctx.getChild(0).getText(); final List<Expr> args = ctx.getChildCount() > 3 ? (List<Expr>) nodes.get(ctx.getChild(2)) : Collections.emptyList(); Expr expr = macroTable.get(fnName, args); if (expr == null) { final Function function = Parser.getFunction(fnName); if (function == null) { <START> throw new RuntimeException("function '" + fnName + "' is not defined."); <END> } expr = new FunctionExpr(function, fnName, args); } nodes.put(ctx, expr); }</code><technical_language>Druid's pattern</technical_language>

Target:
public void exitFunctionExpr(ExprParser.FunctionExprContext ctx) { String fnName = ctx.getChild(0).getText(); final List<Expr> args = ctx.getChildCount() > 3 ? (List<Expr>) nodes.get(ctx.getChild(2)) : Collections.emptyList(); Expr expr = macroTable.get(fnName, args); if (expr == null) { final Function function = Parser.getFunction(fnName); if (function == null) { throw new RE("function '%s' is not defined.", fnName); } expr = new FunctionExpr(function, fnName, args); } nodes.put(ctx, expr); }
Source:
<code>public void build_createANewRadiologyOrderSearchCriteriaInstanceWithAccessionNumberIfAccessionNumberIsSet() throws Exception { String accessionNumber = "1"; radiologyOrderSearchCriteria = new RadiologyOrderSearchCriteria.Builder().withAccessionNumber(accessionNumber) .build(); <START> assertTrue(radiologyOrderSearchCriteria.getAccessionNumber() <END> .equals(accessionNumber)); assertNull(radiologyOrderSearchCriteria.getPatient()); assertFalse(radiologyOrderSearchCriteria.getIncludeVoided()); assertNull(radiologyOrderSearchCriteria.getUrgency()); assertNull(radiologyOrderSearchCriteria.getFromEffectiveStartDate()); assertNull(radiologyOrderSearchCriteria.getToEffectiveStartDate()); }</code><technical_language>@bgeVam assertThat(, is())</technical_language>

Target:
public void build_createANewRadiologyOrderSearchCriteriaInstanceWithAccessionNumberIfAccessionNumberIsSet() throws Exception { String accessionNumber = "1"; radiologyOrderSearchCriteria = new RadiologyOrderSearchCriteria.Builder().withAccessionNumber(accessionNumber) .build(); assertThat(radiologyOrderSearchCriteria.getAccessionNumber(), is(accessionNumber)); assertNull(radiologyOrderSearchCriteria.getPatient()); assertFalse(radiologyOrderSearchCriteria.getIncludeVoided()); assertNull(radiologyOrderSearchCriteria.getUrgency()); assertNull(radiologyOrderSearchCriteria.getFromEffectiveStartDate()); assertNull(radiologyOrderSearchCriteria.getToEffectiveStartDate()); }
Source:
<code>public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { for (ChannelSecurityInterceptor securityInterceptor : securityInterceptors) { ChannelSecurityMetadataSource channelSecurityMetadataSource = (ChannelSecurityMetadataSource) securityInterceptor.obtainSecurityMetadataSource(); <START> if (bean instanceof MessageChannel && this.shouldProxy(beanName, channelSecurityMetadataSource)) { <END> if (AopUtils.isAopProxy(bean) && bean instanceof Advised) { ((Advised) bean).addAdvisor(new DefaultPointcutAdvisor(securityInterceptor)); } else { ProxyFactory proxyFactory = new ProxyFactory(bean); proxyFactory.addAdvisor(new DefaultPointcutAdvisor(securityInterceptor)); bean = proxyFactory.getProxy(); } } } return bean; }</code><technical_language>Move if (bean instanceof MessageChannel) of for loop</technical_language>

Target:
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof MessageChannel) { for (ChannelSecurityInterceptor securityInterceptor : securityInterceptors) { ChannelSecurityMetadataSource channelSecurityMetadataSource = (ChannelSecurityMetadataSource) securityInterceptor.obtainSecurityMetadataSource(); if (this.shouldProxy(beanName, channelSecurityMetadataSource)) { if (AopUtils.isAopProxy(bean) && bean instanceof Advised) { ((Advised) bean).addAdvisor(new DefaultPointcutAdvisor(securityInterceptor)); } else { ProxyFactory proxyFactory = new ProxyFactory(bean); proxyFactory.addAdvisor(new DefaultPointcutAdvisor(securityInterceptor)); bean = proxyFactory.getProxy(); } } } } return bean; }
Source:
<code>public void testEmptyRowSet() { RowSet in = RowSet.newBuilder().build(); RangeSet<RowKeyWrapper> out = adapter.rowSetToRangeSet(in); assertEquals(ImmutableRangeSet.builder().build(), out); <START> Query query = Query.create(TABLE_ID); <END> adapter.rangeSetToByteStringRange(out, query); assertEquals(in, query.toProto(requestContext).getRows()); }</code><technical_language>This is repeated over. Please refactor this logic a new method</technical_language>

Target:
public void testEmptyRowSet() { RowSet in = RowSet.newBuilder().build(); RangeSet<RowKeyWrapper> out = adapter.rowSetToRangeSet(in); assertEquals(ImmutableRangeSet.builder().build(), out); adapter.rangeSetToByteStringRange(out, query); assertEquals(in, query.toProto(requestContext).getRows()); }
Source:
<code>@Test void digestIsNormalized() { final RexNode node0 = and( or(input(tBool(), 1), input(tBool(), 0)), input(tBool(), 0)); final RexNode node1 = and( input(tBool(), 0), or(input(tBool(), 0), input(tBool(), 1))); assertThat(node0.equals(node1), is(true)); final RexNode node2 = eq(input(tVarchar(), 0), literal("0123456789012345")); final RexNode node3 = eq(literal("0123456789012345"), input(tVarchar(), 0)); <START> assertThat(node2.equals(node3), is(true)); <END> final RexNode node4 = eq(input(tVarchar(), 0), literal("01")); final RexNode node5 = eq(literal("01"), input(tVarchar(), 0)); assertThat(node4.equals(node5), is(true)); }</code><technical_language>Please refactor this assertThat(node2.equals(node3), is(true)); a helper method, failure message contains proper context information (e.g. nodes compared other)</technical_language>

Target:
@Test void digestIsNormalized() { assertNodeEquals( and(or(vBool(1), vBool(0)), vBool(0)), and(vBool(0), or(vBool(0), vBool(1)))); assertNodeEquals( and(or(vBool(1), vBool(0)), vBool(0)), and(or(vBool(0), vBool(1)), vBool(0))); assertNodeEquals( eq(vVarchar(0), literal("0123456789012345")), eq(literal("0123456789012345"), vVarchar(0))); assertNodeEquals( eq(vVarchar(0), literal("01")), eq(literal("01"), vVarchar(0))); }
Source:
<code>private void closeSession() { if (session == null) return; debug("attempt to close session " + getSessionName()); if (xaProto != null) xaProto.rollbackCurrentTransaction(); server.removeFromSessionTable(session.connNum); try { session.close(); debug(getSessionName() + " closed"); } catch (SQLException se) { debug("encountered exception while closing session " + getSessionName()); sendUnexpectedException(se); close(); } catch (Exception e) { <START> debug("encountered exception while closing session "+ getSessionName()); <END> server.consoleExceptionPrintTrace(e); throw e; } finally { session = null; database = null; appRequester=null; sockis = null; sockos=null; databaseAccessException=null; } }</code><technical_language>LOG.debug(message, error)</technical_language>

Target:
private void closeSession() { if (session == null) return; if(LOG.isDebugEnabled()) { LOG.debug(String.format("attempt to close session %s", getSessionName())); } if (xaProto != null) xaProto.rollbackCurrentTransaction(); server.removeFromSessionTable(session.connNum); try { session.close(); if(LOG.isDebugEnabled()) { LOG.debug(String.format("%s closed", getSessionName())); } } catch (SQLException se) { if(LOG.isDebugEnabled()) { LOG.debug(String.format("encountered exception while closing session %s", getSessionName())); } sendUnexpectedException(se); close(); } catch (Exception e) { if(LOG.isDebugEnabled()) { LOG.debug(String.format("encountered exception while closing session %s", getSessionName())); } server.consoleExceptionPrintTrace(e); throw e; } finally { session = null; database = null; appRequester=null; sockis = null; sockos=null; databaseAccessException=null; } }
Source:
<code>public ConnectorTransactionHandle create() { long transactionId = metadata.nextTransactionId(); long commitId = metadata.getCurrentCommitId(); Transaction transaction = new Transaction(metadata, transactionId, commitId); RaptorTransactionHandle handle = new RaptorTransactionHandle(transactionId, commitId); transactions.put(handle, transaction); return handle; <START> } <END></code><technical_language>describe a potential data race here. verify a real issue. race some logics jump in line 44 line 48, time series is: thread2 called beginTransaction, get CurrentCommitId == 1 thread1 metadata.getCurrentCommitId(); get CurrentCommitId==1 thread2 execute, finish commit, update CurrentCommitId=2, exit fully CommitCleaner threadxx called oldestActiveCommitId, transactions is empty, CurrentCommitId==2, oldestActiveCommitId == 2 thread1 called transactions.put(handle, transaction); this enters a unsafe state, oldestActiveCommitId is 1, CommitCleaner get 2</technical_language>

Target:
public synchronized ConnectorTransactionHandle create() { long transactionId = metadata.nextTransactionId(); long commitId = metadata.getCurrentCommitId(); Transaction transaction = new Transaction(metadata, transactionId, commitId); RaptorTransactionHandle handle = new RaptorTransactionHandle(transactionId, commitId); transactions.put(handle, transaction); return handle; }
Source:
<code>public void testTransformer() { <START> testWorkflow("eu/dnetlib/iis/workflows/transformers/spark/citationmatching/direct/with_sample_data"); <END> }</code><technical_language>I if subfolder "with_sample_data" is necessary. test app direct</technical_language>

Target:
public void testTransformer() { testWorkflow("eu/dnetlib/iis/workflows/transformers/spark/citationmatching/direct/test"); }
Source:
<code>private void injectFieldByName(Object arg, Class tgtcls, Class parmcls, String fdname) { try { Pair<Class, String> cachedKey = new Pair<Class, String>(tgtcls, fdname); Field fd = _injectedFieldCache.computeIfAbsent(cachedKey, k -> { try { return Classes.getAnyField(tgtcls, fdname); } catch (NoSuchFieldException e) { } return null; }); if (fd != null) injectField(arg, parmcls, fd); } catch (Exception ex2) { <START> throw UiException.Aide.wrap(ex2); <END> } }</code><technical_language>null is invalid</technical_language>

Target:
private void injectFieldByName(Object arg, Class tgtcls, Class parmcls, String fdname) { try { Pair<Class, String> cachedKey = new Pair<Class, String>(tgtcls, fdname); Field fd = _injectedFieldCache.computeIfAbsent(cachedKey, k -> { try { return Classes.getAnyField(tgtcls, fdname); } catch (NoSuchFieldException e) { } return EMPTY_FIELD; }); if (fd != null && !fd.equals(EMPTY_FIELD)) injectField(arg, parmcls, fd); } catch (Exception ex2) { throw UiException.Aide.wrap(ex2); } }
Source:
<code>public static Field saveField(Field oldField) throws DotHibernateException { <START> if (Field.FieldType.HOST_OR_FOLDER.toString().equals(oldField.getFieldType()) <END> || Field.FieldType.LINE_DIVIDER.toString().equals(oldField.getFieldType()) || Field.FieldType.TAB_DIVIDER.toString().equals(oldField.getFieldType()) || Field.FieldType.CATEGORIES_TAB.toString().equals(oldField.getFieldType()) || Field.FieldType.PERMISSIONS_TAB.toString().equals(oldField.getFieldType()) || Field.FieldType.RELATIONSHIPS_TAB.toString().equals(oldField.getFieldType()) || Field.FieldType.CATEGORY.toString().equals(oldField.getFieldType()) || Field.FieldType.TAG.toString().equals(oldField.getFieldType()) || Field.FieldType.HIDDEN.toString().equals(oldField.getFieldType())) { oldField.setFieldContentlet(DataTypes.SYSTEM.toString()); } if(Field.FieldType.HOST_OR_FOLDER.toString().equals(oldField.getFieldType()) || Field.FieldType.TAG.toString().equals(oldField.getFieldType())){ oldField.setIndexed(true); } com.dotcms.contenttype.model.field.Field field = new LegacyFieldTransformer(oldField).from(); try { return new LegacyFieldTransformer( APILocator.getContentTypeFieldAPI().save(field, APILocator.systemUser()) ).asOldField(); } catch (DotDataException | DotSecurityException e) { throw new DotHibernateException(e.getMessage(),e); } }</code><technical_language>do a set instead of a big If</technical_language>

Target:
public static Field saveField(Field oldField) throws DotHibernateException { final Set<String> systemFieldsSet = set(Field.FieldType.HOST_OR_FOLDER.toString(), Field.FieldType.LINE_DIVIDER.toString(), Field.FieldType.TAB_DIVIDER.toString(), Field.FieldType.CATEGORIES_TAB.toString(), Field.FieldType.PERMISSIONS_TAB.toString(), Field.FieldType.RELATIONSHIPS_TAB.toString(), Field.FieldType.CATEGORY.toString(), Field.FieldType.TAG.toString(), Field.FieldType.HIDDEN.toString()); if (systemFieldsSet.contains(oldField.getFieldType())) { oldField.setFieldContentlet(DataTypes.SYSTEM.toString()); } if(Field.FieldType.HOST_OR_FOLDER.toString().equals(oldField.getFieldType()) || Field.FieldType.TAG.toString().equals(oldField.getFieldType())){ oldField.setIndexed(true); } com.dotcms.contenttype.model.field.Field field = new LegacyFieldTransformer(oldField).from(); try { return new LegacyFieldTransformer( APILocator.getContentTypeFieldAPI().save(field, APILocator.systemUser()) ).asOldField(); } catch (DotDataException | DotSecurityException e) { throw new DotHibernateException(e.getMessage(),e); } }
Source:
<code>private Main() { <START> throw new IllegalStateException("Utility class constructor mustn't be called."); <END> }</code><technical_language>I throwing exception is necessary. In majority of other places I empty private constructor</technical_language>

Target:
private Main() { }
Source:
<code>public void checkCommandMetadata() throws Exception { <START> try (CommandController controller = uiTestHarness.createCommandController(RestNewEndpointCommandImpl.class, <END> project.getRoot())) { controller.initialize(); assertTrue(controller.getCommand() instanceof RestNewEndpointCommandImpl); assertTrue(controller.getCommand() instanceof AbstractRestNewCommand); UICommandMetadata metadata = controller.getMetadata(); assertEquals("REST: New Endpoint", metadata.getName()); assertEquals("Java EE", metadata.getCategory().getName()); assertEquals("JAX-RS", metadata.getCategory().getSubCategory().getName()); assertEquals(7, controller.getInputs().size()); assertFalse("Project is created, shouldn't have targetLocation", controller.hasInput("targetLocation")); assertTrue(controller.hasInput("named")); assertTrue(controller.hasInput("targetPackage")); assertTrue(controller.hasInput("overwrite")); assertTrue(controller.hasInput("methods")); assertTrue(controller.hasInput("path")); assertTrue(controller.hasInput("extends")); assertTrue(controller.hasInput("implements")); assertTrue(controller.getValueFor("targetPackage").toString().endsWith(DEFAULT_REST_PACKAGE)); } }</code><technical_language>This test need changed</technical_language>

Target:
public void checkCommandMetadata() throws Exception { try (CommandController controller = uiTestHarness.createCommandController(RestNewEndpointCommand.class, project.getRoot())) { controller.initialize(); assertTrue(controller.getCommand() instanceof RestNewEndpointCommand); assertTrue(controller.getCommand() instanceof AbstractRestNewCommand); UICommandMetadata metadata = controller.getMetadata(); assertEquals("REST: New Endpoint", metadata.getName()); assertEquals("Java EE", metadata.getCategory().getName()); assertEquals("JAX-RS", metadata.getCategory().getSubCategory().getName()); assertEquals(7, controller.getInputs().size()); assertFalse("Project is created, shouldn't have targetLocation", controller.hasInput("targetLocation")); assertTrue(controller.hasInput("named")); assertTrue(controller.hasInput("targetPackage")); assertTrue(controller.hasInput("overwrite")); assertTrue(controller.hasInput("methods")); assertTrue(controller.hasInput("path")); assertTrue(controller.hasInput("extends")); assertTrue(controller.hasInput("implements")); assertTrue(controller.getValueFor("targetPackage").toString().endsWith(DEFAULT_REST_PACKAGE)); } }
Source:
<code><START> private ResendConfirmationCodeResult resendConfirmationCodeInternal(final Map<String, String> clientMetadata) { <END> final ResendConfirmationCodeRequest resendConfirmationCodeRequest = new ResendConfirmationCodeRequest() .withUsername(userId) .withClientId(clientId) .withSecretHash(secretHash); final String pinpointEndpointId = pool.getPinpointEndpointId(); resendConfirmationCodeRequest.setUserContextData(getUserContextData()); if (pinpointEndpointId != null) { AnalyticsMetadataType amd = new AnalyticsMetadataType(); amd.setAnalyticsEndpointId(pinpointEndpointId); resendConfirmationCodeRequest.setAnalyticsMetadata(amd); } return cognitoIdentityProviderClient.resendConfirmationCode(resendConfirmationCodeRequest); }</code><technical_language>is this clientMetadata in this function</technical_language>

Target:
private ResendConfirmationCodeResult resendConfirmationCodeInternal(final Map<String, String> clientMetadata) { final ResendConfirmationCodeRequest resendConfirmationCodeRequest = new ResendConfirmationCodeRequest() .withUsername(userId) .withClientId(clientId) .withSecretHash(secretHash) .withClientMetadata(clientMetadata); final String pinpointEndpointId = pool.getPinpointEndpointId(); resendConfirmationCodeRequest.setUserContextData(getUserContextData()); if (pinpointEndpointId != null) { AnalyticsMetadataType amd = new AnalyticsMetadataType(); amd.setAnalyticsEndpointId(pinpointEndpointId); resendConfirmationCodeRequest.setAnalyticsMetadata(amd); } return cognitoIdentityProviderClient.resendConfirmationCode(resendConfirmationCodeRequest); }
Source:
<code>public void addFilteredExecution(Long activityId) { TaskActivity activity = taskActivitiesDataService.findById(activityId); if (activity == null) { <START> return; <END> } TaskExecutionProgress progress = activity.getTaskExecutionProgress(); progress.addActionFiltered(); updateTaskProgress(progress, activity); }</code><technical_language>omit return in void methods, is readable is hard debugging</technical_language>

Target:
public void addFilteredExecution(Long activityId) { TaskActivity activity = taskActivitiesDataService.findById(activityId); if (activity != null) { TaskExecutionProgress progress = activity.getTaskExecutionProgress(); progress.addActionFiltered(); updateTaskProgress(progress, activity); } }
Source:
<code>public long getTokenExpiration(String tokenId, boolean validate) throws UnknownTokenException { <START> if (validate) { <END> validateToken(tokenId); } long expiration = 0; try { expiration = super.getTokenExpiration(tokenId, validate); return expiration; } catch (UnknownTokenException e) { } try { char[] expStr = aliasService.getPasswordFromAliasForCluster(AliasService.NO_CLUSTER_NAME, tokenId); if (expStr != null) { expiration = Long.parseLong(new String(expStr)); super.updateExpiration(tokenId, expiration); } } catch (Exception e) { log.errorAccessingTokenState(tokenId, e); } return expiration; }</code><technical_language>I this previously, super validate based in-memory store, if in-memory, do want validate alias</technical_language>

Target:
public long getTokenExpiration(String tokenId, boolean validate) throws UnknownTokenException { try { return super.getTokenExpiration(tokenId, validate); } catch (UnknownTokenException e) { } if (validate) { validateToken(tokenId); } long expiration = 0; try { char[] expStr = aliasService.getPasswordFromAliasForCluster(AliasService.NO_CLUSTER_NAME, tokenId); if (expStr != null) { expiration = Long.parseLong(new String(expStr)); super.updateExpiration(tokenId, expiration); } } catch (Exception e) { log.errorAccessingTokenState(tokenId, e); } return expiration; }
Source:
<code><START> public ResponseEntity<?> getStorage(@PathVariable("id") final String id, final NativeWebRequest request) { <END> if (!adminService.isAdmin(AuthorizationService.Operation.READ)) { return status(FORBIDDEN).build(); } final Storage storage = storageService.getStorage(id); return status(OK).body(storage); }</code><technical_language>declare throws please</technical_language>

Target:
public ResponseEntity<?> getStorage(@PathVariable("id") final String id, final NativeWebRequest request) throws PluginException, NoSuchStorageException, InternalNakadiException { if (!adminService.isAdmin(AuthorizationService.Operation.READ)) { return status(FORBIDDEN).build(); } final Storage storage = storageService.getStorage(id); return status(OK).body(storage); }
Source:
<code>Class<?> getASMClass() throws ClassNotFoundException; String getMethodSignature(Method m); String getNonPrimitive(Class<?> tp); String getPrimitive(Class<?> tp); <START> void setBadASM(boolean b); <END> public interface ASMType { int getOpcode(int ireturn); }</code><technical_language>Please remove this method (setBadASM), is internal impl is</technical_language>

Target:
Class<?> getASMClass() throws ClassNotFoundException; String getMethodSignature(Method m); String getNonPrimitive(Class<?> tp); String getPrimitive(Class<?> tp); public interface ASMType { int getOpcode(int ireturn); }
Source:
<code>private static Range<LocalDate> getDateRangeFromLookupFields(String lookupFields, String dateName) { DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); LocalDate min = new LocalDate(); LocalDate max = new LocalDate(); Map<String, String> rangeMap = (Map < String, String>)getObjectFromLookupFields(lookupFields, dateName); <START> if (!StringUtils.isEmpty(rangeMap.get("min"))) { <END> min = formatter.parseLocalDate(rangeMap.get("min")); } if (!StringUtils.isEmpty(rangeMap.get("max"))) { max = formatter.parseLocalDate(rangeMap.get("max")); } if(max != null && min != null && max.isBefore(min)) { return null; } return new Range<>(min, max); }</code><technical_language>isNotBlank</technical_language>

Target:
private static Range<LocalDate> getDateRangeFromLookupFields(String lookupFields, String dateName) { DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); LocalDate min = null; LocalDate max = null; Map<String, String> rangeMap = (Map < String, String>)getObjectFromLookupFields(lookupFields, dateName); if (StringUtils.isNotBlank(rangeMap.get("min"))) { min = formatter.parseLocalDate(rangeMap.get("min")); } if (StringUtils.isNotBlank(rangeMap.get("max"))) { max = formatter.parseLocalDate(rangeMap.get("max")); } if(max != null && min != null && max.isBefore(min)) { return null; } return new Range<>(min, max); }
Source:
<code>private synchronized PackIndex idx() throws IOException { if (loadedIdx == null) { if (invalid) throw new PackInvalidException(packFile); try { final PackIndex idx = PackIndex.open(extFile(INDEX)); if (packChecksum == null) { packChecksum = idx.packChecksum; <START> } else if (!Arrays.equals(packChecksum, idx.packChecksum)) { throw new PackMismatchException(MessageFormat.format( JGitText.get().packChecksumMismatch, packFile.getPath())); } <END> loadedIdx = idx; } catch (InterruptedIOException e) { throw e; } catch (IOException e) { invalid = true; throw e; } } return loadedIdx; }</code><technical_language>include values here</technical_language>

Target:
private synchronized PackIndex idx() throws IOException { if (loadedIdx == null) { if (invalid) throw new PackInvalidException(packFile); try { final PackIndex idx = PackIndex.open(extFile(INDEX)); if (packChecksum == null) { packChecksum = idx.packChecksum; } else if (!Arrays.equals(packChecksum, idx.packChecksum)) { throw new PackMismatchException(MessageFormat.format( JGitText.get().packChecksumMismatch, packFile.getPath(), packChecksum, idx.packChecksum)); } loadedIdx = idx; } catch (InterruptedIOException e) { throw e; } catch (IOException e) { invalid = true; throw e; } } return loadedIdx; }