From 7b167bca82ef476b0756ed2149971d3b09f7f571 Mon Sep 17 00:00:00 2001 From: Daniel Muehlbachler Date: Mon, 3 Jun 2019 08:09:35 +0200 Subject: [PATCH] Issue #222: update to CS 8.21 --- pom.xml | 2 +- .../com/sonar/sqale/checkstyle-model.xml | 13 +++++++ .../org/sonar/l10n/checkstyle.properties | 12 ++++-- ...cks.javadoc.MissingJavadocMethodCheck.html | 10 +++++ .../org/sonar/plugins/checkstyle/rules.xml | 39 +++++++++++++------ .../CheckstyleRulesDefinitionTest.java | 2 +- .../checkstyle/internal/ChecksTest.java | 2 +- 7 files changed, 62 insertions(+), 18 deletions(-) create mode 100644 src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck.html diff --git a/pom.xml b/pom.xml index c4d2971e..99600e81 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ - 8.20 + 8.21 6.7 5.12.0.17701 2.17 diff --git a/src/main/resources/com/sonar/sqale/checkstyle-model.xml b/src/main/resources/com/sonar/sqale/checkstyle-model.xml index 299a21d1..ccfb9c00 100644 --- a/src/main/resources/com/sonar/sqale/checkstyle-model.xml +++ b/src/main/resources/com/sonar/sqale/checkstyle-model.xml @@ -1076,6 +1076,19 @@ min + + checkstyle + com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck + + remediationFunction + CONSTANT_ISSUE + + + offset + 30 + min + + checkstyle com.puppycrawl.tools.checkstyle.checks.metrics.JavaNCSSCheck diff --git a/src/main/resources/org/sonar/l10n/checkstyle.properties b/src/main/resources/org/sonar/l10n/checkstyle.properties index 29de0e1b..a8b9091c 100644 --- a/src/main/resources/org/sonar/l10n/checkstyle.properties +++ b/src/main/resources/org/sonar/l10n/checkstyle.properties @@ -89,18 +89,22 @@ rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodChec rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.param.allowMissingReturnTag=whether to ignore errors when a method returns non-void type does have a return tag in the javadoc. Default is false. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.param.allowMissingThrowsTags=whether to ignore errors when a method declares that it throws exceptions but does have matching throws tags in the javadoc. Default is false. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.param.allowThrowsTagsForSubclasses=whether to allow documented exceptions that are subclass of one of declared exception. Default is false. -rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.param.allowMissingJavadoc=whether to ignore errors when a method javadoc is missed. Default is false. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.param.allowMissingParamTags=whether to ignore errors when a method has parameters but does not have matching param tags in the javadoc. Default is false. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.param.scope=visibility scope where Javadoc comments are checked -rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.param.allowMissingPropertyJavadoc=Whether to allow missing Javadoc on accessor methods for properties (setters and getters). The setter and getter methods must match exactly the structures below. public void setNumber(final int number) '{' mNumber = number; '}' public int getNumber() '{' return mNumber; '}' public boolean isSomething() '{' return false; '}' . Default is false. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.param.excludeScope=visibility scope where Javadoc comments are not checked rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.param.allowUndeclaredRTE=whether to allow documented exceptions that are not declared if they are a subclass of java.lang.RuntimeException. Default is false. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.param.suppressLoadErrors=When set to false all problems with loading classes would be reported as violations. Default is true. -rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.param.ignoreMethodNamesRegex=Method names that match this pattern do not require javadoc blocks -rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.param.minLineCount=Minimal amount of lines in method to demand documentation presence rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.param.allowedAnnotations=List of annotations that could allow missed documentation rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.param.validateThrows=Allows validating throws tags rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.param.logLoadErrors=If set to false a classpath configuration problem is assumed and the TreeWalker stops operating on the class completely. If set to true (the default) , checkstyle assumes a typo or refactoring problem in the javadoc and logs the problem in the normal checkstyle report +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck.name=Javadoc Method +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck.param.tokens=definitions to check +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck.param.scope=visibility scope where Javadoc comments are checked +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck.param.excludeScope=visibility scope where Javadoc comments are not checked +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck.param.minLineCount=Minimal amount of lines in method to demand documentation presence +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck.param.allowedAnnotations=List of annotations that could allow missed documentation +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck.param.ignoreMethodNamesRegex=Method names that match this pattern do not require javadoc blocks +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck.param.allowMissingPropertyJavadoc=Whether to allow missing Javadoc on accessor methods for properties (setters and getters). The setter and getter methods must match exactly the structures below. public void setNumber(final int number) '{' mNumber = number; '}' public int getNumber() '{' return mNumber; '}' public boolean isSomething() '{' return false; '}' . Default is false. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck.name=Regexp Singleline Java rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck.param.ignoreCase=Controls whether to ignore case when searching. Default value is false. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck.param.ignoreComments=Controls whether to ignore text in comments when searching. Default value is false. diff --git a/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck.html b/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck.html new file mode 100644 index 00000000..7a7fab5c --- /dev/null +++ b/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck.html @@ -0,0 +1,10 @@ +Checks for missing Javadoc comments for a method or constructor. The scope to verify is +specified using the Scope class and defaults to Scope.PUBLIC. To verify +another scope, set property scope to a different scope. + +

Javadoc is not required on a method that is tagged with the @Override annotation. +However under Java 5 it is not possible to mark a method required for an interface (this +was corrected under Java 6). Hence Checkstyle supports using the convention of using +a single @inheritDoc tag instead of all the other tags. +

+

diff --git a/src/main/resources/org/sonar/plugins/checkstyle/rules.xml b/src/main/resources/org/sonar/plugins/checkstyle/rules.xml index 06f10f1c..90567917 100644 --- a/src/main/resources/org/sonar/plugins/checkstyle/rules.xml +++ b/src/main/resources/org/sonar/plugins/checkstyle/rules.xml @@ -814,9 +814,6 @@ comment MULTIPLE - - -1 - Override @@ -843,12 +840,6 @@ false - - false - - - false - true @@ -859,6 +850,32 @@ true + READY + + + + MAJOR + + comment + + MULTIPLE + + -1 + + + false + + + Override + + + public + + + + + METHOD_DEF,CTOR_DEF,ANNOTATION_FIELD_DEF + READY @@ -1240,7 +1257,7 @@ - system + lf_cr_crlf @@ -1956,7 +1973,7 @@ false - + CLASS_DEF,INTERFACE_DEF,PACKAGE_DEF,ENUM_CONSTANT_DEF,ENUM_DEF,METHOD_DEF,CTOR_DEF,VARIABLE_DEF diff --git a/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRulesDefinitionTest.java b/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRulesDefinitionTest.java index 810c78b6..954d51be 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(158); + assertThat(rules).hasSize(159); for (RulesDefinition.Rule rule : rules) { assertThat(rule.key()).isNotNull(); diff --git a/src/test/java/org/sonar/plugins/checkstyle/internal/ChecksTest.java b/src/test/java/org/sonar/plugins/checkstyle/internal/ChecksTest.java index ebfdd785..104660b9 100644 --- a/src/test/java/org/sonar/plugins/checkstyle/internal/ChecksTest.java +++ b/src/test/java/org/sonar/plugins/checkstyle/internal/ChecksTest.java @@ -452,7 +452,7 @@ private static Set getProperties(Class clss) { final PropertyDescriptor[] map = PropertyUtils.getPropertyDescriptors(clss); for (PropertyDescriptor p : map) { - if (p.getWriteMethod() != null) { + if (p.getWriteMethod() != null && !p.getWriteMethod().isAnnotationPresent(Deprecated.class)) { result.add(p.getName()); } }