auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Iterable<Rule> getRules(TriggerTypes triggerType, String channel, String event) { List<Rule> result = Lists.newArrayList(); switch (triggerType) { case TRIGGER: Set<Rule> rules = triggerEventTriggeredRules.get(channel); if (rules == null) { return Collections.emptyList(); } for (Rule rule : rules) { for (EventTrigger t : rule.getEventtrigger()) { if (t instanceof EventEmittedTrigger) { EventEmittedTrigger et = (EventEmittedTrigger) t; if (et.getChannel().equals(channel)) { if (et.getTrigger() == null) { result.add(rule); <START> } else if ((et.getTrigger() != null && et.getTrigger().equals(event))) { <END> result.add(rule); } } } } } break; default: return Collections.emptyList(); } return result; }</code><technical_language>part is redundant: _know_ et.getTrigger() is null. Anyway, complicated? a java if (et.getChannel().equals(channel) && (et.getTrigger() == null || et.getTrigger().equals(event))) { done job nicely duplicating (admittedly trivial) block</technical_language>

Target:
public Iterable<Rule> getRules(TriggerTypes triggerType, String channel, String event) { List<Rule> result = Lists.newArrayList(); switch (triggerType) { case TRIGGER: Set<Rule> rules = triggerEventTriggeredRules.get(channel); if (rules == null) { return Collections.emptyList(); } for (Rule rule : rules) { for (EventTrigger t : rule.getEventtrigger()) { if (t instanceof EventEmittedTrigger) { EventEmittedTrigger et = (EventEmittedTrigger) t; if (et.getChannel().equals(channel) && (et.getTrigger() == null || et.getTrigger().equals(event))) { result.add(rule); } } } } break; default: return Collections.emptyList(); } return result; }
Source:
<code>public void checkRenderHeader() { final BaseGridRendererHelper.RenderingInformation ri = makeRenderingInformation(model, <START> Arrays.asList(ROW_HEIGHT, ROW_HEIGHT * 2, ROW_HEIGHT * 3)); <END> final GridHeaderRenderContext context = mock(GridHeaderRenderContext.class); doReturn(model.getColumns()).when(context).getAllColumns(); doReturn(model.getColumns()).when(context).getBlockColumns(); final List<RendererCommand> commands = renderer.renderHeader(model, context, rendererHelper, ri); assertThat(commands).isNotNull(); assertThat(commands).asList().hasSize(2); assertRenderingCommands(commands, RenderHeaderBackgroundCommand.class, RenderHeaderGridLinesCommand.class); verify(columnRenderer).renderHeader(anyList(), any(GridHeaderColumnRenderContext.class), eq(ri)); final ArgumentCaptor<Rectangle> rectangleCaptor = ArgumentCaptor.forClass(Rectangle.class); final Group parent = mock(Group.class); commands.stream().filter(c -> c instanceof RenderHeaderBackgroundCommand).findFirst().ifPresent(c -> c.execute(parent)); verify(parent).add(rectangleCaptor.capture()); assertRenderedRectangle(rectangleCaptor.getValue(), column.getWidth(), BaseGridWidgetRenderingTestUtils.HEADER_HEIGHT); reset(parent); final ArgumentCaptor<Line> lineCaptor = ArgumentCaptor.forClass(Line.class); commands.stream().filter(c -> c instanceof RenderHeaderGridLinesCommand).findFirst().ifPresent(c -> c.execute(parent)); verify(parent).add(lineCaptor.capture()); final Line line = lineCaptor.getValue(); assertEquals(column.getWidth(), line.getBoundingBox().getWidth(), 0.5); }</code><technical_language>HEADER_HEIGHT</technical_language>

Target:
public void checkRenderHeader() { final BaseGridRendererHelper.RenderingInformation ri = makeRenderingInformation(model, Arrays.asList(0d, ROW_HEIGHT, ROW_HEIGHT * 2)); final GridHeaderRenderContext context = mock(GridHeaderRenderContext.class); doReturn(model.getColumns()).when(context).getAllColumns(); doReturn(model.getColumns()).when(context).getBlockColumns(); final List<RendererCommand> commands = renderer.renderHeader(model, context, rendererHelper, ri); assertThat(commands).isNotNull(); assertThat(commands).asList().hasSize(2); assertRenderingCommands(commands, RenderHeaderBackgroundCommand.class, RenderHeaderGridLinesCommand.class); verify(columnRenderer).renderHeader(anyList(), any(GridHeaderColumnRenderContext.class), eq(ri)); final ArgumentCaptor<Rectangle> rectangleCaptor = ArgumentCaptor.forClass(Rectangle.class); final Group parent = mock(Group.class); commands.stream().filter(c -> c instanceof RenderHeaderBackgroundCommand).findFirst().ifPresent(c -> c.execute(parent)); verify(parent).add(rectangleCaptor.capture()); assertRenderedRectangle(rectangleCaptor.getValue(), column.getWidth(), BaseGridWidgetRenderingTestUtils.HEADER_HEIGHT); reset(parent); final ArgumentCaptor<Line> lineCaptor = ArgumentCaptor.forClass(Line.class); commands.stream().filter(c -> c instanceof RenderHeaderGridLinesCommand).findFirst().ifPresent(c -> c.execute(parent)); verify(parent).add(lineCaptor.capture()); final Line line = lineCaptor.getValue(); assertEquals(column.getWidth(), line.getBoundingBox().getWidth(), 0.5); }
Source:
<code>public BinaryContent transform(Metacard metacard, Map<String, Serializable> arguments) throws CatalogTransformerException { if (metacard == null) { throw new CatalogTransformerException("Null metacard cannot be transformed into RTF"); } ByteArrayInputStream rtfStream = <START> Optional.of(metacard).map(this::toRtf).map(this::rtfStringToInputStream).orElse(null); <END> return asBinaryContent(rtfStream); }</code><technical_language>simplify this toRtf return Optional<String> throw exception instead of setting rtfStream null throw exception in asBinaryContent()? toRtf(metacard).map(this::rtfStringToInputStream).orElseThrow(() -> throw new CatalogTransformerException(...));</technical_language>

Target:
public BinaryContent transform(Metacard metacard, Map<String, Serializable> arguments) throws CatalogTransformerException { if (metacard == null) { throw new CatalogTransformerException("Null metacard cannot be transformed into RTF"); } ByteArrayInputStream rtfStream = Optional.of(metacard) .map(this::toRtf) .map(this::rtfStringToInputStream) .orElseThrow(this::emptyRtfException); return new BinaryContentImpl(rtfStream, mimeType); }
Source:
<code>public File getLastContextScreenshot() { List<File> screenshots = currentContextScreenshots.get(); return screenshots == null || screenshots.isEmpty() <START> ? null <END> : screenshots.get(screenshots.size() - 1); }</code><technical_language>return Optional instead of null</technical_language>

Target:
public Optional<File> getLastContextScreenshot() { List<File> screenshots = currentContextScreenshots.get(); return getLastScreenshot(screenshots); }
Source:
<code>} catch (MimeTypeParseException e) { <START> LOGGER.warn("Failure creating MIME type", e); <END> throw new ExceptionInInitializerError(e); }</code><technical_language>log throw is considered anti-pattern; throw here</technical_language>

Target:
} catch (MimeTypeParseException e) { throw new ExceptionInInitializerError(e); }
Source:
<code>private boolean isAttributeAvailable(String attributeName, Iterable<String> attributeNames) { <START> if (attributeName == null || Iterables.contains(attributeNames, attributeName)) <END> { return true; } return false; }</code><technical_language>simplified java return attributeName == null || Iterables.contains(attributeNames, attributeName);</technical_language>

Target:
private boolean isAttributeAvailable(String attributeName, Iterable<String> attributeNames) { return (attributeName == null || Iterables.contains(attributeNames, attributeName)); }
Source:
<code>public String getFilePath() { switch (m_option) { case PLAIN: case BATCH: return m_file.getPath(); case INLINEBATCH: default: <START> String filePath = (m_context == null) ? "no file" : m_context.getFilePath(); <END> assert(m_option == FileOption.INLINEBATCH); return "(inline batch delimited by '" + m_delimiter + "' in " + filePath + ")"; } }</code><technical_language>Do "no file" in other places? I remembered "AdHoc DDL Input" DDL is a file</technical_language>

Target:
public String getFilePath() { switch (m_option) { case PLAIN: case BATCH: return m_file.getPath(); case INLINEBATCH: default: String filePath = (m_context == null) ? "AdHoc DDL Input" : m_context.getFilePath(); assert(m_option == FileOption.INLINEBATCH); return "(inline batch delimited by '" + m_delimiter + "' in " + filePath + ")"; } }
Source:
<code>public void start(final ServiceConfiguration<?> config, final ServiceProvider serviceProvider) { <START> this.serviceLocator = (ServiceLocator)serviceProvider; <END> }</code><technical_language>need cast, a ServiceProvider method need</technical_language>

Target:
public void start(final ServiceConfiguration<?> config, final ServiceProvider serviceProvider) { this.serviceProvider = serviceProvider; }
Source:
<code>private String scriptLauncherCmd(ShellController c, FilePath ws, String interpreter, String scriptPath, String cookieValue, String cookieVariable) throws IOException, InterruptedException { String cmd; FilePath logFile = c.getLogFile(ws); FilePath resultFile = c.getResultFile(ws); FilePath controlDir = c.controlDir(ws); if (capturingOutput) { cmd = String.format("pid=$$; { while [ \\( -d /proc/$pid -o \\! -d /proc/$$ \\) -a -d '%s' -a \\! -f '%s' ]; do touch '%s'; sleep 3; done } & jsc=%s; %s=$jsc %s '%s' > '%s' 2> '%s'; echo $? > '%s.tmp'; mv '%s.tmp' '%s'; wait", controlDir, resultFile, logFile, cookieValue, cookieVariable, interpreter, scriptPath, c.getOutputFile(ws), logFile, resultFile, resultFile, resultFile); } else { <START> cmd = String.format("pid=$$; { while [ \\( -d /proc/$pid -o \\! -d /proc/$$ \\) -a -d '%s' -a \\! -f '%s' ]; do touch '%s'; sleep 3; done } & jsc=%s; %s=$jsc %s '%s' > '%s' 2>&1; echo $? > '%s.tmp'; mv '%s.tmp' '%s'; wait", <END> controlDir, resultFile, logFile, cookieValue, cookieVariable, interpreter, scriptPath, logFile, resultFile, resultFile, resultFile); } return cmd; }</code><technical_language>I I mentioned previously, expect users running binary launcher strip out some of hard-to-test exotica in this case. drop nohup (already that?); /proc heartbeat trick (/proc work Linux anyway!)</technical_language>

Target:
private String scriptLauncherCmd(ShellController c, FilePath ws, String interpreter, String scriptPath, String cookieValue, String cookieVariable) throws IOException, InterruptedException { String cmd; FilePath logFile = c.getLogFile(ws); FilePath resultFile = c.getResultFile(ws); FilePath controlDir = c.controlDir(ws); if (capturingOutput) { cmd = String.format("{ while [ -d '%s' -a \\! -f '%s' ]; do touch '%s'; sleep 3; done } & jsc=%s; %s=$jsc %s '%s' > '%s' 2> '%s'; echo $? > '%s.tmp'; mv '%s.tmp' '%s'; wait", controlDir, resultFile, logFile, cookieValue, cookieVariable, interpreter, scriptPath, c.getOutputFile(ws), logFile, resultFile, resultFile, resultFile); } else { cmd = String.format("{ while [ -d '%s' -a \\! -f '%s' ]; do touch '%s'; sleep 3; done } & jsc=%s; %s=$jsc %s '%s' > '%s' 2>&1; echo $? > '%s.tmp'; mv '%s.tmp' '%s'; wait", controlDir, resultFile, logFile, cookieValue, cookieVariable, interpreter, scriptPath, logFile, resultFile, resultFile, resultFile); } return cmd; }
Source:
<code>protected ConfigurationBuilder getConfiguration() { ConfigurationBuilder cfg = new ConfigurationBuilder(); cfg.persistence() .addStore(DummyInMemoryStoreConfigurationBuilder.class) <START> .segmented(true) <END> .storeName(this.getClass().getName()) .transaction().transactionMode(TransactionMode.TRANSACTIONAL); return cfg; }</code><technical_language>Do want this test run segmented true false</technical_language>

Target:
protected ConfigurationBuilder getConfiguration() { ConfigurationBuilder cfg = new ConfigurationBuilder(); cfg.persistence() .addStore(DummyInMemoryStoreConfigurationBuilder.class) .segmented(segmented) .storeName(this.getClass().getName()) .transaction().transactionMode(TransactionMode.TRANSACTIONAL); return cfg; }
Source:
<code>public static int getMaxPresets(final Player player) { int max = ConfigManager.getConfig().getInt("Properties.MaxPresets"); if (player.isOp()) { return max; } for (int i = max; i > 0; i--) { if (player.hasPermission("bending.command.preset.create." + i)) { <START> return(i); <END> } } return 0; }</code><technical_language>return i;</technical_language>

Target:
public static int getMaxPresets(final Player player) { int max = ConfigManager.getConfig().getInt("Properties.MaxPresets"); if (player.isOp()) { return max; } for (int i = max; i > 0; i--) { if (player.hasPermission("bending.command.preset.create." + i)) { return i; } } return 0; }
Source:
<code>public Boolean call() { CallManagerImpl.EventedCaller<E> caller = batcher.getCaller(); DatabaseClient client = batcher.getClient(callNumber); Calendar callTime = Calendar.getInstance(); E output = null; try { output = caller.callForEvent(client, args); } catch (Throwable throwable) { if (fireFailureListeners) { CallManagerImpl.CallEventImpl input = new CallManagerImpl.CallEventImpl(client, args); initEvent(input, callTime); batcher.sendThrowableToListeners(throwable, "failure calling " + caller.getEndpointPath() + " {}", input); return false; } else if (throwable instanceof RuntimeException) { throw (RuntimeException) throwable; } else { throw new DataMovementException("Failed to retry call", throwable); } } initEvent(output, callTime); batcher.sendSuccessToListeners(output); if(batcher.inputType == Void.class) { <START> CallArgs newInput = batcher.callArgsGenerator.apply(output); <END> if(newInput != null) { batcher.submitCall((CallArgsImpl) newInput); } } return true; }</code><technical_language>need consider respond errors in user code in call generator and, for matter, listeners. Please add a TODO check WriteBatcher QueryBatcher tolerate listener errors</technical_language>

Target:
public Boolean call() { CallManagerImpl.EventedCaller<E> caller = batcher.getCaller(); DatabaseClient client = batcher.getClient(callNumber); Calendar callTime = Calendar.getInstance(); E output = null; try { output = caller.callForEvent(client, args); } catch (Throwable throwable) { if (fireFailureListeners) { CallManagerImpl.CallEventImpl input = new CallManagerImpl.CallEventImpl(client, args); initEvent(input, callTime); batcher.sendThrowableToListeners(throwable, "failure calling " + caller.getEndpointPath() + " {}", input); return false; } else if (throwable instanceof RuntimeException) { throw (RuntimeException) throwable; } else { throw new DataMovementException("Failed to retry call", throwable); } } initEvent(output, callTime); batcher.sendSuccessToListeners(output); if(batcher.callArgsGenerator != null) { CallArgs newInput = batcher.callArgsGenerator.apply(output); if(newInput != null) { if(!(newInput instanceof CallArgsImpl)) throw new MarkLogicInternalException("Unsupported implementation of call arguments."); batcher.submitCall((CallArgsImpl) newInput); } } return true; }
Source:
<code>public synchronized void removeConnection(Socket conn) { try { <START> connections.remove(conn); <END> conn.close(); } catch (IOException ioe) { tsLogger.i18NLogger.warn_could_not_close_transaction_listener_connection(conn, ioe); } finally { notifyAll(); } }</code><technical_language>I clearer if connections.remove of this block I throwing IOException, notifyAll done a problem linkedlist.remove() if is case conn.close() in try block</technical_language>

Target:
public synchronized void removeConnection(Socket conn) { connections.remove(conn); try { conn.close(); } catch (IOException ioe) { tsLogger.i18NLogger.warn_could_not_close_transaction_listener_connection(conn, ioe); } finally { notifyAll(); } }
Source:
<code>public static void initOutputElements() { Set<File> files = listBuiltinFiles().values().stream() .map(p -> p.toFile()) .collect(Collectors.toSet()); listFiles().values().stream() .forEach(f -> files.add(f)); for (File xmlFile : files) { <START> if (!xmlValidate(xmlFile).isOK()) { continue; } <END> preloadXmlAnalysesOutput(xmlFile); } }</code><technical_language>do this beginning of preload, remove this</technical_language>

Target:
public static void initOutputElements() { Set<File> files = listBuiltinFiles().values().stream() .map(p -> p.toFile()) .collect(Collectors.toSet()); listFiles().values().stream() .forEach(f -> files.add(f)); for (File xmlFile : files) { preloadXmlAnalysesOutput(xmlFile); } }
Source:
<code>public List<String> run() { List<String> errorMessageList = new ArrayList<>(); errorMessageList.addAll(checkArguments()); <START> if (errorMessageList.isEmpty()) { <END> ByteArrayOutputStream commandExecutionOutput = new ByteArrayOutputStream(); int resultCode = -1; List<String> generationCommand = createGenerationCommand(); try { SystemCommand sc = new SystemCommand(new File(JMeterUtils.getJMeterBinDir()), COMMAND_TIMEOUT, 100, null, null, commandExecutionOutput, null); LOGGER.debug("Running report generation"); resultCode = sc.run(generationCommand); if (resultCode != 0) { errorMessageList.add(commandExecutionOutput.toString()); LOGGER.info("The HTML report generation failed and returned : {}", commandExecutionOutput); return errorMessageList; } } catch (InterruptedException | IOException e) { errorMessageList.add(commandExecutionOutput.toString()); if (LOGGER.isErrorEnabled()) { LOGGER.error("Error during HTML report generation : {}", e.getMessage(), e); } } LOGGER.debug("SystemCommand ran : returned : {}", generationCommand, resultCode); return errorMessageList; } return errorMessageList; }</code><technical_language>Consider guard clause style too</technical_language>

Target:
public List<String> run() { List<String> errorMessageList = new ArrayList<>(); errorMessageList.addAll(checkArguments()); if (!errorMessageList.isEmpty()) { return errorMessageList; } ByteArrayOutputStream commandExecutionOutput = new ByteArrayOutputStream(); int resultCode = -1; List<String> generationCommand = createGenerationCommand(); try { SystemCommand sc = new SystemCommand(new File(JMeterUtils.getJMeterBinDir()), COMMAND_TIMEOUT, 100, null, null, commandExecutionOutput, null); LOGGER.debug("Running report generation"); resultCode = sc.run(generationCommand); if (resultCode != 0) { errorMessageList.add(commandExecutionOutput.toString()); LOGGER.info("The HTML report generation failed and returned: {}", commandExecutionOutput); return errorMessageList; } } catch (InterruptedException | IOException e) { errorMessageList.add(commandExecutionOutput.toString()); if (LOGGER.isErrorEnabled()) { LOGGER.error("Error during HTML report generation: {}", e.getMessage(), e); } } LOGGER.debug("SystemCommand ran: returned: {}", generationCommand, resultCode); return errorMessageList; }
Source:
<code>public int getPortNumber() { <START> return portNumbers[0]; <END> }</code><technical_language>This assumes portNumbers is null other parts of code do check prior use</technical_language>

Target:
public int getPortNumber() { if (portNumbers == null || portNumbers.length == 0) { return 0; } return portNumbers[0]; }
Source:
<code>public void onEnter() { try { getContext().unregisterAuthorizationUpdates(); } catch (final RuntimeException ex) { getLog().error("Unexpected fail during removing callback for registration updates", ex); } try { if (null != exception) { getOut().onException(exception); } } finally { try { getContext().unregisterSession(); <START> getContext().getZkClient().close(); <END> } catch (IOException e) { getLog().error("Unexpected fail to release zk connection", e); } finally { switchState(StreamingContext.DEAD_STATE); } } }</code><technical_language>I in case of problems zk unregisterSession() throw exception, client closed</technical_language>

Target:
public void onEnter() { try { getContext().unregisterAuthorizationUpdates(); } catch (final RuntimeException ex) { getLog().error("Unexpected fail during removing callback for registration updates", ex); } try { if (null != exception) { getOut().onException(exception); } } finally { try { getContext().unregisterSession(); } finally { switchState(StreamingContext.DEAD_STATE); } try { getContext().getZkClient().close(); } catch (final IOException e) { getLog().error("Unexpected fail to release zk connection", e); } } }
Source:
<code>public void execute() throws MinimesosException { String marathonJson; try { marathonJson = getMarathonJson(); } catch (IOException e) { throw new MinimesosException("Failed to read JSON", e); } MesosCluster cluster = ClusterRepository.loadCluster(new MesosClusterContainersFactory()); if (cluster != null) { Marathon marathon = cluster.getMarathon(); if (marathon == null) { throw new MinimesosException("Marathon container is not found in cluster " + cluster.getClusterId()); } marathon.deployApp(marathonJson); } else { throw new MinimesosException("Running cluster is not found"); <START> } <END> }</code><technical_language>Reorder statements. Check if cluster is running Marathon, JSON</technical_language>

Target:
public void execute() throws MinimesosException { MesosCluster cluster = ClusterRepository.loadCluster(new MesosClusterContainersFactory()); if (cluster != null) { Marathon marathon = cluster.getMarathon(); if (marathon == null) { throw new MinimesosException("Marathon container is not found in cluster " + cluster.getClusterId()); } String marathonJson; try { marathonJson = getMarathonJson(); } catch (IOException e) { throw new MinimesosException("Failed to read JSON", e); } marathon.deployApp(marathonJson); } else { throw new MinimesosException("Running cluster is not found"); } }
Source:
<code>static List<HivePartition> getPartitionsSample(List<HivePartition> partitions, int sampleSize) { checkArgument(sampleSize > 0, "sampleSize is expected to be equal to or greater than zero"); if (partitions.size() <= sampleSize) { return partitions; } Map<String, Integer> hashes = computeHashes(partitions); List<HivePartition> partitionsSortedByHash = new ArrayList<>(partitions); Comparator<HivePartition> comparator = Comparator .comparingInt((HivePartition partition) -> hashes.get(partition.getPartitionId())) .thenComparing(HivePartition::getPartitionId); <START> partitionsSortedByHash.sort(comparator); <END> return ImmutableList.copyOf(partitionsSortedByHash.subList(0, sampleSize)); }</code><technical_language>I hash map is unnecessary. shortening code this code to: HashFunction hashFunction = goodFastHash(32); return partitions.stream() .map(partition -> immutableEntry(partition, hashFunction.hashUnencodedChars(partition.getPartitionId()).asInt())) .sorted(Comparator.<Entry<HivePartition, Integer>, Integer>comparing(Entry::getValue) .thenComparing(entry -> entry.getKey().getPartitionId())) .limit(sampleSize) .map(Entry::getKey) .collect(toImmutableList());</technical_language>

Target:
static List<HivePartition> getPartitionsSample(List<HivePartition> partitions, int sampleSize) { checkArgument(sampleSize > 0, "sampleSize is expected to be greater than zero"); if (partitions.size() <= sampleSize) { return partitions; } List<HivePartition> result = new ArrayList<>(); int samplesLeft = sampleSize; if (samplesLeft > 0) { HivePartition min = partitions.get(0); HivePartition max = partitions.get(0); for (HivePartition partition : partitions) { if (partition.getPartitionId().compareTo(min.getPartitionId()) < 0) { min = partition; } else if (partition.getPartitionId().compareTo(max.getPartitionId()) > 0) { max = partition; } } result.add(min); samplesLeft--; if (samplesLeft > 0) { result.add(max); samplesLeft--; } } if (samplesLeft > 0) { HashFunction hashFunction = goodFastHash(32); Comparator<Map.Entry<HivePartition, Integer>> hashComparator = Comparator .<Map.Entry<HivePartition, Integer>, Integer>comparing(Map.Entry::getValue) .thenComparing(entry -> entry.getKey().getPartitionId()); partitions.stream() .filter(partition -> !result.contains(partition)) .map(partition -> immutableEntry(partition, hashFunction.hashUnencodedChars(partition.getPartitionId()).asInt())) .sorted(hashComparator) .limit(sampleSize) .forEach(entry -> result.add(entry.getKey())); } return unmodifiableList(result); }
Source:
<code>private void pipelineChildren(Object aParent, NavigatorContentExtension[] theOverridingExtensions, INavigatorContentDescriptor firstClassDescriptor, ContributorTrackingSet pipelinedChildren, boolean elements) { IPipelinedTreeContentProvider pipelinedContentProvider; NavigatorContentExtension[] overridingExtensions; for (NavigatorContentExtension <START> theOverridingExtension : <END> theOverridingExtensions) { if (theOverridingExtension.internalGetContentProvider().isPipelined()) { pipelinedContentProvider = (IPipelinedTreeContentProvider) theOverridingExtension .internalGetContentProvider(); pipelinedChildren.setContributor(theOverridingExtension .getDescriptor(), firstClassDescriptor); if (elements) { pipelinedContentProvider.getPipelinedElements(aParent, pipelinedChildren); } else { pipelinedContentProvider.getPipelinedChildren(aParent, pipelinedChildren); } overridingExtensions = theOverridingExtension.getOverridingExtensionsForTriggerPoint(aParent); if (overridingExtensions.length > 0) { pipelineChildren(aParent, overridingExtensions, firstClassDescriptor, pipelinedChildren, elements); } } } }</code><technical_language>rename 'overridingExtension'</technical_language>

Target:
private void pipelineChildren(Object aParent, NavigatorContentExtension[] theOverridingExtensions, INavigatorContentDescriptor firstClassDescriptor, ContributorTrackingSet pipelinedChildren, boolean elements) { IPipelinedTreeContentProvider pipelinedContentProvider; NavigatorContentExtension[] overridingExtensions; for (NavigatorContentExtension overridingExtension : theOverridingExtensions) { if (overridingExtension.internalGetContentProvider().isPipelined()) { pipelinedContentProvider = overridingExtension.internalGetContentProvider(); pipelinedChildren.setContributor(overridingExtension.getDescriptor(), firstClassDescriptor); if (elements) { pipelinedContentProvider.getPipelinedElements(aParent, pipelinedChildren); } else { pipelinedContentProvider.getPipelinedChildren(aParent, pipelinedChildren); } overridingExtensions = overridingExtension.getOverridingExtensionsForTriggerPoint(aParent); if (overridingExtensions.length > 0) { pipelineChildren(aParent, overridingExtensions, firstClassDescriptor, pipelinedChildren, elements); } } } }
Source:
<code>public boolean chkAuthorization(String userName, Object accessObject, String[] userRoles) throws QuadrigaStorageException, QuadrigaAccessException { IDictionary dictionary; String dictionaryId = null; if (accessObject instanceof String) { dictionaryId = (String) accessObject; dictionary = dictonaryManager.getDictionaryDetails(dictionaryId); } else { try { dictionary = (IDictionary) accessObject; } catch (ClassCastException cce) { throw new IllegalObjectException(cce); } } if (dictionary == null) { throw new QuadrigaAccessException(); } String dictionaryOwner = dictionary.getOwner().getUserName(); if (userName.equals(dictionaryOwner)) { return true; } if (userRoles.length == 0) return false; List<String> roles = Arrays.asList(userRoles); <START> List<IDictionaryCollaborator> dictCollaboratorList = dictonaryManager.showCollaboratingUsers(dictionaryId); <END> if (dictCollaboratorList == null || dictCollaboratorList.isEmpty()) return false; for (IDictionaryCollaborator dictCollaborator : dictCollaboratorList) { String collaboratorName = dictCollaborator.getCollaborator().getUserObj().getUserName(); if (userName != null && userName.equals(collaboratorName)) { List<IQuadrigaRole> collaboratorRoles = dictCollaborator.getCollaborator().getCollaboratorRoles(); if (collaboratorRoles != null) { for (IQuadrigaRole collabRole : collaboratorRoles) { String collaboratorRoleId = collabRole.getId(); if (roles != null) { if (roles.contains(collaboratorRoleId)) { return true; } } } } } } return false; }</code><technical_language>this work if do check a dictionary object dictionary id</technical_language>

Target:
public boolean chkAuthorization(String userName, Object accessObject, String[] userRoles) throws QuadrigaStorageException, QuadrigaAccessException { IDictionary dictionary; if (accessObject instanceof String) { String dictionaryId = (String) accessObject; dictionary = dictonaryManager.getDictionaryDetails(dictionaryId); } else { try { dictionary = (IDictionary) accessObject; } catch (ClassCastException cce) { throw new IllegalObjectException(cce); } } if (dictionary == null) { throw new QuadrigaAccessException(); } String dictionaryOwner = dictionary.getOwner().getUserName(); if (userName.equals(dictionaryOwner)) { return true; } if (userRoles.length == 0) return false; List<String> roles = Arrays.asList(userRoles); List<IDictionaryCollaborator> dictCollaboratorList = dictonaryManager .showCollaboratingUsers(dictionary.getDictionaryId()); if (dictCollaboratorList == null || dictCollaboratorList.isEmpty()) return false; for (IDictionaryCollaborator dictCollaborator : dictCollaboratorList) { String collaboratorName = dictCollaborator.getCollaborator().getUserObj().getUserName(); if (userName != null && userName.equals(collaboratorName)) { List<IQuadrigaRole> collaboratorRoles = dictCollaborator.getCollaborator().getCollaboratorRoles(); if (collaboratorRoles != null) { for (IQuadrigaRole collabRole : collaboratorRoles) { String collaboratorRoleId = collabRole.getId(); if (roles != null) { if (roles.contains(collaboratorRoleId)) { return true; } } } } } } return false; }
Source:
<code>public TopologyDescriptor generateConfigWithRoleSwitch() { TopologyDescriptor currentConfig = new TopologyDescriptor(topologyConfig); List<ClusterDescriptor> newActiveClusters = new ArrayList<>(); List<ClusterDescriptor> newStandbyClusters = new ArrayList<>(); currentConfig.getActiveClusters().values().forEach(activeCluster -> newStandbyClusters.add(new ClusterDescriptor(activeCluster, ClusterRole.STANDBY))); currentConfig.getStandbyClusters().values().forEach(standbyCluster -> <START> newActiveClusters.add(new ClusterDescriptor(standbyCluster, ClusterRole.ACTIVE))); <END> return new TopologyDescriptor(++epoch, newActiveClusters, newStandbyClusters); }</code><technical_language>I support actives</technical_language>

Target:
public TopologyDescriptor generateConfigWithRoleSwitch() { TopologyDescriptor currentConfig = new TopologyDescriptor(topologyConfig); List<ClusterDescriptor> newActiveClusters = new ArrayList<>(); List<ClusterDescriptor> newStandbyClusters = new ArrayList<>(); currentConfig.getActiveClusters().values().forEach(activeCluster -> newStandbyClusters.add(new ClusterDescriptor(activeCluster, ClusterRole.STANDBY))); for (ClusterDescriptor standbyCluster : currentConfig.getStandbyClusters().values()) { if (newActiveClusters.isEmpty()) { newActiveClusters.add(new ClusterDescriptor(standbyCluster, ClusterRole.ACTIVE)); } else { newStandbyClusters.add(new ClusterDescriptor(standbyCluster, ClusterRole.STANDBY)); } } return new TopologyDescriptor(++configId, newActiveClusters, newStandbyClusters); }
Source:
<code>private String getMessage() { <START> return "Uncovered range found"; <END> }</code><technical_language>I this is in kie-wb-common log message, fact/field, some more details</technical_language>

Target:
private String getMessage() { return "Uncovered range found " + toString(); }
Source:
<code>public void testHandleTransitionValidation__AssigneesNull() throws OseeCoreException { AtsTestUtil.cleanupAndReset("TransitionManagerTest-F"); <START> TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf(); <END> List<IAtsUser> assigneesBefore = teamArt.getAssignees(); MockTransitionHelper helper = new MockTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt), AtsTestUtil.getImplementStateDef().getName(), null, null, TransitionOption.None); TransitionManager transMgr = new TransitionManager(helper); TransitionResults results = new TransitionResults(); TransitionResults results01 = new TransitionResults(); transMgr.handleTransitionValidation(results); Assert.assertTrue(results.isEmpty()); results01 = transMgr.handleAll(); transMgr.getTransaction().execute(); Assert.assertTrue(results01.isEmpty()); List<IAtsUser> assigneesAfter = teamArt.getAssignees(); Assert.assertTrue(assigneesAfter.containsAll(assigneesBefore)); Assert.assertTrue(assigneesBefore.containsAll(assigneesAfter)); }</code><technical_language>want Assert assignees</technical_language>

Target:
public void testHandleTransitionValidation__AssigneesNull() throws OseeCoreException { AtsTestUtil.cleanupAndReset("TransitionManagerTest-F"); TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf(); List<IAtsUser> assigneesBefore = teamArt.getAssignees(); Assert.assertTrue(assigneesBefore.size() > 0); MockTransitionHelper helper = new MockTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt), AtsTestUtil.getImplementStateDef().getName(), null, null, TransitionOption.None); TransitionManager transMgr = new TransitionManager(helper); TransitionResults results = new TransitionResults(); TransitionResults results01 = new TransitionResults(); transMgr.handleTransitionValidation(results); Assert.assertTrue(results.isEmpty()); results01 = transMgr.handleAll(); transMgr.getTransaction().execute(); Assert.assertTrue(results01.isEmpty()); List<IAtsUser> assigneesAfter = teamArt.getAssignees(); Assert.assertTrue(assigneesAfter.containsAll(assigneesBefore)); Assert.assertTrue(assigneesBefore.containsAll(assigneesAfter)); }
Source:
<code>protected boolean canDoAction() { if (!super.canDoAction()) { return false; } if (!CheckStoragePool()) { return false; } if (validateStoragePoolName()) { return false; } <START> <END> if (!validateStoragePoolTypeChange()) { return false; } if (!CheckStoragePoolNameLengthValid()) { return false; } if (!valdiateComptibilityVersionChange()) { return false; } if (!isNotLocalfsWithDefaultCluster()) { return false; } addCanDoActionMessage(VdcBllMessages.VAR__ACTION__UPDATE); return true; }</code><technical_language>java is reason for trailing spaces</technical_language>

Target:
protected boolean canDoAction() { if (!super.canDoAction()) { return false; } if (!CheckStoragePool()) { return false; } if (!validateStoragePoolName()) { return false; } if (!validateStoragePoolTypeChange()) { return false; } if (!CheckStoragePoolNameLengthValid()) { return false; } if (!validateCompatibilityVersionChange()) { return false; } if (!isNotLocalfsWithDefaultCluster()) { return false; } addCanDoActionMessage(VdcBllMessages.VAR__ACTION__UPDATE); return true; }
Source:
<code>public void testCreateFileHeader_GitLink() throws Exception { ObjectId aId = blob("a\n"); ObjectId bId = blob("b\n"); String diffHeader = makeDiffHeaderModeChange(PATH_A, PATH_A, aId, bId, GITLINK, REGULAR_FILE) + "-Subproject commit " + aId.name() + "\n"; DiffEntry ad = DiffEntry.delete(PATH_A, aId); ad.oldMode = FileMode.GITLINK; DiffEntry abcd = DiffEntry.add(PATH_A, bId); <START> DiffEntry mod = DiffEntry.pair(ChangeType.MODIFY, ad, abcd, 50); <END> FileHeader fh = df.createFileHeader(mod); assertEquals(diffHeader, RawParseUtils.decode(fh.getBuffer())); assertEquals(1, fh.getHunks().size()); HunkHeader hh = fh.getHunks().get(0); assertEquals(0, hh.toEditList().size()); }</code><technical_language>Again, score</technical_language>

Target:
public void testCreateFileHeader_GitLink() throws Exception { ObjectId aId = blob("a\n"); ObjectId bId = blob("b\n"); String diffHeader = makeDiffHeaderModeChange(PATH_A, PATH_A, aId, bId, GITLINK, REGULAR_FILE) + "-Subproject commit " + aId.name() + "\n"; DiffEntry ad = DiffEntry.delete(PATH_A, aId); ad.oldMode = FileMode.GITLINK; DiffEntry abcd = DiffEntry.add(PATH_A, bId); DiffEntry mod = DiffEntry.pair(ChangeType.MODIFY, ad, abcd, 0); FileHeader fh = df.createFileHeader(mod); assertEquals(diffHeader, RawParseUtils.decode(fh.getBuffer())); assertEquals(1, fh.getHunks().size()); HunkHeader hh = fh.getHunks().get(0); assertEquals(0, hh.toEditList().size()); }
Source:
<code>public void encodeCompleteResponse(){ HashMap<String,String> entry = new HashMap<>(); entry.put("foo", "bar"); jedis.xadd( "mystream", StreamEntryID.NEW_ENTRY, entry ); String status = jedis.xgroupCreate("mystream", "mygroup", null, false); Object obj = jedis.sendCommand(XINFO, "STREAM", "mystream"); <START> ArrayList encodeObj = (ArrayList)SafeEncoder.encodeObject(obj); <END> assertEquals( 14, encodeObj.size() ); assertEquals( "length", encodeObj.get(0) ); assertEquals( 1L, encodeObj.get(1) ); ArrayList entryAsList = new ArrayList(2); entryAsList.add("foo"); entryAsList.add("bar"); assertEquals( entryAsList, ((ArrayList)encodeObj.get(11)).get(1) ); assertEquals("PONG", SafeEncoder.encodeObject(jedis.sendCommand(PING))); entry.put("foo2", "bar2"); jedis.hset("hash:test:encode", entry); encodeObj = (ArrayList)SafeEncoder.encodeObject(jedis.sendCommand(HGETALL, "hash:test:encode")); assertEquals( 4, encodeObj.size() ); assertEquals( "foo", encodeObj.get(0) ); assertEquals( "foo2", encodeObj.get(2) ); }</code><technical_language>This subsequent type casts List instead of ArrayList</technical_language>

Target:
public void encodeCompleteResponse(){ HashMap<String,String> entry = new HashMap<>(); entry.put("foo", "bar"); jedis.xadd( "mystream", StreamEntryID.NEW_ENTRY, entry ); String status = jedis.xgroupCreate("mystream", "mygroup", null, false); Object obj = jedis.sendCommand(XINFO, "STREAM", "mystream"); List encodeObj = (List)SafeEncoder.encodeObject(obj); assertEquals( 14, encodeObj.size() ); assertEquals( "length", encodeObj.get(0) ); assertEquals( 1L, encodeObj.get(1) ); List entryAsList = new ArrayList(2); entryAsList.add("foo"); entryAsList.add("bar"); assertEquals( entryAsList, ((List)encodeObj.get(11)).get(1) ); assertEquals("PONG", SafeEncoder.encodeObject(jedis.sendCommand(PING))); entry.put("foo2", "bar2"); jedis.hset("hash:test:encode", entry); encodeObj = (List)SafeEncoder.encodeObject(jedis.sendCommand(HGETALL, "hash:test:encode")); assertEquals( 4, encodeObj.size() ); assertTrue(encodeObj.contains("foo")); assertTrue(encodeObj.contains("foo2")); }
Source:
<code>private boolean isVolumeEncrypted(Volume volume) throws ReadContentInputStream.ReadContentInputStreamException, IOException, TskCoreException { <START> boolean possiblyEncrypted = true; <END> if (possiblyEncrypted) { calculatedEntropy = EncryptionDetectionTools.calculateEntropy(volume); if (calculatedEntropy >= minimumEntropy) { return true; } } return false; }</code><technical_language>code right is conditional this, definitively this "true". written, this variable necessary for this method. original source of this code, variable initialized "false", if 'calculatedEntropy' greater equal 'minimumEntropy', variable set "true". final operation of method, variable returned. done. If preference is simply return "true" "false" directly, get rid of variable condition check</technical_language>

Target:
private boolean isVolumeEncrypted(Volume volume) throws ReadContentInputStream.ReadContentInputStreamException, IOException, TskCoreException { if (volume.getFileSystems().isEmpty()) { calculatedEntropy = EncryptionDetectionTools.calculateEntropy(volume); if (calculatedEntropy >= minimumEntropy) { return true; } } return false; }
Source:
<code>public void setUp() throws Exception { String os = System.getProperty("os.name"); if (os != null && os.toLowerCase().startsWith("windows")) { isWindows = true; } if (!isWindows) { tempProj = Files.createTempDirectory("temp").toFile(); assertTrue(tempProj.exists()); basicDevProj = new File("../resources/basic-dev-project"); assertTrue(basicDevProj.exists()); FileUtils.copyDirectoryStructure(basicDevProj, tempProj); assertTrue(tempProj.listFiles().length > 0); logFile = new File(basicDevProj, "/logFile.txt"); logFile.createNewFile(); <START> String pluginVersion = System.getProperty("testing"); <END> File pomXML = new File(tempProj, "/pom.xml"); assertTrue(pomXML.exists()); Path path = pomXML.toPath(); Charset charset = StandardCharsets.UTF_8; String content = new String(Files.readAllBytes(path), charset); content = content.replaceAll("SUB_VERION", pluginVersion); Files.write(path, content.getBytes(charset)); } }</code><technical_language>move this logic for replacing plugin version a method for readability</technical_language>

Target:
public void setUp() throws Exception { String os = System.getProperty("os.name"); if (os != null && os.toLowerCase().startsWith("windows")) { isWindows = true; } if (!isWindows) { tempProj = Files.createTempDirectory("temp").toFile(); assertTrue(tempProj.exists()); basicDevProj = new File("../resources/basic-dev-project"); assertTrue(basicDevProj.exists()); FileUtils.copyDirectoryStructure(basicDevProj, tempProj); assertTrue(tempProj.listFiles().length > 0); logFile = new File(basicDevProj, "/logFile.txt"); logFile.createNewFile(); replaceVersion(); } }
Source:
<code>public String getConfirmationLink() { StringBuilder ref = new StringBuilder(); ref.append(Const.ActionURIs.INSTRUCTOR_COURSE_JOIN_AUTHENTICATED).append("?key=").append(regkey); if (institute != null) { ref.append('&').append(Const.ParamsNames.INSTRUCTOR_INSTITUTION).append('=') .append(Sanitizer.sanitizeForUri(institute)); } <START> return ref.toString(); <END> }</code><technical_language>Again, if more readable, this be: java return Const.* + "?key=" + regkey + (institute == null ? "" : ("&" + ... + "=" + ...));</technical_language>

Target:
public String getConfirmationLink() { return Const.ActionURIs.INSTRUCTOR_COURSE_JOIN_AUTHENTICATED + "?key=" + regkey + (institute == null ? "" : '&' + Const.ParamsNames.INSTRUCTOR_INSTITUTION + '=' + Sanitizer.sanitizeForUri(institute)); }
Source:
<code>public DockerImageName apply(final DockerImageName original) { <START> return null; <END> }</code><technical_language>suggestion return original;</technical_language>

Target:
public DockerImageName apply(final DockerImageName original) { return DockerImageName.parse("transformed-" + original.asCanonicalNameString()); }
Source:
<code>public HandlesEventDispatching getDispatchDelegate() { <START> return null; <END> }</code><technical_language>This return form, null</technical_language>

Target:
public HandlesEventDispatching getDispatchDelegate() { return this.container.getDispatchDelegate(); }
Source:
<code>public PhysicalOperation visitExchange(ExchangeNode node, LocalExecutionPlanContext context) { checkArgument(node.getScope() == LOCAL, "Only local exchanges are supported in the local planner"); if (node.getOrderingScheme().isPresent()) { return createLocalMerge(node, context); } else { return createLocalExchange(node, context); <START> } <END> }</code><technical_language>nit: prefer put else return in codebase</technical_language>

Target:
public PhysicalOperation visitExchange(ExchangeNode node, LocalExecutionPlanContext context) { checkArgument(node.getScope() == LOCAL, "Only local exchanges are supported in the local planner"); if (node.getOrderingScheme().isPresent()) { return createLocalMerge(node, context); } return createLocalExchange(node, context); }
Source:
<code>public void write(final IDocumentFragment fragment, final OutputStream out) throws IOException { final org.eclipse.jface.text.Document doc = new org.eclipse.jface.text.Document(); docPrintln(doc, "<?xml version='1.0' encoding='UTF-8'?>"); writeNode(fragment, doc, ""); <START> final PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(out, "UTF-8")); <END> printWriter.print(doc.get()); printWriter.flush(); }</code><technical_language>extract method</technical_language>

Target:
public void write(final IDocumentFragment fragment, final OutputStream out) throws IOException { final org.eclipse.jface.text.Document doc = new org.eclipse.jface.text.Document(); docPrintln(doc, "<?xml version='1.0' encoding='UTF-8'?>"); writeNode(fragment, doc, ""); writeToOutputStream(out, doc); }
Source:
<code>public void testForkEnvironmentNull() throws InvalidScriptException { fe = null; Boolean result = new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd); <START> assertEquals(false, result); <END> }</code><technical_language>assertEquals is relevant</technical_language>

Target:
public void testForkEnvironmentNull() throws InvalidScriptException { fe = null; Mockito.when(etd.getInternal()).thenReturn(it); Mockito.when(it.getForkEnvironment()).thenReturn(fe); assertFalse(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd)); }
Source:
<code>public static final Classifier createSpecializedClassifier(final Classifier general, final Classifier parent, final StructuralFeature structuralFeature) { for (final Class<? extends Classifier> c : UNSPECIALIZABLE_CLASSIFIERS) { if (c.isAssignableFrom(general.getClass())) { Application.getInstance().getGUILog() <START> .log("Warning: " + (structuralFeature != null ? structuralFeature.getQualifiedName() : "< >") + " is a " + c.getSimpleName() + ", which is not specializable."); <END> return null; } } Classifier specific = (Classifier) CopyPasting.copyPasteElement(general, parent); ArrayList<NamedElement> members = new ArrayList<>(); for(NamedElement ne : specific.getOwnedMember()){ members.add(ne); } for(NamedElement member : members){ if(member instanceof RedefinableElement) { System.out.println(member.getClassType().getName() + " removing " + member.getName()); specific.getOwnedMember().remove(member); member.dispose(); } } specific.getGeneralization().clear(); SpecializeClassifierAction.specialize(specific, general); return specific; }</code><technical_language>*[WARNING]</technical_language>

Target:
public static final Classifier createSpecializedClassifier(final Classifier general, final Classifier parent, final StructuralFeature structuralFeature) { for (final Class<? extends Classifier> c : UNSPECIALIZABLE_CLASSIFIERS) { if (c.isAssignableFrom(general.getClass())) { Application.getInstance().getGUILog() .log("[WARNING] " + (structuralFeature != null ? structuralFeature.getQualifiedName() : "< >") + " is a " + c.getSimpleName() + ", which is not specializable."); return null; } } Classifier specific = (Classifier) CopyPasting.copyPasteElement(general, parent); ArrayList<NamedElement> members = new ArrayList<>(); for(NamedElement ne : specific.getOwnedMember()){ members.add(ne); } for(NamedElement member : members){ if(member instanceof RedefinableElement) { specific.getOwnedMember().remove(member); member.dispose(); } } specific.getGeneralization().clear(); SpecializeClassifierAction.specialize(specific, general); return specific; }
Source:
<code>public MultiTreeTransformer(List<Map<String, Object>> initList){ <START> List<MultiTree> newList = new ArrayList<>(); <END> if (initList != null){ for(Map<String, Object> map : initList){ newList.add(transform(map)); } } this.list = newList; }</code><technical_language>Consider ImmutableList</technical_language>

Target:
public MultiTreeTransformer(List<Map<String, Object>> initList){ if (initList != null){ for(Map<String, Object> map : initList){ this.list.add(transform(map)); } } }