Portable {}
````
#### [JavadocMethod](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocMethod)
Checks that all public, protected and package methods have a Javadoc block, that all `@throws` tags are used. Basic setters and getters do not require javadoc.
#### [JavadocPackage](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage)
Checks that each package has a `package-info.java` file.
#### [JavadocParagraph](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocParagraph)
Checks that paragraphs in Javadoc blocks are wrapped in `` elements and have blank lines between paragraphs. This first paragraph does not need the `
` elements.
#### [JavadocStyle](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocStyle)
Checks the formatting of the Javadoc blocks. See the official [Checkstyle documentation](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocStyle) for all the checks that are applied.
#### [JavadocType](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocType)
Checks the format for Javadoc for classes and enums. Javadoc must be present, not have any unknown tags and not missing any `@param` tags. The `@author` tag must have a name and, in brackets, an email address.
#### [JavaNCSS](http://checkstyle.sourceforge.net/config_metrics.html#JavaNCSS)
Restricts the NCSS score for methods, classes and files to 40, 1200 and 1600 respectively. The NCSS score is a measure of the number of statements within a scope.
Too high an NCSS score suggests that the method or class is doing too much and should be decomposed into smaller units.
#### [LeftCurly](http://checkstyle.sourceforge.net/config_blocks.html#LeftCurly)
Checks that the left curly brace ('{') is placed at the end of the line. Does not check enums.
Valid:
````
class Foo {
}
````
Invalid:
````
class Bar
{
}
````
#### [LineLength](http://checkstyle.sourceforge.net/config_sizes.html#LineLength)
Limits the line length to 120 characters.
Doesn't check package or import lines.
#### [LocalFinalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalFinalVariableName)
Checks the format of local, `final` variable names, including `catch` parameters.
Identifiers must match `^[a-z][a-zA-Z0-9]*$`.
#### [LocalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalVariableName)
Checks the format of local, non-`final` variable names.
Identifiers must match `^[a-z][a-zA-Z0-9]*$`.
#### [MagicNumber](http://checkstyle.sourceforge.net/config_coding.html#MagicNumber)
Checks that numeric literals are defined as constants. Being constants they then have a name that aids in making them non-magical.
The numbers -1, 0, 1 and 2 are not considered to be magical.
Valid:
````
static final int SECONDS_PER_DAY = 24 * 60 * 60;
static final Border STANDARD_BORDER = BorderFactory.createEmptyBorder(3, 3, 3, 3);
````
Invalid
````
String item = getItem(200);
````
#### [MemberName](http://checkstyle.sourceforge.net/config_naming.html#MemberName)
Checks the format of non-static field names.
Identifiers must match `^[a-z][a-zA-Z0-9]*$`.
#### [MethodCount](http://checkstyle.sourceforge.net/config_sizes.html#MethodCount)
Restricts the number of methods in a type to 30.
#### [MethodLength](http://checkstyle.sourceforge.net/config_sizes.html#MethodLength)
Restricts the number of lines in a method to 60. Include blank lines and single line comments. You should be able to see an entire method without needing to scroll.
#### [MethodName](http://checkstyle.sourceforge.net/config_naming.html#MethodName)
Checks the format of method names.
Identifiers must match `^[a-z][a-zA-Z0-9]*$`.
#### [MethodParamPad](http://checkstyle.sourceforge.net/config_whitespace.html#MethodParamPad)
Checks that the padding between the method identifier and the left parenthesis is on the same line and doesn't have a space in-between.
Valid:
````
void getInstance();
````
Invalid:
````
void getInstance ();
void getValue
();
````
#### [MethodTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#MethodTypeParameterName)
Restricts method generics parameters to be a single uppercase letter.
Valid:
````
List getItems() {}
````
Invalid:
````
List getItems() {}
List getItems() {}
List getItems() {}
````
#### [MissingDeprecated](http://checkstyle.sourceforge.net/config_annotation.html#MissingDeprecated)
Both the `@Deprecated` annotation and the Javadoc tag `@deprecated` must be used in pairs.
Valid:
````
/**
* Foo.
*
* @deprecated
*/
@Deprecated
void foo() {}
````
Invalid:
````
/**
* Foo.
*/
@Deprecated
void foo() {}
/**
* Bar.
*
* @deprecated
*/
void bar() {}
````
#### [MissingSwitchDefault](http://checkstyle.sourceforge.net/config_coding.html#MissingSwitchDefault)
Checks that `switch` statement has a `default` case.
Valid:
````
switch (foo) {
case 1:
//
break;
case 2:
//
break;
default:
throw new IllegalStateExcetion("Foo: " + foo);
}
````
Invalid:
````
switch (foo) {
case 1:
//
break;
case 2:
//
break;
}
````
#### [ModifiedControlVariable](http://checkstyle.sourceforge.net/config_coding.html#ModifiedControlVariable)
Checks that the control variable in a `for` loop is not modified inside the loop.
Invalid:
````
for (int i = 0; i < 1; i++) {
i++;
}
````
#### [ModifierOrder](http://checkstyle.sourceforge.net/config_modifier.html#ModifierOrder)
Check that modifiers are in the following order:
* `public`
* `protected`
* `private`
* `abstract`
* `static`
* `final`
* `transient`
* `volatile`
* `synchronized`
* `native`
* `strictfp`
Type annotations are ignored.
#### [MultipleStringLiterals](http://checkstyle.sourceforge.net/config_coding.html#MultipleStringLiterals)
Checks for multiple occurrences of the same string literal within a single file. Does not apply to empty strings ("").
Invalid:
````
String fooFoo = "foo" + "foo";
````
#### [MultipleVariableDeclarations](http://checkstyle.sourceforge.net/config_coding.html#MultipleVariableDeclarations)
Checks that each variable is declared in its own statement and line.
Valid:
````
int a;
int b;
````
Invalid:
````
int a, b;
````
#### [MutableException](http://checkstyle.sourceforge.net/config_design.html#MutableException)
Checks that `Exception` classes are immutable. However, you can still call `setStackTrace`.
Classes checked are those whose name ends with the following. Or that the class they extend does.
* `Exception`
* `Error`
* `Throwable`
#### [NeedBraces](http://checkstyle.sourceforge.net/config_blocks.html#NeedBraces)
Check that code blocks are surrounded by braces.
Valid:
````
if (obj.isValid()) {
return true;
}
while (obj.isValid()) {
return true;
}
do {
this.notify();
} while (o != null);
for (int i = 0; ;) {
this.notify();
}
````
Invalid:
````
if (obj.isValid()) return true;
while (obj.isValid()) return true;
do this.notify(); while (o != null);
for (int i = 0; ;) this.notify();
````
#### [NestedForDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedForDepth)
Checks that `for` loops are not nested more than 1 deep.
Valid:
````
for (int i = 0; i < 1; i++) { // depth 0
for (int j = 0; j < 1; j++) { // depth 1
//
}
}
````
Invalid:
````
for (int i = 0; i < 1; i++) { // depth 0
for (int j = 0; j < 1; j++) { // depth 1
for (int k = 0; j < 1; k++) { // depth 2!
//
}
}
}
````
#### [NestedIfDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedIfDepth)
Checks that `if` blocks are not nested more than 1 deep.
Valid:
````
if (isValid()) { // depth 0
if (isExpected()) { // depth 1
doIt();
}
}
````
Invalid:
````
if (isValid()) { // depth 0
if (isExpected()) { // depth 1
if (isNecessary()) { // depth 2!
doIt();
}
}
}
````
#### [NestedTryDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedTryDepth)
Checks that `try` blocks are not nested.
Valid:
````
try {
doSomething();
doSomeOtherThing();
} catch (SomeException se) {
// handle it
} catch (OtherExceptions oe) {
// handle it
}
````
Invalid:
````
try {
doSomething();
try {
doSomeOtherThing();
} catch (OtherExceptions oe) {
// handle it
}
} catch (SomeException se) {
// handle it
}
````
#### [NewlineAtEndOfFile](http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile)
Checks that files end with a line-feed character, (i.e. unix-style line ending).
#### [NoClone](http://checkstyle.sourceforge.net/config_coding.html#NoClone)
> This check cannot be suppressed.
Checks that the `clone()` method from `Object` has not been overridden. Use a copy constructor, or better yet, a static factory method.
> See [Effective Java], 2nd Edition by Josh Bloch: Item 11: Override clone judiciously.
#### [NoFinalizer](http://checkstyle.sourceforge.net/config_coding.html#NoFinalizer)
Checks that the `finalize()` method from `Object` has not been overridden.
> See [Effective Java], 2nd Edition by Josh Bloch: Item 7: Avoid finalizers.
#### [NoLineWrap](http://checkstyle.sourceforge.net/config_whitespace.html#NoLineWrap)
Prevents wrapping of `package` and `import` statements.
#### [NonEmptyAtclauseDescription](http://checkstyle.sourceforge.net/config_javadoc.html#NonEmptyAtclauseDescription)
Checks that the Javadoc clauses `@param`, `@return`, `@throws` and `@deprecated` all have descriptions.
Valid:
````
/**
* Foo.
*
* @returns the foo
*/
````
Invalid:
````
/**
* Foo.
*
* @returns
*/
````
#### [NoWhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceAfter)
Checks that there is no whitespace after the array init ('{'), prefix increment ('++'), prefix decrement ('--'), bitwise complement ('~'), logical complement ('!'), array declaration ('[' in `int[] a;`) or array index operator ('[' in `a[2]`).
Valid:
````
int[] y = {1, 2};
++i;
--i;
int j = -1;
int k = +1;
int l = ~2;
boolean state = !isReady();
int b = o.getValue();
int[] a;
int d = a[2];
````
Invalid:
````
int[] y = { 1, 2 };
++ i;
-- i;
int j = - 1;
int k = + 1;
int l = ~ 2;
boolean state = ! isReady();
int b = o. getValue();
int[ ] a;
int d = a[ 2];
````
#### [NoWhitespaceBefore](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceBefore)
Checks that there is no whitespace before the comma operator (','), statement terminator (';'), postfix increment ('++') or postfix decrement ('--').
Valid:
````
int y = {1, 2};
doSomething();
i++;
i--;
````
Invalid:
````
int y = {1 , 2};
doSomething() ;
i ++;
i --;
````
#### [NPathComplexity](http://checkstyle.sourceforge.net/config_metrics.html#NPathComplexity)
Checks that the NPATH score (number of paths) through a method is no more than 5. This is similar to [Cyclomatic Complexity](#cyclomaticcomplexity).
#### [OneStatementPerLine](http://checkstyle.sourceforge.net/config_coding.html#OneStatementPerLine)
Checks that there is only one statement per line.
Valid:
````
doSomething();
doSomethingElse();
````
Invalid:
````
doSomething(); doSomethingElse();
````
#### [OneTopLevelClass](http://checkstyle.sourceforge.net/config_design.html#OneTopLevelClass)
> This check cannot be suppressed.
Checks that each source file contains only one top-level class, interface or enum.
#### [OperatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#OperatorWrap)
Checks that when wrapping a line on an operator that the operator appears on the new line.
Valid:
````
int answer = getTheAnswerToLife() + getTheAnswerToTheUniverse()
+ getTheAnswerToEverything();
````
Invalid:
````
int answer = getTheAnswerToLife() + getTheAnswerToTheUniverse() +
getTheAnswerToEverything();
````
#### [OuterTypeFilename](http://checkstyle.sourceforge.net/config_misc.html#OuterTypeFilename)
> This check cannot be suppressed.
Checks that the source filename matches the name of the top-level class. e.g. `class Foo {}` is in file `Foo.java`.
#### [OverloadMethodsDeclarationOrder](http://checkstyle.sourceforge.net/config_coding.html#OverloadMethodsDeclarationOrder)
Checks that overload methods are grouped together in the source file.
#### [PackageAnnotation](http://checkstyle.sourceforge.net/config_annotation.html#PackageAnnotation)
Checks that package level annotations are in the `package-info.java` file.
#### [PackageDeclaration](http://checkstyle.sourceforge.net/config_coding.html#PackageDeclaration)
> This check cannot be suppressed.
Checks that the class has a `package` definition.
#### [PackageName](http://checkstyle.sourceforge.net/config_naming.html#PackageName)
Checks the format of package names. Only lowercase letters, no initial numbers or any underscores.
Identifiers must match `^[a-z]+(\.[a-z][a-z0-9]+)*$`.
#### [ParameterName](http://checkstyle.sourceforge.net/config_naming.html#ParameterName)
Checks the format of method parameter names, including `catch` parameters.
Identifiers must match `^[a-z][a-zA-Z0-9]*$`.
#### [ParameterNumber](http://checkstyle.sourceforge.net/config_sizes.html#ParameterNumber)
Restricts the number of parameters in a method or constructor to 7. Overridden methods are not checked as there may be no access to change the super method.
#### [ParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#ParenPad)
Checks that there are no spaces padding parentheses.
Valid:
````
doSomething();
doSomethingElse(5);
````
Invalid:
````
doSomething( );
doSomethingElse( 5);
doSomethingElse(5 );
````
#### [RedundantModifier](http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier)
Checks for redundant modifiers. Checks for:
* Interface and annotation definitions.
* Final modifier on methods of final and anonymous classes.
* Inner interface declarations that are declared as static.
* Class constructors.
* Nested enum definitions that are declared as static.
#### [RegexpOnFilename](http://checkstyle.sourceforge.net/config_regexp.html#RegexpOnFilename)
Checks for the existence of forbidden java file names.
File names are forbidden if they match the pattern `(.sync-conflict-| conflicted copy )`.
N.B. only `*.java` files are checked.
This check is intended to detect Syncthing and Dropbox conflict files.
e.g.
````
DataClass (Bob's conflicted copy 2017-03-11).java
DataClass.sync-conflict-20170311-1648.java
````
#### [RequireThis](http://checkstyle.sourceforge.net/config_coding.html#RequireThis)
Checks that references to instance fields where a parameter name overlaps are qualified by `this.`.
#### [ReturnCount](http://checkstyle.sourceforge.net/config_coding.html#ReturnCount)
Restricts methods to have at most 2 `return` statements in non-void methods, and at most 1 in void methods.
Valid:
````
int getNumber(int a) {
if (a > 1) {
return a;
}
return 0;
}
void getName(int a) {
String name = "default";
if (a > 1) {
name = "Bob";
}
return name;
}
````
Invalid:
````
int getNumber(int a) {
if (a > 1) {
return a;
}
if (a < 2) {
return a * a;
}
return 0;
}
void getName(int a) {
if (a > 1) {
return "Bob";
}
return "default";
}
````
#### [RightCurly](http://checkstyle.sourceforge.net/config_blocks.html#RightCurly)
Checks that the right curly brace ('}') is placed on the same line as the next part of a multi-block statement (e.g. try-catch-finally, if-then-else).
Valid:
````
try {
//
} catch (Exception e) {
//
} finally {
//
}
if (a > 0) {
//
} else {
//
}
````
Invalid:
````
try {
//
}
catch (Exception e) {
//
}
finally {
//
}
if (a > 0) {
//
}
else {
//
}
if (a > 0) {
//
} a = 2;
public long getId() {return id;}
````
#### [SeparatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#SeparatorWrap)
Checks the line wrapping around separators.
* The comma separator (',') should be at the end of the line.
* The dot separator ('.') should be on the new line.
Valid:
````
doSomething(alpha, beta,
gamma);
doSomethingElse().stream()
.forEach(System.out::println);
````
Invalid:
````
doSomething(alpha, beta
, gamma);
doSomethingElse().stream().
forEach(System.out::println);
````
#### [SimplifyBooleanExpression](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanExpression)
Checks for overly complicated boolean expressions. Checks for code like `b == true`, `b || true`, `!false`, etc.
Valid:
````
if (b) {}
if (true) {}
````
Invalid:
````
if (b == true) {}
if (b || true) {}
if (!false) {}
````
#### [SimplifyBooleanReturn](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanReturn)
Checks for overly complicated boolean `return` statements.
Valid:
````
return !valid();
````
Invalid:
````
if (valid()) {
return false;
} else {
return true;
}
````
#### [SingleSpaceSeparator](http://checkstyle.sourceforge.net/config_whitespace.html#SingleSpaceSeparator)
Checks that non-whitespace characters on the same line are separated by no more than one whitespace.
Valid:
````
if (a < 0) {}
public long toNanos(long d) { return d; };
````
Invalid:
````
if (a < 0) {}
public long toNanos(long d) { return d; };
````
#### [StaticVariableName](http://checkstyle.sourceforge.net/config_naming.html#StaticVariableName)
Checks the format of `static`, non-`final` variable names.
Identifiers must match `^[a-z][a-zA-Z0-9]*$`.
#### [StringLiteralEquality](http://checkstyle.sourceforge.net/config_coding.html#StringLiteralEquality)
Checks that string literals are not used with `==` or `!=`.
Valid:
````
if ("something".equals(x)) {}
````
Invalid:
````
if (x == "something") {}
````
#### [SuppressWarnings](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarnings)
Prevents the use of `@SuppressWarnings` for the following checks:
* [ConstantName](#constantname)
* [CovariantEquals](#covariantequals)
* [EqualsHashCode](#equalshashcode)
* [NoClone](#noclone)
* [OneTopLevelClass](#onetoplevelclass)
* [OuterTypeFilename](#outertypefilename)
* [PackageDeclaration](#packagedeclaration)
* [TypeName](#typename)
* [VisibilityModifier](#visibilitymodifier)
#### [SuppressWarningsFilter](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsFilter)
Allows the use of the `@SuppressWarnings` annotation.
#### [SuppressWarningsHolder](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsHolder)
Used by Checkstyle to hold the checks to be suppressed from `@SuppressWarnings(...)` annotations.
#### [ThrowsCount](http://checkstyle.sourceforge.net/config_design.html#ThrowsCount)
Restricts non-private methods to only `throws` 4 distinct Exception types. Exceptions should be hierarchical to allow catching suitable root Exceptions.
See [Effective Java], 2nd Edition, Chapter 9: Exceptions
Valid:
````
void doSomething() throws IllegalStateException, DowsingServiceException,
BalancedBudgetException, ManagementInterferanceException {}
````
Invalid:
````
void doSomething() throws IllegalStateException,
DowsingNotPermittedException, DowsingServiceNotReadyException,
BalancedBudgetException, ManagementInterferanceException {}
````
#### [TodoComment](http://checkstyle.sourceforge.net/config_misc.html#TodoComment)
Checks for remaining `TODO` and `FIXME` comments left in code. Their presence indicates that the program isn't finished yet.
#### [TrailingComment](http://checkstyle.sourceforge.net/config_misc.html#TrailingComment)
Checks for comments at the end of lines.
Valid:
````
// comment on line by itself
// comment after white space
if (a < 1) {
//
} // comment on closing brace
int[] a = new int[2](
1, 2
); // comment on closing parenthesis of statement
````
Invalid:
````
int a = 1; // comment in line with statement
if (a < 1) { // comment on line with if statement
//
}
int[] a = new int[2](
1, // first value - invalid comment
2 // second value - also invalid comment
);
````
#### [Translation](http://checkstyle.sourceforge.net/config_misc.html#Translation)
Checks that all `messages*.properties` files all have the same set of keys.
#### [TypecastParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#TypecastParenPad)
Checks that there are no spaces within the typecasting parentheses.
Valid:
````
String s = (String) list.get(2);
````
Invalid:
````
String s = (String ) list.get(2);
String s = ( String) list.get(2);
String s = ( String ) list.get(2);
````
#### [TypeName](http://checkstyle.sourceforge.net/config_naming.html#TypeName)
> This check cannot be suppressed.
Checks the format of `class`, `interface`, `enum` identifiers, including annotations.
Identifiers must match `^[A-Z][a-zA-Z0-9]*$`.
#### [UncommentedMain](http://checkstyle.sourceforge.net/config_misc.html#UncommentedMain)
Checks for `public static void main()` methods that may have been left over from testing. Allowed in classes whose names end in `Main` or `Application`.
#### [UniqueProperties](http://checkstyle.sourceforge.net/config_misc.html#UniqueProperties)
Checks `*.properties` files for duplicate property keys.
#### [UnnecessaryParentheses](http://checkstyle.sourceforge.net/config_coding.html#UnnecessaryParentheses)
Checks for the use of unnecessary parentheses.
Valid:
````
if (a < 1) {}
````
Invalid:
````
if ((a < 1)) {}
````
#### [UnusedImports](http://checkstyle.sourceforge.net/config_imports.html#UnusedImports)
Checks for unused imports. Does not inspect wildcard imports, which should be blocked by [AvoidStarImport](#avoidstarimport) anyway.
Imports are unused if:
* They are not referenced in the file.
* It duplicates another import.
* It import from the `java.lang` package.
* It imports a class from the same package.
* It is only references from the Javadoc.
#### [UpperEll](http://checkstyle.sourceforge.net/config_misc.html#UpperEll)
Checks that `long` numeric literal values are marked by an upper-case ell ('L'). The lower-case ell ('l') can be mistaken for the numeral one ('1').
Valid:
````
long id = 12345L;
````
Invalid:
````
long id = 12345l;
````
#### [VariableDeclarationUsageDistance](http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance)
Checks that a variable declaration and its first usage are not more than 3 lines. Blocks of initialisation methods don't count toward this total.
See the official [Checkstyle documentation](http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance) for examples.
#### [VisibilityModifier](http://checkstyle.sourceforge.net/config_design.html#VisibilityModifier)
> This check cannot be suppressed.
Checks the visibility of class members to help enforce encapsulation. Only `static final` fields, immutable (see list below) fields or field with special annotation (see list below), may be public.
The following are considered immutable when `final`, and can be `public`:
* java.lang.String
* java.lang.Integer
* java.lang.Byte
* java.lang.Character
* java.lang.Short
* java.lang.Boolean
* java.lang.Long
* java.lang.Double
* java.lang.Float
* java.lang.StackTraceElement
* java.math.BigInteger
* java.math.BigDecimal
* java.io.File
* java.util.Locale
* java.util.UUID
* java.net.URL
* java.net.URI
* java.net.Inet4Address
* java.net.Inet6Address
* java.net.InetSocketAddress
Fields with the following annotations may be `public`:
* org.junit.Rule
* org.junit.ClassRule
* com.google.common.annotations.VisibleForTesting
Valid:
````
class Foo {
public final Long id;
public final String name;
private String description;
@VisibleForTesting
public State state;
Foo(final Long id, final String name) {
this.id = id;
this.name = name;
}
}
````
Invalid:
````
class Foo {
public Long id;
public String name;
private String description;
public State state;
Foo(final Long id, final String name) {
this.id = id;
this.name = name;
}
}
````
#### [WhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAfter)
Checks that commas (','), statement terminators (';') and typecasts are all followed by a space.
Valid:
````
doSomething(1, 2, 3);
if (a > 1) { return true; }
String name = (String) list.get(9);
````
Inalid:
````
doSomething(1,2,3);
if (a > 1) { return true;}
String name = (String)list.get(9);
````
#### [WhitespaceAround](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAround)
Checks that tokens are surrounded by whitespace.
### Sevntu
#### [AvoidConstantAsFirstOperandInCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidConstantAsFirstOperandInConditionCheck.html)
Checks that condition expressions don't become less readable by attempting to use a constant on the left-hand-side of a comparison.
Valid:
````
if (a == 12) {}
````
Invalid:
````
if (12 == a) {}
````
#### [AvoidHidingCauseException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidHidingCauseExceptionCheck.html)
Ensures that an exception is re-thrown properly and is not swallowed by a `catch` block.
Valid:
````
try {
doSomething();
} catch (MyException e) {
throw new MyOtherException(e);
}
````
Invalid:
````
try {
doSomething();
} catch (MyException e) {
throw new MyOtherException();
}
````
#### [AvoidNotShortCircuitOperatorsForBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidNotShortCircuitOperatorsForBooleanCheck.html)
Prevents the use of boolean operators that don't allow short-circuiting the expression. (e.g. '|', '&', '|=' and '&=')
Valid:
````
if ((a < b) || (b > getExpensiveValue())) {}
````
Invalid:
````
if ((a < b) | (b > getExpensiveValue())) {}
````
#### [ConfusingCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ConfusingConditionCheck.html)
Checks that the expression with the `if` condition in an `if-then-else` statement is not negated.
Valid:
````
if (isValid()) {
handleValidCondition();
} else {
handleInvalidCondition();
}
````
Invalid:
````
if (!isValid()) {
handleInvalidCondition();
} else {
handleValidCondition();
}
````
#### [ConstructorWithoutParams](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ConstructorWithoutParamsCheck.html)
Exception class constructors must accept parameters for message and/or cause. This check is applied to classes whose name ends with `Exception`.
#### [DiamondOperatorForVariableDefinition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/DiamondOperatorForVariableDefinitionCheck.html)
Checks that the diamond operator is used where possible.
Valid:
````
Map idTable = new HashMap<>();
````
Invalid:
````
Map idTable = new HashMap();
````
#### [EitherLogOrThrow](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EitherLogOrThrowCheck.html)
Checks that when an exception is caught, that if it is logged then it is not also re-thrown. Log or throw; one or the other or neither, but not both.
Accepts `java.util.logging.Logger` and `org.slf4j.Logger`.
#### [EnumValueName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/EnumValueNameCheck.html)
Checks that Enum Values match the pattern: `^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$`
Valid:
````
enum Valid {
ALPHA, BETA, GAMMA_RAY;
}
````
Invalid:
````
enum InvalidConstants {
alpha, Beta;
}
````
#### [ForbidCCommentsInMethods](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCCommentsInMethodsCheck.html)
Prevents the use of `/* C-style */` comments inside methods.
Valid:
````
void doSomething() {
// a comment
}
````
Invalid:
````
void doSomething() {
/* invalid */
}
````
#### [ForbidReturnInFinallyBlock](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidReturnInFinallyBlockCheck.html)
Prevent the use of a `return` statement in the `finally` block.
Invalid:
````
try {
doSomething();
{ catch (IOException e) {
// log error
} finally (
return true; // invalid
}
````
#### [ForbidWildcardAsReturnType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ForbidWildcardAsReturnTypeCheck.html)
Prevents declaring a method from returning a wildcard type as its return value.
Valid:
````
List getList() {}
````
Invalid:
````
List extends E> getList() {}
````
#### [LogicConditionNeedOptimization](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/LogicConditionNeedOptimizationCheck.html)
Prevent the placement of variables or fields after methods in an expression.
Valid:
````
if (property && getProperty()) {}
````
Invalid:
````
if (getProperty() && property) {}
````
#### [MapIterationInForEachLoop](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MapIterationInForEachLoopCheck.html)
Checks for unoptimised iterations over `Map`s. Check use of `map.values()`, `map.keySet()` and `map.entrySet()` against the use of the iterator produced to verify if another could be better.
#### [NameConventionForJunit4TestClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NameConventionForJunit4TestClassesCheck.html)
Checks the names of JUnit test classes. Classes checked are those that have at least one method annotated with `Test` or `org.junit.Test`.
Test class names must match: `.+Test\\d*|.+Tests\\d*|Test.+|Tests.+|.+IT|.+ITs|.+TestCase\\d*|.+TestCases\\d*`
#### [NestedSwitch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NestedSwitchCheck.html)
Checks that `switch` statements are not nested within one another.
Valid:
````
void doSomething(int a, int b) {
switch(a) {
case 1:
doMore(b);
break;
case 2:
// ..
}
}
}
void doMore(int b) {
switch(b) {
case 1:
//
case 2:
//
}
}
````
Invalid:
````
void doSomething(int a, int b) {
switch(a) {
case 1:
switch(b) {
case 1:
//
case 2:
//
}
break;
case 2:
// ..
}
}
}
````
#### [NoMainMethodInAbstractClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NoMainMethodInAbstractClassCheck.html)
Prevents a `main` method from existing in an `abstract` class.
#### [NumericLiteralNeedsUnderscore](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NumericLiteralNeedsUnderscoreCheck.html)
Checks that numeric literals use underscores ('_') if over a certain length.
* Decimals
* 7 or more digits must use the underscore
* No more than 3 digits between underscores
* Hex
* 5 or more digits must use the underscore
* No more than 4 digits between underscores
* Binary
* 9 or more digits must use the underscore
* No more than 8 digits between underscores
#### [OverridableMethodInConstructor](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/OverridableMethodInConstructorCheck.html)
Prevents calls to overridable methods from constuctors including other methods that perform the same functions. (i.e. `Cloneable.clone()` and `Serializable.readObject()`)
Invalid:
````
abstract class Base {
Base() {
overrideMe();
}
}
class Child extends Base {
final int x;
Child(int x) {
this.x = x;
}
void overrideMe() {
System.out.println(x);
}
}
new Child(42); // prints "0"
````
#### [PublicReferenceToPrivateType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/PublicReferenceToPrivateTypeCheck.html)
Checks that a type is not exposed outside its declared scope.
Invalid:
````
public class OuterClass {
public InnerClass inner = new InnerClass();
public SiblingClass sibling = new SiblingClass();
public InnerClass getValue() { return new InnerClass(); }
public SiblingClass getSibling() { return new SiblingClass(); }
private class InnerClass {}
}
class SiblingClass {}
````
#### [RedundantReturn](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/RedundantReturnCheck.html)
Checks for redundant return statements.
Invalid:
````
HelloWorld() {
doStuff();
return;
}
void doStuff() {
doMoreStuff();
return;
}
````
#### [ReturnBooleanFromTernary](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnBooleanFromTernaryCheck.html)
Ternary statements shouldn't have `Boolean` values as results.
Valid:
````
Boolean set = isSet() ? True : False;
Boolean notReady = isReady() ? False : True;
````
Invalid:
````
Boolean set = isSet();
Boolean notReady = !isReady();
````
#### [ReturnNullInsteadOfBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnNullInsteadOfBooleanCheck.html)
The `Boolean` type is meant to only represent a binary state: TRUE or FALSE. It is not a ternary value: TRUE, FALSE, null.
Invalid:
````
Boolean isEnabled() {
if (level > 0) {
return True;
}
if (level < 0) {
return False;
}
return null;
}
````
#### [SimpleAccessorNameNotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SimpleAccessorNameNotationCheck.html)
Checks that setters and getters follow the normal setField(), getField() and isField() pattern, where 'Field' is the name of the field being accessed.
#### [SingleBreakOrContinue](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SingleBreakOrContinueCheck.html)
Checks that there is at most one `continue` or `break` statement within a looping block (e.g. `for`, `while`, ...)
#### [TernaryPerExpressionCount](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/TernaryPerExpressionCountCheck.html)
Checks that there is at most one ternary statments (`?:`) within an expression.
Invalid:
````
String x = value != null ? "A" : "B" + value == null ? "C" : "D"
````
#### [UniformEnumConstantName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/UniformEnumConstantNameCheck.html)
Checks that all the values of an `enum` follow the same naming pattern.
Valid:
````
public enum EnumOne {
FirstElement, SecondElement, ThirdElement;
}
public enum EnumTwo {
FIRST_ELEMENT, SECOND_ELEMENT, THIRD_ELEMENT;
}
````
Invalid:
````
public enum EnumThree {
FirstElement, SECOND_ELEMENT, ThirdElement;
}
````
#### [UselessSingleCatch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSingleCatchCheck.html)
Checks for catch blocks that are useless. i.e. that catch al exceptions and then just rethrow them.
Invalid:
````
try {
doSomething();
} catch (Exception e) {
throw e;
}
````
#### [UselessSuperCtorCall](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSuperCtorCallCheck.html)
Checks for useless calls the the `super()` method in constructors.
Invalid:
````
class Dummy {
Dummy() {
super();
}
}
class Derived extends Base {
Derived() {
super();
}
}
````
## Disabled Checks
These checks are not enabled. Notes are included for each explaining why.
### Checkstyle
#### [ArrayTrailingComma](http://checkstyle.sourceforge.net/config_coding.html#ArrayTrailingComma)
Couldn't get my IDE's (IntelliJ) code style to match.
#### [FinalLocalVariable](http://checkstyle.sourceforge.net/config_coding.html#FinalLocalVariable)
Doesn't recognise Lombok's `val` as being `final`.
#### [IllegalInstantiation](http://checkstyle.sourceforge.net/config_coding.html#IllegalInstantiation)
Not really suitable for a template ruleset as it requires an explicit list of classes to apply to.
#### [IllegalTokenText](http://checkstyle.sourceforge.net/config_coding.html#IllegalTokenText)
Generic rule; doesn't embody a 'quality' check.
#### [ImportControl](http://checkstyle.sourceforge.net/config_imports.html#ImportControl)
Generic rule; doesn't embody a 'quality' check.
#### [ImportOrder](http://checkstyle.sourceforge.net/config_imports.html#ImportOrder)
Generic rule; doesn't embody a 'quality' check.
#### [Indentation](http://checkstyle.sourceforge.net/config_misc.html#Indentation)
Couldn't get my IDE's (IntelliJ) code style to match.
#### [JavadocTagContinuationIndentation](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocTagContinuationIndentation)
Couldn't get my IDE's (IntelliJ) code style to match.
#### [JavadocVariable](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocVariable)
Member variables should usually be named such that it is clear what they are. Comments for clarification should be the exception.
#### [MissingCtor](http://checkstyle.sourceforge.net/config_coding.html#MissingCtor)
Would not see constructors created using Lombok's `@NoArgsConstructor`.
#### [MissingOverride](http://checkstyle.sourceforge.net/config_annotation.html#MissingOverride)
The javadoc compiler automatically inherits the javadoc from the overridden method, it doesn't need to be told to do so.
#### [OuterTypeNumber](http://checkstyle.sourceforge.net/config_sizes.html#OuterTypeNumber)
Already covered by the [OneTopLevelClass](#onetoplevelclass) check.
#### [ParameterAssignment](http://checkstyle.sourceforge.net/config_coding.html#ParameterAssignment)
[FinalParameters](#finalparameters) already protects against assigning values to parameters.
#### [RedundantImport](http://checkstyle.sourceforge.net/config_imports.html#RedundantImport)
[UnusedImports](#unusedimports) performs all the same checks and more.
#### [Regexp](http://checkstyle.sourceforge.net/config_regexp.html#Regexp)
Generic rule; doesn't embody a 'quality' check.
#### [RegexpHeader](http://checkstyle.sourceforge.net/config_header.html#RegexpHeader)
Generic rule; doesn't embody a 'quality' check.
#### [RegexpMultiline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpMultiline)
Generic rule; doesn't embody a 'quality' check.
#### [RegexpOnFilename](http://checkstyle.sourceforge.net/config_regexp.html#RegexpOnFilename)
Generic rule; doesn't embody a 'quality' check.
#### [RegexpSingleline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpSingleline)
Generic rule; doesn't embody a 'quality' check.
#### [RegexpSinglelineJava](http://checkstyle.sourceforge.net/config_regexp.html#RegexpSinglelineJava)
Generic rule; doesn't embody a 'quality' check.
#### [SingleLineJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SingleLineJavadoc)
I don't use single line javadoc blocks.
#### [SummaryJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SummaryJavadoc)
Generic rule; doesn't embody a 'quality' check.
#### [SuperClone](http://checkstyle.sourceforge.net/config_coding.html#SuperClone)
Overridding the `clone()` method is not allowed by the [NoClone](#noclone) check.
#### [SuperFinalize](http://checkstyle.sourceforge.net/config_coding.html#SuperFinalize)
[NoFinalizer](#nofinalizer) prevents use of `finalize()`.
#### [WriteTag](http://checkstyle.sourceforge.net/config_javadoc.html#WriteTag)
Generic rule; doesn't embody a 'quality' check.
### Sevntu
As the sevntu check are considered experimental not all those that are not enabled are listed here. Only where they are disabled due to a conflict with my 'style' or there is another irreconcilable difference that prevents them from being enabled, will they be documented to prevent repeated investigations.
#### [AvoidConditionInversion](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/AvoidConditionInversionCheck.html)
Should already be covered by [SimplifyBooleanExpression](simplifybooleanexpression).
#### [AvoidDefaultSerializableInInnerClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidDefaultSerializableInInnerClassesCheck.html)
TODO: enable
#### [AvoidModifiersForTypes](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidModifiersForTypesCheck.html)
Generic rule; doesn't embody a 'quality' check.
#### [CauseParameterInException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/CauseParameterInExceptionCheck.html)
Should already be covered by [AvoidHidingCauseException](#avoidhidingcauseexception).
#### [ChildBlockLength](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ChildBlockLengthCheck.html)
Appears to be broken as of `1.21.0`.
#### [CustomDeclarationOrder](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/CustomDeclarationOrderCheck.html)
The [DeclarationOrder](#declarationorder) check already imposes an order for class elements.
#### [EmptyPublicCtorInClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EmptyPublicCtorInClassCheck.html)
TODO: enable
#### [FinalizeImplementation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/FinalizeImplementationCheck.html)
TODO: enable
#### [ForbidAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/ForbidAnnotationCheck.html)
Generic rule; doesn't embody a 'quality' check.
#### [ForbidCertainImports](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCertainImportsCheck.html)
Generic rule; doesn't embody a 'quality' check.
#### [ForbidInstantiation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidInstantiationCheck.html)
Generic rule; doesn't embody a 'quality' check.
#### [ForbidThrowAnonymousExceptions](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidThrowAnonymousExceptionsCheck.html)
[IllegalThrows](#illegalthrows) performs a similar check.
#### [RequiredParameterForAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/RequiredParameterForAnnotationCheck.html)
Generic rule; doesn't embody a 'quality' check.
#### [StaticMethodCandidate](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/StaticMethodCandidateCheck.html)
Can't handle private methods called by reflection, which may cause issues with Spring and other DI frameworks.
#### [WhitespaceBeforeArrayInitializer](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/WhitespaceBeforeArrayInitializerCheck.html)
TODO: enable
[Effective Java]: http://amzn.to/2aSz6GE