Cs-contrib.unkrig.de: Difference between revisions
m (→Introduction) |
|||
Line 75: | Line 75: | ||
== Check 'de.unkrig.ParenPad' == | == Check 'de.unkrig.ParenPad' == | ||
Enhanced version of "ParenPad": NOSPACE now allows '( // ...'. | Enhanced version of "ParenPad": NOSPACE now allows '( // ...'. | ||
<span style="color: red">'''This check is superseded by 'de.unkrig.Whitespace'.'''</span> | |||
'''Properties:''' | '''Properties:''' |
Revision as of 13:37, 16 July 2013
Introduction
This project adds custom checks, filters and for CheckStyle and Eclipse-CS.
Install the ECLIPSE plug-in from this update site:
http://cs-contrib.unkrig.de/update
If you're only interested in the checks (and not the ECLIPSE plug-in), you can download the most recent 'de.unkrig.cs-contrib.core_*.jar' file from here and put it onto CheckStyle's classpath.
The change log is also available.
Checks
Check 'de.unkrig.Alignment'
Checks that Java elements are vertically aligned in immediately consecutive lines (and only there!).
public class Main { int x = 7; double xxx = 7.0; // Aligned field names int y = 7; double yyy = 7.0; // Aligned field initializers public static void meth1( String[] p1, int p2 // Aligned parameter names ) { int x = 7;\n\ double xxx = 7.0; // Aligned local variable names int y = 7;\n\ double yyy = 7.0; // Aligned local variable initializers y = 8; yyy = 8.0; // Aligned assignments switch (x) { case 1: break; default: x++; return; // Aligned case groups statements } } public static void meth2() {} public void meth33() {} // Aligned method names and bodies }
Properties:
- applyToFieldName
- Check alignment of field names in declarations.
- applyToFieldInitializer
- Check alignment of '=' in field declarations.
- applyToLocalVariableName
- Check alignment of local variable names in declarations.
- applyToLocalVariableInitializer
- Check alignment of '=' in local variable declarations.
- applyToParameterName
- Check alignment of constructor and method parameter names.
- applyToMethodName
- Check alignment of method (and constructor) names in declarations.
- applyToMethodBody
- Check alignment of '{' in method (and constructor) declarations.
- applyToCaseGroupStatements
- Check alignment of first statement in case groups.
- applyToAssignments
- Check alignment of '=' in assignments.
Check 'de.unkrig.InnerAssignment'
Assignments in expressions must be parenthesized.
Quickfixes:
- Parenthesize assignment
- Parenthesize assignment to indicate that it is intentional
Check 'de.unkrig.NameSpelling'
Checks that the names of Java elements match a given pattern.
Properties:
- elements
- Elements to apply this check to
- requiredModifiers
- Apply only to declarations which have these modifiers
- missingModifiers
- Apply only to declarations which do not have these modifiers
- option
- Whether to REQUIRE or FORBID that names match
- format
- Pattern to match the name against
Check 'de.unkrig.ParenPad'
Enhanced version of "ParenPad": NOSPACE now allows '( // ...'.
This check is superseded by 'de.unkrig.Whitespace'.
Properties:
- option
- Whether space is required or forbidding
- tokens
- Tokens to check
Check 'de.unkrig.WhitespaceAround'
Checks that a token is surrounded by whitespace. Empty constructor bodies, method bodies, catch blocks and type bodies of the form
public MyClass() {} // empty constructor body public void func() {} // empty method body public void func() { new Object() { // ... }.hashCode(); // No space between '}' and '.' -- always allowed try { // ... } catch {} // empty catch block } interface MyInterface {} // emtpy type body
may optionally be exempted from the policy using the allowEmptyMethods
, allowEmptyConstructors
, allowEmptyCatches
and allowEmptyTypes
properties.
Properties:
- allowEmptyConstructors
- allow empty constructor bodies
- allowEmptyMethods
- allow empty method bodies
- allowEmptyCatches
- allow empty catch blocks
- allowEmptyTypes
- allow empty class and interface bodies
- tokens
- Tokens to check
Check 'de.unkrig.WrapAndIndent'
Statements must be uniformly wrapped and indented.
Properties:
- basicOffset
- How many spaces to use for new indentation level
Quickfixes:
- Wrap line
- Wrap this line at the correct position
- Join lines
- Append this line to the previous
- Correct indentation
- Correct the indentation of this line
Check 'de.unkrig.ZeroParameterSuperconstructorInvocation'
Checks that no constructor calls the zero-parameter superconstructor.
Quickfixes:
- Remove
- Remove redundant invocation of zero-parameter superconstructor
Filters
Filter 'de.unkrig.SuppressionLine'
Events (i.e. CheckStyle warnings) are switched off by a 'magic line' ('offCommentFormat') or back on by another 'magic line' ('onCommentFormat').
After the 'off' magic line, events do not show if at least one of the following conditions is true:
- The 'checkNameFormat' (if set) is found in the check name (e.g. 'de.unkrig.cscontrib.checks.Alignment')
- The 'messageFormat' (if set) is found in the event message
- The 'moduleIdFormat' (if set) is found in the ID of the module that generated the event
This filter can only work if a 'FileContentsHolder' module exists in the configuration.
Properties:
- offFormat
- Line pattern to trigger filter to begin suppression
- onFormat
- Line pattern to trigger filter to end suppression
- checkNameFormat
- Check name pattern to suppress
- messageFormat
- Message pattern to suppress
- moduleIdFormat
- Module ID pattern to suppress