diff --git a/pom.xml b/pom.xml index 6ca78a114..df68ac2c4 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE. org.projectlombok lombok - 1.18.28 + 1.18.30 provided @@ -115,7 +115,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE. com.jcabi jcabi-log - 0.22.0 + 0.24.1 com.jcabi @@ -149,6 +149,17 @@ OF THE POSSIBILITY OF SUCH DAMAGE. guava 32.0.0-jre + + com.google.code.gson + gson + 2.8.9 + runtime + + + org.ow2.asm + asm + 9.6 + org.junit.jupiter junit-jupiter-api @@ -194,7 +205,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE. org.hibernate.validator hibernate-validator - 6.0.20.Final + 8.0.1.Final test @@ -224,7 +235,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE. com.qulice qulice-maven-plugin - 0.20.0 + 0.22.0 diff --git a/qulice-checkstyle/src/test/java/com/qulice/checkstyle/ChecksTest.java b/qulice-checkstyle/src/test/java/com/qulice/checkstyle/ChecksTest.java index 32b728aa7..7fdbc8ccb 100644 --- a/qulice-checkstyle/src/test/java/com/qulice/checkstyle/ChecksTest.java +++ b/qulice-checkstyle/src/test/java/com/qulice/checkstyle/ChecksTest.java @@ -57,7 +57,7 @@ * Integration test case for all checkstyle checks. * @since 0.3 */ -public final class ChecksTest { +final class ChecksTest { /** * Test checkstyle for true negative. @@ -66,7 +66,7 @@ public final class ChecksTest { */ @ParameterizedTest @MethodSource("checks") - public void testCheckstyleTruePositive(final String dir) throws Exception { + void testCheckstyleTruePositive(final String dir) throws Exception { final AuditListener listener = Mockito.mock(AuditListener.class); final Collector collector = new ChecksTest.Collector(); Mockito.doAnswer(collector).when(listener) @@ -118,7 +118,7 @@ public void testCheckstyleTruePositive(final String dir) throws Exception { */ @ParameterizedTest @MethodSource("checks") - public void testCheckstyleTrueNegative(final String dir) throws Exception { + void testCheckstyleTrueNegative(final String dir) throws Exception { final AuditListener listener = Mockito.mock(AuditListener.class); final Collector collector = new ChecksTest.Collector(); Mockito.doAnswer(collector).when(listener) diff --git a/qulice-checkstyle/src/test/java/com/qulice/checkstyle/CheckstyleValidatorTest.java b/qulice-checkstyle/src/test/java/com/qulice/checkstyle/CheckstyleValidatorTest.java index 1450da958..13d0d3b84 100644 --- a/qulice-checkstyle/src/test/java/com/qulice/checkstyle/CheckstyleValidatorTest.java +++ b/qulice-checkstyle/src/test/java/com/qulice/checkstyle/CheckstyleValidatorTest.java @@ -65,7 +65,7 @@ "PMD.TooManyMethods", "PMD.AvoidDuplicateLiterals", "PMD.GodClass" } ) -public final class CheckstyleValidatorTest { +final class CheckstyleValidatorTest { /** * Name of property to set to change location of the license. @@ -97,7 +97,7 @@ public void setRule() { * @throws Exception If something wrong happens inside */ @Test - public void catchesCheckstyleViolationsInLicense() throws Exception { + void catchesCheckstyleViolationsInLicense() throws Exception { final Environment.Mock mock = new Environment.Mock(); final File license = this.rule.savePackageInfo( new File(mock.basedir(), CheckstyleValidatorTest.DIRECTORY) @@ -133,7 +133,7 @@ public void catchesCheckstyleViolationsInLicense() throws Exception { * @throws Exception In case of error */ @Test - public void acceptsInstanceMethodReferences() throws Exception { + void acceptsInstanceMethodReferences() throws Exception { this.runValidation( "InstanceMethodRef.java", true ); @@ -145,7 +145,7 @@ public void acceptsInstanceMethodReferences() throws Exception { * @throws Exception In case of error */ @Test - public void reportsErrorWhenParameterObjectIsNotDocumented() + void reportsErrorWhenParameterObjectIsNotDocumented() throws Exception { this.validate( "ParametrizedClass.java", false, @@ -159,7 +159,7 @@ public void reportsErrorWhenParameterObjectIsNotDocumented() * @throws Exception when error. */ @Test - public void reportsErrorWhenLineWrap() + void reportsErrorWhenLineWrap() throws Exception { this.validate( "LineWrapPackage.java", false, @@ -173,7 +173,7 @@ public void reportsErrorWhenLineWrap() * @throws Exception when error. */ @Test - public void reportsErrorWhenIndentationIsIncorrect() throws Exception { + void reportsErrorWhenIndentationIsIncorrect() throws Exception { this.validate( "InvalidIndentation.java", false, @@ -187,7 +187,7 @@ public void reportsErrorWhenIndentationIsIncorrect() throws Exception { * @throws Exception when error. */ @Test - public void doesNotReportErrorWhenMissingJavadocInTests() throws Exception { + void doesNotReportErrorWhenMissingJavadocInTests() throws Exception { this.runValidation("MissingJavadocTest.java", true); } @@ -198,7 +198,7 @@ public void doesNotReportErrorWhenMissingJavadocInTests() throws Exception { */ @Test @SuppressWarnings("unchecked") - public void reportsErrorWhenCommentOrJavadocIsTooLong() throws Exception { + void reportsErrorWhenCommentOrJavadocIsTooLong() throws Exception { final Collection results = this.runValidation("TooLongLines.java", false); MatcherAssert.assertThat( @@ -221,7 +221,7 @@ public void reportsErrorWhenCommentOrJavadocIsTooLong() throws Exception { */ @Test @SuppressWarnings("unchecked") - public void reportsAllCharEncodingUsages() throws Exception { + void reportsAllCharEncodingUsages() throws Exception { final String message = "Use java.nio.charset.StandardCharsets instead"; final String file = "DoNotUseCharEncoding.java"; @@ -268,7 +268,7 @@ public void reportsAllCharEncodingUsages() throws Exception { * @throws Exception If test failed. */ @Test - public void acceptsValidSingleLineComment() throws Exception { + void acceptsValidSingleLineComment() throws Exception { this.runValidation( "ValidSingleLineCommentCheck.java", true ); @@ -280,7 +280,7 @@ public void acceptsValidSingleLineComment() throws Exception { * @throws Exception when error. */ @Test - public void acceptsValidIndentation() throws Exception { + void acceptsValidIndentation() throws Exception { this.runValidation( "ValidIndentation.java", true ); @@ -292,7 +292,7 @@ public void acceptsValidIndentation() throws Exception { * @throws Exception when error. */ @Test - public void reportsErrorOnMoreThanOneReturnStatement() throws Exception { + void reportsErrorOnMoreThanOneReturnStatement() throws Exception { this.validate( "ReturnCount.java", false, "Return count is 2 (max allowed for non-void methods/lambdas is 1)" @@ -304,7 +304,7 @@ public void reportsErrorOnMoreThanOneReturnStatement() throws Exception { * @throws Exception In case of error */ @Test - public void acceptsDefaultMethodsWithFinalModifiers() throws Exception { + void acceptsDefaultMethodsWithFinalModifiers() throws Exception { this.runValidation( "DefaultMethods.java", true ); @@ -318,7 +318,7 @@ public void acceptsDefaultMethodsWithFinalModifiers() throws Exception { * used in field and class annotations. */ @Test - public void acceptsConstantUsedInMethodAnnotation() throws Exception { + void acceptsConstantUsedInMethodAnnotation() throws Exception { this.runValidation("AnnotationConstant.java", true); } @@ -328,7 +328,7 @@ public void acceptsConstantUsedInMethodAnnotation() throws Exception { * @throws Exception In case of error */ @Test - public void acceptsConstructorParametersNamedJustLikeFields() + void acceptsConstructorParametersNamedJustLikeFields() throws Exception { final String file = "ConstructorParams.java"; final Collection results = this.runValidation(file, false); @@ -360,7 +360,7 @@ public void acceptsConstructorParametersNamedJustLikeFields() */ @Test @SuppressWarnings("unchecked") - public void allowsOnlyProperlyNamedLocalVariables() throws Exception { + void allowsOnlyProperlyNamedLocalVariables() throws Exception { final String file = "LocalVariableNames.java"; final Collection results = this.runValidation( file, false @@ -419,7 +419,7 @@ public void allowsOnlyProperlyNamedLocalVariables() throws Exception { * @throws Exception In case of error */ @Test - public void allowsOnlyProperlyOrderedAtClauses() throws Exception { + void allowsOnlyProperlyOrderedAtClauses() throws Exception { final String file = "AtClauseOrder.java"; final Collection results = this.runValidation( file, false @@ -448,7 +448,7 @@ public void allowsOnlyProperlyOrderedAtClauses() throws Exception { */ @Test @Disabled - public void passesWindowsEndsOfLineWithoutException() throws Exception { + void passesWindowsEndsOfLineWithoutException() throws Exception { this.validate("WindowsEol.java", false, "LICENSE found:"); } @@ -462,7 +462,7 @@ public void passesWindowsEndsOfLineWithoutException() throws Exception { */ @Test @Disabled - public void testWindowsEndsOfLineWithLinuxSources() throws Exception { + void testWindowsEndsOfLineWithLinuxSources() throws Exception { this.runValidation("WindowsEolLinux.java", false); } @@ -471,7 +471,7 @@ public void testWindowsEndsOfLineWithLinuxSources() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public void allowsProperIndentationInAnnotations() throws Exception { + void allowsProperIndentationInAnnotations() throws Exception { this.runValidation("AnnotationIndentation.java", true); } @@ -481,7 +481,7 @@ public void allowsProperIndentationInAnnotations() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public void rejectsImproperIndentationInAnnotations() throws Exception { + void rejectsImproperIndentationInAnnotations() throws Exception { this.runValidation("AnnotationIndentationNegative.java", false); } @@ -491,7 +491,7 @@ public void rejectsImproperIndentationInAnnotations() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public void testExtraSemicolonInTryWithResources() throws Exception { + void testExtraSemicolonInTryWithResources() throws Exception { this.validate( "ExtraSemicolon.java", false, "Extra semicolon in the end of try-with-resources head." @@ -503,7 +503,7 @@ public void testExtraSemicolonInTryWithResources() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public void testSupportsRecordTypes() throws Exception { + void testSupportsRecordTypes() throws Exception { this.runValidation("ValidRecord.java", true); } @@ -513,7 +513,7 @@ public void testSupportsRecordTypes() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public void acceptsTryWithResourcesWithoutSemicolon() throws Exception { + void acceptsTryWithResourcesWithoutSemicolon() throws Exception { this.runValidation("ValidSemicolon.java", true); } @@ -523,7 +523,7 @@ public void acceptsTryWithResourcesWithoutSemicolon() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public void acceptsNonStaticMethodsInIt() throws Exception { + void acceptsNonStaticMethodsInIt() throws Exception { this.runValidation("ValidIT.java", true); } @@ -533,7 +533,7 @@ public void acceptsNonStaticMethodsInIt() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public void acceptsNonStaticMethodsInItCases() throws Exception { + void acceptsNonStaticMethodsInItCases() throws Exception { this.runValidation("ValidITCase.java", true); } @@ -544,7 +544,7 @@ public void acceptsNonStaticMethodsInItCases() throws Exception { * @throws Exception In case of error */ @Test - public void doesNotThrowExceptionIfImportsOnly() throws Exception { + void doesNotThrowExceptionIfImportsOnly() throws Exception { final Environment.Mock mock = new Environment.Mock(); final File license = this.rule.savePackageInfo( new File(mock.basedir(), CheckstyleValidatorTest.DIRECTORY) @@ -577,7 +577,7 @@ public void doesNotThrowExceptionIfImportsOnly() throws Exception { */ @Test @SuppressWarnings({"unchecked", "PMD.AvoidDuplicateLiterals"}) - public void distinguishesValidCatchParameterNames() throws Exception { + void distinguishesValidCatchParameterNames() throws Exception { final String file = "CatchParameterNames.java"; final Collection results = this.runValidation( file, false @@ -605,7 +605,7 @@ public void distinguishesValidCatchParameterNames() throws Exception { * @throws Exception In case of error */ @Test - public void doesNotRejectUrlsInLongLines() throws Exception { + void doesNotRejectUrlsInLongLines() throws Exception { this.runValidation("UrlInLongLine.java", true); } @@ -615,7 +615,7 @@ public void doesNotRejectUrlsInLongLines() throws Exception { * @throws Exception In case of error */ @Test - public void allowsSpacesBetweenMethodsOfAnonymousClasses() + void allowsSpacesBetweenMethodsOfAnonymousClasses() throws Exception { this.runValidation("BlankLinesOutsideMethodsPass.java", true); } @@ -627,7 +627,7 @@ public void allowsSpacesBetweenMethodsOfAnonymousClasses() */ @Test @SuppressWarnings({"unchecked", "PMD.AvoidDuplicateLiterals"}) - public void rejectsSpacesInsideMethods() throws Exception { + void rejectsSpacesInsideMethods() throws Exception { final String file = "BlankLinesInsideMethodsFail.java"; final Collection result = this.runValidation( file, false @@ -661,7 +661,7 @@ public void rejectsSpacesInsideMethods() throws Exception { */ @Test @SuppressWarnings("unchecked") - public void rejectsUppercaseAbbreviations() throws Exception { + void rejectsUppercaseAbbreviations() throws Exception { final String file = "InvalidAbbreviationAsWordInNameXML.java"; final Collection results = this.runValidation( file, false @@ -695,7 +695,7 @@ public void rejectsUppercaseAbbreviations() throws Exception { * @throws Exception In case of error */ @Test - public void allowsITUppercaseAbbreviation() throws Exception { + void allowsITUppercaseAbbreviation() throws Exception { this.runValidation("ValidAbbreviationAsWordInNameIT.java", true); } @@ -706,7 +706,7 @@ public void allowsITUppercaseAbbreviation() throws Exception { * @throws Exception In case of error */ @Test - public void allowsUppercaseAbbreviationExceptions() throws Exception { + void allowsUppercaseAbbreviationExceptions() throws Exception { this.runValidation("ValidAbbreviationAsWordInName.java", true); } @@ -718,7 +718,7 @@ public void allowsUppercaseAbbreviationExceptions() throws Exception { */ @Disabled @Test - public void checkLambdaAndGenericsAtEndOfLine() throws Exception { + void checkLambdaAndGenericsAtEndOfLine() throws Exception { this.runValidation("ValidLambdaAndGenericsAtEndOfLine.java", true); } @@ -727,7 +727,7 @@ public void checkLambdaAndGenericsAtEndOfLine() throws Exception { * @throws Exception If error */ @Test - public void rejectsNonDiamondOperatorUsage() throws Exception { + void rejectsNonDiamondOperatorUsage() throws Exception { final String file = "InvalidDiamondsUsage.java"; final String name = "DiamondOperatorCheck"; final String message = "Use diamond operator"; @@ -745,7 +745,7 @@ public void rejectsNonDiamondOperatorUsage() throws Exception { * @throws Exception If error */ @Test - public void allowsDiamondOperatorUsage() throws Exception { + void allowsDiamondOperatorUsage() throws Exception { this.runValidation("ValidDiamondsUsage.java", true); } @@ -755,7 +755,7 @@ public void allowsDiamondOperatorUsage() throws Exception { * @throws Exception If error */ @Test - public void allowsFullGenericOperatorUsage() throws Exception { + void allowsFullGenericOperatorUsage() throws Exception { this.runValidation("DiamondUsageNotNeeded.java", true); } @@ -766,7 +766,7 @@ public void allowsFullGenericOperatorUsage() throws Exception { * @throws Exception If error */ @Test - public void allowsStringLiteralsOnBothSideInComparisons() + void allowsStringLiteralsOnBothSideInComparisons() throws Exception { this.runValidation("ValidLiteralComparisonCheck.java", true); } diff --git a/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/MissingJavadocTest.java b/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/MissingJavadocTest.java index 4a47a1e8d..b6ad30b54 100644 --- a/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/MissingJavadocTest.java +++ b/qulice-checkstyle/src/test/resources/com/qulice/checkstyle/MissingJavadocTest.java @@ -9,7 +9,7 @@ * Simple. * @since 1.0 */ -public class MissingJavadocTest { +class MissingJavadocTest { @Test public void testSomething() { diff --git a/qulice-maven-plugin/pom.xml b/qulice-maven-plugin/pom.xml index cb751feed..d49acb995 100644 --- a/qulice-maven-plugin/pom.xml +++ b/qulice-maven-plugin/pom.xml @@ -163,13 +163,13 @@ OF THE POSSIBILITY OF SUCH DAMAGE. org.apache.maven maven-artifact - 3.0.5 + 3.9.6 provided org.apache.maven.shared maven-dependency-analyzer - 1.5 + 1.13.2 org.apache.maven @@ -179,6 +179,10 @@ OF THE POSSIBILITY OF SUCH DAMAGE. org.apache.maven maven-artifact-manager + + org.ow2.asm + asm + @@ -230,18 +234,26 @@ OF THE POSSIBILITY OF SUCH DAMAGE. org.hibernate hibernate-validator - 6.0.23.Final + 8.0.1.Final runtime net.sourceforge.pmd pmd-core - 6.10.0 + 6.55.0 net.sourceforge.saxon saxon + + org.ow2.asm + asm + + + com.google.code.gson + gson + diff --git a/qulice-maven-plugin/src/it/multi-module/mod-alpha/src/test/java/com/qulice/plugin/alpha/MainTest.java b/qulice-maven-plugin/src/it/multi-module/mod-alpha/src/test/java/com/qulice/plugin/alpha/MainTest.java index 4d851d59b..eec490571 100644 --- a/qulice-maven-plugin/src/it/multi-module/mod-alpha/src/test/java/com/qulice/plugin/alpha/MainTest.java +++ b/qulice-maven-plugin/src/it/multi-module/mod-alpha/src/test/java/com/qulice/plugin/alpha/MainTest.java @@ -45,8 +45,14 @@ final class MainTest { */ @Test void testSquare() { - MatcherAssert.assertThat(1, Matchers.is(Main.square(1))); - MatcherAssert.assertThat(4, Matchers.is(Main.square(2))); + MatcherAssert.assertThat( + "Square for 1 should be 1", + 1, Matchers.is(Main.square(1)) + ); + MatcherAssert.assertThat( + "Square for 2 should be 4", + 4, Matchers.is(Main.square(2)) + ); } } diff --git a/qulice-maven-plugin/src/main/java/com/qulice/maven/AbstractQuliceMojo.java b/qulice-maven-plugin/src/main/java/com/qulice/maven/AbstractQuliceMojo.java index 917b31f84..2e0914aa4 100644 --- a/qulice-maven-plugin/src/main/java/com/qulice/maven/AbstractQuliceMojo.java +++ b/qulice-maven-plugin/src/main/java/com/qulice/maven/AbstractQuliceMojo.java @@ -61,13 +61,13 @@ public abstract class AbstractQuliceMojo extends AbstractMojo /** * Maven project, to be injected by Maven itself. */ - @Component + @Parameter(defaultValue = "${project}", readonly = true) private MavenProject project; /** * Maven session, to be injected by Maven itself. */ - @Component + @Parameter(defaultValue = "${session}", readonly = true) private MavenSession sess; /** diff --git a/qulice-maven-plugin/src/main/java/com/qulice/maven/DependenciesValidator.java b/qulice-maven-plugin/src/main/java/com/qulice/maven/DependenciesValidator.java index 3e0c33000..e07d48f46 100644 --- a/qulice-maven-plugin/src/main/java/com/qulice/maven/DependenciesValidator.java +++ b/qulice-maven-plugin/src/main/java/com/qulice/maven/DependenciesValidator.java @@ -124,7 +124,7 @@ private static ProjectDependencyAnalysis analyze( return ((ProjectDependencyAnalyzer) ((PlexusContainer) env.context().get(PlexusConstants.PLEXUS_KEY) - ).lookup(ProjectDependencyAnalyzer.ROLE, "default") + ).lookup(ProjectDependencyAnalyzer.class.getName(), "default") ).analyze(env.project()); } catch (final ContextException | ComponentLookupException | ProjectDependencyAnalyzerException ex) { diff --git a/qulice-maven-plugin/src/main/java/com/qulice/maven/DuplicateFinderValidator.java b/qulice-maven-plugin/src/main/java/com/qulice/maven/DuplicateFinderValidator.java index ad884436f..12af5049a 100644 --- a/qulice-maven-plugin/src/main/java/com/qulice/maven/DuplicateFinderValidator.java +++ b/qulice-maven-plugin/src/main/java/com/qulice/maven/DuplicateFinderValidator.java @@ -58,6 +58,9 @@ public final class DuplicateFinderValidator implements MavenValidator { // @todo #250 Fix a problem with maven configuration of duplicate finder // plugin in commented out code below, and enable // duplicate-finder-ignore-deps IT in pom.xml. + // @todo #1198 Duplicate-finder-plugin was moved to + // https://github.com/basepom/duplicate-finder-maven-plugin + // Let's update it to the new version @Override @SuppressWarnings("PMD.AvoidDuplicateLiterals") public void validate(final MavenEnvironment env) @@ -88,7 +91,7 @@ public void validate(final MavenEnvironment env) // } props.put("ignoredDependencies", deps); env.executor().execute( - "com.ning.maven.plugins:maven-duplicate-finder-plugin:1.0.7", + "com.ning.maven.plugins:maven-duplicate-finder-plugin:1.0.9", "check", props ); diff --git a/qulice-maven-plugin/src/test/java/com/qulice/maven/CheckMojoTest.java b/qulice-maven-plugin/src/test/java/com/qulice/maven/CheckMojoTest.java index a01bf1776..707dd38e3 100644 --- a/qulice-maven-plugin/src/test/java/com/qulice/maven/CheckMojoTest.java +++ b/qulice-maven-plugin/src/test/java/com/qulice/maven/CheckMojoTest.java @@ -43,14 +43,14 @@ * Test case for {@link CheckMojo} class. * @since 0.3 */ -public final class CheckMojoTest { +final class CheckMojoTest { /** * CheckMojo can skip execution if "skip" flag is set. * @throws Exception If something wrong happens inside */ @Test - public void skipsExecutionOnSkipFlag() throws Exception { + void skipsExecutionOnSkipFlag() throws Exception { final CheckMojo mojo = new CheckMojo(); final Log log = Mockito.mock(Log.class); mojo.setLog(log); @@ -64,7 +64,7 @@ public void skipsExecutionOnSkipFlag() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public void validatesUsingAllProvidedValidators() throws Exception { + void validatesUsingAllProvidedValidators() throws Exception { final CheckMojo mojo = new CheckMojo(); final Validator external = Mockito.mock(Validator.class); Mockito.when(external.name()).thenReturn("somename"); diff --git a/qulice-maven-plugin/src/test/java/com/qulice/maven/DefaultMavenEnvironmentTest.java b/qulice-maven-plugin/src/test/java/com/qulice/maven/DefaultMavenEnvironmentTest.java index 5bfb186e2..fa417b0b3 100644 --- a/qulice-maven-plugin/src/test/java/com/qulice/maven/DefaultMavenEnvironmentTest.java +++ b/qulice-maven-plugin/src/test/java/com/qulice/maven/DefaultMavenEnvironmentTest.java @@ -43,14 +43,14 @@ * @since 0.8 */ @SuppressWarnings("PMD.AvoidDuplicateLiterals") -public class DefaultMavenEnvironmentTest { +final class DefaultMavenEnvironmentTest { /** * DefaultMavenEnvironment can produce list of excludes. * @throws Exception If something wrong happens inside */ @Test - public final void excludeAllFiles() throws Exception { + void excludeAllFiles() throws Exception { final DefaultMavenEnvironment env = new DefaultMavenEnvironment(); env.setExcludes(Collections.singletonList("codenarc:**/*.groovy")); MatcherAssert.assertThat( @@ -64,7 +64,7 @@ public final void excludeAllFiles() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public final void emptyExclude() throws Exception { + void emptyExclude() throws Exception { final DefaultMavenEnvironment env = new DefaultMavenEnvironment(); env.setExcludes(Collections.emptyList()); MatcherAssert.assertThat( @@ -78,7 +78,7 @@ public final void emptyExclude() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public final void noExclude() throws Exception { + void noExclude() throws Exception { final DefaultMavenEnvironment env = new DefaultMavenEnvironment(); MatcherAssert.assertThat( env.excludes("codenarc").iterator().hasNext(), @@ -91,7 +91,7 @@ public final void noExclude() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public final void excludeSomeFiles() throws Exception { + void excludeSomeFiles() throws Exception { final DefaultMavenEnvironment env = new DefaultMavenEnvironment(); env.setExcludes( ImmutableList.builder() @@ -113,7 +113,7 @@ public final void excludeSomeFiles() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public final void passPathsWithWhitespaces() throws Exception { + void passPathsWithWhitespaces() throws Exception { final DefaultMavenEnvironment env = new DefaultMavenEnvironment(); final MavenProject project = Mockito.mock(MavenProject.class); Mockito.when(project.getRuntimeClasspathElements()) @@ -133,7 +133,7 @@ public final void passPathsWithWhitespaces() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public final void producesEmptyExcludesWhenNoMatches() throws Exception { + void producesEmptyExcludesWhenNoMatches() throws Exception { final DefaultMavenEnvironment env = new DefaultMavenEnvironment(); env.setExcludes( ImmutableList.of( diff --git a/qulice-maven-plugin/src/test/java/com/qulice/maven/DefaultValidatorsProviderTest.java b/qulice-maven-plugin/src/test/java/com/qulice/maven/DefaultValidatorsProviderTest.java index 4288b3512..5f3e17fe1 100644 --- a/qulice-maven-plugin/src/test/java/com/qulice/maven/DefaultValidatorsProviderTest.java +++ b/qulice-maven-plugin/src/test/java/com/qulice/maven/DefaultValidatorsProviderTest.java @@ -40,10 +40,10 @@ * Test case for {@link ValidatorsProvider} class. * @since 0.3 */ -public final class DefaultValidatorsProviderTest { +final class DefaultValidatorsProviderTest { @Test - public void producesCollectionOfValidators() throws Exception { + void producesCollectionOfValidators() throws Exception { MatcherAssert.assertThat( new DefaultValidatorsProvider(new Environment.Mock()) .internal().size(), @@ -53,7 +53,7 @@ public void producesCollectionOfValidators() throws Exception { @Test @Disabled - public void producesCollectionOfExtValidators() throws Exception { + void producesCollectionOfExtValidators() throws Exception { MatcherAssert.assertThat( new DefaultValidatorsProvider(new Environment.Mock()) .external().size(), diff --git a/qulice-maven-plugin/src/test/java/com/qulice/maven/DependenciesValidatorTest.java b/qulice-maven-plugin/src/test/java/com/qulice/maven/DependenciesValidatorTest.java index a84319107..7d2b03237 100644 --- a/qulice-maven-plugin/src/test/java/com/qulice/maven/DependenciesValidatorTest.java +++ b/qulice-maven-plugin/src/test/java/com/qulice/maven/DependenciesValidatorTest.java @@ -48,12 +48,12 @@ * Test case for {@link DependenciesValidator} class. * @since 0.3 */ -public final class DependenciesValidatorTest { +final class DependenciesValidatorTest { /** * Plexus role. */ - private static final String ROLE = ProjectDependencyAnalyzer.ROLE; + private static final String ROLE = ProjectDependencyAnalyzer.class.getName(); /** * Plexus hint. @@ -75,7 +75,7 @@ public final class DependenciesValidatorTest { * @throws Exception If something wrong happens inside */ @Test - public void passesIfNoDependencyProblemsFound() throws Exception { + void passesIfNoDependencyProblemsFound() throws Exception { final ProjectDependencyAnalysis analysis = Mockito.mock(ProjectDependencyAnalysis.class); final ProjectDependencyAnalyzer analyzer = this.analyzer(analysis); @@ -92,7 +92,7 @@ public void passesIfNoDependencyProblemsFound() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public void catchesDependencyProblemsAndThrowsException() throws Exception { + void catchesDependencyProblemsAndThrowsException() throws Exception { final ProjectDependencyAnalysis analysis = Mockito.mock(ProjectDependencyAnalysis.class); final Set unused = new HashSet<>(); @@ -115,7 +115,7 @@ public void catchesDependencyProblemsAndThrowsException() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public void ignoresRuntimeScope() throws Exception { + void ignoresRuntimeScope() throws Exception { final ProjectDependencyAnalysis analysis = Mockito.mock(ProjectDependencyAnalysis.class); final Artifact artifact = Mockito.mock(Artifact.class); @@ -137,7 +137,7 @@ public void ignoresRuntimeScope() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public void excludesUsedUndeclaredDependencies() throws Exception { + void excludesUsedUndeclaredDependencies() throws Exception { final ProjectDependencyAnalysis analysis = Mockito.mock(ProjectDependencyAnalysis.class); final Set used = new HashSet<>(); @@ -171,7 +171,7 @@ public void excludesUsedUndeclaredDependencies() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public void excludesUnusedDeclaredDependencies() throws Exception { + void excludesUnusedDeclaredDependencies() throws Exception { final ProjectDependencyAnalysis analysis = Mockito.mock(ProjectDependencyAnalysis.class); final Set unused = new HashSet<>(); diff --git a/qulice-maven-plugin/src/test/java/com/qulice/maven/PomXpathValidatorTest.java b/qulice-maven-plugin/src/test/java/com/qulice/maven/PomXpathValidatorTest.java index 709cfaf0d..c25fe87e8 100644 --- a/qulice-maven-plugin/src/test/java/com/qulice/maven/PomXpathValidatorTest.java +++ b/qulice-maven-plugin/src/test/java/com/qulice/maven/PomXpathValidatorTest.java @@ -42,14 +42,14 @@ * Test case for {@link PomXpathValidator} class. * @since 0.6 */ -public final class PomXpathValidatorTest { +final class PomXpathValidatorTest { /** * PomXpathValidator can validate pom.xml with xpath. * @throws Exception If something wrong happens inside */ @Test - public void canValidatePomWithXpath() throws Exception { + void canValidatePomWithXpath() throws Exception { final MavenEnvironment env = new MavenEnvironmentMocker() .withAsserts( Collections.singletonList( diff --git a/qulice-maven-plugin/src/test/java/com/qulice/maven/SvnPropertiesValidatorTest.java b/qulice-maven-plugin/src/test/java/com/qulice/maven/SvnPropertiesValidatorTest.java index 3b637ce39..6765411c1 100644 --- a/qulice-maven-plugin/src/test/java/com/qulice/maven/SvnPropertiesValidatorTest.java +++ b/qulice-maven-plugin/src/test/java/com/qulice/maven/SvnPropertiesValidatorTest.java @@ -36,14 +36,14 @@ * Test case for {@link SvnPropertiesValidator}. * @since 0.3 */ -public final class SvnPropertiesValidatorTest { +final class SvnPropertiesValidatorTest { /** * Let's simulate the property reading request. * @throws Exception If something goes wrong */ @Test - public void testSimulatesSvnPropgetRequest() throws Exception { + void testSimulatesSvnPropgetRequest() throws Exception { final MavenValidator validator = new SvnPropertiesValidator(); final MavenEnvironment env = new MavenEnvironmentMocker().mock(); validator.validate(env); diff --git a/qulice-maven-plugin/src/test/java/com/qulice/maven/ValidationExclusionTest.java b/qulice-maven-plugin/src/test/java/com/qulice/maven/ValidationExclusionTest.java index a79014f8d..ee9daf728 100644 --- a/qulice-maven-plugin/src/test/java/com/qulice/maven/ValidationExclusionTest.java +++ b/qulice-maven-plugin/src/test/java/com/qulice/maven/ValidationExclusionTest.java @@ -54,7 +54,7 @@ * exclude files from validation. * @since 0.19 */ -public class ValidationExclusionTest { +final class ValidationExclusionTest { /** * Temporary directory for the project source folder. */ @@ -75,7 +75,7 @@ public class ValidationExclusionTest { * @throws Exception If something wrong happens inside */ @Test - public final void excludePathFromPmdValidation() throws Exception { + void excludePathFromPmdValidation() throws Exception { final DefaultMavenEnvironment env = new DefaultMavenEnvironment(); final MavenProject project = Mockito.mock(MavenProject.class); final Path dir = Files.createTempDirectory(ValidationExclusionTest.TEMP_DIR); @@ -116,7 +116,7 @@ public final void excludePathFromPmdValidation() throws Exception { * @throws Exception If something wrong happens inside */ @Test - public final void excludePathFromCheckstyleValidation() throws Exception { + void excludePathFromCheckstyleValidation() throws Exception { final DefaultMavenEnvironment env = new DefaultMavenEnvironment(); final MavenProject project = Mockito.mock(MavenProject.class); final Path dir = Files.createTempDirectory(ValidationExclusionTest.TEMP_DIR); diff --git a/qulice-pmd/pom.xml b/qulice-pmd/pom.xml index 4b3033188..90ad44f7c 100644 --- a/qulice-pmd/pom.xml +++ b/qulice-pmd/pom.xml @@ -65,18 +65,26 @@ OF THE POSSIBILITY OF SUCH DAMAGE. net.sourceforge.pmd pmd-core - 6.10.0 + 6.55.0 net.sf.saxon Saxon-HE + + org.ow2.asm + asm + + + com.google.code.gson + gson + net.sourceforge.pmd pmd-java - 6.10.0 + 6.55.0 net.sf.saxon @@ -87,7 +95,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE. net.sourceforge.pmd pmd-jsp - 6.10.0 + 6.55.0 runtime diff --git a/qulice-pmd/src/main/java/com/qulice/pmd/PmdListener.java b/qulice-pmd/src/main/java/com/qulice/pmd/PmdListener.java index cf48f3fb2..27fb7cb45 100644 --- a/qulice-pmd/src/main/java/com/qulice/pmd/PmdListener.java +++ b/qulice-pmd/src/main/java/com/qulice/pmd/PmdListener.java @@ -37,15 +37,14 @@ import net.sourceforge.pmd.Report.ConfigurationError; import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.RuleViolation; -import net.sourceforge.pmd.ThreadSafeReportListener; -import net.sourceforge.pmd.stat.Metric; /** * Listener of PMD errors. * * @since 0.3 */ -final class PmdListener implements ThreadSafeReportListener { +@SuppressWarnings("deprecation") +final class PmdListener implements net.sourceforge.pmd.ThreadSafeReportListener { /** * Environment. @@ -68,7 +67,7 @@ final class PmdListener implements ThreadSafeReportListener { } @Override - public void metricAdded(final Metric metric) { + public void metricAdded(final net.sourceforge.pmd.stat.Metric metric) { // ignore it } diff --git a/qulice-pmd/src/main/java/com/qulice/pmd/PmdRenderer.java b/qulice-pmd/src/main/java/com/qulice/pmd/PmdRenderer.java index 64450d3ca..67b3d5a8e 100644 --- a/qulice-pmd/src/main/java/com/qulice/pmd/PmdRenderer.java +++ b/qulice-pmd/src/main/java/com/qulice/pmd/PmdRenderer.java @@ -31,6 +31,7 @@ package com.qulice.pmd; import java.io.Writer; +import java.util.List; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.properties.AbstractPropertySource; import net.sourceforge.pmd.renderers.Renderer; @@ -41,6 +42,7 @@ * * @since 1.0 */ +@SuppressWarnings("deprecation") final class PmdRenderer extends AbstractPropertySource implements Renderer { /** * This variable is union of all observed reports. @@ -82,6 +84,11 @@ public void setShowSuppressedViolations(final boolean show) { throw new UnsupportedOperationException("Unimplemented setShowSuppressedViolations"); } + @Override + public void setUseShortNames(final List list) { + // ignore it + } + @Override public Writer getWriter() { throw new UnsupportedOperationException("Unimplemented getWriter"); @@ -117,6 +124,11 @@ public void flush() { // ignore it } + @Override + public void setReportFile(final String report) { + // ignore it + } + @Override public String getPropertySourceType() { throw new UnsupportedOperationException("Unimplemented method 'getPropertySourceType'"); diff --git a/qulice-pmd/src/main/java/com/qulice/pmd/SourceValidator.java b/qulice-pmd/src/main/java/com/qulice/pmd/SourceValidator.java index e89463d94..707a73061 100644 --- a/qulice-pmd/src/main/java/com/qulice/pmd/SourceValidator.java +++ b/qulice-pmd/src/main/java/com/qulice/pmd/SourceValidator.java @@ -36,13 +36,10 @@ import java.util.Collection; import java.util.Collections; import java.util.LinkedList; -import net.sourceforge.pmd.PMD; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RulePriority; -import net.sourceforge.pmd.RuleSetFactory; -import net.sourceforge.pmd.util.ResourceLoader; import net.sourceforge.pmd.util.datasource.DataSource; /** @@ -50,6 +47,7 @@ * * @since 0.3 */ +@SuppressWarnings("deprecation") final class SourceValidator { /** * Rule context. @@ -123,13 +121,14 @@ public Collection validate( * @param source Input source file */ private void validateOne(final DataSource source) { - final RuleSetFactory factory = new RuleSetFactory( - new ResourceLoader(), + final net.sourceforge.pmd.RuleSetFactory factory = + new net.sourceforge.pmd.RuleSetFactory( + new net.sourceforge.pmd.util.ResourceLoader(), RulePriority.LOW, false, true ); - PMD.processFiles( + net.sourceforge.pmd.PMD.processFiles( this.config, factory, new LinkedList<>(Collections.singleton(source)), diff --git a/qulice-pmd/src/main/java/com/qulice/pmd/rules/ProhibitPlainJunitAssertionsRule.java b/qulice-pmd/src/main/java/com/qulice/pmd/rules/ProhibitPlainJunitAssertionsRule.java index 1883ddb6c..b66dddb7a 100644 --- a/qulice-pmd/src/main/java/com/qulice/pmd/rules/ProhibitPlainJunitAssertionsRule.java +++ b/qulice-pmd/src/main/java/com/qulice/pmd/rules/ProhibitPlainJunitAssertionsRule.java @@ -37,13 +37,14 @@ import net.sourceforge.pmd.lang.java.ast.ASTPrimaryExpression; import net.sourceforge.pmd.lang.java.ast.ASTPrimaryPrefix; import net.sourceforge.pmd.lang.java.ast.ASTStatementExpression; -import net.sourceforge.pmd.lang.java.rule.AbstractJUnitRule; /** * Rule to check plain assertions in JUnit tests. * @since 0.17 */ -public final class ProhibitPlainJunitAssertionsRule extends AbstractJUnitRule { +@SuppressWarnings("deprecation") +public final class ProhibitPlainJunitAssertionsRule + extends net.sourceforge.pmd.lang.java.rule.AbstractJUnitRule { /** * Mask of prohibited imports. diff --git a/qulice-pmd/src/main/java/com/qulice/pmd/rules/UnnecessaryLocalRule.java b/qulice-pmd/src/main/java/com/qulice/pmd/rules/UnnecessaryLocalRule.java index 620358d82..713e3b535 100644 --- a/qulice-pmd/src/main/java/com/qulice/pmd/rules/UnnecessaryLocalRule.java +++ b/qulice-pmd/src/main/java/com/qulice/pmd/rules/UnnecessaryLocalRule.java @@ -46,6 +46,7 @@ * * @since 0.4 */ +@SuppressWarnings("deprecation") public final class UnnecessaryLocalRule extends AbstractJavaRule { @Override public Object visit(final ASTMethodDeclaration meth, final Object data) { diff --git a/qulice-pmd/src/main/java/com/qulice/pmd/rules/UseStringIsEmptyRule.java b/qulice-pmd/src/main/java/com/qulice/pmd/rules/UseStringIsEmptyRule.java index a20e7af69..03adf5c31 100644 --- a/qulice-pmd/src/main/java/com/qulice/pmd/rules/UseStringIsEmptyRule.java +++ b/qulice-pmd/src/main/java/com/qulice/pmd/rules/UseStringIsEmptyRule.java @@ -42,23 +42,25 @@ import net.sourceforge.pmd.lang.java.ast.ASTType; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId; import net.sourceforge.pmd.lang.java.ast.JavaNode; -import net.sourceforge.pmd.lang.java.rule.AbstractInefficientZeroCheck; import net.sourceforge.pmd.lang.java.symboltable.JavaNameOccurrence; import net.sourceforge.pmd.lang.java.symboltable.MethodNameDeclaration; import net.sourceforge.pmd.lang.symboltable.NameOccurrence; import net.sourceforge.pmd.lang.symboltable.Scope; -import net.sourceforge.pmd.util.StringUtil; /** * Rule to prohibit use of String.length() when checking for empty string. * String.isEmpty() should be used instead. * @since 0.18 */ -public final class UseStringIsEmptyRule extends AbstractInefficientZeroCheck { +@SuppressWarnings("deprecation") +public final class UseStringIsEmptyRule + extends net.sourceforge.pmd.lang.java.rule.AbstractInefficientZeroCheck { @Override public boolean appliesToClassName(final String name) { - return StringUtil.isSame(name, "String", true, true, true); + return net.sourceforge.pmd.util.StringUtil.isSame( + name, "String", true, true, true + ); } @Override diff --git a/qulice-pmd/src/main/resources/com/qulice/pmd/ruleset.xml b/qulice-pmd/src/main/resources/com/qulice/pmd/ruleset.xml index 84237b3b1..35c1cbc86 100644 --- a/qulice-pmd/src/main/resources/com/qulice/pmd/ruleset.xml +++ b/qulice-pmd/src/main/resources/com/qulice/pmd/ruleset.xml @@ -64,7 +64,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE. - + @@ -214,7 +214,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/qulice-pmd/src/test/java/com/qulice/pmd/EmptyCollectionRuleTest.java b/qulice-pmd/src/test/java/com/qulice/pmd/EmptyCollectionRuleTest.java index c0e901a4f..3e57cf4b6 100644 --- a/qulice-pmd/src/test/java/com/qulice/pmd/EmptyCollectionRuleTest.java +++ b/qulice-pmd/src/test/java/com/qulice/pmd/EmptyCollectionRuleTest.java @@ -38,13 +38,13 @@ * * @since 0.19 */ -public class EmptyCollectionRuleTest { +final class EmptyCollectionRuleTest { /** * Makes sure that empty collections not returned as null. * @throws Exception when something goes wrong */ @Test - public void failsForNullCollection() throws Exception { + void failsForNullCollection() throws Exception { new PmdAssert( "NullCollection.java", Matchers.is(false), diff --git a/qulice-pmd/src/test/java/com/qulice/pmd/LocalVariableCouldBeFinalRuleTest.java b/qulice-pmd/src/test/java/com/qulice/pmd/LocalVariableCouldBeFinalRuleTest.java index 3a14167d0..845b21459 100644 --- a/qulice-pmd/src/test/java/com/qulice/pmd/LocalVariableCouldBeFinalRuleTest.java +++ b/qulice-pmd/src/test/java/com/qulice/pmd/LocalVariableCouldBeFinalRuleTest.java @@ -39,7 +39,7 @@ * * @since 0.18 */ -public class LocalVariableCouldBeFinalRuleTest { +final class LocalVariableCouldBeFinalRuleTest { /** * LocalVariableCouldBeFinal can detect when variable is not @@ -48,7 +48,7 @@ public class LocalVariableCouldBeFinalRuleTest { * @throws Exception If something goes wrong */ @Test - public final void detectLocalVariableCouldBeFinal() throws Exception { + void detectLocalVariableCouldBeFinal() throws Exception { new PmdAssert( "LocalVariableCouldBeFinal.java", new IsEqual<>(false), diff --git a/qulice-pmd/src/test/java/com/qulice/pmd/PmdDisabledRulesTest.java b/qulice-pmd/src/test/java/com/qulice/pmd/PmdDisabledRulesTest.java index f470d165f..414465946 100644 --- a/qulice-pmd/src/test/java/com/qulice/pmd/PmdDisabledRulesTest.java +++ b/qulice-pmd/src/test/java/com/qulice/pmd/PmdDisabledRulesTest.java @@ -39,12 +39,13 @@ /** * Tests for disabled rules. * @since 0.16 + * @checkstyle MethodsOrderCheck (77 lines) */ -public final class PmdDisabledRulesTest { +final class PmdDisabledRulesTest { @ParameterizedTest @MethodSource("parameters") - public void disablesRules(final String rule) throws Exception { + void disablesRules(final String rule) throws Exception { new PmdAssert( String.format("%s.java", rule), Matchers.any(Boolean.class), diff --git a/qulice-pmd/src/test/java/com/qulice/pmd/PmdEmptyTest.java b/qulice-pmd/src/test/java/com/qulice/pmd/PmdEmptyTest.java index eef933d5f..3c9b39081 100644 --- a/qulice-pmd/src/test/java/com/qulice/pmd/PmdEmptyTest.java +++ b/qulice-pmd/src/test/java/com/qulice/pmd/PmdEmptyTest.java @@ -38,18 +38,18 @@ * @since 0.15 */ @SuppressWarnings("PMD.TooManyMethods") -public final class PmdEmptyTest { +final class PmdEmptyTest { /** * Makes sure that empty static initializers fail with an error. * @throws Exception when something goes wrong */ @Test - public void failsForEmptyStaticInitializer() throws Exception { + void failsForEmptyStaticInitializer() throws Exception { new PmdAssert( "EmptyStaticInitializer.java", Matchers.is(false), Matchers.containsString( - "Empty initializer was found (EmptyInitializer)" + "Empty initializer statement (EmptyControlStatement)" ) ).validate(); } @@ -59,12 +59,12 @@ public void failsForEmptyStaticInitializer() throws Exception { * @throws Exception when something goes wrong */ @Test - public void failsForEmptyStatementBlock() throws Exception { + void failsForEmptyStatementBlock() throws Exception { new PmdAssert( "EmptyStatementBlock.java", Matchers.is(false), Matchers.containsString( - "Avoid empty block statements" + "Empty block " ) ).validate(); } @@ -74,12 +74,12 @@ public void failsForEmptyStatementBlock() throws Exception { * @throws Exception when something goes wrong */ @Test - public void failsForEmptyInitializer() throws Exception { + void failsForEmptyInitializer() throws Exception { new PmdAssert( "EmptyInitializer.java", Matchers.is(false), Matchers.containsString( - "Empty initializer was found" + "Empty initializer statement " ) ).validate(); } @@ -89,12 +89,12 @@ public void failsForEmptyInitializer() throws Exception { * @throws Exception when something goes wrong */ @Test - public void failsForEmptyNonLoopStatement() throws Exception { + void failsForEmptyNonLoopStatement() throws Exception { new PmdAssert( "EmptyStatementNotInLoop.java", Matchers.is(false), Matchers.containsString( - "An empty statement (semicolon) not part of a loop" + "Unnecessary semicolon " ) ).validate(); } @@ -104,12 +104,12 @@ public void failsForEmptyNonLoopStatement() throws Exception { * @throws Exception when something goes wrong */ @Test - public void failsForEmptySynchronizedBlock() throws Exception { + void failsForEmptySynchronizedBlock() throws Exception { new PmdAssert( "EmptySynchronizedBlock.java", Matchers.is(false), Matchers.containsString( - "Avoid empty synchronized blocks" + "Empty synchronized statement " ) ).validate(); } @@ -119,12 +119,12 @@ public void failsForEmptySynchronizedBlock() throws Exception { * @throws Exception when something goes wrong */ @Test - public void failsForEmptySwitchStatement() throws Exception { + void failsForEmptySwitchStatement() throws Exception { new PmdAssert( "EmptySwitchStmt.java", Matchers.is(false), Matchers.containsString( - "Avoid empty switch statements" + "Empty switch statement " ) ).validate(); } @@ -134,11 +134,11 @@ public void failsForEmptySwitchStatement() throws Exception { * @throws Exception when something goes wrong */ @Test - public void failsForEmptyFinallyBlock() throws Exception { + void failsForEmptyFinallyBlock() throws Exception { new PmdAssert( "EmptyFinallyBlock.java", Matchers.is(false), - Matchers.containsString("Avoid empty finally blocks") + Matchers.containsString("Empty finally clause") ).validate(); } @@ -147,11 +147,11 @@ public void failsForEmptyFinallyBlock() throws Exception { * @throws Exception when something goes wrong */ @Test - public void failsForEmptyWhileStatement() throws Exception { + void failsForEmptyWhileStatement() throws Exception { new PmdAssert( "EmptyWhileStmt.java", Matchers.is(false), - Matchers.containsString("Avoid empty while statements") + Matchers.containsString("Empty while statement ") ).validate(); } @@ -160,11 +160,11 @@ public void failsForEmptyWhileStatement() throws Exception { * @throws Exception when something goes wrong */ @Test - public void failsForEmptyIfStatement() throws Exception { + void failsForEmptyIfStatement() throws Exception { new PmdAssert( "EmptyIfStmt.java", Matchers.is(false), - Matchers.containsString("Avoid empty if statements") + Matchers.containsString("Empty if statement ") ).validate(); } @@ -173,7 +173,7 @@ public void failsForEmptyIfStatement() throws Exception { * @throws Exception when something goes wrong */ @Test - public void failsForEmptyCatchBlock() throws Exception { + void failsForEmptyCatchBlock() throws Exception { new PmdAssert( "EmptyCatchBlock.java", Matchers.is(false), diff --git a/qulice-pmd/src/test/java/com/qulice/pmd/PmdValidatorTest.java b/qulice-pmd/src/test/java/com/qulice/pmd/PmdValidatorTest.java index b323620f5..13ecb22c2 100644 --- a/qulice-pmd/src/test/java/com/qulice/pmd/PmdValidatorTest.java +++ b/qulice-pmd/src/test/java/com/qulice/pmd/PmdValidatorTest.java @@ -48,7 +48,7 @@ * @since 0.3 */ @SuppressWarnings("PMD.TooManyMethods") -public final class PmdValidatorTest { +final class PmdValidatorTest { /** * Error message for forbidding access to static fields @@ -112,7 +112,7 @@ public final class PmdValidatorTest { * @throws Exception If something wrong happens inside. */ @Test - public void findsProblemsInJavaFiles() throws Exception { + void findsProblemsInJavaFiles() throws Exception { final String file = "src/main/java/Main.java"; final Environment env = new Environment.Mock() .withFile(file, "class Main { int x = 0; }"); @@ -129,7 +129,7 @@ public void findsProblemsInJavaFiles() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void understandsMethodReferences() throws Exception { + void understandsMethodReferences() throws Exception { final String file = "UnderstandsMethodReferences.java"; new PmdAssert( file, @@ -147,7 +147,7 @@ public void understandsMethodReferences() throws Exception { */ @Test @SuppressWarnings("PMD.AvoidDuplicateLiterals") - public void doesNotComplainAboutConstantsInInnerClasses() throws Exception { + void doesNotComplainAboutConstantsInInnerClasses() throws Exception { final String file = "src/main/java/foo/Foo.java"; final Environment env = new Environment.Mock().withFile( file, @@ -177,7 +177,7 @@ public void doesNotComplainAboutConstantsInInnerClasses() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void allowsFieldInitializationWhenConstructorIsMissing() + void allowsFieldInitializationWhenConstructorIsMissing() throws Exception { final String file = "FieldInitNoConstructor.java"; new PmdAssert( @@ -195,7 +195,7 @@ public void allowsFieldInitializationWhenConstructorIsMissing() * @throws Exception If something wrong happens inside. */ @Test - public void forbidsFieldInitializationWhenConstructorExists() + void forbidsFieldInitializationWhenConstructorExists() throws Exception { final String file = "FieldInitConstructor.java"; new PmdAssert( @@ -212,7 +212,7 @@ public void forbidsFieldInitializationWhenConstructorExists() * @throws Exception If something wrong happens inside. */ @Test - public void allowsStaticFieldInitializationWhenConstructorExists() + void allowsStaticFieldInitializationWhenConstructorExists() throws Exception { final String file = "StaticFieldInitConstructor.java"; new PmdAssert( @@ -231,7 +231,7 @@ public void allowsStaticFieldInitializationWhenConstructorExists() * @throws Exception If something wrong happens inside. */ @Test - public void forbidsFieldInitializationInSeveralConstructors() + void forbidsFieldInitializationInSeveralConstructors() throws Exception { final String file = "FieldInitSeveralConstructors.java"; new PmdAssert( @@ -248,7 +248,7 @@ public void forbidsFieldInitializationInSeveralConstructors() * @throws Exception If something wrong happens inside. */ @Test - public void allowsFieldInitializationInOneConstructor() + void allowsFieldInitializationInOneConstructor() throws Exception { final String file = "FieldInitOneConstructor.java"; new PmdAssert( @@ -266,7 +266,7 @@ public void allowsFieldInitializationInOneConstructor() * @throws Exception If something wrong happens inside. */ @Test - public void forbidsUnnecessaryFinalModifier() + void forbidsUnnecessaryFinalModifier() throws Exception { final String file = "UnnecessaryFinalModifier.java"; new PmdAssert( @@ -280,7 +280,7 @@ public void forbidsUnnecessaryFinalModifier() * @throws Exception If something wrong happens inside. */ @Test - public void forbidsUselessParentheses() + void forbidsUselessParentheses() throws Exception { final String file = "UselessParentheses.java"; new PmdAssert( @@ -295,7 +295,7 @@ public void forbidsUselessParentheses() * @throws Exception If something wrong happens inside. */ @Test - public void forbidsCodeInConstructor() + void forbidsCodeInConstructor() throws Exception { final String file = "CodeInConstructor.java"; new PmdAssert( @@ -311,7 +311,7 @@ public void forbidsCodeInConstructor() * @throws Exception If something wrong happens inside. */ @Test - public void allowsLambdaInConstructor() + void allowsLambdaInConstructor() throws Exception { final String file = "LambdaInConstructor.java"; new PmdAssert( @@ -329,7 +329,7 @@ public void allowsLambdaInConstructor() * @throws Exception If something wrong happens inside. */ @Test - public void forbidsFilesCreateFileInTests() throws Exception { + void forbidsFilesCreateFileInTests() throws Exception { new PmdAssert( "FilesCreateFileTest.java", Matchers.is(false), @@ -344,7 +344,7 @@ public void forbidsFilesCreateFileInTests() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void forbidsFilesCreateFileOutsideOfTests() throws Exception { + void forbidsFilesCreateFileOutsideOfTests() throws Exception { new PmdAssert( "FilesCreateFileOther.java", Matchers.is(true), @@ -362,7 +362,7 @@ public void forbidsFilesCreateFileOutsideOfTests() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void acceptsCallToConstructorInConstructor() + void acceptsCallToConstructorInConstructor() throws Exception { final String file = "CallToConstructorInConstructor.java"; new PmdAssert( @@ -381,7 +381,7 @@ public void acceptsCallToConstructorInConstructor() * @throws Exception If something wrong happens inside. */ @Test - public void acceptsCallToStaticFieldsInStaticWay() + void acceptsCallToStaticFieldsInStaticWay() throws Exception { final String file = "StaticAccessToStaticFields.java"; new PmdAssert( @@ -407,7 +407,7 @@ public void acceptsCallToStaticFieldsInStaticWay() * @throws Exception If something wrong happens inside. */ @Test - public void forbidsCallToStaticFieldsDirectly() + void forbidsCallToStaticFieldsDirectly() throws Exception { final String file = "DirectAccessToStaticFields.java"; new PmdAssert( @@ -424,7 +424,7 @@ public void forbidsCallToStaticFieldsDirectly() * @throws Exception If something wrong happens inside. */ @Test - public void forbidsCallToStaticFieldsViaThis() + void forbidsCallToStaticFieldsViaThis() throws Exception { final String file = "AccessToStaticFieldsViaThis.java"; new PmdAssert( @@ -441,7 +441,7 @@ public void forbidsCallToStaticFieldsViaThis() * @throws Exception If something wrong happens inside. */ @Test - public void forbidsCallToStaticMethodsViaThis() + void forbidsCallToStaticMethodsViaThis() throws Exception { final String file = "AccessToStaticMethodsViaThis.java"; new PmdAssert( @@ -458,7 +458,7 @@ public void forbidsCallToStaticMethodsViaThis() * @throws Exception If something wrong happens inside. */ @Test - public void forbidsNonPublicCloneMethod() throws Exception { + void forbidsNonPublicCloneMethod() throws Exception { new PmdAssert( "CloneMethodMustBePublic.java", Matchers.is(false), @@ -478,7 +478,7 @@ public void forbidsNonPublicCloneMethod() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void forbidsCloneMethodReturnTypeNotMatchingClassName() + void forbidsCloneMethodReturnTypeNotMatchingClassName() throws Exception { new PmdAssert( "CloneMethodReturnTypeMustMatchClassName.java", @@ -498,7 +498,7 @@ public void forbidsCloneMethodReturnTypeNotMatchingClassName() * @throws Exception If something wrong happens inside. */ @Test - public void forbidsNonSimplifiedTernaryOperators() + void forbidsNonSimplifiedTernaryOperators() throws Exception { new PmdAssert( "SimplifiedTernary.java", @@ -521,7 +521,7 @@ public void forbidsNonSimplifiedTernaryOperators() * @throws Exception If something wrong happens inside. */ @Test - public void prohibitsStaticImportsPlainAssertionsInTests() + void prohibitsStaticImportsPlainAssertionsInTests() throws Exception { final String file = "PlainJUnitAssertionStaticImportBlock.java"; new PmdAssert( @@ -540,7 +540,7 @@ public void prohibitsStaticImportsPlainAssertionsInTests() * @throws Exception If something wrong happens inside. */ @Test - public void prohibitsPlainJunitAssertionsInTestMethods() + void prohibitsPlainJunitAssertionsInTestMethods() throws Exception { final String file = "PlainJUnitAssertionTestMethod.java"; new PmdAssert( @@ -558,7 +558,7 @@ public void prohibitsPlainJunitAssertionsInTestMethods() * @throws Exception If something wrong happens inside. */ @Test - public void allowsAssertFail() + void allowsAssertFail() throws Exception { final String file = "AllowAssertFail.java"; new PmdAssert( @@ -576,7 +576,7 @@ public void allowsAssertFail() * @throws Exception If something wrong happens inside. */ @Test - public void allowsNonTransientFields() throws Exception { + void allowsNonTransientFields() throws Exception { final String file = "AllowNonTransientFields.java"; new PmdAssert( file, Matchers.is(true), @@ -593,7 +593,7 @@ public void allowsNonTransientFields() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void prohibitsPublicStaticMethods() throws Exception { + void prohibitsPublicStaticMethods() throws Exception { new PmdAssert( "StaticPublicMethod.java", Matchers.is(false), @@ -606,7 +606,7 @@ public void prohibitsPublicStaticMethods() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void allowsPublicStaticMainMethod() throws Exception { + void allowsPublicStaticMainMethod() throws Exception { new PmdAssert( "StaticPublicVoidMainMethod.java", Matchers.is(true), @@ -624,7 +624,7 @@ public void allowsPublicStaticMainMethod() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void allowsJunitFrameworkPublicStaticMethods() throws Exception { + void allowsJunitFrameworkPublicStaticMethods() throws Exception { new PmdAssert( "JunitStaticPublicMethods.java", Matchers.is(true), @@ -639,7 +639,7 @@ public void allowsJunitFrameworkPublicStaticMethods() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void allowsDuplicateLiteralsInAnnotations() throws Exception { + void allowsDuplicateLiteralsInAnnotations() throws Exception { new PmdAssert( "AllowsDuplicateLiteralsInAnnotations.java", Matchers.is(true), @@ -655,7 +655,7 @@ public void allowsDuplicateLiteralsInAnnotations() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void testShouldBePackagePrivate() throws Exception { + void testShouldBePackagePrivate() throws Exception { new PmdAssert( "TestShouldBePackagePrivate.java", Matchers.is(false), @@ -668,7 +668,7 @@ public void testShouldBePackagePrivate() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void allowJunitThirdTestClassToBeFinal() throws Exception { + void allowJunitThirdTestClassToBeFinal() throws Exception { new PmdAssert( "Junit3TestClassShouldBeFinal.java", Matchers.is(false), @@ -681,7 +681,7 @@ public void allowJunitThirdTestClassToBeFinal() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void allowJunitFourthTestClassToBeFinal() throws Exception { + void allowJunitFourthTestClassToBeFinal() throws Exception { new PmdAssert( "Junit4TestClassShouldBeFinal.java", Matchers.is(false), @@ -694,7 +694,7 @@ public void allowJunitFourthTestClassToBeFinal() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void allowJunitFifthTestClassToBeFinal() throws Exception { + void allowJunitFifthTestClassToBeFinal() throws Exception { new PmdAssert( "Junit5TestClassShouldBeFinal.java", Matchers.is(false), @@ -707,7 +707,7 @@ public void allowJunitFifthTestClassToBeFinal() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void allowJunitTestClassToBeFinal() throws Exception { + void allowJunitTestClassToBeFinal() throws Exception { new PmdAssert( "JunitTestClassIsFinal.java", Matchers.is(true), diff --git a/qulice-pmd/src/test/java/com/qulice/pmd/UnusedImportsRuleTest.java b/qulice-pmd/src/test/java/com/qulice/pmd/UnusedImportsRuleTest.java index 26c041bcc..a85a40496 100644 --- a/qulice-pmd/src/test/java/com/qulice/pmd/UnusedImportsRuleTest.java +++ b/qulice-pmd/src/test/java/com/qulice/pmd/UnusedImportsRuleTest.java @@ -39,7 +39,7 @@ * * @since 0.18 */ -public class UnusedImportsRuleTest { +final class UnusedImportsRuleTest { /** * UnusedImport can detect when the class has an unused import line and @@ -48,16 +48,16 @@ public class UnusedImportsRuleTest { * @throws Exception If something goes wrong */ @Test - public final void detectUnusedImportLine() throws Exception { + void detectUnusedImportLine() throws Exception { new PmdAssert( "UnusedImports.java", new IsEqual<>(false), new StringStartsWith( String.join( " ", - "PMD: UnusedImports.java[3-3]: Avoid unused imports such", - "as 'unused.bar.foo.UnusedImport'", - "(UnusedImports)" + "PMD: UnusedImports.java[3-3]: Unused import", + "'unused.bar.foo.UnusedImport'", + "(UnnecessaryImport)" ).trim() ) ).validate(); diff --git a/qulice-pmd/src/test/java/com/qulice/pmd/UseStringIsEmptyRuleTest.java b/qulice-pmd/src/test/java/com/qulice/pmd/UseStringIsEmptyRuleTest.java index 099b15201..e9d39a02e 100644 --- a/qulice-pmd/src/test/java/com/qulice/pmd/UseStringIsEmptyRuleTest.java +++ b/qulice-pmd/src/test/java/com/qulice/pmd/UseStringIsEmptyRuleTest.java @@ -43,7 +43,7 @@ * Test case for {@link com.qulice.pmd.rules.UseStringIsEmptyRule}. * @since 0.18 */ -public final class UseStringIsEmptyRuleTest { +final class UseStringIsEmptyRuleTest { /** * UseStringIsEmpty can detect when used String.length(), when checking for @@ -63,7 +63,7 @@ public final class UseStringIsEmptyRuleTest { "StringLengthNotEqualsZero.java" } ) - public void detectLengthComparisons(final String file) throws Exception { + void detectLengthComparisons(final String file) throws Exception { new PmdAssert( file, new IsEqual<>(false), new CombinableMatcher<>(containsMatcher(file, 16)) @@ -80,7 +80,7 @@ public void detectLengthComparisons(final String file) throws Exception { * @throws Exception If something goes wrong. */ @Test - public void notDetectOnArrayOfStrings() throws Exception { + void notDetectOnArrayOfStrings() throws Exception { new PmdAssert( "ArrayOfStringsLengthGreaterThanZero.java", new IsEqual<>(true), diff --git a/qulice-spi/src/test/java/com/qulice/spi/EnvironmentTest.java b/qulice-spi/src/test/java/com/qulice/spi/EnvironmentTest.java index bf7818977..53b99aceb 100644 --- a/qulice-spi/src/test/java/com/qulice/spi/EnvironmentTest.java +++ b/qulice-spi/src/test/java/com/qulice/spi/EnvironmentTest.java @@ -39,14 +39,14 @@ * Test case for {@link Environment}. * @since 0.3 */ -public final class EnvironmentTest { +final class EnvironmentTest { /** * Environment interface can be mocked/instantiated with Mocker. * @throws Exception If something wrong happens inside. */ @Test - public void canBeInstantiatedWithMocker() throws Exception { + void canBeInstantiatedWithMocker() throws Exception { final Environment env = new Environment.Mock(); MatcherAssert.assertThat(env.basedir().exists(), Matchers.is(true)); MatcherAssert.assertThat(env.tempdir().exists(), Matchers.is(true)); @@ -58,7 +58,7 @@ public void canBeInstantiatedWithMocker() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void writesFileContentToTheDesignatedLocation() throws Exception { + void writesFileContentToTheDesignatedLocation() throws Exception { final String name = "src/main/java/Main.java"; final String content = "class Main {}"; final Environment env = new Environment.Mock() @@ -72,7 +72,7 @@ public void writesFileContentToTheDesignatedLocation() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void writesByteArrayToTheDesignatedLocation() throws Exception { + void writesByteArrayToTheDesignatedLocation() throws Exception { final String name = "src/main/java/Foo.java"; final byte[] bytes = "class Foo {}".getBytes(); final Environment env = new Environment.Mock() @@ -86,7 +86,7 @@ public void writesByteArrayToTheDesignatedLocation() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void setsClasspathOnTheMock() throws Exception { + void setsClasspathOnTheMock() throws Exception { final Environment env = new Environment.Mock(); MatcherAssert.assertThat( env.classpath().size(), @@ -99,7 +99,7 @@ public void setsClasspathOnTheMock() throws Exception { * @throws Exception If something wrong happens inside. */ @Test - public void configuresParametersInMock() throws Exception { + void configuresParametersInMock() throws Exception { final String name = "alpha"; final String value = "some complex value"; final Environment env = new Environment.Mock()