|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<!DOCTYPE module PUBLIC |
| 3 | + "-//Puppy Crawl//DTD Check Configuration 1.3//EN" |
| 4 | + "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd"> |
| 5 | +<!-- |
| 6 | +DSpace CodeStyle Requirements |
| 7 | +
|
| 8 | + 1. 4-space indents for Java, and 2-space indents for XML. NO TABS ALLOWED. |
| 9 | + 2. K&R style braces required. Braces required on all blocks. |
| 10 | + 3. Do not use wildcard imports (e.g. import java.util.*). Duplicated or unused imports also not allowed. |
| 11 | + 4. Javadocs should exist for all public classes and methods. (Methods rule is unenforced at this time.) Keep it short and to the point |
| 12 | + 5. Maximum line length is 120 characters (except for long URLs, packages or imports) |
| 13 | + 6. No trailing spaces allowed (except in comments) |
| 14 | + 7. Tokens should be surrounded by whitespace (see http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAround) |
| 15 | + 8. Each source file must include our license header (validated separately by license-maven-plugin, see pom.xml) |
| 16 | +
|
| 17 | +For more information on CheckStyle configurations below, see: http://checkstyle.sourceforge.net/checks.html |
| 18 | +--> |
| 19 | +<module name="Checker"> |
| 20 | + <!-- Configure checker to use UTF-8 encoding --> |
| 21 | + <property name="charset" value="UTF-8"/> |
| 22 | + <!-- Configure checker to run on files with these extensions --> |
| 23 | + <property name="fileExtensions" value="java, properties, cfg, xml"/> |
| 24 | + |
| 25 | + <!-- Suppression configurations in checkstyle-suppressions.xml in same directory --> |
| 26 | + <module name="SuppressionFilter"> |
| 27 | + <property name="file" value="${checkstyle.suppressions.file}" default="checkstyle-suppressions.xml"/> |
| 28 | + </module> |
| 29 | + |
| 30 | + <!-- No tab characters ('\t') allowed in the source code --> |
| 31 | + <module name="FileTabCharacter"> |
| 32 | + <property name="eachLine" value="true"/> |
| 33 | + <property name="fileExtensions" value="java, properties, cfg, css, js, xml"/> |
| 34 | + </module> |
| 35 | + |
| 36 | + <!-- No Trailing Whitespace, except on lines that only have an asterisk (e.g. Javadoc comments) --> |
| 37 | + <module name="RegexpSingleline"> |
| 38 | + <property name="format" value="(?<!\*)\s+$|\*\s\s+$"/> |
| 39 | + <property name="message" value="Line has trailing whitespace"/> |
| 40 | + <property name="fileExtensions" value="java, properties, cfg, css, js, xml"/> |
| 41 | + </module> |
| 42 | + |
| 43 | + <!-- Allow individual lines of code to be excluded from these rules, if they are annotated |
| 44 | + with @SuppressWarnings. See also SuppressWarningsHolder below --> |
| 45 | + <module name="SuppressWarningsFilter" /> |
| 46 | + |
| 47 | + <!-- Maximum line length is 120 characters --> |
| 48 | + <module name="LineLength"> |
| 49 | + <property name="fileExtensions" value="java"/> |
| 50 | + <property name="max" value="120"/> |
| 51 | + <!-- Only exceptions for packages, imports, URLs, and JavaDoc {@link} tags --> |
| 52 | + <property name="ignorePattern" value="^package.*|^import.*|http://|https://|@link"/> |
| 53 | + </module> |
| 54 | + |
| 55 | + <!-- Check individual Java source files for specific rules --> |
| 56 | + <module name="TreeWalker"> |
| 57 | + <!-- Highlight any TODO or FIXME comments in info messages --> |
| 58 | + <module name="TodoComment"> |
| 59 | + <property name="severity" value="info"/> |
| 60 | + <property name="format" value="(TODO)|(FIXME)"/> |
| 61 | + </module> |
| 62 | + |
| 63 | + <!-- Do not report errors on any lines annotated with @SuppressWarnings --> |
| 64 | + <module name="SuppressWarningsHolder"/> |
| 65 | + |
| 66 | + <!-- ##### Import statement requirements ##### --> |
| 67 | + <!-- Star imports (e.g. import java.util.*) are NOT ALLOWED --> |
| 68 | + <module name="AvoidStarImport"/> |
| 69 | + <!-- Redundant import statements are NOT ALLOWED --> |
| 70 | + <module name="RedundantImport"/> |
| 71 | + <!-- Unused import statements are NOT ALLOWED --> |
| 72 | + <module name="UnusedImports"/> |
| 73 | + <!-- Ensure imports appear alphabetically and grouped --> |
| 74 | + <module name="CustomImportOrder"> |
| 75 | + <property name="sortImportsInGroupAlphabetically" value="true"/> |
| 76 | + <property name="separateLineBetweenGroups" value="true"/> |
| 77 | + <property name="customImportOrderRules" value="STATIC###STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE"/> |
| 78 | + </module> |
| 79 | + |
| 80 | + <!-- ##### Javadocs requirements ##### --> |
| 81 | + <!-- Requirements for Javadocs for classes/interfaces --> |
| 82 | + <module name="JavadocType"> |
| 83 | + <!-- All public classes/interfaces MUST HAVE Javadocs --> |
| 84 | + <property name="scope" value="public"/> |
| 85 | + <!-- Add an exception for anonymous inner classes --> |
| 86 | + <property name="excludeScope" value="anoninner"/> |
| 87 | + <!-- Ignore errors related to unknown tags --> |
| 88 | + <property name="allowUnknownTags" value="true"/> |
| 89 | + <!-- Allow params tags to be optional --> |
| 90 | + <property name="allowMissingParamTags" value="false"/> |
| 91 | + </module> |
| 92 | + <!-- Requirements for Javadocs for methods --> |
| 93 | + <module name="JavadocMethod"> |
| 94 | + <!-- All public methods MUST HAVE Javadocs --> |
| 95 | + <property name="accessModifiers" value="public"/> |
| 96 | + <!-- Allow params, throws and return tags to be optional --> |
| 97 | + <property name="allowMissingParamTags" value="true"/> |
| 98 | + <property name="allowMissingReturnTag" value="true"/> |
| 99 | + </module> |
| 100 | + |
| 101 | + <!-- ##### Requirements for K&R Style braces ##### --> |
| 102 | + <!-- Code blocks MUST HAVE braces, even single line statements (if, while, etc) --> |
| 103 | + <module name="NeedBraces"/> |
| 104 | + <!-- Left braces should be at the end of current line (default value)--> |
| 105 | + <module name="LeftCurly"/> |
| 106 | + <!-- Right braces should be on start of a new line (default value) --> |
| 107 | + <module name="RightCurly"/> |
| 108 | + |
| 109 | + <!-- ##### Indentation / Whitespace requirements ##### --> |
| 110 | + <!-- Require 4-space indentation (default value) --> |
| 111 | + <module name="Indentation"/> |
| 112 | + <!-- Whitespace should exist around all major tokens --> |
| 113 | + <module name="WhitespaceAround"> |
| 114 | + <!-- However, make an exception for empty constructors, methods, types, etc. --> |
| 115 | + <property name="allowEmptyConstructors" value="true"/> |
| 116 | + <property name="allowEmptyMethods" value="true"/> |
| 117 | + <property name="allowEmptyTypes" value="true"/> |
| 118 | + <property name="allowEmptyLoops" value="true"/> |
| 119 | + </module> |
| 120 | + <!-- Validate whitespace around Generics (angle brackets) per typical conventions |
| 121 | + http://checkstyle.sourceforge.net/config_whitespace.html#GenericWhitespace --> |
| 122 | + <module name="GenericWhitespace"/> |
| 123 | + |
| 124 | + <!-- ##### Requirements for "switch" statements ##### --> |
| 125 | + <!-- "switch" statements MUST have a "default" clause --> |
| 126 | + <module name="MissingSwitchDefault"/> |
| 127 | + <!-- "case" clauses in switch statements MUST include break, return, throw or continue --> |
| 128 | + <module name="FallThrough"/> |
| 129 | + |
| 130 | + <!-- ##### Other / Miscellaneous requirements ##### --> |
| 131 | + <!-- Require utility classes do not have a public constructor --> |
| 132 | + <module name="HideUtilityClassConstructor"/> |
| 133 | + <!-- Require each variable declaration is its own statement on its own line --> |
| 134 | + <module name="MultipleVariableDeclarations"/> |
| 135 | + <!-- Each line of code can only include one statement --> |
| 136 | + <module name="OneStatementPerLine"/> |
| 137 | + <!-- Require that "catch" statements are not empty (must at least contain a comment) --> |
| 138 | + <module name="EmptyCatchBlock"/> |
| 139 | + </module> |
| 140 | +</module> |
0 commit comments