File tree Expand file tree Collapse file tree 3 files changed +29
-6
lines changed
java/org/checkstyle/autofix/recipe
resources/org/checkstyle/autofix/recipe/upperell/hexoctalliteral Expand file tree Collapse file tree 3 files changed +29
-6
lines changed Original file line number Diff line number Diff line change 6565 </dependency >
6666
6767 <!-- Test dependencies -->
68+ <dependency >
69+ <groupId >com.google.truth</groupId >
70+ <artifactId >truth</artifactId >
71+ <version >1.4.4</version >
72+ <scope >test</scope >
73+ </dependency >
6874 <dependency >
6975 <groupId >com.puppycrawl.tools</groupId >
7076 <artifactId >checkstyle</artifactId >
Original file line number Diff line number Diff line change @@ -64,6 +64,9 @@ protected void verify(String testCaseName) throws Exception {
6464 final Configuration config = getCheckConfigurations (inputPath );
6565 final List <CheckstyleViolation > violations = runCheckstyle (inputPath , config );
6666
67+ String [] expectedMessages = convertToExpectedMessages (violations );
68+ verifyWithInlineConfigParser (getPath (inputPath ), expectedMessages );
69+
6770 final String beforeCode = readFile (getPath (inputPath ));
6871 final String expectedAfterCode = readFile (getPath (outputPath ));
6972
@@ -117,6 +120,18 @@ private void verifyOutputFile(String outputPath) throws Exception {
117120 }
118121 }
119122
123+ private String [] convertToExpectedMessages (List <CheckstyleViolation > violations ) {
124+ return violations .stream ()
125+ .map (v -> {
126+ if (v .getColumn () > 0 ) {
127+ return v .getLine () + ":" + v .getColumn () + ": " + v .getMessage ();
128+ } else {
129+ return v .getLine () + ": " + v .getMessage ();
130+ }
131+ })
132+ .toArray (String []::new );
133+ }
134+
120135 private Configuration getCheckConfigurations (String inputPath ) throws Exception {
121136 final String configFilePath = getPath (inputPath );
122137 final TestInputConfiguration testInputConfiguration =
Original file line number Diff line number Diff line change 1414package org .checkstyle .autofix .recipe .upperell .hexoctalliteral ;
1515
1616public class InputHexOctalLiteral {
17- private long hexLower = 0x1ABCl ;
18- private long hexUpper = 0X2DEFl ;
19- private long octal = 0777l ;
20- private long binary = 0b1010l;
21- private long decimal = 12345l ;
17+ private long hexLower = 0x1ABCl ; //violation
18+ private long hexUpper = 0X2DEFl ; //violation
19+ private long octal = 0777l ; //violation
20+ private long binary = 0b1010l; //violation
21+ private long decimal = 12345l ; //violation
2222
2323 public void calculateValues () {
24+ //violation below
2425 long hexResult = 0xDEADBEEFl + 0xDEADBEFl ; //suppressed violation for 0xDEADBEFl
26+ //violation below
2527 long octalResult = 01234l + 0xDEADBEEFl ; //suppressed violation for 01234l
26- long binaryResult = 0b11110000l;
28+ long binaryResult = 0b11110000l; //violation
2729 }
2830}
You can’t perform that action at this time.
0 commit comments