Enable @SuppressWarnings annotation support by default for Java (#1052)

* Enable @SuppressWarnings annotation support by default for Java checkstyle

* Ensure that args is used

* Add updates to the sun_checks in .github/linters

* Comment out Javadoc linter to remove need for package-info

* Fix expected-JAVA.tap to match new test cases

* Fix expected-JAVA.tap to match output

Co-authored-by: Lukas Gravley <admiralawkbar@github.com>
This commit is contained in:
Thad Craft 2020-12-04 09:46:42 -05:00 committed by GitHub
parent 30d4aa6743
commit 32b3cde716
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 12 deletions

View file

@ -0,0 +1,12 @@
public class Application {
/**
* main.
*
* @param args
*/
public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
}

View file

@ -0,0 +1,13 @@
@SuppressWarnings("checkstyle:hideutilityclassconstructor")
public class Application {
/**
* main.
*
* @param args
*/
public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
}

View file

@ -1,7 +1,12 @@
TAP version 13 TAP version 13
1..2 1..4
not ok 1 - java_bad_1.java not ok 1 - java_bad_1.java
--- ---
message: Starting audit...\n[ERROR] /tmp/lint/.automation/test/java/java_bad_1.java 1 1 Utility classes should not have a public or default constructor. [HideUtilityClassConstructor]\n[ERROR] /tmp/lint/.automation/test/java/java_bad_1.java 1 7 Name 'java_bad_1' must match pattern '^[A-Z][a-zA-Z0-9]*$'. [TypeName]\n[ERROR] /tmp/lint/.automation/test/java/java_bad_1.java 2 1 '{' at column 1 should be on the previous line. [LeftCurly]\n[ERROR] /tmp/lint/.automation/test/java/java_bad_1.java 4 29 Parameter args should be final. [FinalParameters]\n[ERROR] /tmp/lint/.automation/test/java/java_bad_1.java 4 40 Array brackets at illegal position. [ArrayTypeStyle]\n[ERROR] /tmp/lint/.automation/test/java/java_bad_1.java 5 5 '{' at column 5 should be on the previous line. [LeftCurly]\nAudit done.\nCheckstyle ends with 6 errors.\n message: Starting audit...\n[ERROR] /tmp/lint/.automation/test/java/java_bad_1.java 1 1 Utility classes should not have a public or default constructor. [HideUtilityClassConstructor]\n[ERROR] /tmp/lint/.automation/test/java/java_bad_1.java 1 7 Name 'java_bad_1' must match pattern '^[A-Z][a-zA-Z0-9]*$'. [TypeName]\n[ERROR] /tmp/lint/.automation/test/java/java_bad_1.java 2 1 '{' at column 1 should be on the previous line. [LeftCurly]\n[ERROR] /tmp/lint/.automation/test/java/java_bad_1.java 4 29 Parameter args should be final. [FinalParameters]\n[ERROR] /tmp/lint/.automation/test/java/java_bad_1.java 4 40 Array brackets at illegal position. [ArrayTypeStyle]\n[ERROR] /tmp/lint/.automation/test/java/java_bad_1.java 5 5 '{' at column 5 should be on the previous line. [LeftCurly]\nAudit done.\nCheckstyle ends with 6 errors.\n
... ...
ok 2 - java_good_1.java not ok 2 - java_bad_2.java
---
message: Starting audit...\n[ERROR] /tmp/lint/.automation/test/java/java_bad_2.java 1 1 Utility classes should not have a public or default constructor. [HideUtilityClassConstructor]\nAudit done.\nCheckstyle ends with 1 errors.\n
...
ok 3 - java_good_1.java
ok 4 - java_good_2.java

View file

@ -51,8 +51,7 @@
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter --> <!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
<module name="SuppressionFilter"> <module name="SuppressionFilter">
<property name="file" value="${org.checkstyle.sun.suppressionfilter.config}" <property name="file" value="${org.checkstyle.sun.suppressionfilter.config}" default="checkstyle-suppressions.xml" />
default="checkstyle-suppressions.xml" />
<property name="optional" value="true"/> <property name="optional" value="true"/>
</module> </module>
@ -95,6 +94,8 @@
<!-- <property name="fileExtensions" value="java"/> --> <!-- <property name="fileExtensions" value="java"/> -->
<!-- </module> --> <!-- </module> -->
<!-- Enables @SuppressWarnings Support -->
<module name="SuppressWarningsFilter"/>
<module name="TreeWalker"> <module name="TreeWalker">
<!-- Checks for Javadoc comments. --> <!-- Checks for Javadoc comments. -->
@ -105,6 +106,8 @@
<module name="JavadocVariable"/> <module name="JavadocVariable"/>
<module name="JavadocStyle"/> <module name="JavadocStyle"/>
<module name="MissingJavadocMethod"/> <module name="MissingJavadocMethod"/>
<!-- Enables @SuppressWarnings Support -->
<module name="SuppressWarningsHolder"/>
<!-- Checks for Naming Conventions. --> <!-- Checks for Naming Conventions. -->
<!-- See https://checkstyle.org/config_naming.html --> <!-- See https://checkstyle.org/config_naming.html -->
@ -121,7 +124,8 @@
<!-- Checks for imports --> <!-- Checks for imports -->
<!-- See https://checkstyle.org/config_imports.html --> <!-- See https://checkstyle.org/config_imports.html -->
<module name="AvoidStarImport"/> <module name="AvoidStarImport"/>
<module name="IllegalImport"/> <!-- defaults to sun.* packages --> <module name="IllegalImport"/>
<!-- defaults to sun.* packages -->
<module name="RedundantImport"/> <module name="RedundantImport"/>
<module name="UnusedImports"> <module name="UnusedImports">
<property name="processJavadoc" value="false"/> <property name="processJavadoc" value="false"/>
@ -188,8 +192,7 @@
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter --> <!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
<module name="SuppressionXpathFilter"> <module name="SuppressionXpathFilter">
<property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}" <property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}" default="checkstyle-xpath-suppressions.xml" />
default="checkstyle-xpath-suppressions.xml" />
<property name="optional" value="true"/> <property name="optional" value="true"/>
</module> </module>

View file

@ -51,8 +51,7 @@
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter --> <!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
<module name="SuppressionFilter"> <module name="SuppressionFilter">
<property name="file" value="${org.checkstyle.sun.suppressionfilter.config}" <property name="file" value="${org.checkstyle.sun.suppressionfilter.config}" default="checkstyle-suppressions.xml" />
default="checkstyle-suppressions.xml" />
<property name="optional" value="true"/> <property name="optional" value="true"/>
</module> </module>
@ -95,6 +94,8 @@
<!-- <property name="fileExtensions" value="java"/> --> <!-- <property name="fileExtensions" value="java"/> -->
<!-- </module> --> <!-- </module> -->
<!-- Enables @SuppressWarnings Support -->
<module name="SuppressWarningsFilter"/>
<module name="TreeWalker"> <module name="TreeWalker">
<!-- Checks for Javadoc comments. --> <!-- Checks for Javadoc comments. -->
@ -105,6 +106,8 @@
<module name="JavadocVariable"/> <module name="JavadocVariable"/>
<module name="JavadocStyle"/> <module name="JavadocStyle"/>
<module name="MissingJavadocMethod"/> <module name="MissingJavadocMethod"/>
<!-- Enables @SuppressWarnings Support -->
<module name="SuppressWarningsHolder"/>
<!-- Checks for Naming Conventions. --> <!-- Checks for Naming Conventions. -->
<!-- See https://checkstyle.org/config_naming.html --> <!-- See https://checkstyle.org/config_naming.html -->
@ -121,7 +124,8 @@
<!-- Checks for imports --> <!-- Checks for imports -->
<!-- See https://checkstyle.org/config_imports.html --> <!-- See https://checkstyle.org/config_imports.html -->
<module name="AvoidStarImport"/> <module name="AvoidStarImport"/>
<module name="IllegalImport"/> <!-- defaults to sun.* packages --> <module name="IllegalImport"/>
<!-- defaults to sun.* packages -->
<module name="RedundantImport"/> <module name="RedundantImport"/>
<module name="UnusedImports"> <module name="UnusedImports">
<property name="processJavadoc" value="false"/> <property name="processJavadoc" value="false"/>
@ -188,8 +192,7 @@
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter --> <!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
<module name="SuppressionXpathFilter"> <module name="SuppressionXpathFilter">
<property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}" <property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}" default="checkstyle-xpath-suppressions.xml" />
default="checkstyle-xpath-suppressions.xml" />
<property name="optional" value="true"/> <property name="optional" value="true"/>
</module> </module>