Is your feature request related to a problem? Please describe.
Specify violations in the input file is real source of pain for newcomers. Just checkout our discord and you will find most of queries beginners have are about errors they are facing in making their tests pass.
There are various ways to specify violations in input file:
- // violation 'message' (for if violation is present on the same line.)
- // violation above/below 'message'
- // violation n lines above/below 'message'
- Format of the message could also be modified: either full error message or shorted error message using '*'.
here are some examples:
switch (num) { // violation '.* incorrect indentation level 6, expected .* 8.'
// violation above 'Method name 'XmlHttpRequest' must match pattern'
// violation 3 lines above 'Javadoc tag '@param' should be preceded with an empty line.'
// violation 3 lines below ''else' construct must use '{}'s.'
// violation below 'Type name 'inputHeaderEnum' must match pattern'
// violation below 'Type name 'InputHeader___Interface' .* .*'
take a look at various regexp patterns for violations :
|
final Matcher violationMatcher = |
Describe the solution you'd like
A clear description of how to specify violations for testing should be present on checkstyle's website. In additional we could also add a section about how to make tests on input files, some common mistakes beginners might make. Like In the below example, everything is alright except for one extra space after One 27:1 :
which causes test to fail. it should be like this: 27:1:.
"27:1 : " + getCheckMessage(MSG_CHILD_ERROR, "synchronized", 0, 12),
"30:13: " + getCheckMessage(MSG_ERROR, "synchronized lparen", 12, 8),
missing (1) : 27:1 : 'synchronized' child has incorrect indentation level 0, expected level should be 12.
unexpected (1): 27:1: 'synchronized' child has incorrect indentation level 0, expected level should be 12.
this will save everyone's time.
Is your feature request related to a problem? Please describe.
Specify violations in the input file is real source of pain for newcomers. Just checkout our discord and you will find most of queries beginners have are about errors they are facing in making their tests pass.
There are various ways to specify violations in input file:
here are some examples:
take a look at various regexp patterns for violations :
checkstyle/src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java
Line 928 in c92091b
Describe the solution you'd like
A clear description of how to specify violations for testing should be present on checkstyle's website. In additional we could also add a section about how to make tests on input files, some common mistakes beginners might make. Like In the below example, everything is alright except for one extra space after One
27:1 :which causes test to fail. it should be like this:
27:1:.this will save everyone's time.