This includes confining its scope to src/*.java and resources/*.properties.
This can be modified interactively through the checkstyle properties editor.
- Checkstyle config files in resources/checkstyle:
+ Checkstyle config files in utils/checkstyle:
checkstyle.xml : main configuration file with selected checkstyle modules
checkstyle-suppress.xml : rules to exclude certain checks / files
import-control.xml : package import rules
Option 2: on demand on selected code
- right-click on a class or package and Checkstyle | Check code with checkstyle
+ - (or Clear Checkstyle violations to remove checkstyle warnings)
Checkstyle rules
----------------
Suppressing findings
--------------------
- If there are warnings you judge it ok to suppress, your options are
- (from most global to most local scope):
+ If there are warnings you judge it ok to suppress (false positives),
+ your options are (from most global to most local impact):
- remove the rule entirely
- adjust its properties
- add an entry in checkstyle-suppress.xml to skip the file for the rule
- add comments around the reported source lines
- // CHECKSTYLE.OFF: RuleName
+ // CHECKSTYLE.OFF: RuleName 'a comment to justify suppression'
source code here
// CHECKSTYLE.ON: RuleName
The suppression should be as localised as possible, to avoid false negatives.
-<?xml version="1.0" encoding="UTF-8"?>\r
-\r
-<!DOCTYPE suppressions PUBLIC\r
- "-//Puppy Crawl//DTD Suppressions 1.1//EN"\r
- "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">\r
-\r
-<suppressions>\r
- <!-- \r
- Do not put individual file-level suppressions here.\r
- Instead use embedded comments to switch checks on and off.\r
- -->\r
- \r
- <!-- \r
- Suppress check of XML binding generated code packages \r
- --> \r
- <suppress checks="[a-zA-Z0-9]*" files="jalview[\\/]schemabinding[\\/]*"/>\r
- <suppress checks="[a-zA-Z0-9]*" files="jalview[\\/]binding[\\/]*"/>\r
- <suppress checks="[a-zA-Z0-9]*" files="jalview[\\/]json[\\/]binding[\\/]*"/>\r
- <suppress checks="[a-zA-Z0-9]*" files="jalview[\\/]xml[\\/]binding[\\/]*"/>\r
- \r
- <!-- \r
- Suppress check of externally sourced code \r
- --> \r
- <suppress checks="[a-zA-Z0-9]*" files="com[\\/]*"/>\r
- <suppress checks="[a-zA-Z0-9]*" files="ext[\\/]*"/>\r
- <suppress checks="[a-zA-Z0-9]*" files="org[\\/]*"/>\r
- <suppress checks="[a-zA-Z0-9]*" files="uk[\\/]*"/>\r
- \r
- <!-- \r
- ImportControl can only handle one top level package\r
- -->\r
- <suppress checks="ImportControl" files="MCview[\\/]*" />\r
- <suppress checks="ImportControl" files="vamsas[\\/]*" />\r
- \r
- <!-- \r
- Suppress checks by name \r
- -->\r
- <suppress checks="FinalLocalVariable" files=".*\.java"/>\r
- \r
- <!-- \r
- Suppress checks by id \r
- -->\r
- <suppress id="InterfaceNaming" files=".*\.java"/>\r
- <suppress id="NoStaticInitialization" files=".*\.java"/>\r
- \r
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.1//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
+
+<suppressions>
+ <!--
+ Do not put individual file-level suppressions here.
+ Instead use embedded comments to switch checks on and off.
+ -->
+
+ <!--
+ Suppress check of XML binding generated code packages
+ -->
+ <suppress checks="[a-zA-Z0-9]*" files="jalview[\\/]schemabinding[\\/]*"/>
+ <suppress checks="[a-zA-Z0-9]*" files="jalview[\\/]binding[\\/]*"/>
+ <suppress checks="[a-zA-Z0-9]*" files="jalview[\\/]json[\\/]binding[\\/]*"/>
+ <suppress checks="[a-zA-Z0-9]*" files="jalview[\\/]xml[\\/]binding[\\/]*"/>
+
+ <!--
+ Suppress check of externally sourced code
+ -->
+ <suppress checks="[a-zA-Z0-9]*" files="com[\\/]*"/>
+ <suppress checks="[a-zA-Z0-9]*" files="ext[\\/]*"/>
+ <suppress checks="[a-zA-Z0-9]*" files="org[\\/]*"/>
+ <suppress checks="[a-zA-Z0-9]*" files="uk[\\/]*"/>
+
+ <!--
+ ImportControl can only handle one top level package
+ -->
+ <suppress checks="ImportControl" files="MCview[\\/]*" />
+ <suppress checks="ImportControl" files="vamsas[\\/]*" />
+
+ <!--
+ Suppress checks by name
+ -->
+ <suppress checks="FinalLocalVariable" files=".*\.java"/>
+
+ <!--
+ Suppress checks by id
+ -->
+ <suppress id="InterfaceNaming" files=".*\.java"/>
+ <suppress id="NoStaticInitialization" files=".*\.java"/>
+
</suppressions>
\ No newline at end of file
Add any metrics that you wish to suppress to the following file.
-->
<module name="SuppressionFilter">
- <property name="file" value="${basedir}/resources/checkstyle/checkstyle-suppress.xml"/>
+ <property name="file" value="${basedir}/utils/checkstyle/checkstyle-suppress.xml"/>
</module>
<!--
see http://checkstyle.sourceforge.net/config_imports.html#ImportControl
-->
<module name="ImportControl">
- <property name="file" value="${basedir}/resources/checkstyle/import-control.xml"/>
+ <property name="file" value="${basedir}/utils/checkstyle/import-control.xml"/>
<property name="severity" value="error"/>
</module>