auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
START String toDMNString(final String years, END final String months) { final YearsMonthsValue value = new YearsMonthsValue(); value.setYears(years); value.setMonths(months); return toDMNString(value); } I think `fromDMNString` and `toDMNString` can be public as they are the main feature of this class, or do I miss something?

Target:
public String toDMNString(final String years, final String months) { final YearsMonthsValue value = new YearsMonthsValue(); value.setYears(years); value.setMonths(months); return toDMNString(value); }
Source:
START String toDisplayValue(final String dmnValue) { END final YearsMonthsValue yearsMonthsValue = fromDMNString(dmnValue); return toDisplayValue(yearsMonthsValue); } Maybe also this could be public and rest could be private?

Target:
public String toDisplayValue(final String dmnValue) { final YearsMonthsValue yearsMonthsValue = fromDMNString(dmnValue); return toDisplayValue(yearsMonthsValue); }
Source:
public static boolean isTypeOf(Class<?> type, Object instance) { START return instance.getClass().isAssignableFrom(type); END } I'm fine on doing this on all server side classes, but in this case for `ClassUtils`, which is inside `core-common` module, it's not correct, because that class is also visible to the GWT compiler, and as far as I know it does not emulate the `isAssignableFrom` method from JRE... That's the reason I remember to do the comparison via classname, which the method is emulated and so we can always compare on js two strings... but feel free to test it guys, if I'm wrong lemme know and I'm agree on this change.

Target:
public static boolean isTypeOf(Class<?> type, Object instance) { return instance.getClass().getName().equals(type.getName()); }
Source:
String toDisplay(final String rawValue) { if (StringUtils.isEmpty(rawValue)) { return ""; } final String dateString = removePrefixAndSuffix(rawValue); try { START final java.util.Date date = RAW_FORMAT.parse(dateString); END return DISPLAY_FORMAT.format(date); } catch (final IllegalArgumentException exception) { return ""; } } Could we please add `java.util.Date ` to imports and use declare variable just like `final Date date = RAW_FORMAT.parse(dateString);`

Target:
String toDisplay(final String rawValue) { if (StringUtils.isEmpty(rawValue)) { return ""; } final String dateString = removePrefixAndSuffix(rawValue); try { final Date date = RAW_FORMAT.parse(dateString); return DISPLAY_FORMAT.format(date); } catch (final IllegalArgumentException exception) { return ""; } }
Source:
START private static void mockAdapterRegistry(BackendDefinitionAdapter definitionAdapter, BackendDefinitionSetAdapter definitionSetAdapter, BackendPropertySetAdapter propertySetAdapter, BackendPropertyAdapter propertyAdapter) { END when(adapterRegistry.getDefinitionSetAdapter(any(Class.class))).thenReturn(definitionSetAdapter); when(adapterRegistry.getDefinitionAdapter(any(Class.class))).thenReturn(definitionAdapter); when(adapterRegistry.getPropertySetAdapter(any(Class.class))).thenReturn(propertySetAdapter); when(adapterRegistry.getPropertyAdapter(any(Class.class))).thenReturn(propertyAdapter); } Do the methods need to be static?

Target:
private void mockAdapterRegistry(BackendDefinitionAdapter definitionAdapter, BackendDefinitionSetAdapter definitionSetAdapter, BackendPropertySetAdapter propertySetAdapter, BackendPropertyAdapter propertyAdapter) { when(adapterRegistry.getDefinitionSetAdapter(any(Class.class))).thenReturn(definitionSetAdapter); when(adapterRegistry.getDefinitionAdapter(any(Class.class))).thenReturn(definitionAdapter); when(adapterRegistry.getPropertySetAdapter(any(Class.class))).thenReturn(propertySetAdapter); when(adapterRegistry.getPropertyAdapter(any(Class.class))).thenReturn(propertyAdapter); }
Source:
START public void testGetDiagram(){ END final CanvasHandler handler = mock(CanvasHandler.class); doNothing().when(presenter).refreshTreeView(); final Diagram expectedDiagram = mock(Diagram.class); doReturn(expectedDiagram).when(handler).getDiagram(); presenter.setHandler(handler); final Diagram actual = presenter.getDiagram(); assertEquals(expectedDiagram, actual); } I think there's a format issue here: ```suggestion public void testGetDiagram() { ```

Target:
public void testGetDiagram() { final CanvasHandler handler = mock(CanvasHandler.class); final Diagram expectedDiagram = mock(Diagram.class); doNothing().when(presenter).refreshTreeView(); doReturn(expectedDiagram).when(handler).getDiagram(); presenter.setHandler(handler); final Diagram actual = presenter.getDiagram(); assertEquals(expectedDiagram, actual); }
Source:
public UpdateCanvasControlPointPositionCommand(final Edge edge, final ControlPoint[] controlPoints) { this.edge = edge; this.controlPoints = controlPoints; // Actual control points must be cloned at this point, before execution. oldControlPoints = Stream.of(getControlPoints(edge)) .map(ControlPoint::copy) .toArray(ControlPoint[]::new); START ; END } unnecessary **;**

Target:
public UpdateCanvasControlPointPositionCommand(final Edge edge, final ControlPoint[] controlPoints) { this.edge = edge; this.controlPoints = controlPoints; // Actual control points must be cloned at this point, before execution. oldControlPoints = Stream.of(getControlPoints(edge)) .map(ControlPoint::copy) .toArray(ControlPoint[]::new); }
Source:
public void setup() { START this.literalExpression = spy(new LiteralExpression()); END } Do we need `spy` in this case?

Target:
public void setup() { this.literalExpression = new LiteralExpression(); }
Source:
START public void disableOkButton() { END modal.disableOkButton(); } I think this could be `package-private`: ```suggestion void disableOkButton() { ```

Target:
void disableOkButton() { modal.disableOkButton(); }
Source:
public void testInit() { final DataTypeConstraintRangeView mocked = mock(DataTypeConstraintRangeView.class); doCallRealMethod().when(mocked).init(any()); mocked.init(presenter); START verify(mocked).setupInputFields(); END } We can change the `setup` method to this: ```java @Before public void setup() { view = spy(new DataTypeConstraintRangeView(startValue, endValue, includeStartValue, includeEndValue)); } ``` ..to simplify this method to this: ```java @Test public void testInit() { view.init(presenter); verify(view).setupInputFields(); } ```

Target:
public void testInit() { verify(view).setupInputFields(); }
Source:
START public void setup() { END final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, DMNModelInstrumentedBase.Namespace.KIE.getPrefix()); when(dmnUnary.getId()).thenReturn(ID); when(dmnUnary.getAdditionalAttributes()).thenReturn(additionalAttributes); when(dmnUnary.getText()).thenReturn(TEXT); when(additionalAttributes.getOrDefault(key, "")).thenReturn(CONSTRAINT_TYPE_TEXT); } ```java @RunWith(MockitoJUnitRunner.class) public class InputClauseUnaryTestsPropertyConverterTest { private static final String ID = "thisId"; private static final String TEXT = "1,2,3"; private static final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, DMNModelInstrumentedBase.Namespace.KIE.getPrefix()); @Mock private org.kie.dmn.model.api.UnaryTests dmnUnary; @Mock private Map<QName, String> additionalAttributes; @Before public void setup() { when(dmnUnary.getId()).thenReturn(ID); when(dmnUnary.getAdditionalAttributes()).thenReturn(additionalAttributes); when(dmnUnary.getText()).thenReturn(TEXT); } @Test public void testWbFromDMNEnumeration() { testWbFromDMN(ConstraintType.ENUMERATION); } @Test public void testWbFromDMNExpression() { testWbFromDMN(ConstraintType.EXPRESSION); } @Test public void testWbFromDMNRange() { testWbFromDMN(ConstraintType.RANGE); } private void testWbFromDMN(final ConstraintType constraintType) { when(additionalAttributes.getOrDefault(key, "")).thenReturn(constraintType.name().toLowerCase()); final InputClauseUnaryTests inputClause = InputClauseUnaryTestsPropertyConverter.wbFromDMN(dmnUnary); assertEquals(inputClause.getConstraintType(), constraintType); assertEquals(inputClause.getId().getValue(), ID); assertEquals(inputClause.getText().getValue(), TEXT); } } ```

Target:
public void setup() { when(dmnUnary.getId()).thenReturn(ID); when(dmnUnary.getAdditionalAttributes()).thenReturn(additionalAttributes); when(dmnUnary.getText()).thenReturn(TEXT); }
Source:
void load(final String type, final String value, final ConstraintType constraintType) { this.constraintValue = value; START if (!Objects.isNull(value) && !value.isEmpty() && constraintType == null) { END this.constraintType = inferComponentType(value); } else { this.constraintType = constraintType; } prepareView(type, value, constraintType); } We can shorten this condition: ```java (StringUtils.nonEmpty(value) && constraintType == null) ``` FQN for `StringUtils` is `org.kie.workbench.common.stunner.core.util.StringUtils`

Target:
void load(final String type, final String value, final ConstraintType constraintType) { this.constraintValue = value; if (!StringUtils.isEmpty(value) && constraintType == null) { this.constraintType = inferComponentType(value); } else { this.constraintType = constraintType; } prepareView(type, value, constraintType); }
Source:
void onSelectChange(final JQuerySelectPickerEvent event) { final String constraintType = event.target.value; if (!isEmpty(constraintType)) { START ConstraintType constraint = ConstraintType.fromString(constraintType); END loadComponent(constraint); presenter.setConstraintType(constraint); } } I would add a `final` here: ```suggestion final ConstraintType constraint = ConstraintType.fromString(constraintType); ```

Target:
void onSelectChange(final JQuerySelectPickerEvent event) { final String constraintType = event.target.value; if (!isEmpty(constraintType)) { final ConstraintType constraint = ConstraintType.fromString(constraintType); loadComponent(constraint); presenter.setConstraintType(constraint); } }
Source:
public void setUp() throws Exception { super.setUp(); when(canvasPanel.getLocationConstraints()).thenReturn(PANEL_BOUNDS); when(candidate.getContent()).thenReturn(new ViewImpl<>(mock(Object.class), ELEMENT_BOUNDS)); START ; END } Useless semicolon.

Target:
public void setUp() throws Exception { super.setUp(); when(canvasPanel.getLocationConstraints()).thenReturn(PANEL_BOUNDS); when(candidate.getContent()).thenReturn(new ViewImpl<>(mock(Object.class), ELEMENT_BOUNDS)); }
Source:
START private String parseFunctionClose() throws ParseException { END int index = nextNonBlank(); if (index < 0 || expression.charAt(index) != ')') { throw new ParseException(errorMessage(FUNCTION_CALL_NOT_CLOSED_PROPERLY_ERROR, functionName), parseIndex); } setParseIndex(index + 1); return ")"; } Return value of the method is never used.

Target:
private void parseFunctionClose() throws ParseException { int index = nextNonBlank(); if (index < 0 || expression.charAt(index) != ')') { throw new ParseException(errorMessage(FUNCTION_CALL_NOT_CLOSED_PROPERLY_ERROR, functionName), parseIndex); } setParseIndex(index + 1); }
Source:
START private String parseParamDelimiter() throws ParseException { END int index = nextNonBlank(); if (index < 0 || expression.charAt(index) != ',') { throw new ParseException(errorMessage(PARAMETER_DELIMITER_EXPECTED_ERROR), parseIndex); } setParseIndex(index + 1); return ","; } Return value of the method is never used.

Target:
private void parseParamDelimiter() throws ParseException { int index = nextNonBlank(); if (index < 0 || expression.charAt(index) != ',') { throw new ParseException(errorMessage(PARAMETER_DELIMITER_EXPECTED_ERROR), parseIndex); } setParseIndex(index + 1); }
Source:
START public void testUnaryFunctionsParsingUnsuccessful() throws Exception { END for (String function : unaryFunctions) { testFunctionParsingUnsuccessful(function, failingUnaryFunctionExpressions); } } Exception is never thrown in the method.

Target:
public void testUnaryFunctionsParsingUnsuccessful() { for (String function : unaryFunctions) { testFunctionParsingUnsuccessful(function, failingUnaryFunctionExpressions); } }
Source:
START ParamDef mockParamDef(String name, String type) { END ParamDef paramDef = mock(ParamDef.class); when(paramDef.getName()).thenReturn(name); when(paramDef.getType()).thenReturn(type); return paramDef; } This method can be private.

Target:
private ParamDef mockParamDef(String name, String type) { ParamDef paramDef = mock(ParamDef.class); when(paramDef.getName()).thenReturn(name); when(paramDef.getType()).thenReturn(type); return paramDef; }
Source:
START ConditionParamPresenter mockParamPresenter() { END ConditionParamPresenter paramPresenter = mock(ConditionParamPresenter.class); ConditionParamPresenter.View paramPresenterView = mock(ConditionParamPresenter.View.class); HTMLElement element = mock(HTMLElement.class); when(paramPresenter.getView()).thenReturn(paramPresenterView); when(paramPresenterView.getElement()).thenReturn(element); return paramPresenter; } This method can be private.

Target:
private ConditionParamPresenter mockParamPresenter() { ConditionParamPresenter paramPresenter = mock(ConditionParamPresenter.class); ConditionParamPresenter.View paramPresenterView = mock(ConditionParamPresenter.View.class); HTMLElement element = mock(HTMLElement.class); when(paramPresenter.getView()).thenReturn(paramPresenterView); when(paramPresenterView.getElement()).thenReturn(element); return paramPresenter; }
Source:
public void onOrganizationalUnitRemoved(@Observes final AfterDeleteOrganizationalUnitEvent removedOrganizationalUnitEvent) { START if (isLibraryPerspectiveOpen() && isSpaceActive(removedOrganizationalUnitEvent)) { END projectContext.getActiveOrganizationalUnit() .filter(active -> active.equals(removedOrganizationalUnitEvent.getOrganizationalUnit())) .ifPresent(active -> goToOrganizationalUnits()); } } I'm wondering why we even need the method `isSpaceActive` and this additional check `&& isSpaceActive(removedOrganizationalUnitEvent)` when it's doing similar check as the `.filter(active -> active.equals(removedOrganizationalUnitEvent.getOrganizationalUnit()))` below. Can it happen that you can have 2 different OrganizationalUnits that are equal but don't have the same identifier? I think we should remove the newly added private isSpaceActive and remove that && check and it will behave the same.

Target:
public void onOrganizationalUnitRemoved(@Observes final AfterDeleteOrganizationalUnitEvent removedOrganizationalUnitEvent) { if (isLibraryPerspectiveOpen()) { projectContext.getActiveOrganizationalUnit() .filter(active -> active.equals(removedOrganizationalUnitEvent.getOrganizationalUnit())) .ifPresent(active -> this.goToOrganizationalUnits()); } }
Source:
START public void setup() throws Exception { END profileInstances = spy(new MockInstanceImpl<>(profile1, profile2)); tested = new BackendProfileManager(definitionUtils, profileInstances); } Method doesn't throw an exception.

Target:
public void setup() { profileInstances = spy(new MockInstanceImpl<>(profile1, profile2)); tested = new BackendProfileManager(definitionUtils, profileInstances); }
Source:
public void setup() throws Exception { START profileInstances = spy(new ManagedInstanceStub<Profile>(profile1, profile2)); END tested = new ClientProfileManager(definitionUtils, profileInstances); } Explicit type argument Profile can be replaced with <>.

Target:
public void setup() { profileInstances = spy(new ManagedInstanceStub<>(profile1, profile2)); tested = new ClientProfileManager(definitionUtils, profileInstances); }
Source:
public void save(String id) { context.saveStyle(); HashMap<String, String> map = new HashMap<>(); //setting the node id in case it exists on graph START Optional.ofNullable(id).ifPresent(node -> map.put(DEFAULT_NODE_ID, id)); END context.addAttributes(map); } Dtto.

Target:
public void save(String id) { context.saveStyle(); HashMap<String, String> map = new HashMap<>(); //setting the node id in case it exists on graph if (id != null) { map.put(DEFAULT_NODE_ID, id); } context.addAttributes(map); }
Source:
public ErrorsAndDMNModelAsSerialized(List<Message> messages, Definitions definitions) { START super(); END this.messages = Collections.unmodifiableList(messages); this.definitions = definitions; } We don't really need a call to `super()`

Target:
public ErrorsAndDMNModelAsSerialized(List<Message> messages, Definitions definitions) { this.messages = Collections.unmodifiableList(messages); this.definitions = definitions; }
Source:
public void testSetVisibleSizeAndRefresh() { uiModel.setVisibleSizeAndRefresh(0, 0); START verify(delegate).setVisibleSizeAndRefresh(eq(0), eq(0)); END } IMO it's better to use different values, e.g. `0` and `1` to be sure, for example, that the "delegated" method is not simply using the first parameter twice...

Target:
public void testSetVisibleSizeAndRefresh() { uiModel.setVisibleSizeAndRefresh(0, 1); verify(delegate).setVisibleSizeAndRefresh(eq(0), eq(1)); }
Source:
public Optional<?> getProperty(T pojo, String propertyName) { return ReflectionAdapterUtils.getFields(pojo.getClass()).stream() START .filter(f -> Objects.equals(propertyName, f.getName())) END .map(field -> Exceptions.swallow(() -> field.get(pojo), null)) .findFirst(); } Could we please use `field` instead of `f` to be consistent with line below?

Target:
public Optional<?> getProperty(T pojo, String propertyName) { return ReflectionAdapterUtils.getFields(pojo.getClass()).stream() .filter(field -> Objects.equals(propertyName, field.getName())) .map(field -> Exceptions.swallow(() -> field.get(pojo), null)) .findFirst(); }
Source:
private Optional<String> getGraphUUID() { final Diagram diagram = getDiagram(); if (Objects.isNull(diagram)) { return Optional.empty(); } final Graph graph = diagram.getGraph(); if (Objects.isNull(graph)) { return Optional.empty(); } return Optional.of(graph.getUUID()); START } END I think we could simplify this method with something like this: ```java private Optional<String> getGraphUUID() { if (Objects.isNull(getDiagram()) || Objects.isNull(getGraph())) { return Optional.empty(); } return Optional.of(getGraph().getUUID()); } ``` ..but feel free to keep it as is :-)

Target:
private Optional<String> getGraphUUID() { if (Objects.isNull(getGraph())) { return Optional.empty(); } return Optional.of(getGraph().getUUID()); }
Source:
public BPMNShapeFactory(final BasicShapesFactory basicShapesFactory, final SVGShapeFactory svgShapeFactory, final DelegateShapeFactory<BPMNDefinition, Shape> delegateShapeFactory, final ManagedInstance<WorkItemDefinitionRegistry> workItemDefinitionRegistry, final DefinitionUtils definitionUtils, final StunnerPreferencesRegistries preferencesRegistries) { this.basicShapesFactory = basicShapesFactory; this.svgShapeFactory = svgShapeFactory; this.delegateShapeFactory = delegateShapeFactory; START this.workItemDefinitionRegistry = () -> workItemDefinitionRegistry.get(); END this.definitionUtils = definitionUtils; this.preferencesRegistries = preferencesRegistries; } Not sure, why you replaced it, I prefer as it was, but it is matter of taste, so no needs to revert.

Target:
public BPMNShapeFactory(final BasicShapesFactory basicShapesFactory, final SVGShapeFactory svgShapeFactory, final DelegateShapeFactory<BPMNDefinition, Shape> delegateShapeFactory, final ManagedInstance<WorkItemDefinitionRegistry> workItemDefinitionRegistry, final DefinitionUtils definitionUtils, final StunnerPreferencesRegistries preferencesRegistries) { this.basicShapesFactory = basicShapesFactory; this.svgShapeFactory = svgShapeFactory; this.delegateShapeFactory = delegateShapeFactory; this.workItemDefinitionRegistry = workItemDefinitionRegistry::get; this.definitionUtils = definitionUtils; this.preferencesRegistries = preferencesRegistries; }
Source:
public void setup() throws Exception { CanvasCommandManagerImpl commandManager = new CanvasCommandManagerImpl(); when(canvasHandler.getCanvas()).thenReturn(canvas); when(clientSessionManager.getCurrentSession()).thenReturn(editorSession); when(editorSession.getCanvasHandler()).thenReturn(canvasHandler); when(editorSession.getCommandRegistry()).thenReturn(commandRegistry); when(editorSession.getCommandManager()).thenReturn(commandManager); START this.tested = new RequestCommandManager(clientSessionManager, commandRegisteredEvent); END } it is missing the `verify` of the commandRegisteredEvent fire on the tests. You can use the `EventSourceMock` to mock the event.

Target:
public void setup() throws Exception { CanvasCommandManagerImpl commandManager = new CanvasCommandManagerImpl(); when(canvasHandler.getCanvas()).thenReturn(canvas); when(clientSessionManager.getCurrentSession()).thenReturn(editorSession); when(editorSession.getCanvasHandler()).thenReturn(canvasHandler); when(editorSession.getCommandRegistry()).thenReturn(commandRegistry); when(editorSession.getCommandManager()).thenReturn(commandManager); this.tested = new RequestCommandManager(clientSessionManager); }
Source:
START public void setVirtual(final boolean virtual) { END this.isVirtual = virtual; } I think this method could be private.

Target:
private void setVirtual(final boolean virtual) { this.isVirtual = virtual; }
Source:
START public double getMedian() { END return median; } I think this method could be private.

Target:
private double getMedian() { return median; }
Source:
HTMLOptGroupElement makeOptionGroup(final String groupTitle, final List<DataType> dataTypes, final Function<DataType, String> dataTypeConsumer) { final HTMLOptGroupElement optionGroup = makeHTMLOptGroupElement(); optionGroup.label = groupTitle; dataTypes.stream() START .sorted(DATA_TYPE_COMPARATOR) END .forEach(dataType -> { final HTMLOptionElement option = makeOption(dataType, dataTypeConsumer); optionGroup.appendChild(option); }); return optionGroup; } Here we're ordering the data types by `DataType::getName`, however, take a look here: https://github.com/kiegroup/kie-wb-common/blob/0bb304e4805cabd3879c31d154add5a7ac486d75/kie-wb-common-dmn/kie-wb-common-dmn-client/src/main/java/org/kie/workbench/common/dmn/client/editors/types/listview/DataTypeSelectView.java#L102 ..we're using the `DataType::getType` function for default data types. So, I think they are not being correctly ordered.

Target:
HTMLOptGroupElement makeOptionGroup(final String groupTitle, final List<DataType> dataTypes, final Function<DataType, String> dataTypeConsumer) { final HTMLOptGroupElement optionGroup = makeHTMLOptGroupElement(); optionGroup.label = groupTitle; dataTypes.stream() .forEach(dataType -> { final HTMLOptionElement option = makeOption(dataType, dataTypeConsumer); optionGroup.appendChild(option); }); return optionGroup; }
Source:
START private boolean isNotCyclicEdge(final Edge edge) { END final String sourceId = edge.getSourceNode() != null ? edge.getSourceNode().getUUID() : null; final String targetId = edge.getTargetNode() != null ? edge.getTargetNode().getUUID() : null; return !Objects.equals(sourceId, targetId); } it can be `static`

Target:
private static boolean isNotCyclicEdge(final Edge edge) { final String sourceId = edge.getSourceNode() != null ? edge.getSourceNode().getUUID() : null; final String targetId = edge.getTargetNode() != null ? edge.getTargetNode().getUUID() : null; return !Objects.equals(sourceId, targetId); }
Source:
private Lane getLaneNodeById(Diagram<Graph, Metadata> diagram, String id) { Node<? extends Definition, ?> node = getNodebyId(diagram, id); START return Lane.class.cast(node.getContent().getDefinition()); END } I guess `return (Lane) node.getContent().getDefinition();` will be more clear here.

Target:
private Lane getLaneNodeById(Diagram<Graph, Metadata> diagram, String id) { Node<? extends Definition, ?> node = getNodebyId(diagram, id); return (Lane) node.getContent().getDefinition(); }
Source:
public List<DataType> all() { START return new ArrayList<>(dataTypes.values()); END } as the `all()` is used just internally I think we can rewrite it as: ```java public Collection<DataType> all() { return dataTypes.values(); } ```

Target:
private Collection<DataType> all() { return dataTypes.values(); }
Source:
START public static String getCaseFileVariableName(Property p) { END String name = p.getName(); // legacy uses ID instead of name return name == null ? p.getId() : name; } this could be private, or is it used on other classes?

Target:
private static String getCaseFileVariableName(Property p) { String name = p.getName(); // legacy uses ID instead of name return name == null ? p.getId() : name; }
Source:
START public WorkspaceCompilationInfo(Path prjPath, Properties bannedEnvVars) { END this.prjPath = prjPath; } why the bannedEnvVars, looks left over

Target:
public WorkspaceCompilationInfo(Path prjPath, Properties bannedEnvVars) { this.prjPath = prjPath; this.bannedEnvVars = bannedEnvVars; }
Source:
public void setup(final String headerKey, final String labelKey) { getView().setHeader(translationService.format(headerKey)); getView().setLabel(translationService.format(labelKey)); START superSetup(); END } same here, use _setup_

Target:
public void setup(final String headerKey, final String labelKey) { getView().setHeader(translationService.format(headerKey)); getView().setLabel(translationService.format(labelKey)); setup(); }
Source:
private static void write(String filename, String content) throws IOException { START BufferedWriter writer = new BufferedWriter(new FileWriter(filename)); END writer.write(content); writer.close(); } Please use try-with-resources

Target:
private static void write(String filename, String content) throws IOException { try(BufferedWriter writer = new BufferedWriter(new FileWriter(filename))) { writer.write(content); } }
Source:
public DefaultCompilationResponse(final Boolean successful, final List<String> mavenOutput, final Path workingDir, START final String requestUUID) { END this.successful = successful; if(mavenOutput != null) { this.mavenOutput = new ArrayList<>(mavenOutput); }else{ this.mavenOutput = Collections.emptyList(); } this.workingDir = workingDir; this.requestUUID = requestUUID; } This constructor should really be calling the more featureful constructor for consistency and to avoid duplication. Something like this: ``` this(successful, mavenOutput, workingDir, Collections.emptyList(), Collections.emptyList(), requestUUID); ```

Target:
public DefaultCompilationResponse(final Boolean successful, final List<String> mavenOutput, final Path workingDir, final String requestUUID) { this(successful,mavenOutput,workingDir, Collections.emptyList(), Collections.emptyList(), requestUUID); }
Source:
public static void setup() { START gitDaemonEnabled = System.getProperty("org.uberfire.nio.git.daemon.enabled"); END gitSshEnabled = System.getProperty("org.uberfire.nio.git.ssh.enabled"); System.setProperty("org.uberfire.nio.git.daemon.enabled", "false"); System.setProperty("org.uberfire.nio.git.ssh.enabled", "false"); } One more unnecessary "save and restore" of system property value. Please remove it to be consistent in the entire test suite and use `clearProperty` below.

Target:
public static void setup() { System.setProperty("org.uberfire.nio.git.daemon.enabled", "false"); System.setProperty("org.uberfire.nio.git.ssh.enabled", "false"); }
Source:
private <T> List<T> nullToEmpty(List<T> list) { if (list == null) { return Collections.emptyList(); START } else { END return new ArrayList<>(list); } } please remove else, code will be more readable

Target:
private <T> List<T> nullToEmpty(List<T> list) { if (list == null) { return Collections.emptyList(); } return new ArrayList<>(list); }
Source:
private Path getWorkingDir(String workingDir){ if(workingDir!= null){ return Paths.get("file://"+workingDir); } START else{ END return null; } } please remove else, code will be more readable; also follow KIE code style

Target:
private Path getWorkingDir(String workingDir){ if(workingDir!= null){ return Paths.get("file://"+workingDir); } return null; }
Source:
START public void updateEnhanced(final EnhancedDependency enhancedDependency) { END if (this.enhancedDependencies.contains(enhancedDependency)) { this.enhancedDependencies.update(enhancedDependency); } else { this.enhancedDependencies.add(enhancedDependency); } } Doesn't seem like this change is needed.

Target:
private void updateEnhanced(final EnhancedDependency enhancedDependency) { if (this.enhancedDependencies.contains(enhancedDependency)) { this.enhancedDependencies.update(enhancedDependency); } else { this.enhancedDependencies.add(enhancedDependency); } }
Source:
private ControlPointControlImpl.StunnerControlPointsAcceptor createStunnerControlPointsAcceptor(ControlPointControl controlPointControl) { Function<String, Edge> connectorSupplier = uuid -> uuid.equals(EDGE_UUID) ? edge : null; START ; END return new ControlPointControlImpl.StunnerControlPointsAcceptor(controlPointControl, connectorSupplier); } useless comma.

Target:
private ControlPointControlImpl.StunnerControlPointsAcceptor createStunnerControlPointsAcceptor(ControlPointControl controlPointControl) { Function<String, Edge> connectorSupplier = uuid -> uuid.equals(EDGE_UUID) ? edge : null; return new ControlPointControlImpl.StunnerControlPointsAcceptor(controlPointControl, connectorSupplier); }
Source:
public CommandResult<CanvasViolation> execute(AbstractCanvasHandler context) { ShapeUtils.removeControlPoints(candidate, context, controlPoints); START ShapeUtils.hideControlPoints(candidate, context); END ShapeUtils.showControlPoints(candidate, context); return buildResult(); } hide is after remove, doesn't it inverted?

Target:
public CommandResult<CanvasViolation> execute(AbstractCanvasHandler context) { ShapeUtils.hideControlPoints(candidate, context); ShapeUtils.removeControlPoints(candidate, context, controlPoints); ShapeUtils.showControlPoints(candidate, context); return buildResult(); }
Source:
public static List<URL> readAllDepsAsUrls(List<String> prjDeps) { List<URL> deps = new ArrayList<>(); for(String dep:prjDeps){ try { deps.add(new URL(dep)); }catch (MalformedURLException e){ logger.error(e.getMessage()); } } START if(deps.size()>0) { END return deps; }else{ return Collections.emptyList(); } } This if-else is redundand. Please replace it with just `return deps;` If no deps are added in the for loop, the deps will be empty ;) The same in the method below.

Target:
public static List<URL> readAllDepsAsUrls(List<String> prjDeps) { List<URL> deps = new ArrayList<>(); for (String dep : prjDeps) { try { deps.add(new URL(dep)); } catch (MalformedURLException e) { logger.error(e.getMessage()); } } return deps; }
Source:
public void buildAndSkipDepsNonExistentProject() throws Exception{ AFCompilerService service = new DefaultKieCompilerService(); CompletableFuture<KieCompilationResponse> futureRes = service.build(tmpRoot, mavenRepo.toString(), Boolean.FALSE); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isFalse(); assertThat(res.getDependencies().isEmpty()).isTrue(); START assertThat(res.getDependencies().size()).isEqualTo(0); END } Please replace `.size()).isEqualTo(` with `.hasSize(` 16x in this PR: Ctrl+f `.size()).isEqualTo(`

Target:
public void buildAndSkipDepsNonExistentProject() throws Exception{ AFCompilerService service = new DefaultKieCompilerService(); CompletableFuture<KieCompilationResponse> futureRes = service.build(tmpRoot, mavenRepo.toString(), Boolean.FALSE); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isFalse(); assertThat(res.getDependencies()).isEmpty(); }
Source:
public DefaultCompilationResponse(final Boolean successful, final List<String> mavenOutput, final Path workingDir, final List<String> targetContent, final List<String> projectDependencies) { this.successful = successful; this.mavenOutput = mavenOutput; this.workingDir = workingDir; START this.targetContent = targetContent; END this.projectDependencies = projectDependencies; } lists shouldn't be copied, best copy them; ```java this.targetContent = new ArrayList<>(targetContent); ``` as if anyone still holds access to the parameter list, it can modify it

Target:
public DefaultCompilationResponse(final Boolean successful, final List<String> mavenOutput, final Path workingDir, final List<String> targetContent, final List<String> projectDependencies) { this.successful = successful; this.mavenOutput = mavenOutput; this.workingDir = workingDir; this.targetContent = new ArrayList<>(targetContent); this.projectDependencies = new ArrayList<>(projectDependencies); }
Source:
public int hashCode() { START return HashUtil.combineHashCodes(Objects.hashCode(getClass().getName()), END Objects.hashCode(general), Objects.hashCode(backgroundSet), Objects.hashCode(fontSet), Objects.hashCode(dimensionsSet), Objects.hashCode(labels)); } what about just `getClass()` instead of `getClass().getName()`? Applies for all bellow...

Target:
public int hashCode() { return HashUtil.combineHashCodes(Objects.hashCode(getClass()), Objects.hashCode(general), Objects.hashCode(backgroundSet), Objects.hashCode(fontSet), Objects.hashCode(dimensionsSet), Objects.hashCode(labels)); }
Source:
public Package getSelectedPackage() { START if (packages.size() == 0) { END return null; } return packages.get(selectedPackage); } Optional nitpick: `packages.isEmpty()`

Target:
public Package getSelectedPackage() { if (packages.isEmpty()) { return null; } return packages.get(selectedPackage); }
Source:
public Optional<DecisionTable> getModelClass() { final DecisionTable dtable = new DecisionTable(); START return Optional.of(dtable); END } We could shorten now to `return Optional.of(new DecisionTable());`

Target:
public Optional<DecisionTable> getModelClass() { return Optional.of(new DecisionTable()); }
Source:
public Optional<Context> getModelClass() { final Context context = new Context(); START return Optional.of(context); END } We could shorten to one line `return Optional.of(new Context());`

Target:
public Optional<Context> getModelClass() { return Optional.of(new Context()); }
Source:
public Set<String> getDefinitions(final String label) { final Set<String> ids = definitionsByLabel.get(label); if (null == ids) { return Collections.emptySet(); } START return ids; END } Can be shortened to one line, but take this more as question, if it would be of better performance: ```java return Optional.ofNullable(definitionsByLabel.get(label)).orElse(Collections.emptySet()); ```

Target:
public Set<String> getDefinitions(final String label) { final Set<String> ids = definitionsByLabel.get(label); return null != ids ? ids : Collections.emptySet(); }
Source:
public void setKSessions(final List<String> ksessions) { String[] names = ksessions.toArray(new String[ksessions.size()]); ksessionSelect.setup(ksessionSelectContainer, buildOptions(names), names[0], new Consumer<String>() { @Override public void accept(String s) { onSelectionChange(); } START }); END } Also this consumer could be simplified by lambda but leaving decision to you. `selectedKieSession -> onSelectionChange()`

Target:
public void setKSessions(final List<String> ksessions) { String[] names = ksessions.toArray(new String[ksessions.size()]); ksessionSelect.setup(ksessionSelectContainer, buildOptions(names), names[0], s -> onSelectionChange()); }
Source:
private void setItemEnabled(final Class<? extends ClientSessionCommand> type, START final boolean enabled) { END menuItems.get(type).setEnabled(enabled); } This parameter value of private method is always `False`

Target:
public void setItemEnabled(final Class<? extends ClientSessionCommand> type, final boolean enabled) { menuItems.get(type).setEnabled(enabled); }
Source:
START private boolean jsonExists(String path){ END File test = new File(path + "/" + JSON_POM_FILE); return test.exists() && test.isFile(); } It would be nice to provide some feedback if this check fails. Like "The file BLABLA doesn't exist in the directory you provided. Please try again..."

Target:
private boolean jsonExists(String path) { File test = new File(path, JSON_POM_FILE); return test.exists() && test.isFile(); }
Source:
private boolean jsonExists(String path) { START File test = new File(path + File.separator + JSON_POM_FILE); END return test.exists() && test.isFile(); } Don't worry about changing this, but just FYI there is a constructor on `File` that takes a parent and child path and concatenates them together. It's nice because then you don't have to worry about using `File.separator` and concatenating the path yourself.

Target:
private boolean jsonExists(String path) { File test = new File(path, JSON_POM_FILE); return test.exists() && test.isFile(); }
Source:
public void testInitAggregator() throws Exception { START final List<BuiltinAggregator> aggregators = Arrays.asList(BuiltinAggregator.COUNT, END BuiltinAggregator.MAX, BuiltinAggregator.MIN, BuiltinAggregator.SUM); testedView.initBuiltinAggregators(aggregators); aggregators.stream().forEach(agg -> verify(lstBuiltinAggregator).addOption(agg.value())); } Out of interest why can you not do ```BuiltinAggregator.values()```?

Target:
public void testInitAggregator() throws Exception { final List<BuiltinAggregator> aggregators = Arrays.asList(BuiltinAggregator.values()); testedView.initBuiltinAggregators(aggregators); aggregators.stream().forEach(agg -> verify(lstBuiltinAggregator).addOption(agg.value())); }
Source:
public void testInitOrientations() throws Exception { START final List<DecisionTableOrientation> orientations = Arrays.asList(DecisionTableOrientation.CROSS_TABLE, END DecisionTableOrientation.RULE_AS_COLUMN, DecisionTableOrientation.RULE_AS_ROW); testedView.initDecisionTableOrientations(orientations); orientations.stream().forEach(orientation -> verify(lstDecisionTableOrientation).addOption(orientation.value())); } Out of interest why can you not do ```DecisionTableOrientation.values()```?

Target:
public void testInitOrientations() throws Exception { final List<DecisionTableOrientation> orientations = Arrays.asList(DecisionTableOrientation.values()); testedView.initDecisionTableOrientations(orientations); orientations.stream().forEach(orientation -> verify(lstDecisionTableOrientation).addOption(orientation.value())); }
Source:
public boolean isSupported(String feature) { throwException(); START return true; END } This is redundant line now.

Target:
public boolean isSupported(String feature) { throwException(); return false; }
Source:
public void init() { paletteDefinitionBuilder START .itemFilter(defId -> true) END .categoryFilter(category -> !EXCLUDED_CATEGORIES.contains(category)); } Looking on `AbstractPaletteDefinitionBuilder#initDefaults` I think this line can be omitted.

Target:
public void init() { paletteDefinitionBuilder .categoryFilter(category -> !EXCLUDED_CATEGORIES.contains(category)); }
Source:
START static <T, U> Function<T, Result<U>> ignored(Class<?> expectedClass) { END return t -> Result.ignored( "Ignored: " + Optional.ofNullable(t) .map(o -> o.getClass().getCanonicalName()) .orElse("null -- expected " + expectedClass.getCanonicalName())); } Can be private method.

Target:
private static <T, U> Function<T, Result<U>> ignored(Class<?> expectedClass) { return t -> Result.ignored( "Ignored: " + Optional.ofNullable(t) .map(o -> o.getClass().getCanonicalName()) .orElse("null -- expected " + expectedClass.getCanonicalName())); }
Source:
public static AssociationList fromString(String encoded) { if (encoded.isEmpty()) return new AssociationList(); else return new AssociationList( START Arrays.asList(encoded.split(",")).stream() END .map(AssociationDeclaration::fromString) .collect(Collectors.toList())); } Arrays.asList(encoded.split(",")).stream() can be replaced with Arrays.stream(encoded.split(","))

Target:
public static AssociationList fromString(String encoded) { if (encoded.isEmpty()) { return new AssociationList(); } else { return new AssociationList( Arrays.stream(encoded.split(",")) .map(AssociationDeclaration::fromString) .collect(Collectors.toList())); } }
Source:
START void setStringValue(String value) { END if (value == null || value.isEmpty()) { return; } DataInputAssociation input = input(value); getIoSpecification(element).getDataInputs().add((DataInput) input.getTargetRef()); element.getDataInputAssociations().add(input); } Method can be private

Target:
private void setStringValue(String value) { if (value == null || value.isEmpty()) { return; } DataInputAssociation input = input(value); getIoSpecification(element).getDataInputs().add((DataInput) input.getTargetRef()); element.getDataInputAssociations().add(input); }
Source:
public static DeclarationList fromString(String encoded) { return new DeclarationList( START Arrays.asList(encoded.split(",")).stream() END .map(VariableDeclaration::fromString) .collect(Collectors.toList())); } Arrays.asList().stream() can be replaced with Arrays.stream()

Target:
public static DeclarationList fromString(String encoded) { return new DeclarationList( Arrays.stream(encoded.split(",")) .map(VariableDeclaration::fromString) .collect(Collectors.toList())); }
Source:
public void testMinimalWidthOneCellInEachRowWithPadding() throws Exception { gridData.appendColumn(column); gridData.appendRow(new DMNGridRow()); gridData.appendRow(new DMNGridRow()); gridData.appendRow(new DMNGridRow()); START mockCellsWithPadding(0, 0, PADDING, 100d); END mockCellsWithPadding(1, 0, PADDING, 150); mockCellsWithPadding(2, 0, PADDING, 125); Assertions.assertThat(column.getMinimumWidth()).isEqualTo(170); } I think the `d` is not necessary here, could be simplified to: `mockCellsWithPadding(0, 0, PADDING, 100);`

Target:
public void testMinimalWidthOneCellInEachRowWithPadding() throws Exception { gridData.appendColumn(column); gridData.appendRow(new DMNGridRow()); gridData.appendRow(new DMNGridRow()); gridData.appendRow(new DMNGridRow()); mockCellsWithPadding(0, 0, PADDING, 100); mockCellsWithPadding(1, 0, PADDING, 150); mockCellsWithPadding(2, 0, PADDING, 125); Assertions.assertThat(column.getMinimumWidth()).isEqualTo(170); }
Source:
private List<Expression> extractColumnData(final int uiColumnIndex) { final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; START final List<Expression> values = relation.getRow().stream().map(row -> row.getExpression().get(iiIndex)).collect(Collectors.toList()); END return values; } Do we have this local variable `values` for debugging purposes? If not, we could shorten the statement: ```java return relation.getRow().stream().map(row -> row.getExpression().get(iiIndex)).collect(Collectors.toList()); ``` Let me know WDYT.

Target:
private List<Expression> extractColumnData(final int uiColumnIndex) { final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT; return relation.getRow() .stream() .map(row -> row.getExpression().get(iiIndex)) .collect(Collectors.toList()); }
Source:
protected void fireExpressionEditorSelectedEvent() { START final Optional<BaseExpressionGrid> parentGrid = findParentGrid(parent); END editorSelectedEvent.fire(new ExpressionEditorSelectedEvent(sessionManager.getCurrentSession(), parentGrid)); } Maybe your version is more readable, just wanted to ask if you noticed. Here you could update to: ```java final Optional<BaseExpressionGrid> parentGrid = findParentGrid(); ``` if the `findParentGrid` declared as: ```java private Optional<BaseExpressionGrid> findParentGrid() ```

Target:
protected void fireExpressionEditorSelectedEvent() { final Optional<BaseExpressionGrid> parentGrid = findParentGrid(); editorSelectedEvent.fire(new ExpressionEditorSelectedEvent(sessionManager.getCurrentSession(), parentGrid)); }
Source:
public void testDefinitionEquals() { DefinitionImpl<String> a = new DefinitionImpl<>("a"); DefinitionImpl<String> b = new DefinitionImpl<>("a"); assertEquals(a, b); b.setDefinition("b"); assertNotEquals(a, b); b.setDefinition("a"); assertEquals(a, b); START } END I guess null check is also will be nice to see here. Like ```java assertNotEquals(a, null); b.setDefinition(null); assertNotEquals(a, b); assertNotEquals(b, a); ```

Target:
public void testDefinitionEquals() { DefinitionImpl<String> a = new DefinitionImpl<>("a"); DefinitionImpl<String> b = new DefinitionImpl<>("a"); assertEquals(a, b); b.setDefinition(null); assertNotEquals(a, b); b.setDefinition("b"); assertNotEquals(a, b); b.setDefinition("a"); assertEquals(a, b); }
Source:
private static String loadTaskForm(String taskForm) { String taskFormJson = ""; try { taskFormJson = Resources.toString(FormValuesProcessorTest.class.getResource(taskForm), Charsets.UTF_8); } catch (IOException e) { START e.printStackTrace(); END } return taskFormJson; } Also, when you do that, you'll be able to return directly from the `try` block, reducing the size of the method by nearly a third.

Target:
private static String loadTaskForm(String taskForm) throws IOException { return Resources.toString(FormValuesProcessorTest.class.getResource(taskForm), Charsets.UTF_8); }
Source:
public static void setup() { START textAreaFormFieldValueProcessor = new TextAreaFormFieldValueProcessor(); END multipleSubFormFieldValueProcessor = new MultipleSubFormFieldValueProcessor(); subFormFieldValueProcessor = new SubFormFieldValueProcessor(); localDateFieldValueProcessor = new LocalDateFieldValueProcessor(); localDateFieldValueProcessor.init(); formSerializer = new FormDefinitionSerializerImpl(new FieldSerializer(), new FormModelSerializer(), new TestMetaDataEntryManager()); textAreaTaskForm = getFormDefinition("TextareaTask-taskform.frm"); localDateTaskForm = getFormDefinition("LocalDateFieldTask-taskform.frm"); subformTaskForm = getFormDefinition("SubformTask-taskform.frm"); } Why not initialize all of those fields at the declaration site? This `@BeforeClass` in my opinion doesn't add much value. (It would make sense if any of these constructors threw exceptions.)

Target:
public static void setup() throws IOException { textAreaTaskForm = getFormDefinition("TextareaTask-taskform.frm"); localDateTaskForm = getFormDefinition("LocalDateFieldTask-taskform.frm"); subformTaskForm = getFormDefinition("SubformTask-taskform.frm"); }
Source:
public void onShowTimeDateTimePicker() { view.showTimeDate(false); String value = view.getTimeDate(); try { Date date = view.parseFromISO(value); view.setTimeDateTimePickerValue(date); START } catch (Exception e) { END view.setTimeDateTimePickerValue(value); } view.showTimeDateTimePicker(true); } is to possible to catch some `Exception` sub-type? I mean some `ParserException`..

Target:
public void onShowTimeDateTimePicker() { view.showTimeDate(false); String value = view.getTimeDate(); try { Date date = view.parseFromISO(value); view.setTimeDateTimePickerValue(date); } catch (IllegalArgumentException e) { view.setTimeDateTimePickerValue(value); } view.showTimeDateTimePicker(true); }
Source:
protected void update() { this.view.clear(); this.hideEmptyState(); START int offset = getOffset(); END this.resolveAssetsCount(); this.getAssets(this.filter, this.filterType, offset, this.currentPage * this.pageSize, this::addAssetsToView); this.view.setCurrentPage(this.currentPage); this.checkPaginationButtons(); } Just passing `getOffset()` directly (not introducing local variable `offset`) as argument of `getAssets()` could help improve readability, what do you think?

Target:
protected void update() { this.view.clear(); this.hideEmptyState(); this.resolveAssetsCount(); this.getAssets(this.filter, this.filterType, getOffset(), this.currentPage * this.pageSize, this::addAssetsToView); this.view.setCurrentPage(this.currentPage); this.checkPaginationButtons(); }
Source:
START String getCreatedTime(final AssetInfo asset) { END return ts.format(LibraryConstants.Created) + " " + SocialDateFormatter.format(asset.getCreatedTime()); } Please add access modifier, `private` probably?

Target:
private String getCreatedTime(final AssetInfo asset) { return ts.format(LibraryConstants.Created) + " " + SocialDateFormatter.format(asset.getCreatedTime()); }
Source:
public PopulatedAssetsView() { START domUtil = new Elemental2DomUtil(); END } Why not inject this?

Target:
public PopulatedAssetsView() { }
Source:
public void init(final DeleteProjectPopUpScreen presenter) { START domUtil = new Elemental2DomUtil(); END this.presenter = presenter; modalSetup(); } Why not inject this?

Target:
public void init(final DeleteProjectPopUpScreen presenter) { this.presenter = presenter; modalSetup(); }