From c445970f44d04a10916f37d78426e6afecdaf5ea Mon Sep 17 00:00:00 2001 From: Roman Ivanov Date: Sun, 29 Jan 2017 15:49:52 -0800 Subject: [PATCH] Issue #62: upgrade to checkstyle 7.5 --- README.md | 1 + .../org/sonar/l10n/checkstyle.properties | 4 +- ...yle.checks.imports.ImportControlCheck.html | 165 +++++++++++++----- ...tyle.checks.naming.ParameterNameCheck.html | 2 +- .../org/sonar/plugins/checkstyle/rules.xml | 9 +- pom.xml | 2 +- 6 files changed, 130 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index 87f6f8eb..a933b808 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ This plugin provides coding rules from [Checkstyle](http://checkstyle.sourceforg Checkstyle Plugin|Sonar|Checkstyle|Jdk -----------------|-----|----------|--- +3.5|5.6.4|7.5|1.8 3.4|5.6.4|7.4|1.8 3.3|5.6.4|7.3|1.8 3.2|5.6.4|7.2|1.8 diff --git a/checkstyle-sonar-plugin/src/main/resources/org/sonar/l10n/checkstyle.properties b/checkstyle-sonar-plugin/src/main/resources/org/sonar/l10n/checkstyle.properties index 9e1f977a..a606008e 100644 --- a/checkstyle-sonar-plugin/src/main/resources/org/sonar/l10n/checkstyle.properties +++ b/checkstyle-sonar-plugin/src/main/resources/org/sonar/l10n/checkstyle.properties @@ -147,8 +147,7 @@ rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.TranslationCheck.param.re rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck.name=Parameter Name rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck.param.format=Regular expression rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck.param.ignoreOverridden=Allows to skip methods with Override annotation from validation. -rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck.param.scope=Visibility scope of methods where parameters are checked. -rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck.param.excludeScope=Visibility scope of methods where parameters are not checked. +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck.param.accessModifiers=Access modifiers of methods where parameters are checked. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.modifier.RedundantModifierCheck.name=Redundant Modifier rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.modifier.RedundantModifierCheck.param.tokens=tokens to check rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck.name=Empty For Initializer Pad @@ -489,6 +488,7 @@ rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.blocks.EmptyCatchBlockChe rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck.name=Import Control rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck.param.file=name of the file containing the import control configuration rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck.param.url=URL of the file containing the import control configuration +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck.param.path=Regular expression of file paths to which this check should apply. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.indentation.CommentsIndentationCheck.name=Comments Indentation rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.indentation.CommentsIndentationCheck.param.tokens=tokens to check rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.whitespace.SeparatorWrapCheck.name=Separator Wrap diff --git a/checkstyle-sonar-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck.html b/checkstyle-sonar-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck.html index 328eae90..e0a75357 100644 --- a/checkstyle-sonar-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck.html +++ b/checkstyle-sonar-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck.html @@ -1,30 +1,31 @@
-

ImportControl

- +
+

ImportControl

+

Description

- +

Controls what can be imported in each package. Useful for ensuring that application layering rules are not violated, especially on large projects.

- +

The DTD for a import control XML document is at http://checkstyle.sourceforge.net/dtds/import_control_1_2.dtd. It contains documentation on each of the elements and attributes.

- +

The check validates a XML document when it loads the document. To validate against the above DTD, include the following document type declaration in your XML document:

- +
<!DOCTYPE import-control PUBLIC
     "-//Puppy Crawl//DTD Import Control 1.2//EN"
@@ -32,72 +33,102 @@ 

Description

- +

Properties

- + - + - + - + - + - + - + - + - + - - - + + + - + - + - + - - - + + + + + + + + + + + + + +
namedescriptiontypedefault value
file The location of the file containing the import control configuration. It can be a regular file, URL or resource path. It will try loading the path as a URL first, then as a file, and finally as a resource. URIURInull
url URL of the file containing the import control configuration. This property is deprecated. Please use the file property to load configurations from URLs. URIURInull
path + Regular expression of file paths to which this check should apply. Files that + don't match the pattern will not be checked. The pattern will be matched against + the full absolute file path. + Regular Expression".*"
- +

Examples

- +

- To configure the check using a import control file called + To configure the check using an import control file called "config/import-control.xml", then have the following:

- +
<module name="ImportControl">
     <property name="file" value="config/import-control.xml"/>
 </module>
         
- + +

+ To configure the check to only check the "src/main" directory + using an import control file called "config/import-control.xml", + then have the following: +

+ + +
+
<module name="ImportControl">
+    <property name="file" value="config/import-control.xml"/>
+    <property name="path" value="^.*[\\/]src[\\/]main[\\/].*$"/>
+</module>
+        
+ +

In the example below access to package com.puppycrawl.tools.checkstyle.checks and its subpackages is @@ -109,7 +140,7 @@

Examples

and ClassPath classes).

- +
<import-control pkg="com.puppycrawl.tools.checkstyle">
     <allow pkg="com.puppycrawl.tools.checkstyle.api"/>
@@ -128,7 +159,7 @@ 

Examples

</import-control>
- +

In the next example regular expressions are used to enforce a layering rule: In all dao packages it is not allowed to access UI layer code (ui, @@ -138,7 +169,7 @@

Examples

with the same rules.

- +
<import-control pkg="(de.olddomain|de.newdomain)\..*" regex="true">
     <subpackage pkg="[^.]+\.dao" regex="true">
@@ -151,17 +182,17 @@ 

Examples

</import-control>
- +

For a real-life import control file look at the file called import-control.xml which is part of the Checkstyle distribution.

- +

Notes on regular expressions

- +

Regular expressions in import rules have to match either Java packages or classes. The language rules for packages and class names can be described by the @@ -169,39 +200,39 @@

Notes on regular expressions

contain any unicode letter, numbers, underscores, and dollar signs (see section 3.8 in the Java specs):

- +
    - +
  • [\p{Letter}_$][\p{Letter}\p{Number}_$]* or short [\p{L}_$][\p{L}\p{N}_$]* for a class name or package component.
  • - +
  • ([\p{L}_$][\p{L}\p{N}_$]*\.)*[\p{L}_$][\p{L}\p{N}_$]* for a fully qualified name.
- +

But it is not necessary to use these complicated expressions since no validation is required. Differentiating between package separator '.' and others is sufficient. Unfortunately '.' has a special meaning in regular expressions so one has to write \. to match an actual dot.

- +
    - +
  • Use [^.]+ (one or more "not a dot" characters) for a class name or package component.
  • - +
  • Use com\.google\.common\.[^.]+ to match any subpackage of com.google.common.
  • - +
  • When matching concrete packages like com.google.common omitting the backslash before the dots may improve readability and may be just exact enough: @@ -209,7 +240,7 @@

    Notes on regular expressions

    com.google.common but e.g. also of com.googleecommon but you may not care for that.
  • - +
  • Do not use .* unless you really do not care for what is matched. Often you want to match only a certain package level instead. @@ -217,4 +248,48 @@

    Notes on regular expressions

+ +
+

Example of Usage

+ + +
+ + +
+

Error Messages

+ + + +

+ All messages can be customized if the default message doesn't suite you. + Please see the documentation to learn how to. +

+
+ + + +
\ No newline at end of file diff --git a/checkstyle-sonar-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck.html b/checkstyle-sonar-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck.html index 89cd9e03..9edeeedc 100644 --- a/checkstyle-sonar-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck.html +++ b/checkstyle-sonar-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck.html @@ -1,4 +1,4 @@ Checks that parameter names conform to the specified format - +For more details please refere to online documentation

diff --git a/checkstyle-sonar-plugin/src/main/resources/org/sonar/plugins/checkstyle/rules.xml b/checkstyle-sonar-plugin/src/main/resources/org/sonar/plugins/checkstyle/rules.xml index 7f1a2e23..bbbc82b5 100644 --- a/checkstyle-sonar-plugin/src/main/resources/org/sonar/plugins/checkstyle/rules.xml +++ b/checkstyle-sonar-plugin/src/main/resources/org/sonar/plugins/checkstyle/rules.xml @@ -1275,10 +1275,8 @@ false - - anoninner - - + + public, protected, package, private READY @@ -1968,6 +1966,9 @@ + + .* + READY diff --git a/pom.xml b/pom.xml index 7d230588..134ef073 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,7 @@ - 7.4 + 7.5 5.6.4 3.7 1.8