diff --git a/pom.xml b/pom.xml index d10aecce2..3cd64e655 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ edu.hm.hafner codingstyle-pom - 4.13.0 + 4.14.0 diff --git a/src/main/java/edu/hm/hafner/analysis/Report.java b/src/main/java/edu/hm/hafner/analysis/Report.java index 147654d94..925098b8b 100644 --- a/src/main/java/edu/hm/hafner/analysis/Report.java +++ b/src/main/java/edu/hm/hafner/analysis/Report.java @@ -1121,7 +1121,7 @@ private void readIssues(final ObjectInputStream input, final int size) throws IO var additionalProperties = (Serializable) input.readObject(); var uuid = (UUID) input.readObject(); - Issue issue = new Issue(path, fileName, + var issue = new Issue(path, fileName, lineStart, lineEnd, columnStart, columnEnd, lineRanges, category, type, packageName, moduleName, severity, message, description, diff --git a/src/test/java/edu/hm/hafner/analysis/DuplicationGroupTest.java b/src/test/java/edu/hm/hafner/analysis/DuplicationGroupTest.java index 7ffd0f38e..df9dae26d 100644 --- a/src/test/java/edu/hm/hafner/analysis/DuplicationGroupTest.java +++ b/src/test/java/edu/hm/hafner/analysis/DuplicationGroupTest.java @@ -25,7 +25,7 @@ class DuplicationGroupTest extends SerializableTest { @Override protected DuplicationGroup createSerializable() { - DuplicationGroup group = new DuplicationGroup(); + var group = new DuplicationGroup(); try (IssueBuilder builder = new IssueBuilder()) { group.add(builder.setAdditionalProperties(group).setFileName("1").build()); @@ -54,7 +54,7 @@ void shouldReadIssueFromOldSerialization() { @Test void shouldBeEmptyWhenCreated() { - DuplicationGroup group = new DuplicationGroup(); + var group = new DuplicationGroup(); assertThat(group.getCodeFragment()).isEmpty(); assertThat(group.getDuplications()).isEmpty(); @@ -62,7 +62,7 @@ void shouldBeEmptyWhenCreated() { @Test void shouldNotOverwriteFragmentOnceItHasBeenSet() { - DuplicationGroup group = new DuplicationGroup(); + var group = new DuplicationGroup(); assertThat(group.getCodeFragment()).isEmpty(); @@ -72,7 +72,7 @@ void shouldNotOverwriteFragmentOnceItHasBeenSet() { group.setCodeFragment("other"); assertThat(group.getCodeFragment()).isEqualTo(CODE_FRAGMENT); - DuplicationGroup groupWithFragment = new DuplicationGroup(CODE_FRAGMENT); + var groupWithFragment = new DuplicationGroup(CODE_FRAGMENT); assertThat(groupWithFragment.getCodeFragment()).isEqualTo(CODE_FRAGMENT); groupWithFragment.setCodeFragment("other"); @@ -82,7 +82,7 @@ void shouldNotOverwriteFragmentOnceItHasBeenSet() { @Test void shouldReferenceAllDuplications() { try (IssueBuilder builder = new IssueBuilder()) { - DuplicationGroup group = new DuplicationGroup(CODE_FRAGMENT); + var group = new DuplicationGroup(CODE_FRAGMENT); assertThat(group.getDuplications()).isEmpty(); @@ -100,9 +100,9 @@ void shouldReferenceAllDuplications() { @Test void shouldObeyEqualsContract() { try (IssueBuilder builder = new IssueBuilder()) { - LineRangeList red = new LineRangeList(); + var red = new LineRangeList(); red.add(new LineRange(1)); - LineRangeList blue = new LineRangeList(); + var blue = new LineRangeList(); blue.add(new LineRange(2)); EqualsVerifier .forClass(DuplicationGroup.class) diff --git a/src/test/java/edu/hm/hafner/analysis/FileNameResolverTest.java b/src/test/java/edu/hm/hafner/analysis/FileNameResolverTest.java index 6d67006ec..36f28c845 100644 --- a/src/test/java/edu/hm/hafner/analysis/FileNameResolverTest.java +++ b/src/test/java/edu/hm/hafner/analysis/FileNameResolverTest.java @@ -46,7 +46,7 @@ class FileNameResolverTest { @ValueSource(strings = {"/does/not/exist", "!<>$&/&(", "\0 Null-Byte", "C:/!<>$&/&( \0", "/!<>$&/&( \0"}) @DisplayName("Should not change path on errors") void shouldReturnFallbackOnError(final String fileName) { - Report report = createIssuesSingleton(fileName, new IssueBuilder()); + var report = createIssuesSingleton(fileName, new IssueBuilder()); resolvePaths(report, RESOURCE_FOLDER_PATH); @@ -66,7 +66,7 @@ private void resolvePaths(final Report report, final Path resourceFolderPath, @Test @DisplayName("Should skip processing if there are no issues") void shouldDoNothingIfNoIssuesPresent() { - Report report = new Report(); + var report = new Report(); resolvePaths(report, RESOURCE_FOLDER_PATH); @@ -77,7 +77,7 @@ void shouldDoNothingIfNoIssuesPresent() { @Test @DisplayName("Should set path if the relative file name exists") void shouldSetPath() { - Report report = new Report(); + var report = new Report(); try (IssueBuilder builder = new IssueBuilder()) { report.add(builder.setFileName(RELATIVE_FILE).build()); @@ -98,7 +98,7 @@ void shouldSetPath() { @Test @DisplayName("Should not set path if the relative file name doe not exist") void shouldNotSetPath() { - Report report = new Report(); + var report = new Report(); try (IssueBuilder builder = new IssueBuilder()) { report.add(builder.setFileName("not here").build()); @@ -119,7 +119,7 @@ void shouldNotSetPath() { @Test @DisplayName("Should skip existing absolute paths") void shouldNotTouchAbsolutePathOrEmptyPath() { - Report report = new Report(); + var report = new Report(); try (IssueBuilder builder = new IssueBuilder()) { report.add(builder.setFileName("").build()); @@ -170,8 +170,7 @@ void shouldNotTouchAbsolutePathOrEmptyPath() { @DisplayName("Should normalize different relative paths to the same file (file name is relative)") void shouldResolveRelativePath(final String fileName) { try (IssueBuilder builder = new IssueBuilder()) { - Report report; - report = createIssuesSingleton(fileName, builder.setOrigin(ID)); + var report = createIssuesSingleton(fileName, builder.setOrigin(ID)); resolvePaths(report, RESOURCE_FOLDER_PATH); assertThatFileResolvesToRelativeFile(report, fileName); @@ -183,12 +182,11 @@ void shouldResolveRelativePath(final String fileName) { @DisplayName("Should normalize different relative paths to the same file (file name is absolute)") void shouldNormalizePaths(final String fileName) { try (IssueBuilder issueBuilder = new IssueBuilder()) { - Report report = new Report(); - Issue issue; - issue = issueBuilder + Issue issue = issueBuilder .setDirectory(RESOURCE_FOLDER_STRING) .setFileName(normalize(fileName)) .build(); + var report = new Report(); report.add(issue); resolvePaths(report, Paths.get(RESOURCE_FOLDER)); @@ -252,7 +250,7 @@ private static boolean isWindows() { } private Report createIssuesSingleton(final String fileName, final IssueBuilder issueBuilder) { - Report report = new Report(); + var report = new Report(); Issue issue = issueBuilder.setFileName(fileName).build(); report.add(issue); return report; diff --git a/src/test/java/edu/hm/hafner/analysis/FileReaderFactoryTest.java b/src/test/java/edu/hm/hafner/analysis/FileReaderFactoryTest.java index 974042834..a7a4f0633 100644 --- a/src/test/java/edu/hm/hafner/analysis/FileReaderFactoryTest.java +++ b/src/test/java/edu/hm/hafner/analysis/FileReaderFactoryTest.java @@ -26,7 +26,7 @@ class FileReaderFactoryTest extends ResourceTest { @Test void shouldRemoveColorCodesAfterAllLineMappers() { - ConsoleLogReaderFactory factory = new ConsoleLogReaderFactory( + var factory = new ConsoleLogReaderFactory( getResourceAsFile("ath-colored.log")); assertThat(factory.readString()).isEqualTo("[WARNING]\n" diff --git a/src/test/java/edu/hm/hafner/analysis/FingerprintGeneratorBenchmark.java b/src/test/java/edu/hm/hafner/analysis/FingerprintGeneratorBenchmark.java index 003746567..c8302951f 100644 --- a/src/test/java/edu/hm/hafner/analysis/FingerprintGeneratorBenchmark.java +++ b/src/test/java/edu/hm/hafner/analysis/FingerprintGeneratorBenchmark.java @@ -28,7 +28,7 @@ public class FingerprintGeneratorBenchmark extends AbstractBenchmark { */ @Benchmark public void benchmarkingOneIssue(final BenchmarkState state) { - FingerprintGenerator generator = new FingerprintGenerator(); + var generator = new FingerprintGenerator(); generator.run(state.getFullTextFingerprint(), state.getSingleIssueReport(), CHARSET_AFFECTED_FILE); } @@ -41,7 +41,7 @@ public void benchmarkingOneIssue(final BenchmarkState state) { */ @Benchmark public void benchmarkingMultipleIssues(final BenchmarkState state) { - FingerprintGenerator generator = new FingerprintGenerator(); + var generator = new FingerprintGenerator(); generator.run(new FullTextFingerprint(), state.getMultipleIssuesReport(), CHARSET_AFFECTED_FILE); } @@ -57,6 +57,7 @@ public static class BenchmarkState { private Report singleIssueReport = new Report(); private FullTextFingerprint fingerprint = new FullTextFingerprint(); private Report multipleIssuesReport = new Report(); + @SuppressWarnings("NullAway") private Random random; public Report getSingleIssueReport() { @@ -87,7 +88,7 @@ public void doSetup() { @SuppressFBWarnings("PREDICTABLE_RANDOM") private Report createMultipleIssues(final int number) { - Report report = new Report(); + var report = new Report(); try (IssueBuilder builder = new IssueBuilder()) { builder.setFileName(AFFECTED_FILE_NAME); for (int i = 0; i < number; i++) { diff --git a/src/test/java/edu/hm/hafner/analysis/FingerprintGeneratorTest.java b/src/test/java/edu/hm/hafner/analysis/FingerprintGeneratorTest.java index 1874563fc..24d529584 100644 --- a/src/test/java/edu/hm/hafner/analysis/FingerprintGeneratorTest.java +++ b/src/test/java/edu/hm/hafner/analysis/FingerprintGeneratorTest.java @@ -27,7 +27,7 @@ class FingerprintGeneratorTest extends ResourceTest { @Test void shouldSkipFingerprintingIfEncodingIsWrong() throws IOException { - FingerprintGenerator generator = new FingerprintGenerator(); + var generator = new FingerprintGenerator(); Report report; try (IssueBuilder issueBuilder = new IssueBuilder()) { @@ -50,7 +50,7 @@ void shouldSkipFingerprintingIfEncodingIsWrong() throws IOException { @Test void shouldNotChangeIssuesWithFingerPrint() { try (IssueBuilder issueBuilder = new IssueBuilder()) { - FingerprintGenerator generator = new FingerprintGenerator(); + var generator = new FingerprintGenerator(); issueBuilder.setFileName(AFFECTED_FILE_NAME); Report report = createIssues(); @@ -70,9 +70,9 @@ void shouldNotChangeIssuesWithFingerPrint() { @Test void shouldSetDefaultFingerprintIfNoFileIsGiven() { try (IssueBuilder issueBuilder = new IssueBuilder()) { - FingerprintGenerator generator = new FingerprintGenerator(); + var generator = new FingerprintGenerator(); - Report report = new Report(); + var report = new Report(); report.add(issueBuilder.build()); generator.run(new FullTextFingerprint(), report, CHARSET_AFFECTED_FILE); @@ -84,14 +84,14 @@ void shouldSetDefaultFingerprintIfNoFileIsGiven() { @Test void shouldAssignIdenticalFingerprint() { - Report report = createTwoIssues(); - FingerprintGenerator generator = new FingerprintGenerator(); - FullTextFingerprint fingerprint = createFullTextFingerprint("fingerprint-one.txt"); + var report = createTwoIssues(); + var generator = new FingerprintGenerator(); + var fingerprint = createFullTextFingerprint("fingerprint-one.txt"); generator.run(fingerprint, report, CHARSET_AFFECTED_FILE); - Issue referenceIssue = report.get(0); - Issue currentIssue = report.get(1); + var referenceIssue = report.get(0); + var currentIssue = report.get(1); assertThat(referenceIssue).isNotEqualTo(currentIssue); assertThat(referenceIssue.getFingerprint()).isEqualTo(currentIssue.getFingerprint()); @@ -105,7 +105,7 @@ void shouldAssignIdenticalFingerprint() { @SuppressWarnings("MustBeClosedChecker") private FileSystem stubFileSystem(final String firstFile, final String secondFile) { try { - FileSystem fileSystem = mock(FileSystem.class); + var fileSystem = mock(FileSystem.class); when(fileSystem.readLinesFromFile(anyString(), any())) .thenReturn(asStream(firstFile)).thenReturn(asStream(secondFile)); return fileSystem; @@ -117,9 +117,9 @@ private FileSystem stubFileSystem(final String firstFile, final String secondFil @Test void shouldAssignDifferentFingerprint() { - Report report = createTwoIssues(); - FingerprintGenerator generator = new FingerprintGenerator(); - FullTextFingerprint fingerprint = createFullTextFingerprint("fingerprint-two.txt"); + var report = createTwoIssues(); + var generator = new FingerprintGenerator(); + var fingerprint = createFullTextFingerprint("fingerprint-two.txt"); generator.run(fingerprint, report, CHARSET_AFFECTED_FILE); @@ -135,7 +135,7 @@ void shouldAssignDifferentFingerprint() { void shouldUseFallbackFingerprintOnError(final String fileName) { var report = createReportWithOneIssueFor(fileName); - FingerprintGenerator generator = new FingerprintGenerator(); + var generator = new FingerprintGenerator(); generator.run(new FullTextFingerprint(), report, CHARSET_AFFECTED_FILE); assertThatIssueHasDefaultFingerprint(report); @@ -148,7 +148,7 @@ void shouldUseFallbackFingerprintOnError(final String fileName) { void shouldUseFallbackFingerprintOnNonSourceFiles(final String fileName) { var report = createReportWithOneIssueFor(fileName); - FingerprintGenerator generator = new FingerprintGenerator(); + var generator = new FingerprintGenerator(); generator.run(createFullTextFingerprint("fingerprint-two.txt"), report, CHARSET_AFFECTED_FILE); @@ -162,7 +162,7 @@ void shouldUseFallbackFingerprintOnIllegalFilenamesOnWindows(final String fileNa var report = createReportWithOneIssueFor(fileName); - FingerprintGenerator generator = new FingerprintGenerator(); + var generator = new FingerprintGenerator(); generator.run(createFullTextFingerprint("fingerprint-two.txt"), report, CHARSET_AFFECTED_FILE); @@ -170,12 +170,11 @@ void shouldUseFallbackFingerprintOnIllegalFilenamesOnWindows(final String fileNa } private Report createReportWithOneIssueFor(final String fileName) { - Report report; try (IssueBuilder issueBuilder = new IssueBuilder()) { - report = new Report(); + var report = new Report(); report.add(issueBuilder.setFileName(fileName).build()); + return report; } - return report; } private void assertThatIssueHasDefaultFingerprint(final Report report) { diff --git a/src/test/java/edu/hm/hafner/analysis/FullTextFingerprintTest.java b/src/test/java/edu/hm/hafner/analysis/FullTextFingerprintTest.java index dcc48594e..4b2b700ed 100644 --- a/src/test/java/edu/hm/hafner/analysis/FullTextFingerprintTest.java +++ b/src/test/java/edu/hm/hafner/analysis/FullTextFingerprintTest.java @@ -24,9 +24,9 @@ class FullTextFingerprintTest extends ResourceTest { */ @Test void shouldExtractCorrectLines() { - String affectedFile = new String(readAllBytes("context.txt"), StandardCharsets.UTF_8); + var affectedFile = new String(readAllBytes("context.txt"), StandardCharsets.UTF_8); - FullTextFingerprint fingerprint = new FullTextFingerprint(); + var fingerprint = new FullTextFingerprint(); assertThat(fingerprint.extractContext(-1, asIterator(affectedFile))) .as("Fingerprint for illegal line numbers should be empty").isEmpty(); @@ -44,7 +44,7 @@ void shouldExtractCorrectLines() { assertThat(fingerprint.extractContext(29, asIterator(affectedFile))).isEqualTo("67890"); assertThat(fingerprint.extractContext(30, asIterator(affectedFile))).isEqualTo("7890"); - // actually illegal but we use the remaining lines: + // actually illegal, but we use the remaining lines: assertThat(fingerprint.extractContext(31, asIterator(affectedFile))).isEqualTo("890"); assertThat(fingerprint.extractContext(32, asIterator(affectedFile))).isEqualTo("90"); assertThat(fingerprint.extractContext(33, asIterator(affectedFile))).isEqualTo("0"); @@ -59,11 +59,11 @@ void shouldExtractCorrectLines() { */ @Test void shouldAssignIdenticalFingerprints() { - String affectedFile = new String(readAllBytes("context.txt"), StandardCharsets.UTF_8); + var affectedFile = new String(readAllBytes("context.txt"), StandardCharsets.UTF_8); - FullTextFingerprint code = new FullTextFingerprint(); + var code = new FullTextFingerprint(); - String fingerprint = code.createFingerprint(10, getTextLinesAsStream(affectedFile), StandardCharsets.UTF_8); + var fingerprint = code.createFingerprint(10, getTextLinesAsStream(affectedFile), StandardCharsets.UTF_8); assertThat(fingerprint).isEqualTo("C10CFE4EC75F0C7F54980D432624D1C9"); for (int line = 0; line < 34; line++) { @@ -80,7 +80,7 @@ void shouldAssignIdenticalFingerprints() { @Test void shouldThrowNoSuchFileExceptionIfFileDoesNotExist() { - FullTextFingerprint fingerprint = new FullTextFingerprint(); + var fingerprint = new FullTextFingerprint(); assertThatExceptionOfType(NoSuchFileException.class) .isThrownBy(() -> fingerprint.compute("/does/not/exist", 1, StandardCharsets.UTF_8)); diff --git a/src/test/java/edu/hm/hafner/analysis/GradleModuleDetectorTest.java b/src/test/java/edu/hm/hafner/analysis/GradleModuleDetectorTest.java index b5e059da3..acc0f16c3 100644 --- a/src/test/java/edu/hm/hafner/analysis/GradleModuleDetectorTest.java +++ b/src/test/java/edu/hm/hafner/analysis/GradleModuleDetectorTest.java @@ -37,7 +37,7 @@ void shouldIdentifyModuleByReadingGradlePath() { when(stub.find(any(), anyString())).thenReturn( new String[] {PATH_PREFIX_GRADLE + GradleModuleDetector.BUILD_GRADLE})); - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_GRADLE + "build/reports/something.txt")) .isEqualTo(EXPECTED_GRADLE_MODULE_ROOT_BY_PATH); @@ -54,7 +54,7 @@ void shouldIdentifyModuleByFindingClosestGradlePath() { PATH_PREFIX_GRADLE + "a-module/" + GradleModuleDetector.BUILD_GRADLE, })); - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); String gradleWorkspace = PREFIX + PATH_PREFIX_GRADLE; assertThat(detector.guessModuleName( @@ -75,7 +75,7 @@ void shouldIdentifyModuleByReadingGradleKtsPath() { when(stub.find(any(), anyString())).thenReturn( new String[] {PATH_PREFIX_GRADLE + GradleModuleDetector.BUILD_GRADLE_KTS})); - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_GRADLE + "build/reports/something.txt")) .isEqualTo(EXPECTED_GRADLE_MODULE_ROOT_BY_PATH); @@ -94,7 +94,7 @@ void shouldIdentifyModuleByReadingGradleSettings() { when(stub.open(anyString())).thenAnswer(filename -> read("settings-1.gradle")); }); - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); String gradleWorkspace = PREFIX + PATH_PREFIX_GRADLE; assertThat(detector.guessModuleName( @@ -118,7 +118,7 @@ void shouldIdentifyModuleByReadingGradleSettingsKts() { when(stub.open(anyString())).thenAnswer(filename -> read("settings-1.gradle")); }); - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); String gradleWorkspace = PREFIX + PATH_PREFIX_GRADLE; assertThat(detector.guessModuleName(gradleWorkspace + "build/reports/something.txt")) @@ -139,7 +139,7 @@ void shouldEnsureThatGradleSettingsHasPrecedenceOverRootBuild() { when(stub.open(anyString())).thenAnswer(filename -> read("settings-1.gradle")); }); - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); String gradleWorkspace = PREFIX + PATH_PREFIX_GRADLE; assertThat(detector.guessModuleName( @@ -165,7 +165,7 @@ void shouldEnsureThatGradleSettingsCanParseFormat1() { String gradleWorkspace = PREFIX + PATH_PREFIX_GRADLE; - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); assertThat(detector.guessModuleName(gradleWorkspace + "build/reports/something.txt")) .isEqualTo(EXPECTED_GRADLE_MODULE_ROOT); } @@ -181,7 +181,7 @@ void shouldEnsureThatGradleSettingsCanParseFormat2() { String gradleWorkspace = PREFIX + PATH_PREFIX_GRADLE; - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); assertThat(detector.guessModuleName(gradleWorkspace + "build/reports/something.txt")) .isEqualTo("root-project-2"); } @@ -197,7 +197,7 @@ void shouldEnsureThatGradleSettingsCanParseFormat3() { String gradleWorkspace = PREFIX + PATH_PREFIX_GRADLE; - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); assertThat(detector.guessModuleName(gradleWorkspace + "build/reports/something.txt")) .isEqualTo("root-project-3"); } @@ -213,7 +213,7 @@ void shouldEnsureThatGradleSettingsCanParseFormat4() { String gradleWorkspace = PREFIX + PATH_PREFIX_GRADLE; - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); assertThat(detector.guessModuleName(gradleWorkspace + "build/reports/something.txt")) .isEqualTo("root-project-4"); } @@ -230,7 +230,7 @@ void shouldIgnoreGradleSettingsWithoutProjectName() { String gradleWorkspace = PREFIX + PATH_PREFIX_GRADLE; - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); assertThat(detector.guessModuleName(gradleWorkspace + "build/reports/something.txt")) .isEqualTo(EXPECTED_GRADLE_MODULE_ROOT_BY_PATH); } @@ -242,7 +242,7 @@ void shouldIgnoreGradleFileWithNoParentPath() { GradleModuleDetector.BUILD_GRADLE, })); - ModuleDetector detector = new ModuleDetector(ROOT_ABSOLUTE, factory); + var detector = new ModuleDetector(ROOT_ABSOLUTE, factory); assertThat(detector.guessModuleName("build/reports/something.txt")) .isEqualTo(StringUtils.EMPTY); } diff --git a/src/test/java/edu/hm/hafner/analysis/IssueBuilderTest.java b/src/test/java/edu/hm/hafner/analysis/IssueBuilderTest.java index 15fb3908b..190c506ac 100644 --- a/src/test/java/edu/hm/hafner/analysis/IssueBuilderTest.java +++ b/src/test/java/edu/hm/hafner/analysis/IssueBuilderTest.java @@ -239,12 +239,12 @@ void shouldCreateNewInstanceOnEveryCall() { void shouldCollectLineRanges() { try (IssueBuilder builder = new IssueBuilder()) { builder.setLineStart(1).setLineEnd(2); - LineRangeList lineRanges = new LineRangeList(); + var lineRanges = new LineRangeList(); lineRanges.add(new LineRange(3, 4)); lineRanges.add(new LineRange(5, 6)); builder.setLineRanges(lineRanges); - Issue issue = builder.build(); + var issue = builder.build(); assertThat(issue).hasLineStart(1).hasLineEnd(2); assertThat(issue).hasOnlyLineRanges(new LineRange(3, 4), new LineRange(5, 6)); @@ -258,11 +258,11 @@ void shouldCollectLineRanges() { @Test void shouldMoveLineRangeToAttributes() { try (IssueBuilder builder = new IssueBuilder()) { - LineRangeList lineRanges = new LineRangeList(); + var lineRanges = new LineRangeList(); lineRanges.add(new LineRange(1, 2)); builder.setLineRanges(lineRanges); - Issue issue = builder.build(); + var issue = builder.build(); assertThat(issue).hasLineStart(1).hasLineEnd(2); assertThat(issue).hasNoLineRanges(); } @@ -272,11 +272,11 @@ void shouldMoveLineRangeToAttributes() { void shouldMoveLineRangeToAttributesEvenIfLineEndIsSet() { try (IssueBuilder builder = new IssueBuilder()) { builder.setLineEnd(2); - LineRangeList lineRanges = new LineRangeList(); + var lineRanges = new LineRangeList(); lineRanges.add(new LineRange(1, 2)); builder.setLineRanges(lineRanges); - Issue issue = builder.build(); + var issue = builder.build(); assertThat(issue).hasLineStart(1).hasLineEnd(2); assertThat(issue).hasNoLineRanges(); } @@ -286,11 +286,11 @@ void shouldMoveLineRangeToAttributesEvenIfLineEndIsSet() { void shouldCleanupLineRanges() { try (IssueBuilder builder = new IssueBuilder()) { builder.setLineStart(1).setLineEnd(2); - LineRangeList lineRanges = new LineRangeList(); + var lineRanges = new LineRangeList(); lineRanges.add(new LineRange(1, 2)); builder.setLineRanges(lineRanges); - Issue issue = builder.build(); + var issue = builder.build(); assertThat(issue).hasLineStart(1).hasLineEnd(2); assertThat(issue).hasNoLineRanges(); } @@ -300,11 +300,11 @@ void shouldCleanupLineRanges() { void shouldNotCleanupDifferentLineRanges() { try (IssueBuilder builder = new IssueBuilder()) { builder.setLineStart(1).setLineEnd(2); - LineRangeList lineRanges = new LineRangeList(); + var lineRanges = new LineRangeList(); lineRanges.add(new LineRange(1, 3)); builder.setLineRanges(lineRanges); - Issue issue = builder.build(); + var issue = builder.build(); assertThat(issue).hasLineStart(1).hasLineEnd(2); assertThat(issue).hasOnlyLineRanges(new LineRange(1, 3)); } @@ -327,7 +327,7 @@ void shouldUseProvidedId() { @Test void testFileNameBackslashConversion() { try (IssueBuilder builder = new IssueBuilder()) { - Issue issue = builder.setFileName(FILE_NAME_WITH_BACKSLASHES).build(); + var issue = builder.setFileName(FILE_NAME_WITH_BACKSLASHES).build(); assertThat(issue).hasFileName(FILE_NAME); } @@ -336,8 +336,8 @@ void testFileNameBackslashConversion() { @Test void shouldCacheFileName() { try (IssueBuilder builder = new IssueBuilder()) { - Issue issue = builder.setFileName("fileName").build(); - Issue anotherIssue = builder.setFileName("fileName").build(); + var issue = builder.setFileName("fileName").build(); + var anotherIssue = builder.setFileName("fileName").build(); assertThat(issue.getFileNameTreeString()).isSameAs(anotherIssue.getFileNameTreeString()); } @@ -346,8 +346,8 @@ void shouldCacheFileName() { @Test void shouldCachePackageName() { try (IssueBuilder builder = new IssueBuilder()) { - Issue issue = builder.setPackageName("packageName").build(); - Issue anotherIssue = builder.setFileName("packageName").build(); + var issue = builder.setPackageName("packageName").build(); + var anotherIssue = builder.setFileName("packageName").build(); assertThat(issue.getPackageNameTreeString()).isSameAs(anotherIssue.getPackageNameTreeString()); } diff --git a/src/test/java/edu/hm/hafner/analysis/IssueDifferenceTest.java b/src/test/java/edu/hm/hafner/analysis/IssueDifferenceTest.java index 87e121289..a28153ef7 100644 --- a/src/test/java/edu/hm/hafner/analysis/IssueDifferenceTest.java +++ b/src/test/java/edu/hm/hafner/analysis/IssueDifferenceTest.java @@ -23,28 +23,28 @@ class IssueDifferenceTest extends ResourceTest { @Test void shouldCreateIssueDifferenceBasedOnPropertiesAndThenOnFingerprint() { - Report referenceIssues = new Report().addAll( + var referenceIssues = new Report().addAll( createIssue("OUTSTANDING 1", "OUT 1"), createIssue("OUTSTANDING 2", "OUT 2"), createIssue("OUTSTANDING 3", "OUT 3"), createIssue("TO FIX 1", "FIX 1"), createIssue("TO FIX 2", "FIX 2")); - Report currentIssues = new Report().addAll( + var currentIssues = new Report().addAll( createIssue("UPD OUTSTANDING 1", "OUT 1"), createIssue("OUTSTANDING 2", "UPD OUT 2"), createIssue("OUTSTANDING 3", "OUT 3"), createIssue("NEW 1", "NEW 1")); - IssueDifference issueDifference = new IssueDifference(currentIssues, CURRENT_BUILD, referenceIssues); + var issueDifference = new IssueDifference(currentIssues, CURRENT_BUILD, referenceIssues); - Report outstanding = issueDifference.getOutstandingIssues(); + var outstanding = issueDifference.getOutstandingIssues(); assertThat(outstanding).hasSize(3); assertThat(outstanding.get(0)).hasMessage("OUTSTANDING 2").hasReference(REFERENCE_BUILD); assertThat(outstanding.get(1)).hasMessage("OUTSTANDING 3").hasReference(REFERENCE_BUILD); assertThat(outstanding.get(2)).hasMessage("UPD OUTSTANDING 1").hasReference(REFERENCE_BUILD); - Report fixed = issueDifference.getFixedIssues(); + var fixed = issueDifference.getFixedIssues(); assertThat(fixed).hasSize(2); assertThat(fixed.get(0)).hasMessage("TO FIX 1").hasReference(REFERENCE_BUILD); assertThat(fixed.get(1)).hasMessage("TO FIX 2").hasReference(REFERENCE_BUILD); @@ -66,14 +66,14 @@ void shouldCreateOutstandingIssueDifference() { private void shouldFindOutstandingFromEqualsOrFingerprint( final String currentMessage, final String currentFingerprint) { - Report referenceIssues = new Report().add(createIssue("OLD", "OLD")); - Report currentIssues = new Report().add(createIssue(currentMessage, currentFingerprint)); + var referenceIssues = new Report().add(createIssue("OLD", "OLD")); + var currentIssues = new Report().add(createIssue(currentMessage, currentFingerprint)); - IssueDifference issueDifference = new IssueDifference(currentIssues, CURRENT_BUILD, referenceIssues); + var issueDifference = new IssueDifference(currentIssues, CURRENT_BUILD, referenceIssues); assertThat(issueDifference.getFixedIssues()).isEmpty(); assertThat(issueDifference.getNewIssues()).isEmpty(); - Report outstanding = issueDifference.getOutstandingIssues(); + var outstanding = issueDifference.getOutstandingIssues(); assertThat(outstanding).hasSize(1); assertThat(outstanding.get(0)) @@ -84,11 +84,11 @@ private void shouldFindOutstandingFromEqualsOrFingerprint( @Test void shouldCreateIssueDifferenceWithEmptyCurrent() { - Report referenceIssues = new Report().addAll(createIssue("OLD 1", "FA"), + var referenceIssues = new Report().addAll(createIssue("OLD 1", "FA"), createIssue("OLD 2", "FB")); - Report currentIssues = new Report(); + var currentIssues = new Report(); - IssueDifference issueDifference = new IssueDifference(currentIssues, CURRENT_BUILD, referenceIssues); + var issueDifference = new IssueDifference(currentIssues, CURRENT_BUILD, referenceIssues); assertThat(issueDifference.getNewIssues()).isEmpty(); assertThat(issueDifference.getOutstandingIssues()).isEmpty(); @@ -102,11 +102,11 @@ void shouldCreateIssueDifferenceWithEmptyCurrent() { @Test void shouldCreateIssueDifferenceWithEmptyReference() { - Report referenceIssues = new Report(); - Report currentIssues = new Report().addAll(createIssue("NEW 1", "FA"), + var referenceIssues = new Report(); + var currentIssues = new Report().addAll(createIssue("NEW 1", "FA"), createIssue("NEW 2", "FB")); - IssueDifference issueDifference = new IssueDifference(currentIssues, CURRENT_BUILD, referenceIssues); + var issueDifference = new IssueDifference(currentIssues, CURRENT_BUILD, referenceIssues); assertThat(issueDifference.getFixedIssues()).isEmpty(); assertThat(issueDifference.getOutstandingIssues()).isEmpty(); @@ -126,7 +126,7 @@ void shouldAlsoUseFingerprintIfIssuesAreEqual() { createIssue("NEW 1", "FP"), createIssue("OLD 1", "FP")); - IssueDifference issueDifference = new IssueDifference(currentIssues, CURRENT_BUILD, referenceIssues); + var issueDifference = new IssueDifference(currentIssues, CURRENT_BUILD, referenceIssues); assertThat(issueDifference.getFixedIssues()).isEmpty(); @@ -148,7 +148,7 @@ void shouldRemoveForSecondPass() { createIssue("NEW 1", "FP1"), createIssue("NEW 3", "FP2")); - IssueDifference issueDifference = new IssueDifference(currentIssues, CURRENT_BUILD, referenceIssues); + var issueDifference = new IssueDifference(currentIssues, CURRENT_BUILD, referenceIssues); assertThat(issueDifference.getFixedIssues()).hasSize(1); assertThat(issueDifference.getNewIssues()).hasSize(1); @@ -184,20 +184,20 @@ private Issue createIssue(final String message, final String fingerprint, final @Test @org.junitpioneer.jupiter.Issue("JENKINS-65482") void shouldHandleAggregatedResults() { - Report firstAxis = readSpotBugsWarnings(); + var firstAxis = readSpotBugsWarnings(); assertThat(firstAxis).hasSize(2); - Report secondAxis = readSpotBugsWarnings(); + var secondAxis = readSpotBugsWarnings(); assertThat(secondAxis).hasSize(2); - Report aggregation = new Report(); + var aggregation = new Report(); aggregation.addAll(firstAxis, secondAxis); assertThat(aggregation).hasSize(2); - Report reference = new Report(); + var reference = new Report(); reference.addAll(firstAxis, secondAxis); - IssueDifference issueDifference = new IssueDifference(aggregation, CURRENT_BUILD, reference); + var issueDifference = new IssueDifference(aggregation, CURRENT_BUILD, reference); assertThat(issueDifference).hasNoFixedIssues().hasNoNewIssues(); assertThat(issueDifference.getOutstandingIssues()).hasSize(2); } diff --git a/src/test/java/edu/hm/hafner/analysis/IssueFilterTest.java b/src/test/java/edu/hm/hafner/analysis/IssueFilterTest.java index 81b31eae9..4ae9b00cd 100644 --- a/src/test/java/edu/hm/hafner/analysis/IssueFilterTest.java +++ b/src/test/java/edu/hm/hafner/analysis/IssueFilterTest.java @@ -13,6 +13,7 @@ * * @author Raphael Furch */ +@SuppressWarnings("resource") class IssueFilterTest { private static final Issue ISSUE1 = new IssueBuilder() .setFileName("FileName1") @@ -47,21 +48,21 @@ class IssueFilterTest { */ @Test void shouldHandleApostrophe() { - Predicate predicate = new IssueFilterBuilder().setExcludeMessageFilter( + var predicate = new IssueFilterBuilder().setExcludeMessageFilter( "'tools.jar' was not found, kapt may work unreliably").build(); - Report report = new Report(); + var report = new Report(); report.add(new IssueBuilder().setMessage("'tools.jar' was not found, kapt may work unreliably").build()); - Report filtered = report.filter(predicate); + var filtered = report.filter(predicate); assertThat(filtered).hasSize(0); } @Test void shouldUseFindRatherThanMatch() { - Predicate predicate = new IssueFilterBuilder().setIncludeMessageFilter("something").build(); + var predicate = new IssueFilterBuilder().setIncludeMessageFilter("something").build(); - Report report = new Report(); + var report = new Report(); report.add(new IssueBuilder().setLineStart(1).setMessage("something").build()); report.add(new IssueBuilder().setLineStart(2).setMessage(" something").build()); report.add(new IssueBuilder().setLineStart(3).setMessage("something ").build()); @@ -70,21 +71,20 @@ void shouldUseFindRatherThanMatch() { report.add(new IssueBuilder().setLineStart(6).setMessage("Before something").build()); report.add(new IssueBuilder().setLineStart(7).setMessage("something After").build()); - Report filtered = report.filter(predicate); + var filtered = report.filter(predicate); assertThat(filtered).hasSize(7); } @Test void shouldMatchMultiLinesInMessage() { - Predicate predicate - = new IssueFilterBuilder().setExcludeMessageFilter(".*something.*").build(); + var predicate = new IssueFilterBuilder().setExcludeMessageFilter(".*something.*").build(); - Report report = new Report(); + var report = new Report(); report.add(new IssueBuilder().setMessage("something").build()); report.add(new IssueBuilder().setMessage("something\nelse").build()); report.add(new IssueBuilder().setMessage("else\nsomething").build()); - Report filtered = report.filter(predicate); + var filtered = report.filter(predicate); assertThat(filtered).hasSize(0); } @@ -95,15 +95,14 @@ void shouldMatchMultiLinesInMessage() { */ @Test void shouldMatchMultiLinesInDescription() { - Predicate predicate - = new IssueFilterBuilder().setExcludeMessageFilter(".*something.*").build(); + var predicate = new IssueFilterBuilder().setExcludeMessageFilter(".*something.*").build(); - Report report = new Report(); + var report = new Report(); report.add(new IssueBuilder().setDescription("something").build()); report.add(new IssueBuilder().setDescription("something\nelse").build()); report.add(new IssueBuilder().setDescription("else\nsomething").build()); - Report filtered = report.filter(predicate); + var filtered = report.filter(predicate); assertThat(filtered).hasSize(0); } @@ -114,28 +113,27 @@ void shouldMatchMultiLinesInDescription() { */ @Test void shouldMatchMessageOrDescriptionInIncludeFilter() { - Predicate predicate - = new IssueFilterBuilder().setIncludeMessageFilter(".*something.*").build(); + var predicate = new IssueFilterBuilder().setIncludeMessageFilter(".*something.*").build(); - Report report = new Report(); + var report = new Report(); report.add(new IssueBuilder().setDescription("something").setMessage("else").build()); report.add(new IssueBuilder().setDescription("else").setMessage("something").build()); report.add(new IssueBuilder().setDescription("else").setMessage("else").build()); report.add(new IssueBuilder().setDescription("something").setMessage("something").build()); - Report filtered = report.filter(predicate); + var filtered = report.filter(predicate); assertThat(filtered).hasSize(3); } @Test void shouldNothingChangeWhenNoFilterIsAdded() { - Predicate filter = new IssueFilterBuilder().build(); + var filter = new IssueFilterBuilder().build(); applyFilterAndCheckResult(filter, getIssues(), ISSUE1, ISSUE2, ISSUE3); } @Test void shouldPassAllWhenUselessFilterIsAdded() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setIncludeFileNameFilter("[a-zA-Z1]*") .setIncludeFileNameFilter("[a-zA-Z2]*") .setIncludeFileNameFilter("[a-zA-Z3]*") @@ -145,7 +143,7 @@ void shouldPassAllWhenUselessFilterIsAdded() { @Test void shouldPassAllWhenUselessFilterIsAddedAsList() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setIncludeFileNameFilter("[a-zA-Z1]*", "[a-zA-Z2]*", "[a-zA-Z3]*") .build(); applyFilterAndCheckResult(filter, getIssues(), ISSUE1, ISSUE2, ISSUE3); @@ -153,7 +151,7 @@ void shouldPassAllWhenUselessFilterIsAddedAsList() { @Test void shouldPassNoWhenMasterFilterIsAdded() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setExcludeFileNameFilter("[a-zA-Z_1-3]*") .build(); applyFilterAndCheckResult(filter, getIssues()); @@ -161,7 +159,7 @@ void shouldPassNoWhenMasterFilterIsAdded() { @Test void shouldPassNoWhenMasterFilterIsAddedAsList() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setExcludeFileNameFilter("[a-zA-Z1]*", "[a-zA-Z2]*", "[a-zA-Z3]*") .build(); applyFilterAndCheckResult(filter, getIssues()); @@ -169,7 +167,7 @@ void shouldPassNoWhenMasterFilterIsAddedAsList() { @Test void shouldFindIssue1ByAFileNameIncludeMatch() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setIncludeFileNameFilter("FileName1") .build(); applyFilterAndCheckResult(filter, getIssues(), ISSUE1); @@ -177,7 +175,7 @@ void shouldFindIssue1ByAFileNameIncludeMatch() { @Test void shouldFindIssue1ByAFileNameExcludeMatch() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setExcludeFileNameFilter("FileName1") .build(); applyFilterAndCheckResult(filter, getIssues(), ISSUE2, ISSUE3); @@ -185,7 +183,7 @@ void shouldFindIssue1ByAFileNameExcludeMatch() { @Test void shouldFindIssue2ByAPackageNameIncludeMatch() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setIncludePackageNameFilter("PackageName2") .build(); @@ -194,7 +192,7 @@ void shouldFindIssue2ByAPackageNameIncludeMatch() { @Test void shouldFindIssue2ByAPackageNameExcludeMatch() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setExcludePackageNameFilter("PackageName2") .build(); applyFilterAndCheckResult(filter, getIssues(), ISSUE1, ISSUE3); @@ -202,7 +200,7 @@ void shouldFindIssue2ByAPackageNameExcludeMatch() { @Test void shouldFindIssue3ByAModuleNameIncludeMatch() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setIncludeModuleNameFilter("ModuleName3") .build(); @@ -211,7 +209,7 @@ void shouldFindIssue3ByAModuleNameIncludeMatch() { @Test void shouldFindIssue3ByAModuleNameExcludeMatch() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setExcludeModuleNameFilter("ModuleName3") .build(); applyFilterAndCheckResult(filter, getIssues(), ISSUE1, ISSUE2); @@ -219,7 +217,7 @@ void shouldFindIssue3ByAModuleNameExcludeMatch() { @Test void shouldFindIssue1ByACategoryIncludeMatch() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setIncludeCategoryFilter("CategoryName1") .build(); applyFilterAndCheckResult(filter, getIssues(), ISSUE1); @@ -227,7 +225,7 @@ void shouldFindIssue1ByACategoryIncludeMatch() { @Test void shouldFindIssue1ByACategoryExcludeMatch() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setExcludeCategoryFilter("CategoryName1") .build(); applyFilterAndCheckResult(filter, getIssues(), ISSUE2, ISSUE3); @@ -235,7 +233,7 @@ void shouldFindIssue1ByACategoryExcludeMatch() { @Test void shouldFindIssue2ByATypeIncludeMatch() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setIncludeTypeFilter("Type2") .build(); applyFilterAndCheckResult(filter, getIssues(), ISSUE2); @@ -243,7 +241,7 @@ void shouldFindIssue2ByATypeIncludeMatch() { @Test void shouldFindIssue2ByACategoryExcludeMatch() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setExcludeTypeFilter("Type2") .build(); applyFilterAndCheckResult(filter, getIssues(), ISSUE1, ISSUE3); @@ -251,7 +249,7 @@ void shouldFindIssue2ByACategoryExcludeMatch() { @Test void shouldFindIntersectionFromIncludeAndExcludeBySameProperty() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setIncludeFileNameFilter("FileName1") .setIncludeFileNameFilter("FileName2") .setExcludeFileNameFilter("FileName2") @@ -261,7 +259,7 @@ void shouldFindIntersectionFromIncludeAndExcludeBySameProperty() { @Test void shouldFindIntersectionFromIncludeAndExcludeByOtherProperty() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setIncludeFileNameFilter("FileName1") .setIncludeFileNameFilter("FileName2") .setExcludeTypeFilter("Type2") @@ -271,7 +269,7 @@ void shouldFindIntersectionFromIncludeAndExcludeByOtherProperty() { @Test void shouldFindNoIntersectionFromEmptyIncludeAndExclude() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setIncludeFileNameFilter("FileNameNotExisting") .setExcludeTypeFilter("Type2") .build(); @@ -280,7 +278,7 @@ void shouldFindNoIntersectionFromEmptyIncludeAndExclude() { @Test void shouldFindIssue1ByAMessageIncludeMatch() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setIncludeMessageFilter("Message1") .build(); applyFilterAndCheckResult(filter, getIssues(), ISSUE1); @@ -288,7 +286,7 @@ void shouldFindIssue1ByAMessageIncludeMatch() { @Test void shouldRemoveIssue2ByAMessageExcludeMatch() { - Predicate filter = new IssueFilterBuilder() + var filter = new IssueFilterBuilder() .setExcludeMessageFilter("Message2") .build(); applyFilterAndCheckResult(filter, getIssues(), ISSUE1, ISSUE3); diff --git a/src/test/java/edu/hm/hafner/analysis/IssueTest.java b/src/test/java/edu/hm/hafner/analysis/IssueTest.java index 6933143cc..df5fdb3a5 100644 --- a/src/test/java/edu/hm/hafner/analysis/IssueTest.java +++ b/src/test/java/edu/hm/hafner/analysis/IssueTest.java @@ -60,7 +60,7 @@ class IssueTest extends SerializableTest { @Test void shouldSplitFileNameElements() { - Issue issue = new Issue(PATH_NAME, FILE_NAME_TS, 2, 1, 2, 1, LINE_RANGES, CATEGORY, + var issue = new Issue(PATH_NAME, FILE_NAME_TS, 2, 1, 2, 1, LINE_RANGES, CATEGORY, TYPE, PACKAGE_NAME_TS, MODULE_NAME, SEVERITY, MESSAGE_TS, DESCRIPTION, ORIGIN, ORIGIN_NAME, REFERENCE, FINGERPRINT, ADDITIONAL_PROPERTIES, UUID.randomUUID()); @@ -73,7 +73,7 @@ void shouldSplitFileNameElements() { .hasBaseName(BASE_NAME); } - TreeString newName = TreeString.valueOf("new.txt"); + var newName = TreeString.valueOf("new.txt"); issue.setFileName("/new", newName); try (SoftAssertions softly = new SoftAssertions()) { softly.assertThat(issue) @@ -83,13 +83,13 @@ void shouldSplitFileNameElements() { .hasBaseName("new.txt"); } - Issue other = new Issue(PATH_NAME, newName, 2, 1, 2, 1, LINE_RANGES, CATEGORY, + var other = new Issue(PATH_NAME, newName, 2, 1, 2, 1, LINE_RANGES, CATEGORY, TYPE, PACKAGE_NAME_TS, MODULE_NAME, SEVERITY, MESSAGE_TS, DESCRIPTION, ORIGIN, ORIGIN_NAME, REFERENCE, FINGERPRINT, ADDITIONAL_PROPERTIES, UUID.randomUUID()); assertThat(issue).as("Equals should not consider pathName in computation").isEqualTo(other); - Issue emptyPath = new Issue("", FILE_NAME_TS, 2, 1, 2, 1, LINE_RANGES, CATEGORY, + var emptyPath = new Issue("", FILE_NAME_TS, 2, 1, 2, 1, LINE_RANGES, CATEGORY, TYPE, PACKAGE_NAME_TS, MODULE_NAME, SEVERITY, MESSAGE_TS, DESCRIPTION, ORIGIN, ORIGIN_NAME, REFERENCE, FINGERPRINT, ADDITIONAL_PROPERTIES, UUID.randomUUID()); @@ -105,7 +105,7 @@ void shouldSplitFileNameElements() { @Test void shouldConvertWindowsNames() { - Issue issue = new Issue("C:\\Windows", FILE_NAME_TS, 2, 1, 2, 1, LINE_RANGES, CATEGORY, + var issue = new Issue("C:\\Windows", FILE_NAME_TS, 2, 1, 2, 1, LINE_RANGES, CATEGORY, TYPE, PACKAGE_NAME_TS, MODULE_NAME, SEVERITY, MESSAGE_TS, DESCRIPTION, ORIGIN, ORIGIN_NAME, REFERENCE, FINGERPRINT, ADDITIONAL_PROPERTIES, UUID.randomUUID()); @@ -135,7 +135,7 @@ void shouldExpandPath() { @Test void shouldEnsureThatEndIsGreaterOrEqualStart() { - Issue issue = new Issue(PATH_NAME, FILE_NAME_TS, 3, 2, 2, 1, LINE_RANGES, CATEGORY, + var issue = new Issue(PATH_NAME, FILE_NAME_TS, 3, 2, 2, 1, LINE_RANGES, CATEGORY, TYPE, PACKAGE_NAME_TS, MODULE_NAME, SEVERITY, MESSAGE_TS, DESCRIPTION, ORIGIN, ORIGIN_NAME, REFERENCE, FINGERPRINT, ADDITIONAL_PROPERTIES, UUID.randomUUID()); @@ -158,7 +158,7 @@ void shouldEnsureThatEndIsGreaterOrEqualStart() { */ @Test void shouldSetAllPropertiesInConstructor() { - Issue issue = createFilledIssue(); + var issue = createFilledIssue(); try (SoftAssertions softly = new SoftAssertions()) { softly.assertThat(issue.getId()).isNotNull(); @@ -197,7 +197,7 @@ void shouldSetAllPropertiesInConstructor() { @Test void shouldChangeMutableProperties() { - Issue issue = createFilledIssue(); + var issue = createFilledIssue(); String origin = "new-origin"; issue.setOrigin(origin); @@ -245,7 +245,7 @@ void shouldChangeMutableProperties() { @Test @SuppressWarnings("NullAway") void testDefaultIssueNullStringsNegativeIntegers() { - Issue issue = new Issue(null, UNDEFINED_TS, 0, 0, 0, 0, LINE_RANGES, null, null, + var issue = new Issue(null, UNDEFINED_TS, 0, 0, 0, 0, LINE_RANGES, null, null, UNDEFINED_TS, null, SEVERITY, EMPTY_TS, EMPTY, null, ORIGIN_NAME, null, null, null, UUID.randomUUID()); @@ -255,7 +255,7 @@ void testDefaultIssueNullStringsNegativeIntegers() { @Test void testDefaultIssueEmptyStringsNegativeIntegers() { - Issue issue = new Issue(EMPTY, UNDEFINED_TS, -1, -1, -1, -1, LINE_RANGES, EMPTY, EMPTY, + var issue = new Issue(EMPTY, UNDEFINED_TS, -1, -1, -1, -1, LINE_RANGES, EMPTY, EMPTY, UNDEFINED_TS, EMPTY, SEVERITY, EMPTY_TS, EMPTY, EMPTY, ORIGIN_NAME, EMPTY, EMPTY, EMPTY, UUID.randomUUID()); @@ -286,7 +286,7 @@ private void assertIsDefaultIssue(final Issue issue) { @Test void testZeroLineColumnEndsDefaultToLineColumnStarts() { - Issue issue = new Issue(PATH_NAME, FILE_NAME_TS, LINE_START, 0, COLUMN_START, 0, LINE_RANGES, CATEGORY, TYPE, + var issue = new Issue(PATH_NAME, FILE_NAME_TS, LINE_START, 0, COLUMN_START, 0, LINE_RANGES, CATEGORY, TYPE, PACKAGE_NAME_TS, MODULE_NAME, SEVERITY, MESSAGE_TS, DESCRIPTION, ORIGIN, ORIGIN_NAME, REFERENCE, FINGERPRINT, ADDITIONAL_PROPERTIES, UUID.randomUUID()); @@ -302,7 +302,7 @@ void testZeroLineColumnEndsDefaultToLineColumnStarts() { @Test void testNullPriorityDefaultsToNormal() { - Issue issue = new Issue(PATH_NAME, FILE_NAME_TS, LINE_START, LINE_END, COLUMN_START, COLUMN_END, LINE_RANGES, + var issue = new Issue(PATH_NAME, FILE_NAME_TS, LINE_START, LINE_END, COLUMN_START, COLUMN_END, LINE_RANGES, CATEGORY, TYPE, PACKAGE_NAME_TS, MODULE_NAME, null, MESSAGE_TS, DESCRIPTION, ORIGIN, ORIGIN_NAME, REFERENCE, FINGERPRINT, @@ -334,7 +334,7 @@ protected Issue createFilledIssue() { @Test void shouldObeyEqualsContract() { - LineRangeList filled = new LineRangeList(15); + var filled = new LineRangeList(15); filled.add(new LineRange(15)); EqualsVerifier.simple() diff --git a/src/test/java/edu/hm/hafner/analysis/JavaPackageDetectorTest.java b/src/test/java/edu/hm/hafner/analysis/JavaPackageDetectorTest.java index b7a795707..99d73edbb 100644 --- a/src/test/java/edu/hm/hafner/analysis/JavaPackageDetectorTest.java +++ b/src/test/java/edu/hm/hafner/analysis/JavaPackageDetectorTest.java @@ -36,14 +36,14 @@ void shouldExtractPackageNameFromJavaSource(final String fileName, final String @ParameterizedTest(name = "{index} => Invalid package name: {0}") @ValueSource(strings = {"package EDU.hm.hafner.analysis;", "package 0123.hm.hafner.analysis;"}) void shouldSkipPackagesThatDoNotStartWithLowerCase(final String name) throws IOException { - JavaPackageDetector detector = new JavaPackageDetector(); + var detector = new JavaPackageDetector(); assertThat(detector.detectPackageName(IOUtils.toInputStream(name, UTF_8), UTF_8)).isEqualTo("-"); } @Test void shouldAcceptCorrectFileSuffix() { - JavaPackageDetector packageDetector = new JavaPackageDetector(); + var packageDetector = new JavaPackageDetector(); assertThat(packageDetector.accepts("Action.java")).as("Does not accept a Java file.") .isTrue(); assertThat(packageDetector.accepts("ActionBinding.cs")).as("Accepts a non-Java file.") diff --git a/src/test/java/edu/hm/hafner/analysis/KotlinPackageDetectorTest.java b/src/test/java/edu/hm/hafner/analysis/KotlinPackageDetectorTest.java index bfbfc33d0..115d31cae 100644 --- a/src/test/java/edu/hm/hafner/analysis/KotlinPackageDetectorTest.java +++ b/src/test/java/edu/hm/hafner/analysis/KotlinPackageDetectorTest.java @@ -36,14 +36,14 @@ void shouldExtractPackageNameFromKotlinSource(final String fileName, final Strin @ParameterizedTest(name = "{index} => Invalid package name: {0}") @ValueSource(strings = {"package EDU.hm.hafner.analysis;", "package 0123.hm.hafner.analysis;"}) void shouldSkipPackagesThatDoNotStartWithLowerCase(final String name) throws IOException { - KotlinPackageDetector detector = new KotlinPackageDetector(); + var detector = new KotlinPackageDetector(); assertThat(detector.detectPackageName(IOUtils.toInputStream(name, UTF_8), UTF_8)).isEqualTo("-"); } @Test void shouldAcceptCorrectFileSuffix() { - KotlinPackageDetector packageDetector = new KotlinPackageDetector(); + var packageDetector = new KotlinPackageDetector(); assertThat(packageDetector.accepts("Action.kt")).as("Does not accept a Kotlin file.") .isTrue(); assertThat(packageDetector.accepts("ActionBinding.cs")).as("Accepts a non-Java file.") diff --git a/src/test/java/edu/hm/hafner/analysis/MavenModuleDetectorTest.java b/src/test/java/edu/hm/hafner/analysis/MavenModuleDetectorTest.java index 11c3b57b6..676dab477 100644 --- a/src/test/java/edu/hm/hafner/analysis/MavenModuleDetectorTest.java +++ b/src/test/java/edu/hm/hafner/analysis/MavenModuleDetectorTest.java @@ -36,7 +36,7 @@ void shouldIdentifyModuleByReadingMavenPom() { when(stub.open(anyString())).thenAnswer(fileName -> read(MavenModuleDetector.MAVEN_POM)); }); - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_MAVEN + "something.txt")).isEqualTo( EXPECTED_MAVEN_MODULE); @@ -52,7 +52,7 @@ void shouldIdentifyModuleByReadingMavenPomWithoutName() { when(stub.open(anyString())).thenAnswer(filename -> read("no-name-pom.xml")); }); - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); String artifactId = "com.avaloq.adt.core"; assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_MAVEN + "something.txt")) diff --git a/src/test/java/edu/hm/hafner/analysis/ModuleDetectorTest.java b/src/test/java/edu/hm/hafner/analysis/ModuleDetectorTest.java index f64b46317..a639d4db2 100644 --- a/src/test/java/edu/hm/hafner/analysis/ModuleDetectorTest.java +++ b/src/test/java/edu/hm/hafner/analysis/ModuleDetectorTest.java @@ -48,7 +48,7 @@ void shouldIdentifyModuleIfThereAreMoreEntries() { when(stub.open(PREFIX + maven)).thenAnswer(filename -> read(MavenModuleDetector.MAVEN_POM)); }); - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_ANT + "something.txt")) .isEqualTo(EXPECTED_ANT_MODULE); @@ -89,7 +89,7 @@ private void verifyOrder(final String prefix, final String ant, final String mav when(stub.open(maven)).thenAnswer(filename -> read(MavenModuleDetector.MAVEN_POM)); }); - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); assertThat(detector.guessModuleName(prefix + "something.txt")).isEqualTo(EXPECTED_MAVEN_MODULE); } @@ -105,7 +105,7 @@ private void verifyOrder(final String prefix, final String ant, final String mav when(stub.open(prefix + "/" + OsgiModuleDetector.BUNDLE_PROPERTIES)).thenAnswer(filename -> createEmptyStream()); }); - ModuleDetector detector = new ModuleDetector(ROOT, fileSystem); + var detector = new ModuleDetector(ROOT, fileSystem); assertThat(detector.guessModuleName(prefix + "something.txt")).isEqualTo(EXPECTED_OSGI_MODULE); } diff --git a/src/test/java/edu/hm/hafner/analysis/ModuleResolverTest.java b/src/test/java/edu/hm/hafner/analysis/ModuleResolverTest.java index 2c82cf90b..668704f86 100644 --- a/src/test/java/edu/hm/hafner/analysis/ModuleResolverTest.java +++ b/src/test/java/edu/hm/hafner/analysis/ModuleResolverTest.java @@ -17,7 +17,7 @@ class ModuleResolverTest { @SuppressFBWarnings("DMI") void shouldAssignModuleName() { try (IssueBuilder builder = new IssueBuilder()) { - Report report = new Report(); + var report = new Report(); String fileName = "/file/with/warnings.txt"; builder.setFileName(fileName); Issue noModule = builder.build(); @@ -27,10 +27,10 @@ void shouldAssignModuleName() { Issue withModule = builder.build(); report.add(withModule); - ModuleDetector detector = mock(ModuleDetector.class); + var detector = mock(ModuleDetector.class); when(detector.guessModuleName(fileName)).thenReturn("module1"); - ModuleResolver resolver = new ModuleResolver(); + var resolver = new ModuleResolver(); resolver.run(report, detector); assertThat(report.get(0)).hasModuleName("module1"); diff --git a/src/test/java/edu/hm/hafner/analysis/OsgiModuleDetectorTest.java b/src/test/java/edu/hm/hafner/analysis/OsgiModuleDetectorTest.java index f9e8da95b..6a18235c4 100644 --- a/src/test/java/edu/hm/hafner/analysis/OsgiModuleDetectorTest.java +++ b/src/test/java/edu/hm/hafner/analysis/OsgiModuleDetectorTest.java @@ -38,7 +38,7 @@ void shouldIdentifyModuleByReadingOsgiBundle() { when(stub.open(anyString())).thenReturn(read(MANIFEST)); }); - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_OSGI + "something.txt")) .isEqualTo(EXPECTED_OSGI_MODULE); @@ -55,7 +55,7 @@ void shouldIdentifyModuleByReadingOsgiBundleWithVendorInL10nProperties() { when(stub.open(anyString())).thenReturn(read(MANIFEST), read("l10n.properties")); }); - ModuleDetector detector = new ModuleDetector(ROOT, factory); + var detector = new ModuleDetector(ROOT, factory); String expectedName = "de.faktorlogik.prototyp (My Vendor)"; assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_OSGI + "something.txt")) @@ -74,7 +74,7 @@ void shouldIdentifyModuleByReadingOsgiBundleWithManifestName() { when(stub.open(anyString())).thenReturn(read(MANIFEST_NAME), read("l10n.properties")); }); - ModuleDetector detector = new ModuleDetector(ROOT, fileSystem); + var detector = new ModuleDetector(ROOT, fileSystem); String expectedName = "My Bundle"; assertThat(detector.guessModuleName(PREFIX + PATH_PREFIX_OSGI + "something.txt")) diff --git a/src/test/java/edu/hm/hafner/analysis/PackageNameResolverBenchmark.java b/src/test/java/edu/hm/hafner/analysis/PackageNameResolverBenchmark.java index aecf4bdec..0aca7a051 100644 --- a/src/test/java/edu/hm/hafner/analysis/PackageNameResolverBenchmark.java +++ b/src/test/java/edu/hm/hafner/analysis/PackageNameResolverBenchmark.java @@ -36,7 +36,7 @@ public class PackageNameResolverBenchmark extends AbstractBenchmark { @BenchmarkMode(Mode.Throughput) @Fork(value = 5, warmups = 5) public void benchmark1000IssuesTest(final BenchmarkState state) throws IOException { - PackageNameResolver resolver = new PackageNameResolver(createFileSystemStub()); + var resolver = new PackageNameResolver(createFileSystemStub()); resolver.run(state.getReport(), StandardCharsets.UTF_8); } diff --git a/src/test/java/edu/hm/hafner/analysis/PackageNameResolverTest.java b/src/test/java/edu/hm/hafner/analysis/PackageNameResolverTest.java index 7d647d0d6..3366e8734 100644 --- a/src/test/java/edu/hm/hafner/analysis/PackageNameResolverTest.java +++ b/src/test/java/edu/hm/hafner/analysis/PackageNameResolverTest.java @@ -28,7 +28,7 @@ class PackageNameResolverTest { void shouldDoNothingForEmptyIssues() { Report report = createIssues(); - PackageNameResolver resolver = new PackageNameResolver(); + var resolver = new PackageNameResolver(); resolver.run(report, StandardCharsets.UTF_8); assertThat(report).hasSize(0); @@ -39,7 +39,7 @@ void shouldSkipExistingPackage() { Report report = createIssues(); report.add(ISSUE_WITH_PACKAGE); - PackageNameResolver resolver = new PackageNameResolver(); + var resolver = new PackageNameResolver(); resolver.run(report, StandardCharsets.UTF_8); assertThat(report).hasSize(1); @@ -51,7 +51,7 @@ void shouldResolvePackage() throws IOException { Report report = createIssues(); report.add(ISSUE_WITHOUT_PACKAGE); - PackageNameResolver resolver = new PackageNameResolver(createFileSystemStub()); + var resolver = new PackageNameResolver(createFileSystemStub()); resolver.run(report, StandardCharsets.UTF_8); @@ -65,7 +65,7 @@ void shouldResolvePackageAndSkipExistingPackage() throws IOException { report.add(ISSUE_WITHOUT_PACKAGE); report.add(ISSUE_WITH_PACKAGE); - PackageNameResolver resolver = new PackageNameResolver(createFileSystemStub()); + var resolver = new PackageNameResolver(createFileSystemStub()); resolver.run(report, StandardCharsets.UTF_8); diff --git a/src/test/java/edu/hm/hafner/analysis/ReportSerializationBenchmark.java b/src/test/java/edu/hm/hafner/analysis/ReportSerializationBenchmark.java index 12d5a367e..62cd80d42 100644 --- a/src/test/java/edu/hm/hafner/analysis/ReportSerializationBenchmark.java +++ b/src/test/java/edu/hm/hafner/analysis/ReportSerializationBenchmark.java @@ -47,8 +47,7 @@ public void benchmarkingReportDeserialization(final Blackhole blackhole) { private static Report createReportWith(final int number) { try (IssueBuilder builder = new IssueBuilder()) { - Report report; - report = new Report(); + var report = new Report(); builder.setFileName(AFFECTED_FILE_NAME); builder.setLineStart(5); @@ -68,7 +67,7 @@ private static Report createReportWith(final int number) { * @return bytes */ private static byte[] toByteArray(final Report report) { - ByteArrayOutputStream out = new ByteArrayOutputStream(); + var out = new ByteArrayOutputStream(); try (ObjectOutputStream stream = new ObjectOutputStream(out)) { stream.writeObject(report); @@ -90,7 +89,7 @@ private static byte[] toByteArray(final Report report) { */ @SuppressFBWarnings("OBJECT_DESERIALIZATION") private static Report toReport(final byte[] bytes) { - ByteArrayInputStream in = new ByteArrayInputStream(bytes); + var in = new ByteArrayInputStream(bytes); try (ObjectInputStream stream = new ObjectInputStream(in)) { return (Report) stream.readObject(); diff --git a/src/test/java/edu/hm/hafner/analysis/ReportTest.java b/src/test/java/edu/hm/hafner/analysis/ReportTest.java index e994a90c4..f13d96744 100644 --- a/src/test/java/edu/hm/hafner/analysis/ReportTest.java +++ b/src/test/java/edu/hm/hafner/analysis/ReportTest.java @@ -99,7 +99,7 @@ static Issue build(final Consumer configuration) { @Test void shouldFindIssuesInModifiedCode() { - Report report = new Report(); + var report = new Report(); report.addAll(allIssuesAsList()); assertThat(report).hasNoInModifiedCode(); @@ -132,7 +132,7 @@ void shouldMergeLog() { @Test void shouldVerifyExistenceOfProperties() { - Report report = new Report(); + var report = new Report(); assertThat(report.hasTools()).isFalse(); assertThat(report.hasModules()).isFalse(); @@ -167,8 +167,7 @@ void shouldVerifyExistenceOfProperties() { private void verifySeverity(final Report report) { try (IssueBuilder issueBuilder = new IssueBuilder()) { - Issue additional; - additional = issueBuilder.setSeverity(Severity.WARNING_HIGH).build(); + Issue additional = issueBuilder.setSeverity(Severity.WARNING_HIGH).build(); report.add(additional); assertThat(report.hasTools()).isFalse(); assertThat(report.hasModules()).isFalse(); @@ -304,7 +303,7 @@ private void verifyOrigin(final Report report) { @Test void shouldFilterPriorities() { - Report report = new Report(); + var report = new Report(); report.addAll(allIssuesAsList()); assertThat(report.getSeverities()) @@ -328,7 +327,7 @@ void shouldFilterPriorities() { @Test @SuppressWarnings("NullAway") void shouldGroupIssuesByProperty() { - Report report = new Report(); + var report = new Report(); report.addAll(allIssuesAsList()); Map byPriority = report.groupByProperty("severity"); @@ -349,7 +348,7 @@ void shouldGroupIssuesByProperty() { */ @Test void shouldProvideNoWritingIterator() { - Report report = new Report(); + var report = new Report(); report.addAll(HIGH, NORMAL_1, NORMAL_2, LOW_2_A, LOW_2_B, LOW_FILE_3); Iterator iterator = report.iterator(); iterator.next(); @@ -361,22 +360,22 @@ void shouldProvideNoWritingIterator() { */ @Test void shouldCopyProperties() { - Report expected = new Report(ID, NAME, SOURCE_FILE); + var expected = new Report(ID, NAME, SOURCE_FILE); expected.addAll(HIGH, NORMAL_1, NORMAL_2, LOW_2_A, LOW_2_B, LOW_FILE_3); expected.logInfo("Hello"); expected.logInfo("World!"); expected.logError("Boom!"); expected.setCounter(KEY, VALUE); - Report copy = expected.copy(); + var copy = expected.copy(); assertThat(copy).isEqualTo(expected); assertThatAllIssuesHaveBeenAdded(copy); - Report report = new Report(); + var report = new Report(); report.addAll(expected); assertThatAllIssuesHaveBeenAdded(report); - Report empty = expected.copyEmptyInstance(); + var empty = expected.copyEmptyInstance(); assertThat(empty).isEmpty(); assertThat(empty.getErrorMessages()).isEqualTo(expected.getErrorMessages()); assertThat(empty.getInfoMessages()).isEqualTo(expected.getInfoMessages()); @@ -393,13 +392,13 @@ void shouldCopyProperties() { @Test void shouldSumCountersOnMerge() { - Report first = new Report(); + var first = new Report(); first.addAll(HIGH, NORMAL_1, NORMAL_2); first.addAll(HIGH, NORMAL_1, NORMAL_2); // 3 duplicates first.setCounter(KEY, 10); first.setCounter("one", 100); - Report second = new Report(); + var second = new Report(); second.addAll(LOW_2_A, LOW_2_B); second.addAll(LOW_2_A, LOW_2_B); // 2 duplicates second.setCounter(KEY, 1); @@ -416,17 +415,17 @@ void shouldSumCountersOnMerge() { /** Verifies some additional variants of the {@link Report#addAll(Report[])}. */ @Test void shouldVerifyPathInteriorCoverageOfAddAll() { - Report first = new Report().add(HIGH); + var first = new Report().add(HIGH); first.logInfo("1 info"); first.logError("1 error"); - Report second = new Report().addAll(NORMAL_1, NORMAL_2); + var second = new Report().addAll(NORMAL_1, NORMAL_2); second.logInfo("2 info"); second.logError("2 error"); - Report third = new Report().addAll(LOW_2_A, LOW_2_B, LOW_FILE_3); + var third = new Report().addAll(LOW_2_A, LOW_2_B, LOW_FILE_3); third.logInfo("3 info"); third.logError("3 error"); - Report report = new Report(); + var report = new Report(); report.addAll(first); assertThat((Iterable) report).containsExactly(HIGH); assertThat(report.getInfoMessages()).containsExactly("1 info"); @@ -437,13 +436,13 @@ void shouldVerifyPathInteriorCoverageOfAddAll() { assertThat(report.getInfoMessages()).containsExactly("1 info", "2 info", "3 info"); assertThat(report.getErrorMessages()).containsExactly("1 error", "2 error", "3 error"); - Report altogether = new Report(); + var altogether = new Report(); altogether.addAll(first, second, third); assertThatAllIssuesHaveBeenAdded(report); assertThat(report.getInfoMessages()).containsExactly("1 info", "2 info", "3 info"); assertThat(report.getErrorMessages()).containsExactly("1 error", "2 error", "3 error"); - Report inConstructor = new Report(first, second, third); + var inConstructor = new Report(first, second, third); assertThatAllIssuesHaveBeenAdded(inConstructor); assertThat(inConstructor.getInfoMessages()).containsExactly("1 info", "2 info", "3 info"); assertThat(inConstructor.getErrorMessages()).containsExactly("1 error", "2 error", "3 error"); @@ -451,7 +450,7 @@ void shouldVerifyPathInteriorCoverageOfAddAll() { @Test void shouldBeEmptyWhenCreated() { - Report report = new Report(); + var report = new Report(); assertThat(report).isEmpty(); assertThat(report.isNotEmpty()).isFalse(); @@ -470,7 +469,7 @@ private void assertThatReportHasSeverities(final Report report, final int expect @Test void shouldAddMultipleIssuesOneByOne() { - Report report = new Report(); + var report = new Report(); report.add(HIGH); report.add(NORMAL_1); @@ -484,7 +483,7 @@ void shouldAddMultipleIssuesOneByOne() { @Test void shouldAddMultipleIssuesAsCollection() { - Report report = new Report(); + var report = new Report(); List issueList = allIssuesAsList(); report.addAll(issueList); @@ -494,7 +493,7 @@ void shouldAddMultipleIssuesAsCollection() { @Test void shouldIterateOverAllElementsInCorrectOrder() { - Report report = new Report(); + var report = new Report(); report.add(HIGH); report.addAll(NORMAL_1, NORMAL_2); @@ -510,9 +509,9 @@ void shouldIterateOverAllElementsInCorrectOrder() { @Test void shouldSkipAddedElements() { - Report report = new Report().addAll(allIssuesAsList()); + var report = new Report().addAll(allIssuesAsList()); - Report fromEmpty = new Report(); + var fromEmpty = new Report(); fromEmpty.addAll(report.get()); assertThatAllIssuesHaveBeenAdded(fromEmpty); @@ -521,17 +520,17 @@ void shouldSkipAddedElements() { .hasDuplicatesSize(6); assertThatReportHasSeverities(report, 0, 1, 2, 3); - Report left = new Report().addAll(HIGH, NORMAL_1, NORMAL_2); - Report right = new Report().addAll(LOW_2_A, LOW_2_B, LOW_FILE_3); + var left = new Report().addAll(HIGH, NORMAL_1, NORMAL_2); + var right = new Report().addAll(LOW_2_A, LOW_2_B, LOW_FILE_3); - Report everything = new Report(); + var everything = new Report(); everything.addAll(left, right); assertThat(everything).hasSize(6); } @Test void shouldAddMultipleIssuesToNonEmpty() { - Report report = new Report(); + var report = new Report(); report.add(HIGH); report.addAll(asList(NORMAL_1, NORMAL_2)); @@ -566,7 +565,7 @@ private void assertThatAllIssuesHaveBeenAdded(final Report report) { @Test void shouldSkipDuplicates() { - Report report = new Report(); + var report = new Report(); report.add(HIGH); assertThat(report).hasSize(1).hasDuplicatesSize(0); report.add(HIGH); @@ -589,7 +588,7 @@ void shouldRemoveById() { } private void shouldRemoveOneIssue(final Issue... initialElements) { - Report report = new Report(); + var report = new Report(); report.addAll(asList(initialElements)); assertThat(report.remove(HIGH.getId())).isEqualTo(HIGH); @@ -599,7 +598,7 @@ private void shouldRemoveOneIssue(final Issue... initialElements) { @Test void shouldThrowExceptionWhenRemovingWithWrongKey() { - Report report = new Report(); + var report = new Report(); UUID id = HIGH.getId(); assertThatThrownBy(() -> report.remove(id)) @@ -609,7 +608,7 @@ void shouldThrowExceptionWhenRemovingWithWrongKey() { @Test void shouldFindIfOnlyOneIssue() { - Report report = new Report(); + var report = new Report(); report.addAll(Collections.singletonList(HIGH)); Issue found = report.findById(HIGH.getId()); @@ -625,7 +624,7 @@ void shouldFindWithinMultipleIssues() { } private void shouldFindIssue(final Issue... elements) { - Report report = new Report(); + var report = new Report(); report.addAll(asList(elements)); Issue found = report.findById(HIGH.getId()); @@ -640,7 +639,7 @@ void shouldThrowExceptionWhenSearchingWithWrongKey() { } private void shouldFindNothing(final Issue... elements) { - Report report = new Report(); + var report = new Report(); report.addAll(asList(elements)); UUID id = NORMAL_2.getId(); @@ -651,7 +650,7 @@ private void shouldFindNothing(final Issue... elements) { @Test void shouldReturnEmptyListIfPropertyDoesNotMatch() { - Report report = new Report(); + var report = new Report(); report.addAll(asList(HIGH, NORMAL_1, NORMAL_2)); Set found = report.findByProperty(Issue.bySeverity(Severity.WARNING_LOW)); @@ -661,7 +660,7 @@ void shouldReturnEmptyListIfPropertyDoesNotMatch() { @Test void testFindByProperty() { - Report report = new Report(); + var report = new Report(); report.addAll(asList(HIGH, NORMAL_1, NORMAL_2)); Set found = report.findByProperty(Issue.bySeverity(Severity.WARNING_HIGH)); @@ -671,7 +670,7 @@ void testFindByProperty() { @Test void shouldReturnIndexedValue() { - Report report = new Report(); + var report = new Report(); report.addAll(asList(HIGH, NORMAL_1, NORMAL_2)); assertThat(report.get(0)).isSameAs(HIGH); @@ -682,7 +681,7 @@ void shouldReturnIndexedValue() { @Test @SuppressFBWarnings("RV") void shouldThrowExceptionOnWrongIndex() { - Report report = new Report(); + var report = new Report(); report.addAll(asList(HIGH, NORMAL_1, NORMAL_2)); assertThatThrownBy(() -> report.get(-1)) @@ -695,7 +694,7 @@ void shouldThrowExceptionOnWrongIndex() { @Test void shouldReturnFiles() { - Report report = new Report(); + var report = new Report(); report.addAll(allIssuesAsList()); assertThat(report.getFiles()).contains("file-1", "file-1", "file-3"); @@ -707,7 +706,7 @@ private List allIssuesAsList() { @Test void shouldReturnSizeInToString() { - Report report = new Report(); + var report = new Report(); report.addAll(asList(HIGH, NORMAL_1, NORMAL_2)); assertThat(report.toString()).contains("3"); @@ -715,7 +714,7 @@ void shouldReturnSizeInToString() { @Test void shouldReturnProperties() { - Report report = new Report(); + var report = new Report(); report.addAll(allIssuesAsList()); Set properties = report.getProperties(Issue::getMessage); @@ -728,10 +727,10 @@ void shouldReturnProperties() { @Test void testCopy() { - Report original = new Report(); + var original = new Report(); original.addAll(asList(HIGH, NORMAL_1, NORMAL_2)); - Report copy = original.copy(); + var copy = original.copy(); assertThat(copy).isNotSameAs(original); assertThat(copy.iterator()).toIterable().containsExactly(HIGH, NORMAL_1, NORMAL_2); @@ -755,7 +754,7 @@ private void assertFilterFor(final BiFunction> propertyGetter, final String propertyName, final Function> predicate) { try (IssueBuilder builder = new IssueBuilder()) { - Report report = new Report(); + var report = new Report(); for (int i = 1; i < 4; i++) { for (int j = i; j < 4; j++) { @@ -778,7 +777,7 @@ private void assertFilterFor(final BiFunction predicate = filterBuilder.setIncludeCategoryFilter("Style").build(); assertThat(checkStyle.filter(predicate)).hasSize(1).hasId(CHECKSTYLE_ID).hasName(CHECKSTYLE_NAME); - Report filtered = container.filter(predicate); + var filtered = container.filter(predicate); verifyContainer(filtered, checkstyleWarning, spotBugsWarning); - Report copy = container.copy(); + var copy = container.copy(); verifyContainer(copy, checkstyleWarning, spotBugsWarning); - Report copyOfCopy = copy.copy(); + var copyOfCopy = copy.copy(); verifyContainer(copyOfCopy, checkstyleWarning, spotBugsWarning); assertThat(container.stream().map(Issue::getOrigin).collect(Collectors.toSet())) diff --git a/src/test/java/edu/hm/hafner/analysis/SeverityTest.java b/src/test/java/edu/hm/hafner/analysis/SeverityTest.java index 671f9e9bc..073e58a80 100644 --- a/src/test/java/edu/hm/hafner/analysis/SeverityTest.java +++ b/src/test/java/edu/hm/hafner/analysis/SeverityTest.java @@ -41,7 +41,7 @@ void shouldAssignSeverities() { @Test @SuppressWarnings("PMD.LiteralsFirstInComparisons") void shouldCreateNewSeverityThatOverridesEqualsAndToString() { String name = "severity"; - Severity severity = new Severity(name); + var severity = new Severity(name); assertThat(severity.getName()).isEqualTo(name); assertThat(severity).hasToString(name); diff --git a/src/test/java/edu/hm/hafner/analysis/parser/ParserBenchmark.java b/src/test/java/edu/hm/hafner/analysis/parser/ParserBenchmark.java index c71b6535d..dcb407093 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/ParserBenchmark.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/ParserBenchmark.java @@ -65,7 +65,9 @@ public void benchmarkPmdParser(final BenchmarkState state, final Blackhole black */ @State(Scope.Benchmark) public static class BenchmarkState { + @SuppressWarnings("NullAway") private ReaderFactory checkstyleFileReaderFactory; + @SuppressWarnings("NullAway") private ReaderFactory pmdFileReaderFactory; private ReaderFactory createFileReaderFactory(final String fileName) throws URISyntaxException { diff --git a/src/test/java/edu/hm/hafner/analysis/parser/XmlParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/XmlParserTest.java index 7bfc8f8b7..7c6907e9d 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/XmlParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/XmlParserTest.java @@ -62,9 +62,9 @@ protected XmlParser createParser() { @Test void shouldParseWithCustomPath() { - XmlParser parser = new XmlParser(CUSTOM_PATH); - Report report = parser.parse(createReaderFactory(ISSUES_CUSTOM_PATH_FILE)); - Iterator iterator = report.iterator(); + var parser = new XmlParser(CUSTOM_PATH); + var report = parser.parse(createReaderFactory(ISSUES_CUSTOM_PATH_FILE)); + var iterator = report.iterator(); try (SoftAssertions softly = new SoftAssertions()) { softly.assertThat(report) .hasSize(2); diff --git a/src/test/java/edu/hm/hafner/analysis/parser/checkstyle/CheckStyleRulesTest.java b/src/test/java/edu/hm/hafner/analysis/parser/checkstyle/CheckStyleRulesTest.java index dad8b5b5e..f399a0abc 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/checkstyle/CheckStyleRulesTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/checkstyle/CheckStyleRulesTest.java @@ -13,11 +13,13 @@ */ class CheckStyleRulesTest { private static final int NUMBER_OF_AVAILABLE_CHECKSTYLE_RULES = 163; + private static final Pattern EMPTY_ANNOTATION + = Pattern.compile(".*// empty annotation type\\s+.*", Pattern.MULTILINE | Pattern.DOTALL); /** Test whether we could parse the Checkstyle rule meta data. */ @Test void shouldLoadAndParseAllRules() { - CheckStyleRules rules = new CheckStyleRules(); + var rules = new CheckStyleRules(); assertThat(rules.getRules()).hasSize(NUMBER_OF_AVAILABLE_CHECKSTYLE_RULES); assertThat(rules.getRule("EmptyBlock")) @@ -42,7 +44,7 @@ void shouldLoadAndParseAllRules() { assertThat(rules.getRule("WhitespaceAround").getDescription()) .as("Wrong substitution of tag.") .contains("
public MyClass() {}      // empty constructor")
-                .matches(Pattern.compile(".*// empty annotation type\\s+
.*", Pattern.MULTILINE | Pattern.DOTALL)); + .matches(EMPTY_ANNOTATION); for (Rule rule : rules.getRules()) { assertThat(rule.getDescription()).as("Rule %s has no description", rule.getName()) diff --git a/src/test/java/edu/hm/hafner/analysis/parser/dry/cpd/CpdParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/dry/cpd/CpdParserTest.java index 4ceba3743..8ee1c3c45 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/dry/cpd/CpdParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/dry/cpd/CpdParserTest.java @@ -123,7 +123,7 @@ void shouldAssignPriority() { } private Report parse(final int highThreshold, final int normalThreshold) { - CpdParser parser = new CpdParser(highThreshold, normalThreshold); + var parser = new CpdParser(highThreshold, normalThreshold); return parser.parse(createReaderFactory("issue12516.xml")); } diff --git a/src/test/java/edu/hm/hafner/analysis/parser/dry/dupfinder/DupFinderParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/dry/dupfinder/DupFinderParserTest.java index a14904b5d..7d00589bc 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/dry/dupfinder/DupFinderParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/dry/dupfinder/DupFinderParserTest.java @@ -126,7 +126,7 @@ void shouldAssignPriority() { } private Report parse(final int highThreshold, final int normalThreshold) { - DupFinderParser parser = new DupFinderParser(highThreshold, normalThreshold); + var parser = new DupFinderParser(highThreshold, normalThreshold); return parser.parse(createReaderFactory("without-sourcecode.xml")); } } diff --git a/src/test/java/edu/hm/hafner/analysis/parser/dry/simian/SimianParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/dry/simian/SimianParserTest.java index 06527d467..531ded6d3 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/dry/simian/SimianParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/dry/simian/SimianParserTest.java @@ -1,5 +1,7 @@ package edu.hm.hafner.analysis.parser.dry.simian; +import java.util.Locale; + import org.junit.jupiter.api.Test; import edu.hm.hafner.analysis.Issue; @@ -108,7 +110,7 @@ void shouldFindOneDuplicationInFourFiles() { } private String getFileName(final int number) { - return String.format("C:/java/foo%d.java", number); + return String.format(Locale.ENGLISH, "C:/java/foo%d.java", number); } @Test @@ -147,7 +149,7 @@ void shouldAssignPriority() { } private Report parse(final int highThreshold, final int normalThreshold) { - SimianParser parser = new SimianParser(highThreshold, normalThreshold); + var parser = new SimianParser(highThreshold, normalThreshold); return parser.parse(createReaderFactory("twofile.xml")); } } diff --git a/src/test/java/edu/hm/hafner/analysis/parser/findbugs/FindBugsMessagesTest.java b/src/test/java/edu/hm/hafner/analysis/parser/findbugs/FindBugsMessagesTest.java index ebaf4abf5..476daca85 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/findbugs/FindBugsMessagesTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/findbugs/FindBugsMessagesTest.java @@ -48,7 +48,7 @@ void shouldReadAllFbContribMessages() { @Test void shouldMapMessagesToTypes() { - FindBugsMessages messages = new FindBugsMessages(); + var messages = new FindBugsMessages(); String expectedMessage = "A value that could be null is stored into a field that has been annotated as @Nonnull."; assertThat(messages.getMessage(NP_STORE_INTO_NONNULL_FIELD)) .contains(expectedMessage); @@ -64,7 +64,7 @@ void shouldMapMessagesToTypes() { @Test void issue55707() { - FindBugsMessages messages = new FindBugsMessages(); + var messages = new FindBugsMessages(); assertThat(messages.getShortMessage(PATH_TRAVERSAL_IN)) .isEqualTo("Potential Path Traversal (file read)"); assertThat(messages.getMessage(PATH_TRAVERSAL_IN)) diff --git a/src/test/java/edu/hm/hafner/analysis/parser/pmd/PmdMessagesTest.java b/src/test/java/edu/hm/hafner/analysis/parser/pmd/PmdMessagesTest.java index a8adaed1d..d9dcc7901 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/pmd/PmdMessagesTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/pmd/PmdMessagesTest.java @@ -14,7 +14,7 @@ class PmdMessagesTest { @Test void shouldInitializeRuleSets() { - PmdMessages messages = new PmdMessages(); + var messages = new PmdMessages(); assertThat(messages.size()) .as("Wrong number of rule sets found") .isEqualTo(EXPECTED_RULE_SETS_SIZE); diff --git a/src/test/java/edu/hm/hafner/analysis/parser/pylint/PyLintDescriptionsTest.java b/src/test/java/edu/hm/hafner/analysis/parser/pylint/PyLintDescriptionsTest.java index 37cbf6c7a..d304cd9f3 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/pylint/PyLintDescriptionsTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/pylint/PyLintDescriptionsTest.java @@ -12,7 +12,7 @@ class PyLintDescriptionsTest { @Test void shouldReadAllRules() { - PyLintDescriptions descriptions = new PyLintDescriptions(); + var descriptions = new PyLintDescriptions(); assertThat(descriptions.size()).isEqualTo(274); assertThat(descriptions.getDescription("C0112")) diff --git a/src/test/java/edu/hm/hafner/analysis/parser/violations/CppCheckAdapterTest.java b/src/test/java/edu/hm/hafner/analysis/parser/violations/CppCheckAdapterTest.java index 1fb8cdbc1..9a982e400 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/violations/CppCheckAdapterTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/violations/CppCheckAdapterTest.java @@ -140,12 +140,12 @@ void shouldFindErrorWithoutLocation() { */ @Test void shouldSkipDuplicatesJenkins61939() { - Report first = parse("cpp-check-1.xml"); + var first = parse("cpp-check-1.xml"); assertThat(first).hasSize(2); - Report second = parse("cpp-check-2.xml"); + var second = parse("cpp-check-2.xml"); assertThat(second).hasSize(3); - Report aggregation = new Report(); + var aggregation = new Report(); aggregation.addAll(first, second); assertThat(second).hasSize(3); } diff --git a/src/test/java/edu/hm/hafner/analysis/registry/AbstractParserTest.java b/src/test/java/edu/hm/hafner/analysis/registry/AbstractParserTest.java index 84efb190a..d711ca065 100644 --- a/src/test/java/edu/hm/hafner/analysis/registry/AbstractParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/registry/AbstractParserTest.java @@ -137,7 +137,7 @@ protected Report parseDefaultFile() { void shouldBeSerializable() throws IOException { IssueParser parser = createParser(); - ByteArrayOutputStream out = new ByteArrayOutputStream(); + var out = new ByteArrayOutputStream(); try (ObjectOutputStream stream = new ObjectOutputStream(out)) { stream.writeObject(parser); } @@ -153,7 +153,7 @@ void shouldBeSerializable() throws IOException { void shouldHandleEmptyFile() { boolean passed; try { - Report report = parseStringContent(""); + var report = parseStringContent(""); passed = report.isEmpty(); } catch (ParsingException e) { diff --git a/src/test/java/edu/hm/hafner/analysis/registry/ParserRegistryTest.java b/src/test/java/edu/hm/hafner/analysis/registry/ParserRegistryTest.java index 6fca68a0c..a4c58ae2c 100644 --- a/src/test/java/edu/hm/hafner/analysis/registry/ParserRegistryTest.java +++ b/src/test/java/edu/hm/hafner/analysis/registry/ParserRegistryTest.java @@ -26,7 +26,7 @@ class ParserRegistryTest extends ResourceTest { @Test void shouldThrowExceptionIfParserNotFound() { - ParserRegistry parserRegistry = new ParserRegistry(); + var parserRegistry = new ParserRegistry(); assertThatExceptionOfType(NoSuchElementException.class) .isThrownBy(() -> parserRegistry.get("-")); @@ -34,7 +34,7 @@ void shouldThrowExceptionIfParserNotFound() { @Test void shouldFindSomeParsers() { - ParserRegistry parserRegistry = new ParserRegistry(); + var parserRegistry = new ParserRegistry(); assertThat(parserRegistry).hasIds(SPOTBUGS, CHECKSTYLE, PMD).hasNames("SpotBugs", "CheckStyle", "PMD"); assertThat(parserRegistry.get(SPOTBUGS)).hasId(SPOTBUGS).hasName("SpotBugs"); @@ -47,8 +47,8 @@ void shouldFindSomeParsers() { @Test void shouldConfigureCpdParser() { - ParserRegistry parserRegistry = new ParserRegistry(); - ParserDescriptor cpdDescriptor = parserRegistry.get("cpd"); + var parserRegistry = new ParserRegistry(); + var cpdDescriptor = parserRegistry.get("cpd"); IssueParser parser = cpdDescriptor.createParser(); @@ -78,8 +78,8 @@ void shouldAssignCorrectSeverityForSpotBugs() { private void verifyPriority(final String type, final int expectedHighSize, final int expectedNormalSize, final int expectedLowSize) { - ParserRegistry parserRegistry = new ParserRegistry(); - ParserDescriptor findbugsDescriptor = parserRegistry.get("findbugs"); + var parserRegistry = new ParserRegistry(); + var findbugsDescriptor = parserRegistry.get("findbugs"); IssueParser parser = findbugsDescriptor.createParser(new Option(FindBugsDescriptor.PRIORITY_OPTION_KEY, type)); diff --git a/src/test/java/edu/hm/hafner/analysis/registry/ParsersTest.java b/src/test/java/edu/hm/hafner/analysis/registry/ParsersTest.java index 44de4e6f5..49698a990 100644 --- a/src/test/java/edu/hm/hafner/analysis/registry/ParsersTest.java +++ b/src/test/java/edu/hm/hafner/analysis/registry/ParsersTest.java @@ -348,8 +348,8 @@ void shouldFindAllCheckStyleIssues() { private void assertThatDescriptionOfIssueIsSet(final String tool, final Issue issue, final String expectedDescription) { - ParserRegistry parserRegistry = new ParserRegistry(); - ParserDescriptor descriptor = parserRegistry.get(tool); + var parserRegistry = new ParserRegistry(); + var descriptor = parserRegistry.get(tool); assertThat(issue).hasDescription(""); assertThat(descriptor.getDescription(issue)).contains(expectedDescription); @@ -359,7 +359,7 @@ private void assertThatDescriptionOfIssueIsSet(final String tool, final Issue is @Test void shouldFindAllFindBugsIssues() { String findbugs = "findbugs"; - Report report = findIssuesOfTool(2, findbugs, "findbugs-native.xml"); + var report = findIssuesOfTool(2, findbugs, "findbugs-native.xml"); assertThatDescriptionOfIssueIsSet(findbugs, report.get(0), "

The fields of this class appear to be accessed inconsistently with respect\n" @@ -406,7 +406,7 @@ void shouldFindAllSpotBugsIssues() { + "

"; String spotBugs = "spotbugs"; - Report report = findIssuesOfTool(2, spotBugs, "spotbugsXml.xml"); + var report = findIssuesOfTool(2, spotBugs, "spotbugsXml.xml"); assertThatDescriptionOfIssueIsSet(spotBugs, report.get(0), expectedDescription); } @@ -420,8 +420,8 @@ void shouldProvideMessagesAndDescriptionForSecurityIssuesWithSpotBugs() { + "by the user. If that is the case, the reported instance is a false positive.

"; String spotBugs = "spotbugs"; - Report report = findIssuesOfTool(1, spotBugs, "issue55707.xml"); - Issue issue = report.get(0); + var report = findIssuesOfTool(1, spotBugs, "issue55707.xml"); + var issue = report.get(0); assertThatDescriptionOfIssueIsSet(spotBugs, issue, expectedDescription); assertThat(issue).hasMessage( "java/nio/file/Paths.get(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path; reads a file whose location might be specified by user input"); @@ -868,10 +868,10 @@ void shouldFindAllOELintAdvIssues() { } private Report findIssuesOfTool(final int expectedSizeOfIssues, final String tool, final String... fileNames) { - ParserRegistry registry = new ParserRegistry(); - ParserDescriptor descriptor = registry.get(tool); + var registry = new ParserRegistry(); + var descriptor = registry.get(tool); - Report allIssues = new Report(); + var allIssues = new Report(); for (String fileName : fileNames) { IssueParser parser = descriptor.createParser(); Report report = parser.parse(new FileReaderFactory(getResourceAsFile("../parser/").resolve(fileName)));