auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void setProjects(Map<String,Project> projects) { START this.projects = (HashMap<String, Project>) projects; END } if you do it [here](https://github.com/OpenGrok/OpenGrok/pull/1543/files#r113946427) the this cast is not necessary

Target:
public void setProjects(Map<String,Project> projects) { this.projects = projects; }
Source:
START public void readConfiguration(File file) throws IOException, FileNotFoundException { END setConfiguration(Configuration.read(file)); } FileNotFoundException is a subclass of IOException

Target:
public void readConfiguration(File file) throws IOException { setConfiguration(Configuration.read(file)); }
Source:
public byte[] apply(RuntimeEnvironment env) throws IOException { START if (hasTag("reindex")) { END env.applyConfig(this, true); } else { env.applyConfig(this, false); } return null; } Possibly shorter to just write ```java env.applyConfig(this, hasTag("reindex")); ``` but this is ok

Target:
public byte[] apply(RuntimeEnvironment env) throws IOException { env.applyConfig(this, hasTag("reindex")); return null; }
Source:
public void setTextFromFile(String filepath) { try { byte[] encoded = Files.readAllBytes(Paths.get(filepath)); this.text = new String(encoded); } catch (IOException ex) { System.err.println("Cannot read '" + filepath + "': " + ex); START System.exit(1); END } } Do not use system.exit, this is not a main program. Throw an exception or return a boolean and check it in the main program

Target:
public void setTextFromFile(String filepath) throws IOException { byte[] encoded = Files.readAllBytes(Paths.get(filepath)); this.text = new String(encoded); }
Source:
public static boolean isLocal(Project project, String path) { RuntimeEnvironment env = RuntimeEnvironment.getInstance(); String srcRoot = env.getSourceRootPath(); if (path.startsWith(srcRoot)) { START if (env.hasProjects()) { END String relPath = path.substring(srcRoot.length()); if (project != null && project.equals(Project.getProject(relPath))) { // File is under the current project, so it's local. return true; } } else { // File is under source root, and we don't have projects, so // consider it local. return true; } } return false; } could do the project != null check here to avoid the substring operation

Target:
public static boolean isLocal(Project project, String path) { RuntimeEnvironment env = RuntimeEnvironment.getInstance(); String srcRoot = env.getSourceRootPath(); if (path.startsWith(srcRoot)) { if (env.hasProjects()) { if (project != null && project.equals(Project.getProject(path.substring(srcRoot.length())))) { // File is under the current project, so it's local. return true; } } else { // File is under source root, and we don't have projects, so // consider it local. return true; } } return false; }
Source:
public void setTags(final List<String> tags) { START this.tags = tags != null ? SetUniqueList.decorate(tags) : null; END } For my knowledge: What is the impact of that ? Before it was possible to have multiple time the same value in tag list ?

Target:
public void setTags(final List<String> tags) { this.tags = tags != null ? SetUniqueList.decorate(new ArrayList(tags)) : null; }
Source:
public Set<String> getCollections() { START return collections != null ? new TreeSet<>(collections) : null; END } Avoid logic in this class. This is inconsistent with other collection fields. You can't do an update with this field set to null. Also, why a tree set?

Target:
public Set<String> getCollections() { return collections; }
Source:
public void setCollections(final Set<String> collections) { START this.collections = collections != null ? new TreeSet<>(collections) : null; END } Avoid logic in this class.

Target:
public void setCollections(final Set<String> collections) { this.collections = collections; }
Source:
private static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); START mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true); END mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setDateFormat(new ISO8601DateFormat()); return mapper; } Remove this (ORDER_MAP_ENTRIES_BY_KEYS).

Target:
private static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setDateFormat(new ISO8601DateFormat()); return mapper; }
Source:
static public Drive getDriveService(String token) { GoogleCredential credential = new GoogleCredential().setAccessToken(token); return new Drive.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).setHttpRequestInitializer(new HttpRequestInitializer() { @Override public void initialize(HttpRequest httpRequest) throws IOException { credential.initialize(httpRequest); START httpRequest.setConnectTimeout(300 * 60000); // 300 minutes connect timeout END httpRequest.setReadTimeout(300 * 60000); // 300 minutes read timeout } }) .setApplicationName(SERVICE_APP_NAME).build(); } @jackyq2015 Is this timeout value still what Google recommends ? I know that Apache HTTP has a internal default of 3 minutes timeout that can be overridden in Apache's newer package version.

Target:
static public Drive getDriveService(String token) { GoogleCredential credential = new GoogleCredential().setAccessToken(token); return new Drive.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).setHttpRequestInitializer(new HttpRequestInitializer() { @Override public void initialize(HttpRequest httpRequest) throws IOException { credential.initialize(httpRequest); httpRequest.setConnectTimeout(3 * 60000); // 3 minutes connect timeout httpRequest.setReadTimeout(3 * 60000); // 3 minutes read timeout } }) .setApplicationName(SERVICE_APP_NAME).build(); }
Source:
static public LocalDateTime stringToLocalDate(String s) { if (s.endsWith("Z")) { // UTC time Instant instant = Instant.parse(s); return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); START } else END return LocalDateTime.parse(s, DateTimeFormatter.ISO_LOCAL_DATE_TIME); } Missing brace

Target:
static public LocalDateTime stringToLocalDate(String s) { if (s.endsWith("Z")) { // UTC time Instant instant = Instant.parse(s); return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); } else { return LocalDateTime.parse(s, DateTimeFormatter.ISO_LOCAL_DATE_TIME); } }
Source:
private static boolean mayHaveValidDate(final String value) { List<String> matches = fetchDateStrings(value); if (!matches.isEmpty()) { try { DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("yyyy-MM-dd"); matches.forEach(dateTimeFormat::parseStrict); START } catch (Exception e) { END return false; } } return true; } I understand that the key point is the use of the `DateTimeFormat.parseStrict` method. Once calling it, if an execptoin occurs, we can assume that the given date is not valid. But maybe we can be more specific on the exception type being catched on this assumption - does it makes sense assuming once any "generic" exception occurs is due to the date is not valid (eg: leap days)? Is there any other Exception subtype we could use for the catch block instead? Just brainstorming, just asking :)

Target:
private static boolean mayHaveValidDate(final String value) { List<String> matches = fetchDateStrings(value); if (!matches.isEmpty()) { try { DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("yyyy-MM-dd"); matches.forEach(dateTimeFormat::parseStrict); } catch (IllegalArgumentException e) { return false; } } return true; }
Source:
private static int getIndexOfFileSeparator(String string) { int index = string.indexOf('/'); START if (index == -1) { END return string.indexOf('\\'); } return index; } can be inlined into a single return line

Target:
private static int getIndexOfFileSeparator(String string) { int index = string.indexOf('/'); return index == -1 ? string.indexOf('\\') : index; }
Source:
protected String composeUniqueNodeName(final String name) { final String originalName = Optional.ofNullable(name).orElse(""); try { final MatchResult nameSuffixMatcher = NAME_SUFFIX_REGEX.exec(originalName); if (nameSuffixMatcher != null) { return buildNameWithIncrementedSuffixIndex(originalName, nameSuffixMatcher); } START } catch (Exception e) { END LOGGER.warning("There was an issue while parsing node with name " + originalName + " - A fallback will be used for it"); } return joinPrefixWithIndexedSuffix(originalName); } Small suggestion to investigate how could we avoid a generic exception since that would be hard to inspect if something would happen if exec will throw any exception like IndexOutOfBounds or buildNameWithIncrementedSuffixIndex throw some exception(bcs it would probably just skipped)

Target:
protected String composeUniqueNodeName(final String name) { final String originalName = Optional.ofNullable(name).orElse(""); final MatchResult nameSuffixMatcher = NAME_SUFFIX_REGEX.exec(originalName); if (nameSuffixMatcher != null) { return buildNameWithIncrementedSuffixIndex(originalName, nameSuffixMatcher); } return joinPrefixWithIndexedSuffix(originalName); }
Source:
public void setValue(String value, boolean fireEvents) { String oldValue = current; current = value; START if (current.equals("0")) { END view.setLocalTimeZone(); } else { view.setValue(current); } if (fireEvents) { ValueChangeEvent.fireIfNotEqual(this, oldValue, value); } } I just understood the condition now at the first read, great!! thanks a lot for this small things, I think those become important at the long term, easier to maintan... :+1:

Target:
public void setValue(String value, boolean fireEvents) { String oldValue = current; current = value; view.setValue(current); if (fireEvents) { ValueChangeEvent.fireIfNotEqual(this, oldValue, value); } }
Source:
START protected String getInvalidCharsInName(final String value) { END return getInvalidCharsInName(regExp, value); } can be `private`? or at least package protected access?

Target:
private String getInvalidCharsInName(final String value) { return getInvalidCharsInName(regExp, value); }
Source:
START protected String testForInvalidValue(final String value) { END if (value == null || value.isEmpty() || invalidValues == null) { return null; } String testValue; if (!isCaseSensitive) { testValue = value.toLowerCase(); } else { testValue = value; } if (invalidValues.contains(testValue)) { return invalidValueErrorMessage; } else { return null; } } can be `private`? or at least package protected access?

Target:
private String testForInvalidValue(final String value) { if (value == null || value.isEmpty() || invalidValues == null) { return null; } String testValue; if (!isCaseSensitive) { testValue = value.toLowerCase(); } else { testValue = value; } if (invalidValues.contains(testValue)) { return invalidValueErrorMessage; } else { return null; } }
Source:
START public void setCurrentContainer(FormsContainer container) { END this.container = container; } this method should not be `public`, otherwise doesn't make sense the arguments for the `flush(ClientSession, String)` method, as each session (editor) will have a different associated `FormsContainer` instance, which could not be the one set in `setCurrentContainer`... Can you please change it to package protected access (so no access modifier set)? Does it work/make sense for you?

Target:
void setCurrentContainer(FormsContainer container) { this.container = container; }
Source:
START public String getName() { END if (StringUtils.isEmpty(name)) { this.name = getNewRuleAnnotationClauseName(); } return this.name; } Can this be `private` (or at least package protected)? It's only used by this class.

Target:
private String getName() { return this.name; }
Source:
START public Optional<RuleAnnotationClauseColumn> getUiModelColumn() { END return uiModelColumn; } In fact why do we need it at all!? If it's only use is this class or the test, the value is know by the test already as it constructs the instance.

Target:
Optional<RuleAnnotationClauseColumn> getUiModelColumn() { return uiModelColumn; }
Source:
public ZoomLevelSelectorPresenter show() { cancelHide(); floatingView.show(); START if(zoomLevelInit){ END zoomLevelInit = false; scheduleHide(); } return this; } Hi @handreyrc can you appply KIE style formatting?

Target:
public ZoomLevelSelectorPresenter show() { if (zoomLevelInit) { zoomLevelInit = false; } else { cancelHide(); floatingView.show(); } return this; }
Source:
public static JSITLiteralExpression dmnFromWB(final OutputClauseLiteralExpression wb) { if (Objects.isNull(wb)) { return null; } else if (StringUtils.isEmpty(wb.getText().getValue())) { return null; START } END return LiteralExpressionPropertyConverter.dmnFromWB(wb); } `wb.getText()` never returns `null`?

Target:
public static JSITLiteralExpression dmnFromWB(final OutputClauseLiteralExpression wb) { if (Objects.isNull(wb)) { return null; } else if (Objects.isNull(wb.getText())) { return null; } else if (StringUtils.isEmpty(wb.getText().getValue())) { return null; } return LiteralExpressionPropertyConverter.dmnFromWB(wb); }
Source:
public void testPopulateMenu() { START placeManager = mock(PlaceManager.class); END final DMNEditorMenuSessionItems menuItems = spy(new DMNEditorMenuSessionItems(builder, sessionCommands, placeManager)); final MenuItem menuItem = mock(MenuItem.class); doNothing().when(menuItems).superPopulateMenu(any()); doReturn(menuItem).when(menuItems).newPerformAutomaticLayout(); menuItems.populateMenu(fileMenuBuilder); verify(menuItems).addPerformAutomaticLayout(any()); } You don't need to `mock(..)` it if you've `@Mock`'ed it.

Target:
public void testPopulateMenu() { final DMNEditorMenuSessionItems menuItems = spy(new DMNEditorMenuSessionItems(builder, sessionCommands, placeManager)); final MenuItem menuItem = mock(MenuItem.class); doNothing().when(menuItems).superPopulateMenu(any()); doReturn(menuItem).when(menuItems).newPerformAutomaticLayout(); menuItems.populateMenu(fileMenuBuilder); verify(menuItems).addPerformAutomaticLayout(any()); }
Source:
public static IThenable.ThenOnFulfilledCallbackFn<List<String>, Object> getListObjectThenOnFulfilledCallbackFn(List<String> simpleDataTypes, ListBoxValues dataTypeListBoxValues) { return serverDataTypes -> { List<String> mergedList = new ArrayList<>(simpleDataTypes); START for (String type : serverDataTypes) { END String displayType = createDataTypeDisplayName(type); getMapDataTypeNamesToDisplayNames().put( displayType, type ); mergedList.add(displayType); } dataTypeListBoxValues.addValues(mergedList); return null; }; } same here, maybe using Streams may result more readable.

Target:
static IThenable.ThenOnFulfilledCallbackFn<List<String>, Object> getListObjectThenOnFulfilledCallbackFn(List<String> simpleDataTypes, ListBoxValues dataTypeListBoxValues) { return serverDataTypes -> { List<String> mergedList = new ArrayList<>(simpleDataTypes); for (String type : serverDataTypes) { String displayType = createDataTypeDisplayName(type); getMapDataTypeNamesToDisplayNames().put( displayType, type ); mergedList.add(displayType); } dataTypeListBoxValues.addValues(mergedList); return null; }; }
Source:
public boolean equals( final Object o ) { if ( this == o ) { return true; } if ( !( o instanceof DependencyPathSelectedEvent ) ) { return false; } final DependencyPathSelectedEvent that = (DependencyPathSelectedEvent) o; if ( !context.equals( that.context ) ) { return false; } START if (!isSelected == that.isSelected) { END return false; } return path.equals( that.path ); } ```suggestion if (isSelected != that.isSelected) { ```

Target:
public boolean equals( final Object o ) { if ( this == o ) { return true; } if ( !( o instanceof DependencyPathSelectedEvent ) ) { return false; } final DependencyPathSelectedEvent that = (DependencyPathSelectedEvent) o; if ( !context.equals( that.context ) ) { return false; } return path.equals( that.path ); }
Source:
public void setInitialPositionY(final HTMLElement dragAndDropElement, final List<HTMLElement> children) { Integer parentY = Position.getY(dragAndDropElement); START for (final Element element : children) { parentY++; Position.setY(element, parentY); END } } This is the same as below, but I am fine if you want to keep as it is. ```java for (final Element element : children) { Position.setY(element, ++parentY); } ```

Target:
public void setInitialPositionY(final HTMLElement dragAndDropElement, final List<HTMLElement> children) { Integer parentY = Position.getY(dragAndDropElement); for (final Element element : children) { Position.setY(element, ++parentY); } }
Source:
START public void testGetTopLevelDataTypeWithName(){ END final String topLevelType = "tType"; final DataType dataType = mock(DataType.class); final Optional<DataType> type = Optional.of(dataType); doReturn(type).when(manager).findTopLevelDataTypeWithName(topLevelType); final DataType actual = manager.getTopLevelDataTypeWithName(topLevelType); assertEquals(dataType, actual); } formatting

Target:
public void testGetTopLevelDataTypeWithName() { final String topLevelType = "tType"; final DataType dataType = mock(DataType.class); final Optional<DataType> type = Optional.of(dataType); doReturn(type).when(manager).findTopLevelDataTypeWithName(topLevelType); final Optional<DataType> actual = manager.getTopLevelDataTypeWithName(topLevelType); assertTrue(actual.isPresent()); assertEquals(dataType, actual.get()); }
Source:
public void testLoadDataObjectsWithNullWorkspaceProject() { START assertTrue(dataObjectsService.loadDataObjects(null).isEmpty()); END } Please use assertj assertion. In case of fail it gives error message explaining different list sizes. Current implementation will just print assertion error, expected true but was false with no reference to list size.

Target:
public void testLoadDataObjectsWithNullWorkspaceProject() { assertThat(dataObjectsService.loadDataObjects(null)).isEmpty(); }
Source:
public void testDestroy() { final UberfireDock uberfireDock = mock(UberfireDock.class); START dock.setOpened(false); END doReturn(uberfireDock).when(dock).getUberfireDock(); dock.destroy(); verify(uberfireDocks).remove(uberfireDock); } I do not understand why we need this method, could you please clarify?

Target:
public void testDestroy() { final UberfireDock uberfireDock = mock(UberfireDock.class); doReturn(uberfireDock).when(dock).getUberfireDock(); dock.destroy(); verify(uberfireDocks).remove(uberfireDock); }
Source:
private static JSITDMNElement.JSIExtensionElements getOrCreateExtensionElements(final JSITDRGElement target) { // TODO {gcardosi} add because present in original json JSITDMNElement.JSIExtensionElements toReturn = target.getExtensionElements() == null ? new JSITDMNElement.JSIExtensionElements() : target.getExtensionElements(); if (!Objects.isNull(toReturn) && Objects.isNull(toReturn.getAny())) { START toReturn.setAny(new ArrayList<>()); END } return toReturn; } Can't we use `Collections.emptyList()` just asking, do not knwo if can cause troubles as return no-modifiable list.

Target:
private static JSITDMNElement.JSIExtensionElements getOrCreateExtensionElements(final JSITDRGElement target) { // Add because it is present in the original JSON when unmarshalling JSITDMNElement.JSIExtensionElements toReturn = Objects.isNull(target.getExtensionElements()) ? new JSITDMNElement.JSIExtensionElements() : target.getExtensionElements(); if (!Objects.isNull(toReturn) && Objects.isNull(toReturn.getAny())) { toReturn.setAny(new ArrayList<>()); } return toReturn; }
Source:
START Worker createWorker() { END return Worker.create(pathToVerifier); } @Rikkola If 'Worker' class can be managed exclusively by this class with no possibility to override its behavior, I suggest to put the 'private' visibility to this method. Anyway, your choice.

Target:
protected Worker createWorker() { return Worker.create(pathToVerifier); }
Source:
START public void setUp() throws Exception { END receiver = new Receiver(reporter) { @Override public Object fromJSON(final String json) { return returnObject; } }; receiver.setUp(worker); verify(worker).setOnMessage(messageHandlerArgumentCaptor.capture()); } @Rikkola is this "throws' Exception really necessary?

Target:
public void setUp() { receiver = new Receiver(reporter) { @Override public Object fromJSON(final String json) { return returnObject; } }; receiver.setUp(worker); verify(worker).setOnMessage(messageHandlerArgumentCaptor.capture()); }
Source:
START public void setUp() throws END Exception { verifierWebWorkerConnection = spy(new VerifierWebWorkerConnectionImpl(initialize, "verifier/dtableVerifier/dtableVerifier.nocache.js", poster, receiver) { @Override Worker createWorker() { return worker; } }); } @Rikkola is this "throws' Exception really necessary?

Target:
public void setUp() { verifierWebWorkerConnection = spy(new VerifierWebWorkerConnectionImpl(initialize, "verifier/dtableVerifier/dtableVerifier.nocache.js", poster, receiver) { @Override protected Worker createWorker() { return worker; } }); }
Source:
public void testSetReadOnly() { START boolean arbitraryValue = false; END view.setReadOnly(arbitraryValue); verify(slaTimeDuration).setDisabled(arbitraryValue); } ```suggestion final boolean arbitraryValue = false; ```

Target:
public void testSetReadOnly() { final boolean arbitraryValue = false; view.setReadOnly(arbitraryValue); verify(slaTimeDuration).setDisabled(arbitraryValue); }
Source:
public void search(final String term) { START final boolean isNewSearch = Objects.equals(term, currentTerm); END final Optional<SearchResult<T>> result; if (isNewSearch) { result = findNextElement(term); } else { result = findFirstElement(term); } currentResult = result.orElse(currentResult); currentTerm = term; triggerOnFoundCommand(); } Variable name is misleading.. `isNewSearch` is when `!Objects.equals(term, currentTerm)`

Target:
public void search(final String term) { final boolean isNewSearch = !Objects.equals(term, currentTerm); final Optional<SearchResult<T>> result; if (isNewSearch) { result = findFirstElement(term); } else { result = findNextElement(term); } currentResult = result.orElse(null); currentTerm = term; triggerOnFoundCommand(); }
Source:
public boolean equals(Object o) { if (this == o) { return true; } START if (o == null || getClass() != o.getClass()) { END return false; } AdHocActivationCondition that = (AdHocActivationCondition) o; return Objects.equals(value, that.value); } It can be like: ```java if (o instanceof AdHocActivationCondition) { AdHocActivationCondition that = (AdHocActivationCondition) o; return Objects.equals(value, that.value); } return false; ``` instanceof operator check null value as well.

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (o instanceof AdHocActivationCondition) { AdHocActivationCondition that = (AdHocActivationCondition) o; return Objects.equals(value, that.value); } return false; }
Source:
public void onDeleteLinkClick(final ClickEvent clickEvent) { START locker.fire(new LockRequiredEvent()); END if (!Objects.isNull(getOnDeleted())) { getOnDeleted().accept(externalLink); } } Presumably this is to acquire the _lock_ icon on the Editor Title and Project Explorer? Personally, I'd prefer to see this _behaviour_ on the `Presenter` rather than this (dumb) `View`. Perhaps having the "on delete consumer" fire this event is going to be as close to that as we can get (although IIRC that _consumer_ is a `View` too.. at least the physical delete and firing of the event would be in the same place. WDYT?

Target:
public void onDeleteLinkClick(final ClickEvent clickEvent) { if (!Objects.isNull(getOnDeleted())) { getOnDeleted().accept(externalLink); } }
Source:
public void testGetSlaDueDate() { GenericServiceTaskExecutionSet a = new GenericServiceTaskExecutionSet( new GenericServiceTaskInfo(), new SLADueDate(SLA_DUE_DATE_1)); START Assert.assertTrue(a.getSlaDueDate().getValue().equals(SLA_DUE_DATE_1)); END } You can use assertEquals here to express what is an expected value.

Target:
public void testGetSlaDueDate() { GenericServiceTaskExecutionSet a = new GenericServiceTaskExecutionSet( new GenericServiceTaskInfo(), new SLADueDate(SLA_DUE_DATE_1)); assertEquals(SLA_DUE_DATE_1, a.getSlaDueDate().getValue()); }
Source:
private Object[] toArray(List<?> messageArguments) { START return messageArguments.stream().toArray(Object[]::new); END } same here messageArguments.toArray();

Target:
private Object[] toArray(List<?> messageArguments) { return messageArguments.toArray(new Object[0]); }
Source:
public Graph unmarshall(Metadata metadata, InputStream input) throws IOException { MarshallingResponse<Graph> marshallingResponse = unmarshallWithValidation(MarshallingRequest.builder() .metadata(metadata) .input(input) .mode(MarshallingRequest.Mode.ERROR) .build()); START return marshallingResponse.getResult().get(); END } optional without present check access

Target:
public Graph unmarshall(Metadata metadata, InputStream input) { MarshallingResponse<Graph> marshallingResponse = unmarshallWithValidation(MarshallingRequest.builder() .metadata(metadata) .input(input) .mode(MarshallingRequest.Mode.ERROR) .build()); return marshallingResponse.getResult(); }
Source:
public static <T extends FlowElement> MarshallingMessageDecorator<T> flowElementDecorator() { return MarshallingMessageDecorator.of(o -> Optional.ofNullable(o.getName()) START .orElseGet(() -> o.getId()), END g -> g.getClass().getSimpleName()); } method reference can be used instead of o.getId()

Target:
public static <T extends FlowElement> MarshallingMessageDecorator<T> flowElementDecorator() { return MarshallingMessageDecorator.of(o -> Optional.ofNullable(o.getName()) .orElseGet(o::getId), g -> g.getClass().getSimpleName()); }
Source:
START private Property findPropertyById(String id) { END return variableScope.lookup(id) .map(VariableScope.Variable::getTypedIdentifier) .orElse(null); } yes, I could see that a null is returned. But question is, how can this affect to callers of this method. Since a null es returned, the callers of this method will fail by returning a NPE. But before, an exception was thrown at least saying that the expected variable XXX was not found

Target:
private Optional<Property> findPropertyById(String id) { return variableScope.lookup(id) .map(VariableScope.Variable::getTypedIdentifier); }
Source:
String getFileName(final Diagram diagram) { START Metadata metadata = diagram.getMetadata(); END final Optional<Path> path = Optional.ofNullable(metadata.getPath()); return path.map(Path::getFileName).orElse(translationService.format(DMNDocumentationFactory_NoFileName)); } can be also `final`

Target:
String getFileName(final Diagram diagram) { final Metadata metadata = diagram.getMetadata(); final Optional<Path> path = Optional.ofNullable(metadata.getPath()); return path.map(Path::getFileName).orElse(translationService.format(DMNDocumentationFactory_NoFileName)); }
Source:
public void testUnmarshallSubprocessLevelEventEmptyProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_CATCHING_INTERMEDIATE_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); IntermediateErrorEventCatching emptySubprocessEvent = getCatchingIntermediateNodeById(diagram, EMPTY_SUBPROCESS_LEVEL_EVENT_ID, HAS_NO_INCOME_EDGE, HAS_NO_OUTGOING_EDGE); assertGeneralSet(emptySubprocessEvent.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); START assertErrorEventExecutionSet(emptySubprocessEvent.getExecutionSet(), EMPTY_VALUE, CANCELLING, ""); END assertDataIOSet(emptySubprocessEvent.getDataIOSet(), EMPTY_VALUE); } ```suggestion assertErrorEventExecutionSet(emptySubprocessEvent.getExecutionSet(), EMPTY_VALUE, CANCELLING, EMPTY_VALUE); ```

Target:
public void testUnmarshallSubprocessLevelEventEmptyProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_CATCHING_INTERMEDIATE_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); IntermediateErrorEventCatching emptySubprocessEvent = getCatchingIntermediateNodeById(diagram, EMPTY_SUBPROCESS_LEVEL_EVENT_ID, HAS_NO_INCOME_EDGE, HAS_NO_OUTGOING_EDGE); assertGeneralSet(emptySubprocessEvent.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); assertErrorEventExecutionSet(emptySubprocessEvent.getExecutionSet(), EMPTY_VALUE, CANCELLING, EMPTY_VALUE); assertDataIOSet(emptySubprocessEvent.getDataIOSet(), EMPTY_VALUE); }
Source:
public void testUnmarshallTopLevelEmptyEventProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_CATCHING_INTERMEDIATE_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); IntermediateTimerEvent emptyTopEvent = getCatchingIntermediateNodeById(diagram, EMPTY_TOP_LEVEL_EVENT_ID, HAS_NO_INCOME_EDGE, HAS_NO_OUTGOING_EDGE); assertGeneralSet(emptyTopEvent.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); START assertTimerEventEmpty(emptyTopEvent.getExecutionSet(), NON_CANCELLING, ""); END } ```suggestion assertTimerEventEmpty(emptyTopEvent.getExecutionSet(), NON_CANCELLING, EMPTY_VALUE); ```

Target:
public void testUnmarshallTopLevelEmptyEventProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_CATCHING_INTERMEDIATE_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); IntermediateTimerEvent emptyTopEvent = getCatchingIntermediateNodeById(diagram, EMPTY_TOP_LEVEL_EVENT_ID, HAS_NO_INCOME_EDGE, HAS_NO_OUTGOING_EDGE); assertGeneralSet(emptyTopEvent.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); assertTimerEventEmpty(emptyTopEvent.getExecutionSet(), NON_CANCELLING, EMPTY_VALUE); }
Source:
public void testUnmarshallTopLevelEmptyEventProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_CATCHING_INTERMEDIATE_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); IntermediateConditionalEvent emptyTopEvent = getCatchingIntermediateNodeById(diagram, EMPTY_TOP_LEVEL_EVENT_ID, HAS_NO_INCOME_EDGE, HAS_NO_OUTGOING_EDGE); assertGeneralSet(emptyTopEvent.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); assertConditionalEventExecutionSet(emptyTopEvent.getExecutionSet(), CONDITION_EXPRESSION_SCRIPT_DEFAULT_VALUE, CONDITION_EXPRESSION_LANGUAGE, CONDITION_ERPRESSION_TYPE, CANCELLING, START ""); END } ```suggestion EMPTY_VALUE); ```

Target:
public void testUnmarshallTopLevelEmptyEventProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_CATCHING_INTERMEDIATE_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); IntermediateConditionalEvent emptyTopEvent = getCatchingIntermediateNodeById(diagram, EMPTY_TOP_LEVEL_EVENT_ID, HAS_NO_INCOME_EDGE, HAS_NO_OUTGOING_EDGE); assertGeneralSet(emptyTopEvent.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); assertConditionalEventExecutionSet(emptyTopEvent.getExecutionSet(), CONDITION_EXPRESSION_SCRIPT_DEFAULT_VALUE, CONDITION_EXPRESSION_LANGUAGE, CONDITION_ERPRESSION_TYPE, CANCELLING, EMPTY_VALUE); }
Source:
public Collection<FormElementFilter> provideFilters(final String uuid, final Object definition) { START final Predicate predicate = o -> isBoundaryEvent(uuid) && isCancelActivityEnabled(uuid); END final FormElementFilter isInterruptingFilter = new FormElementFilter("executionSet.cancelActivity", predicate); return Collections.singletonList(isInterruptingFilter); } not a must, but predicate.and( o -> isCancelActivityEnabled(uuid)); can also be used

Target:
public Collection<FormElementFilter> provideFilters(final String uuid, final Object definition) { Predicate predicate = o -> isBoundaryEvent(uuid); predicate = predicate.and(o -> isCancelActivityEnabled(uuid)); final FormElementFilter isInterruptingFilter = new FormElementFilter("executionSet.cancelActivity", predicate); return Collections.singletonList(isInterruptingFilter); }
Source:
START public void testGetGraphIndex() throws Exception { END final Edge edge = mock(Edge.class); when(edge.getTargetNode()).thenReturn(child); when(parent.getOutEdges()).thenReturn(Collections.singletonList(edge)); assertEquals(0, CaseManagementCommandUtil.getChildGraphIndex(parent, child)); } The Exception is never thrown.

Target:
public void testGetGraphIndex() { final Edge edge = mock(Edge.class); when(edge.getTargetNode()).thenReturn(child); when(parent.getOutEdges()).thenReturn(Collections.singletonList(edge)); assertEquals(0, CaseManagementCommandUtil.getChildGraphIndex(parent, child)); }
Source:
START public void testIsStageNode() throws Exception { END setupForStage(); assertTrue(CaseManagementCommandUtil.isStageNode(child)); } The Exception is never thrown. Can you please use more descriptive name of test method?

Target:
public void testIsStageNode() { setupForStage(); assertTrue(CaseManagementCommandUtil.isStageNode(child)); }
Source:
START public void testChildPredicate() throws Exception { END final Predicate<Edge> predicate = CaseManagementCommandUtil.childPredicate(); final Edge edge = mock(Edge.class); when(edge.getContent()).thenReturn(mock(Child.class)); assertTrue(predicate.test(edge)); } The Exception is never thrown.

Target:
public void testChildPredicate() { final Predicate<Edge> predicate = CaseManagementCommandUtil.childPredicate(); final Edge edge = mock(Edge.class); when(edge.getContent()).thenReturn(mock(Child.class)); assertTrue(predicate.test(edge)); }
Source:
START public void testIsAdHocAutostart_false() throws Exception { END String id = UUID.randomUUID().toString(); AdHocSubProcess adHocSubProcess = bpmn2.createAdHocSubProcess(); adHocSubProcess.setId(id); CustomElement.autoStart.of(adHocSubProcess).set(Boolean.FALSE); tested = new AdHocSubProcessPropertyReader(adHocSubProcess, definitionResolverReal.getDiagram(), definitionResolverReal); assertFalse(tested.isAdHocAutostart()); } The Exception is never thrown.

Target:
public void testIsAdHocAutostart_false() { String id = UUID.randomUUID().toString(); AdHocSubProcess adHocSubProcess = bpmn2.createAdHocSubProcess(); adHocSubProcess.setId(id); CustomElement.autoStart.of(adHocSubProcess).set(Boolean.FALSE); tested = new AdHocSubProcessPropertyReader(adHocSubProcess, definitionResolverReal.getDiagram(), definitionResolverReal); assertFalse(tested.isAdHocAutostart()); }
Source:
START public void testIsDrawable_InvalidUserTask() throws Exception { END testIsDrawable(CaseManagementDiagram.class, UserTask.class, false); } The Exception is never thrown.

Target:
public void testIsDrawable_InvalidUserTask() { testIsDrawable(CaseManagementDiagram.class, UserTask.class, false); }
Source:
START public void setUp() throws Exception { END tested = new CaseManagementSwitchViewServiceImpl(factoryManager, definitionSetServiceInstances); } The Exception is never thrown.

Target:
public void setUp() { tested = new CaseManagementSwitchViewServiceImpl(factoryManager, definitionSetServiceInstances); }
Source:
START public void testReopenSession() throws Exception { END final ProjectDiagram projectDiagram = mock(ProjectDiagram.class); tested.reopenSession(projectDiagram); verify(sessionEditorPresenter, times(1)).destroy(); verify(sessionEditorPresenter, times(1)).open(eq(projectDiagram), any(SessionPresenter.SessionPresenterCallback.class)); } The Exception is never thrown.

Target:
public void testReopenSession() { final ProjectDiagram projectDiagram = mock(ProjectDiagram.class); tested.reopenSession(projectDiagram); verify(sessionEditorPresenter, times(1)).destroy(); verify(sessionEditorPresenter, times(1)).open(eq(projectDiagram), any(SessionPresenter.SessionPresenterCallback.class)); }
Source:
START public void setUp() throws Exception { END tested = new SwitchViewControl("COLUMNS", "Case View", caseViewSwitchHandler, "SITEMAP", "Process View", processViewSwitchHandler); } The Exception is never thrown.

Target:
public void setUp() { tested = new SwitchViewControl("COLUMNS", "Case View", caseViewSwitchHandler, "SITEMAP", "Process View", processViewSwitchHandler); }
Source:
default void logWarning(final ClientRuntimeError error) { START warn("[WARNING] DMNClientService could not get the asset list."); END warn(error.getMessage()); } I think this message comes from`DMNIncludeModelsClient`? As this is general method for logging, I think we can't have it here?

Target:
default void logWarning(final ClientRuntimeError error) { warn(error.getMessage()); }
Source:
public void testAcceptWhenIsExpectedClass() { when(rule.getId()).thenReturn(definition.getClass().getName()); START boolean actual = check.accepts(rule, context); END assertTrue(actual); } Just for consistency, please use `final boolean actual`

Target:
public void testAcceptWhenIsExpectedClass() { when(rule.getId()).thenReturn(definition.getClass().getName()); final boolean actual = check.accepts(rule, context); assertTrue(actual); }
Source:
public void testAcceptWhenIsNotExpectedClass() { when(rule.getId()).thenReturn("SomeOtherClass"); START boolean actual = check.accepts(rule, context); END assertFalse(actual); } Just for consistency, please use `final boolean actual`

Target:
public void testAcceptWhenIsNotExpectedClass() { when(rule.getId()).thenReturn("SomeOtherClass"); final boolean actual = check.accepts(rule, context); assertFalse(actual); }
Source:
public void testUnmarshallTopLevelEmptyEventProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_CONDITIONAL_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); StartConditionalEvent emptyTop = getStartNodeById(diagram, EMPTY_TOP_LEVEL_EVENT_ID, StartConditionalEvent.class); assertGeneralSet(emptyTop.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); assertConditionalEventExecutionSet(emptyTop.getExecutionSet(), CONDITION_EXPRESSION_SCRIPT_DEFAULT_VALUE, CONDITION_EXPRESSION_LANGUAGE, CONDITION_ERPRESSION_TYPE, INTERRUPTING, START ""); END } ```suggestion EMPTY_VALUE); ```

Target:
public void testUnmarshallTopLevelEmptyEventProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_CONDITIONAL_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); StartConditionalEvent emptyTop = getStartNodeById(diagram, EMPTY_TOP_LEVEL_EVENT_ID, StartConditionalEvent.class); assertGeneralSet(emptyTop.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); assertConditionalEventExecutionSet(emptyTop.getExecutionSet(), CONDITION_EXPRESSION_SCRIPT_DEFAULT_VALUE, CONDITION_EXPRESSION_LANGUAGE, CONDITION_ERPRESSION_TYPE, INTERRUPTING, EMPTY_VALUE); }
Source:
public void testUnmarshallTopLevelEmptyEventProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_START_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); StartErrorEvent emptyTop = getStartNodeById(diagram, EMPTY_TOP_LEVEL_EVENT_ID, getStartEventType()); assertGeneralSet(emptyTop.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); START assertErrorEventExecutionSet(emptyTop.getExecutionSet(), EMPTY_VALUE, NON_INTERRUPTING, ""); END assertDataIOSet(emptyTop.getDataIOSet(), EMPTY_VALUE); } ```suggestion assertErrorEventExecutionSet(emptyTop.getExecutionSet(), EMPTY_VALUE, NON_INTERRUPTING, EMPTY_VALUE); ```

Target:
public void testUnmarshallTopLevelEmptyEventProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_START_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); StartErrorEvent emptyTop = getStartNodeById(diagram, EMPTY_TOP_LEVEL_EVENT_ID, getStartEventType()); assertGeneralSet(emptyTop.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); assertErrorEventExecutionSet(emptyTop.getExecutionSet(), EMPTY_VALUE, NON_INTERRUPTING, EMPTY_VALUE); assertDataIOSet(emptyTop.getDataIOSet(), EMPTY_VALUE); }
Source:
public void testUnmarshallTopLevelEmptyEventProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_START_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); StartEscalationEvent emptyTop = getStartNodeById(diagram, EMPTY_TOP_LEVEL_EVENT_ID, StartEscalationEvent.class); assertGeneralSet(emptyTop.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); START assertEscalationEventExecutionSet(emptyTop.getExecutionSet(), EMPTY_VALUE, INTERRUPTING, ""); END assertDataIOSet(emptyTop.getDataIOSet(), EMPTY_VALUE); } ```suggestion assertEscalationEventExecutionSet(emptyTop.getExecutionSet(), EMPTY_VALUE, INTERRUPTING, EMPTY_VALUE); ```

Target:
public void testUnmarshallTopLevelEmptyEventProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_START_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); StartEscalationEvent emptyTop = getStartNodeById(diagram, EMPTY_TOP_LEVEL_EVENT_ID, StartEscalationEvent.class); assertGeneralSet(emptyTop.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); assertEscalationEventExecutionSet(emptyTop.getExecutionSet(), EMPTY_VALUE, INTERRUPTING, EMPTY_VALUE); assertDataIOSet(emptyTop.getDataIOSet(), EMPTY_VALUE); }
Source:
START public void testUnmarshallSubprocessLevelEventFilledProperties() throws Exception { END final String EVENT_NAME = "It is also not empty ~`!@#$%^&*()_+=-{}|\\][:\";'?><,./"; final String EVENT_DOCUMENTATION = "Some documentation as well\n~`!@#$%^&*()_+=-{}|\\][:\";'?><,./\n"; Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_START_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); StartNoneEvent filledSubprocess = getStartNodeById(diagram, FILLED_SUBPROCESS_LEVEL_EVENT_ID, StartNoneEvent.class); assertGeneralSet(filledSubprocess.getGeneral(), EVENT_NAME, EVENT_DOCUMENTATION); assertStartEventSlaDueDate(filledSubprocess.getExecutionSet(), SLA_DUE_DATE); } Missing assertNotNull for executionSet here.

Target:
public void testUnmarshallSubprocessLevelEventFilledProperties() throws Exception { final String EVENT_NAME = "It is also not empty ~`!@#$%^&*()_+=-{}|\\][:\";'?><,./"; final String EVENT_DOCUMENTATION = "Some documentation as well\n~`!@#$%^&*()_+=-{}|\\][:\";'?><,./\n"; Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_START_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); StartNoneEvent filledSubprocess = getStartNodeById(diagram, FILLED_SUBPROCESS_LEVEL_EVENT_ID, StartNoneEvent.class); assertGeneralSet(filledSubprocess.getGeneral(), EVENT_NAME, EVENT_DOCUMENTATION); assertNotNull(filledSubprocess.getExecutionSet()); assertStartEventSlaDueDate(filledSubprocess.getExecutionSet(), SLA_DUE_DATE); }
Source:
public DataTypeListItem getItem() { START return this.item; END } Just for consistency, we do not need the keyword `this` here, see the getter of `isEditModeEnabled`.

Target:
public DataTypeListItem getItem() { return item; }
Source:
private List<ItemDefinition> setItemDefinitionsNamespace(final List<ItemDefinition> itemDefinitions, final String namespace) { return itemDefinitions .stream() START .peek(itemDefinition -> setItemDefinitionNamespace(itemDefinition, namespace)) END .collect(Collectors.toList()); } Reading [this](https://stackoverflow.com/a/44371170) I think we should use `map` instead of `peek` , however I may miss something.

Target:
private List<ItemDefinition> setItemDefinitionsNamespace(final List<ItemDefinition> itemDefinitions, final String namespace) { return itemDefinitions .stream() .map(itemDefinition -> setItemDefinitionNamespace(itemDefinition, namespace)) .collect(Collectors.toList()); }
Source:
private void setItemDefinitionNamespace(final ItemDefinition itemDefinition, final String namespace) { START final String nameWithNamespace = namespace + "." + itemDefinition.getName(); END final List<ItemDefinition> itemComponents = itemDefinition.getItemComponent(); if (itemDefinition.getTypeRef() != null && !isBuiltInType(itemDefinition.getTypeRef())) { itemDefinition.setTypeRef(makeQNameWithNamespace(itemDefinition.getTypeRef(), namespace)); } itemDefinition.setName(nameWithNamespace); setItemDefinitionsNamespace(itemComponents, namespace); } Is `namespace` always non empty? Is this why you asked on chat if you can assume it?

Target:
private ItemDefinition setItemDefinitionNamespace(final ItemDefinition itemDefinition, final String namespace) { final String nameWithNamespace = namespace + "." + itemDefinition.getName(); final List<ItemDefinition> itemComponents = itemDefinition.getItemComponent(); if (itemDefinition.getTypeRef() != null && !isBuiltInType(itemDefinition.getTypeRef())) { itemDefinition.setTypeRef(makeQNameWithNamespace(itemDefinition.getTypeRef(), namespace)); } itemDefinition.setName(nameWithNamespace); setItemDefinitionsNamespace(itemComponents, namespace); return itemDefinition; }
Source:
START wbFromDMN(final String description) { END if (description == null) { return new Description(""); } else { return new Description(description); } } Please restore the original formatting.

Target:
public static Description wbFromDMN(final String description) { if (description == null) { return new Description(""); } else { return new Description(description); } }
Source:
public void setAbsoluteBounds(Node<? extends View, ?> node) { Object definition = node.getContent().getDefinition(); setBounds(absoluteBounds(node)); START if (definition instanceof BaseAdHocSubprocess || END definition instanceof EventSubprocess || definition instanceof EmbeddedSubprocess) { shape.setIsExpanded(true); } } This `if` condition could be placed `SubProcessPropertyWriter` overriding this method. Since this is specific to subprocesses. Makes sense?

Target:
public void setAbsoluteBounds(Node<? extends View, ?> node) { setBounds(absoluteBounds(node)); }
Source:
public static Node<View, Edge> getDockSourceNode(final Node<? extends View, ?> node) { return (Node<View, Edge>) node .getInEdges() .stream() .filter(PropertyWriterUtils::isDockEdge) .map(Edge::getSourceNode) .findFirst() START .orElse(null); END } why not returning the` Optional<Node> `?

Target:
public static Optional<Node<View, Edge>> getDockSourceNode(final Node<? extends View, ?> node) { return node.getInEdges().stream() .filter(PropertyWriterUtils::isDockEdge) .map(Edge::getSourceNode) .map(n -> (Node<View, Edge>) n) .findFirst(); }
Source:
public void testEqualsId() { START import1.setId(new Id("123")); END import2.setId(new Id("123")); assertEquals(import1, import2); } You don't need to set the `Id` here as it's done in the `setup()` method (but does no harm and makes the test clearer!)

Target:
public void testEqualsId() { assertEquals(import1, import2); }
Source:
void onCommandUndoExecuted(final @Observes CanvasCommandUndoneEvent commandUndoExecutedEvent) { CanvasHandler canvasHandler = commandUndoExecutedEvent.getCanvasHandler(); if (getSession().getCanvasHandler().equals(canvasHandler)) { START checkNotNull("commandUndoExecutedEvent", END commandUndoExecutedEvent); if (null != commandUndoExecutedEvent.getCommand()) { redoCommandHandler.onUndoCommandExecuted(commandUndoExecutedEvent.getCommand()); } checkState(); } } This check is pointless, as the NPE would have been thrown on L#120

Target:
void onCommandUndoExecuted(final @Observes CanvasCommandUndoneEvent commandUndoExecutedEvent) { checkNotNull("commandUndoExecutedEvent", commandUndoExecutedEvent); CanvasHandler canvasHandler = commandUndoExecutedEvent.getCanvasHandler(); if (getSession().getCanvasHandler().equals(canvasHandler)) { if (null != commandUndoExecutedEvent.getCommand()) { redoCommandHandler.onUndoCommandExecuted(commandUndoExecutedEvent.getCommand()); } checkState(); } }
Source:
START void init() { END dragArea.onmousedown = this::onDragAreaMouseDown; dragArea.onmouseup = this::onDragAreaMouseUp; dragArea.onmousemove = this::onDragAreaMouseMove; } I think this method could be `private`: ```suggestion private void init() { ```

Target:
private void init() { dragArea.onmousedown = this::onDragAreaMouseDown; dragArea.onmouseup = this::onDragAreaMouseUp; dragArea.onmousemove = this::onDragAreaMouseMove; }
Source:
public static <TYPE> Collection<ScanResult<TYPE>> scan(IOService ioService, Path rootPath, Collection<String> extensions, Function<InputStream, TYPE> converter) { START return scan(ioService, rootPath, extensions, converter, resouce -> true); END } Typo, `resource -> true` (you have `resouce`)

Target:
public static <TYPE> Collection<ScanResult<TYPE>> scan(IOService ioService, Path rootPath, Collection<String> extensions, Function<InputStream, TYPE> converter) { return scan(ioService, rootPath, extensions, converter, resource -> true); }