JAL-1854 two more rules, readme notes
[jalview.git] / resources / checkstyle / checkstyle.xml
index 4189a21..423f698 100644 (file)
                <module name="MultipleVariableDeclarations"/>
                
                <!-- 
+                       Don't have more than one statement on a line
+                       (code formatting on save may enforce this anyway)
+                -->
+               <module name="OneStatementPerLine"/>
+
+               <!-- 
+                       Declare variables close to their point of first use 
+                       (doesn't handle variables used inside loops very well) 
+               -->
+               <module name="VariableDeclarationUsageDistance">
+                       <property name="allowedDistance" value="5" />
+                       <message key="variable.declaration.usage.distance.extend"
+                               value="Distance between declaration of ''{0}'' and its first use is {1}, suggested maximum is {2}. Consider moving, or make final if it may not be modified." />
+               </module>
+       
+               <!-- 
                        Only use blocks within control statements 
                -->
-               <module name="AvoidNestedBlocks"/>
-               
+               <module name="AvoidNestedBlocks" />
+
                <!-- 
                        Require at least a comment within a block. 
-                       Note this will accept auto-generated // TODO comments,
-                       (but they should be flagged up by the TodoComment rule)
+                       Note this will accept auto-generated // TODO comments, 
+                       (but they should be flagged up by the TodoComment rule) 
                -->
                <module name="EmptyBlock">
                        <property name="option" value="text"/>
        <!-- ****************************** -->
 
                <!-- 
-                       Check for use of factory method rather than constructor for specified classes 
+                       Check for use of factory method rather than constructor for specified classes
+                       e.g. Boolean.valueOf(true) rather than new Boolean(true)
                -->
                <module name="IllegalInstantiation">
                        <property name="classes" value="java.lang.Boolean"/>
                </module>
                
                <!-- 
-                       Checks that clone() invokes super.clone() 
+                       Don't override clone - it never works! 
+                -->
+               <module name="NoClone"/>
+               
+               <!-- 
+                       Checks that clone() invokes super.clone()
+                       (for classes that break the NoClone rule)
                 -->
                <module name="SuperClone"/>
                
                        Checks that exceptions are immutable (have only final fields)
                 -->
                <module name="MutableException"/>
+               
+               <!-- 
+                       A general rule to check for source text tokens that shouldn't be there
+                       see http://checkstyle.sourceforge.net/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html
+                -->
+               <module name="IllegalToken">
+                  <property name="tokens" value="LITERAL_ASSERT"/>
+               </module>
 
        <!-- ****************************** -->
        <!--           COMPLEXITY           -->