Code Conventions

From WebLab Wiki
Jump to navigationJump to search

The WebLab code conventions are based on Sun and Eclipse checks.

You can find the current version of the used checkstyle here: weblab_checks.xml.

The checks applied are:

AnonInnerLength Checks for long anonymous inner classes.
ArrayTypeStyle Checks the style of array type definitions.
AvoidInlineConditionals Detects inline conditionals.
AvoidNestedBlocks Finds nested blocks.
AvoidStarImport Check that finds import statements that use the * notation.
AvoidStaticImport Check that finds static imports.
ConstantName Checks that constant names conform to a format specified by the format property.
DefaultComesLast Check that the default is after all the cases in a switch statement.
DoubleCheckedLocking Detect the double-checked locking idiom, a technique that tries to avoid synchronization overhead but is incorrect because of subtle artifacts of the java memory model.
EqualsHashCode Checks that classes that override equals() also override hashCode().
EmptyBlock Checks for empty blocks.
EmptyForIteratorPad Checks the padding of an empty for iterator; that is whether a space is required at an empty for iterator, or such spaces are forbidden.
EmptyStatement Detects empty statements (standalone ';').
FinalClass Checks that class which has only private ctors is declared as final.
FinalParameters Check that method/constructor/catch/foreach parameters are final.
FileLength Checks for long source files.
FileTabCharacter Checks to see if a file contains a tab character.
Header Checks the header of the source against a fixed header file.
HiddenField Checks that a local variable or a parameter does not shadow a field that is defined in the same class.
HideUtilityClassConstructor Make sure that utility classes (classes that contain only static methods) do not have a public constructor.
InterfaceIsType Implements Bloch, Effective Java, Item 17 - Use Interfaces only to define types.
IllegalImport Checks for imports from a set of illegal packages.
IllegalInstantiation Checks for illegal instantiations where a factory method is preferred.
IllegalThrows Throwing java.lang.Error or java.lang.RuntimeException is almost never acceptable.
InnerAssignment Checks for assignments in subexpressions, such as in String s = Integer.toString(i = 2);.
LeftCurly Checks the placement of left curly braces on types, methods and other blocks:
LineLength Checks for long lines.
LocalFinalVariableName Checks that local final variable names conform to a format specified by the format property.
LocalVariableName Checks that local, non-final variable names conform to a format specified by the format property.
MagicNumber Checks for magic numbers.
MemberName Checks that instance variable names conform to a format specified by the format property.
MethodName Checks that method names conform to a format specified by the format property.
MethodLength Checks for long methods.
MethodParamPad Checks the padding between the identifier of a method definition, constructor definition, method call, or constructor invocation; and the left parenthesis of the parameter list.
MissingDeprecated This class is used to verify that both the java.lang.Deprecated annotation is present and the @deprecated Javadoc tag is present when either is present.
MissingSwitchDefault Checks that switch statement has "default" clause.
MissingOverride This class is used to verify that the java.lang.Override annotation is present when the {@inheritDoc} javadoc tag is present.
ModifiedControlVariable Check for ensuring that for loop control variables are not modified inside the for block.
MultipleStringLiterals Checks for multiple occurrences of the same string literal within a single file.
NeedBraces Checks for braces around code blocks.
NoWhitespaceAfter Checks that there is no whitespace after a token.
NoWhitespaceBefore Checks that there is no whitespace before a token.
OperatorWrap Checks line wrapping for operators.
PackageName Checks that package names conform to a format specified by the format property.
ParameterNumber Checks the number of parameters that a method or constructor has.
ParameterName Checks that parameter names conform to a format specified by the format property.
ParenPad Checks the padding of parentheses; that is whether a space is required after a left parenthesis and before a right parenthesis, or such spaces are forbidden, with the exception that it does not check for padding of the right parenthesis at an empty for iterator.
RedundantImport Checks for imports that are redundant.
RedundantThrows Checks for redundant exceptions declared in throws clause such as duplicates, unchecked exceptions or subclasses of another declared exception.
RightCurly Checks the placement of right curly braces.
SimplifyBooleanExpression Checks for overly complicated boolean expressions.
SimplifyBooleanReturn Checks for overly complicated boolean return statements.
StaticVariableName Checks that static, non-final variable names conform to a format specified by the format property.
StringLiteralEquality Checks that string literals are not used with == or !=.
TypecastParenPad Checks the padding of parentheses for typecasts.
TypeName Checks that type names conform to a format specified by the format property.
Translation The TranslationCheck class helps to ensure the correct translation of code by checking property files for consistency regarding their keys.
UnusedImports Checks for unused import statements.
UpperEll Checks that long constants are defined with an upper ell.
VisibilityModifier Checks visibility of class members.
WhitespaceAfter Checks that a token is followed by whitespace, with the exception that it does not check for whitespace after the semicolon of an empty for iterator.
WhitespaceAround Checks that a token is surrounded by whitespace.