From 754924006141492c1766109064593cc159c5473a Mon Sep 17 00:00:00 2001 From: Daniel Muehlbachler Date: Wed, 25 Sep 2019 13:01:34 +0200 Subject: [PATCH] Issue #238: update to CS 8.23 --- README.md | 1 + pom.xml | 2 +- .../checkstyle/CheckstyleProfileImporter.java | 1 + .../resources/com/sonar/sqale/checkstyle-model.xml | 13 +++++++++++++ .../resources/org/sonar/l10n/checkstyle.properties | 3 +++ ....checkstyle.checks.coding.MagicNumberCheck.html | 3 +-- ...yle.checks.coding.OneStatementPerLineCheck.html | 8 ++++---- ...checks.javadoc.InvalidJavadocPositionCheck.html | 3 +++ .../org/sonar/plugins/checkstyle/rules.xml | 14 ++++++++++++++ .../checkstyle/CheckstyleRulesDefinitionTest.java | 2 +- 10 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocPositionCheck.html diff --git a/README.md b/README.md index c5709c59..c5d244cc 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Compatibility matrix from checkstyle team: Checkstyle Plugin|Sonar min|Sonar max|Checkstyle|Jdk -----------------|---------|---------|----------|--- +4.23|6.7 |7.7+|8.23|1.8 4.22|6.7 |7.7+|8.22|1.8 4.21|6.7 |7.7+|8.21|1.8 4.20|6.7 |7.7+|8.20|1.8 diff --git a/pom.xml b/pom.xml index b04803aa..bbf57262 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ - 8.22 + 8.23 6.7 5.12.0.17701 2.17 diff --git a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java b/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java index 5b3c1cb5..dec57821 100644 --- a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java +++ b/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java @@ -61,6 +61,7 @@ public class CheckstyleProfileImporter extends ProfileImporter { "SuppressionCommentFilter", "SuppressWithNearbyCommentFilter", "SuppressionXpathSingleFilter", + "SuppressionSingleFilter", }; private final RuleFinder ruleFinder; diff --git a/src/main/resources/com/sonar/sqale/checkstyle-model.xml b/src/main/resources/com/sonar/sqale/checkstyle-model.xml index 867954a9..ba59acb8 100644 --- a/src/main/resources/com/sonar/sqale/checkstyle-model.xml +++ b/src/main/resources/com/sonar/sqale/checkstyle-model.xml @@ -1362,6 +1362,19 @@ min + + checkstyle + com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocPositionCheck + + remediationFunction + CONSTANT_ISSUE + + + offset + 30 + min + + checkstyle com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck diff --git a/src/main/resources/org/sonar/l10n/checkstyle.properties b/src/main/resources/org/sonar/l10n/checkstyle.properties index 877b4fab..a19dd1f1 100644 --- a/src/main/resources/org/sonar/l10n/checkstyle.properties +++ b/src/main/resources/org/sonar/l10n/checkstyle.properties @@ -8,6 +8,7 @@ rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageChe rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck.param.allowLegacy=If set then allow the use of a package.html file. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck.param.fileExtensions=file type extension of files to process rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocPackageCheck.name=Missing Javadoc Package +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocPositionCheck.name=Invalid Javadoc Position rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.coding.DeclarationOrderCheck.name=Declaration Order rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.coding.DeclarationOrderCheck.param.ignoreModifiers=Whether to ignore modifiers rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.coding.DeclarationOrderCheck.param.ignoreConstructors=Whether to ignore constructors @@ -141,6 +142,7 @@ rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck.p rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck.param.ignoreHashCodeMethod=ignore magic numbers in hashCode methods. Default is false. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck.param.ignoreAnnotation=ignore magic numbers in annotation declarations. Default is false. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck.param.ignoreFieldDeclaration=ignore magic numbers in field declarations +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck.param.ignoreAnnotationElementDefaults=Ignore magic numbers in annotation elements defaults rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck.name=Header rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck.param.header=the required header specified inline. Individual header lines must be separated by the string "\\n" (even on platforms with a different line separator) rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck.param.headerFile=the file that contains the header to check against. @@ -461,6 +463,7 @@ rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.sizes.MethodCountCheck.pa rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.sizes.MethodCountCheck.param.maxProtected=maximum allowable number of protected methods. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.sizes.MethodCountCheck.param.maxPublic=maximum allowable number of public methods. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck.name=One Statement Per Line +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck.param.treatTryResourcesAsStatement=Enable resources processing rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.naming.ClassTypeParameterNameCheck.name=Class Type(Generic) Parameter Name rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.naming.ClassTypeParameterNameCheck.param.format=Regular expression rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterNameCheck.name=Method Type(Generic) Parameter Name diff --git a/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck.html b/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck.html index 4947a92b..f5cc7728 100644 --- a/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck.html +++ b/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck.html @@ -1,4 +1,3 @@ -Checks for magic numbers. -

+ Checks that there are no "magic numbers" where a magic number is a numeric literal that is not defined as a constant. By default, -1, 0, 1, and 2 are not considered to be magic numbers.

diff --git a/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck.html b/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck.html index 4eec1deb..801dc213 100644 --- a/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck.html +++ b/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck.html @@ -1,6 +1,6 @@

-Checks there is only one statement per line. The following line will be flagged as an error: x = 1; y = 2; // Two statments on a single line. -

- -

+ Checks that there is only one statement per line.
+ Rationale: It's very difficult to read multiple statements on one line.
+ In the Java programming language, statements are the fundamental unit of execution. All statements except blocks are terminated by a semicolon. Blocks are denoted by open and close curly braces.
+ OneStatementPerLineCheck checks the following types of statements: variable declaration statements, empty statements, import statements, assignment statements, expression statements, increment statements, object creation statements, 'for loop' statements, 'break' statements, 'continue' statements, 'return' statements, resources statements (optional).

diff --git a/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocPositionCheck.html b/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocPositionCheck.html new file mode 100644 index 00000000..deb37213 --- /dev/null +++ b/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocPositionCheck.html @@ -0,0 +1,3 @@ +

+ Checks that Javadocs are located at the correct position. As specified at Documentation Comment Specification for the Standard Doclet, Javadocs are recognized only when placed immediately before module, package, class, interface, constructor, method, or field declarations. Any other position, like in the body of a method, will be ignored by the javadoc tool and is considered invalid by this check. +

diff --git a/src/main/resources/org/sonar/plugins/checkstyle/rules.xml b/src/main/resources/org/sonar/plugins/checkstyle/rules.xml index 9ed58f09..6f4416c4 100644 --- a/src/main/resources/org/sonar/plugins/checkstyle/rules.xml +++ b/src/main/resources/org/sonar/plugins/checkstyle/rules.xml @@ -136,6 +136,14 @@ READY + + MINOR + + comment + + READY + + MAJOR @@ -1066,6 +1074,9 @@ false + + true + READY @@ -1811,6 +1822,9 @@ MAJOR + + false + READY diff --git a/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRulesDefinitionTest.java b/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRulesDefinitionTest.java index 484266b8..8f309b6c 100644 --- a/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRulesDefinitionTest.java +++ b/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRulesDefinitionTest.java @@ -61,7 +61,7 @@ public void test() { assertThat(repository.language()).isEqualTo("java"); final List rules = repository.rules(); - assertThat(rules).hasSize(163); + assertThat(rules).hasSize(164); for (RulesDefinition.Rule rule : rules) { assertThat(rule.key()).isNotNull();