Skip to content

Commit

Permalink
Issue #62: upgrade to checkstyle 7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
romani committed Jan 29, 2017
1 parent 55ad8dd commit c445970
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 53 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,103 +1,134 @@
<div >
<h2><a name="ImportControl"></a>ImportControl</h2>

<div class="section">
<h2><a name="ImportControl"></a>ImportControl<div class="anchor"><a href="http://checkstyle.sourceforge.net/config_imports.html#ImportControl"><img src="images/anchor.png"></a></div></h2>

<div class="section">
<h3><a name="Description"></a>Description</h3>

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


<p>
The DTD for a import control XML document is at <a class="externalLink" href="http://checkstyle.sourceforge.net/dtds/import_control_1_2.dtd">
http://checkstyle.sourceforge.net/dtds/import_control_1_2.dtd</a>. It
contains documentation on each of the elements and attributes.
</p>


<p>
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:
</p>


<div>
<pre>&lt;!DOCTYPE import-control PUBLIC
"-//Puppy Crawl//DTD Import Control 1.2//EN"
"http://checkstyle.sourceforge.net/dtds/import_control_1_2.dtd"&gt;
</pre></div>
</div>


<div class="section">
<h3><a name="Properties"></a>Properties</h3>

<table class="bodyTable" border="0">

<tbody><tr class="a">

<th>name</th>

<th>description</th>

<th>type</th>

<th>default value</th>
</tr>

<tr class="b">

<td>file</td>

<td>
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.
</td>
<td><a href="http://checkstyle.sourceforge.net/property_types.html#uri">URI</a></td>

<td><a href="property_types.html#uri">URI</a></td>

<td><tt>null</tt></td>
</tr>

<tr class="a">

<td>url</td>

<td>
URL of the file containing the import control configuration.
This property is deprecated. Please use the file property to load configurations
from URLs.
</td>
<td><a href="http://checkstyle.sourceforge.net/property_types.html#uri">URI</a></td>

<td><a href="property_types.html#uri">URI</a></td>

<td><tt>null</tt></td>
</tr>

<tr class="b">

<td>path</td>

<td>
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.
</td>

<td><a href="property_types.html#regexp">Regular Expression</a></td>

<td><tt>".*"</tt></td>
</tr>
</tbody></table>
</div>


<div class="section">
<h3><a name="Examples"></a>Examples</h3>

<p>
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:
</p>


<div class="source">
<pre>&lt;module name="ImportControl"&gt;
&lt;property name="file" value="config/import-control.xml"/&gt;
&lt;/module&gt;
</pre></div>



<p>
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:
</p>


<div class="source">
<pre>&lt;module name="ImportControl"&gt;
&lt;property name="file" value="config/import-control.xml"/&gt;
&lt;property name="path" value="^.*[\\/]src[\\/]main[\\/].*$"/&gt;
&lt;/module&gt;
</pre></div>


<p>
In the example below access to package
<tt>com.puppycrawl.tools.checkstyle.checks</tt> and its subpackages is
Expand All @@ -109,7 +140,7 @@ <h3><a name="Examples"></a>Examples</h3>
and <tt>ClassPath</tt> classes).
</p>


<div class="source">
<pre>&lt;import-control pkg="com.puppycrawl.tools.checkstyle"&gt;
&lt;allow pkg="com.puppycrawl.tools.checkstyle.api"/&gt;
Expand All @@ -128,7 +159,7 @@ <h3><a name="Examples"></a>Examples</h3>
&lt;/import-control&gt;
</pre></div>


<p>
In the next example regular expressions are used to enforce a layering rule: In all
<tt>dao</tt> packages it is not allowed to access UI layer code (<tt>ui</tt>,
Expand All @@ -138,7 +169,7 @@ <h3><a name="Examples"></a>Examples</h3>
with the same rules.
</p>


<div class="source">
<pre>&lt;import-control pkg="(de.olddomain|de.newdomain)\..*" regex="true"&gt;
&lt;subpackage pkg="[^.]+\.dao" regex="true"&gt;
Expand All @@ -151,70 +182,114 @@ <h3><a name="Examples"></a>Examples</h3>
&lt;/import-control&gt;
</pre></div>


<p>
For a real-life import control file look at the file called <a class="externalLink" href="https://github.com/checkstyle/checkstyle/blob/master/config/import-control.xml">
import-control.xml</a>
which is part of the Checkstyle distribution.
</p>


<div class="section" id="regex-notes">
<h4 id="regex-notes">Notes on regular expressions</h4>

<p>
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
following complicated regular expression that takes into account that Java names may
contain any unicode letter, numbers, underscores, and dollar signs (see section 3.8
in the <a class="externalLink" href="http://docs.oracle.com/javase/specs/">Java specs</a>):
</p>

<ul>

<li>
<tt>[\p{Letter}_$][\p{Letter}\p{Number}_$]*</tt> or short
<tt>[\p{L}_$][\p{L}\p{N}_$]*</tt> for a class name or package component.
</li>

<li>
<tt>([\p{L}_$][\p{L}\p{N}_$]*\.)*[\p{L}_$][\p{L}\p{N}_$]*</tt>
for a fully qualified name.
</li>
</ul>

<p>
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 <tt>\.</tt> to match an actual dot.
</p>

<ul>

<li>
Use <tt>[^.]+</tt> (one or more "not a dot" characters) for a class name or
package component.
</li>

<li>
Use <tt>com\.google\.common\.[^.]+</tt> to match any subpackage of
<tt>com.google.common</tt>.
</li>

<li>
When matching concrete packages like <tt>com.google.common</tt> omitting the
backslash before the dots may improve readability and may be just exact enough:
<tt>com.google.common\.[^.]+</tt> matches not only subpackages of
<tt>com.google.common</tt> but e.g. also of <tt>com.googleecommon</tt> but
you may not care for that.
</li>

<li>
Do not use <tt>.*</tt> unless you really do not care for what is matched. Often
you want to match only a certain package level instead.
</li>
</ul>
</div></div>


<div class="section">
<h3><a name="Example_of_Usage"></a>Example of Usage</h3>

<ul>

<li>
<a class="externalLink" href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+ImportControl">
Checkstyle Style</a>
</li>
</ul>
</div>


<div class="section">
<h3><a name="Error_Messages"></a>Error Messages</h3>

<ul>

<li>
<a class="externalLink" href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fimports+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22import.control.disallowed%22">
import.control.disallowed</a>
</li>

<li>
<a class="externalLink" href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fimports+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22import.control.missing.file%22">
import.control.missing.file</a>
</li>

<li>
<a class="externalLink" href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fimports+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22import.control.unknown.pkg%22">
import.control.unknown.pkg</a>
</li>
</ul>

<p>
All messages can be customized if the default message doesn't suite you.
Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
</p>
</div>



</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Checks that parameter names conform to the specified format

For more details please refere to <a href="http://checkstyle.sourceforge.net/config_naming.html#ParameterName">online documentation</a>
<p>
</p>
Original file line number Diff line number Diff line change
Expand Up @@ -1275,10 +1275,8 @@
<param key="ignoreOverridden" type="BOOLEAN">
<defaultValue>false</defaultValue>
</param>
<param key="scope" type="s[nothing,public,protected,package,private,anoninner]">
<defaultValue>anoninner</defaultValue>
</param>
<param key="excludeScope" type="s[nothing,public,protected,package,private,anoninner]">
<param key="accessModifiers" type="s[public,protected,package,private]">
<defaultValue>public, protected, package, private</defaultValue>
</param>
<status>READY</status>
</rule>
Expand Down Expand Up @@ -1968,6 +1966,9 @@
</param>
<param key="url" type="STRING">
</param>
<param key="path" type="REGULAR_EXPRESSION">
<defaultValue>.*</defaultValue>
</param>
<status>READY</status>
</rule>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
</ciManagement>

<properties>
<checkstyle.version>7.4</checkstyle.version>
<checkstyle.version>7.5</checkstyle.version>
<sonar.version>5.6.4</sonar.version>
<sonar-java.version>3.7</sonar-java.version>
<java.version>1.8</java.version>
Expand Down

0 comments on commit c445970

Please sign in to comment.