All these changes are because I wanted to fix a small documentation
bug. Ended up having to move the RedundantModifierCheck around.
This commit is contained in:
parent
6602b4c461
commit
bc66e150c2
|
|
@ -1,7 +1,5 @@
|
|||
noNewlineAtEOF=File does not end with a newline.
|
||||
|
||||
redundantModifier=Redundant ''{0}'' modifier.
|
||||
|
||||
todo.match=Comment matches to-do format ''{0}''.
|
||||
|
||||
upperEll=Should use uppercase ''L''.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
noNewlineAtEOF=Datei endet nicht mit einem Zeilenumbruch.
|
||||
|
||||
|
||||
redundantModifier=Überflüssiger Modifier ''{0}''.
|
||||
|
||||
todo.match=Kommentar entspricht to-do-Format ''{0}''.
|
||||
|
||||
upperEll=Zur besseren Lesbarkeit sollte ein großes ''L'' verwendet werden.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
noNewlineAtEOF=Tiedosto ei pääty rivinvaihtoon.
|
||||
|
||||
redundantModifier=Tarpeeton määrite: ''{0}''
|
||||
|
||||
todo.match=Kommentti on to-do formaatin ''{0}'' mukainen.
|
||||
|
||||
upperEll=Pitää olla iso ''L''.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
noNewlineAtEOF=Il manque un caractère NewLine à la fin du fichier
|
||||
|
||||
redundantModifier=Mot-clef ''{0}'' redondant.
|
||||
|
||||
todo.match=Le commentaire correspond au format TODO ''{0}''.
|
||||
|
||||
upperEll=Utilisez un ''L'' majuscule pour une meilleure lisibilité.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
noNewlineAtEOF=ファイルが新しい行で終了していません。
|
||||
|
||||
redundantModifier=冗長な ''{0}'' 修飾子です。
|
||||
|
||||
todo.match=コメントが to-do の形式 ''{0}'' に合致しています。
|
||||
|
||||
upperEll=大文字の ''L'' を使用すべきです。
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ illegal.regexp=A linha condiz com o padr
|
|||
missing.switch.default=switch sem o ramo \"default\".
|
||||
mod.order=Modificador ''{0}'' fora da orderm sugerida pela JLS.
|
||||
noNewlineAtEOF=File does not end with a newline.
|
||||
redundantModifier=Modificador ''{0}'' é redundante.
|
||||
todo.match=O comentário condiz com o padrão de tarefa pendente ''{0}''.
|
||||
translation.missingKey=Falta a chave ''{0}''.
|
||||
uncommented.main=Método main não comentado encontrado.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
package com.puppycrawl.tools.checkstyle.checks.modifier;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.api.Check;
|
||||
import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
||||
|
|
@ -27,30 +27,6 @@ import com.puppycrawl.tools.checkstyle.api.ScopeUtils;
|
|||
* Checks for redundant modifiers in interface and annotation definitions.
|
||||
* Also checks for redundant final modifiers on methods of final classes.
|
||||
*
|
||||
* <p>
|
||||
* Rationale: The Java Language Specification strongly discourages the usage
|
||||
* of "public" and "abstract" for method declarations in interface definitions
|
||||
* as a matter of style.
|
||||
* </p>
|
||||
* <p>
|
||||
* Variables in interfaces and annotations are automatically public, static and
|
||||
* final, so these modifiers are redundant as well.
|
||||
* </p>
|
||||
* <p>
|
||||
* As annotations are a form of interface, their fields are also automatically
|
||||
* public, static and final just as their annotation fields are automatically
|
||||
* public and abstract.
|
||||
* </p>
|
||||
* <p>
|
||||
* Final classes by definition can not be extended so the final modifier on the
|
||||
* method of a final class is redundant.
|
||||
* </p>
|
||||
* <p>
|
||||
* An example of how to configure the check is:
|
||||
* </p>
|
||||
* <pre>
|
||||
* <module name="RedundantModifier"/>
|
||||
* </pre>
|
||||
* @author lkuehne
|
||||
*/
|
||||
public class RedundantModifierCheck
|
||||
|
|
@ -0,0 +1 @@
|
|||
redundantModifier=Redundant ''{0}'' modifier.
|
||||
|
|
@ -0,0 +1 @@
|
|||
redundantModifier=Überflüssiger Modifier ''{0}''.
|
||||
|
|
@ -0,0 +1 @@
|
|||
redundantModifier=Tarpeeton määrite: ''{0}''
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
redundantModifier=Mot-clef ''{0}'' redondant.
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
redundantModifier=冗長な ''{0}'' 修飾子です。
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
redundantModifier=Modificador ''{0}'' é redundante.
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
<html>
|
||||
<head></head>
|
||||
|
||||
<body>
|
||||
|
||||
<p>Contains the modifier checks that are bundled with the main distribution.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
<package name="indentation"/>
|
||||
<package name="javadoc"/>
|
||||
<package name="metrics"/>
|
||||
<package name="modifier"/>
|
||||
<package name="naming"/>
|
||||
<package name="sizes"/>
|
||||
<package name="whitespace"/>
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ public class PackageNamesLoaderTest extends TestCase
|
|||
"com.puppycrawl.tools.checkstyle.checks.indentation.",
|
||||
"com.puppycrawl.tools.checkstyle.checks.javadoc.",
|
||||
"com.puppycrawl.tools.checkstyle.checks.metrics.",
|
||||
"com.puppycrawl.tools.checkstyle.checks.modifier.",
|
||||
"com.puppycrawl.tools.checkstyle.checks.naming.",
|
||||
"com.puppycrawl.tools.checkstyle.checks.sizes.",
|
||||
"com.puppycrawl.tools.checkstyle.checks.whitespace.",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.checks.modifier.RedundantModifierTest;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
package com.puppycrawl.tools.checkstyle.checks.modifier;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
import com.puppycrawl.tools.checkstyle.checks.modifier.RedundantModifierCheck;
|
||||
|
||||
public class RedundantModifierTest
|
||||
extends BaseCheckTestCase
|
||||
|
|
@ -71,39 +71,41 @@
|
|||
<a href="config.html#treewalker">TreeWalker</a>
|
||||
</p>
|
||||
</subsection>
|
||||
</section>
|
||||
|
||||
<subsection name="RedundantModifier">
|
||||
<section name="RedundantModifier">
|
||||
|
||||
<subsection name="Description">
|
||||
<p>
|
||||
Checks that:
|
||||
Checks for redundant modifiers in interface and annotation
|
||||
definitions. Also checks for redundant final modifiers on
|
||||
methods of final classes.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Rationale: The Java Language Specification strongly
|
||||
discourages the usage of "public" and "abstract" for method
|
||||
declarations in interface definitions as a matter of style.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Variables in interfaces and annotations are automatically
|
||||
public, static and final, so these modifiers are redundant as
|
||||
well.
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
method declarations in interfaces include neither the <span
|
||||
class="code"> public</span> modifier nor the <span
|
||||
class="code">abstract</span> modifier (see the <a
|
||||
href="http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html">Java
|
||||
Language specification, section 9.4</a>).
|
||||
</li>
|
||||
<li>
|
||||
all <span class="code">private</span> method declarations and all
|
||||
method declarations in a <span class="code">final</span> class do
|
||||
not include modifier <span class="code">final</span> (see the <a
|
||||
href="http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#11246">Java
|
||||
Language specification, section 8.4.3.3</a>).
|
||||
</li>
|
||||
<li>
|
||||
variable declarations in interfaces include none of the following
|
||||
modifiers: <span class="code">public</span>, <span
|
||||
class="code">static</span>, <span class="code">final</span>
|
||||
(variables in interface definitions are constants and have these
|
||||
modifiers implicitly, see the <a
|
||||
href="http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html">Java
|
||||
Language specification, section 9.3</a>).
|
||||
</li>
|
||||
</ul>
|
||||
</subsection>
|
||||
<p>
|
||||
As annotations are a form of interface, their fields are also
|
||||
automatically public, static and final just as their
|
||||
annotation fields are automatically public and abstract.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Final classes by definition can not be extended so the final
|
||||
modifier on the method of a final class is redundant.
|
||||
</p>
|
||||
</subsection>
|
||||
|
||||
<subsection name="Properties">
|
||||
<table>
|
||||
<tr>
|
||||
|
|
@ -119,13 +121,17 @@
|
|||
subset of tokens <a
|
||||
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
|
||||
<a
|
||||
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">VARIABLE_DEF</a>
|
||||
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">VARIABLE_DEF</a>,
|
||||
<a
|
||||
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_FIELD_DEF">ANNOTATION_FIELD_DEF</a>
|
||||
</td>
|
||||
<td>
|
||||
<a
|
||||
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">METHOD_DEF</a>,
|
||||
<a
|
||||
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">VARIABLE_DEF</a>
|
||||
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">VARIABLE_DEF</a>,
|
||||
<a
|
||||
href="api/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_FIELD_DEF">ANNOTATION_FIELD_DEF</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
@ -136,7 +142,7 @@
|
|||
<source>
|
||||
<module name="RedundantModifier"/>
|
||||
</source>
|
||||
|
||||
|
||||
<p>
|
||||
To configure the check to check only methods and not variables:
|
||||
</p>
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
<item name="Imports" href="/config_import.html"/>
|
||||
<item name="Size Violations" href="/config_sizes.html"/>
|
||||
<item name="Whitespace" href="/config_whitespace.html"/>
|
||||
<item name="Modifiers" href="/config_modifiers.html"/>
|
||||
<item name="Modifiers" href="/config_modifier.html"/>
|
||||
<item name="Block Checks" href="/config_blocks.html"/>
|
||||
<item name="Coding" href="/config_coding.html"/>
|
||||
<item name="Class Design" href="/config_design.html"/>
|
||||
|
|
|
|||
|
|
@ -132,6 +132,10 @@
|
|||
</div>
|
||||
#end
|
||||
|
||||
#macro ( token $value)
|
||||
<a href="../../blah/jibber/$value>$value</a>
|
||||
#end
|
||||
|
||||
## ============================================
|
||||
## subsection macro
|
||||
## ============================================
|
||||
|
|
|
|||
|
|
@ -13,5 +13,5 @@
|
|||
lines="176"/>
|
||||
<suppress checks="MagicNumber"
|
||||
files="JavadocMethodCheck.java"
|
||||
lines="753,785,810"/>
|
||||
lines="714,746,771"/>
|
||||
</suppressions>
|
||||
|
|
|
|||
Loading…
Reference in New Issue