Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public abstract class AbstractRecipeTestSupport extends AbstractXmlTestSupport

protected abstract String getSubpackage();

protected abstract String getCheckName();

protected abstract Recipe createRecipe(List<CheckstyleViolation> violations);

@Override
Expand Down
33 changes: 15 additions & 18 deletions src/test/java/org/checkstyle/autofix/recipe/UpperEllTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,43 @@

package org.checkstyle.autofix.recipe;

import java.io.IOException;
import java.nio.file.Path;
import java.util.List;

import org.checkstyle.autofix.parser.CheckstyleReportParser;
import org.checkstyle.autofix.parser.CheckstyleViolation;
import org.junit.jupiter.api.Test;
import org.openrewrite.Recipe;

import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
public class UpperEllTest extends AbstractRecipeTestSupport {

public class UpperEllTest extends AbstractRecipeTest {
@Override
protected String getSubpackage() {
return "upperell";
}

@Override
protected Recipe getRecipe() {
final String reportPath = "src/test/resources/org/checkstyle/autofix/recipe/upperell"
+ "/report.xml";
protected Recipe createRecipe(List<CheckstyleViolation> violations) {

final List<CheckstyleViolation> violations =
CheckstyleReportParser.parse(Path.of(reportPath));
return new UpperEll(violations);
}

@Test
void hexOctalLiteralTest() throws IOException, CheckstyleException {
testRecipe("upperell", "HexOctalLiteral");
void hexOctalLiteral() throws Exception {
verify("HexOctalLiteral");
}

@Test
void complexLongLiterals() throws IOException, CheckstyleException {
testRecipe("upperell", "ComplexLongLiterals");
void complexLongLiterals() throws Exception {
verify("ComplexLongLiterals");
}

@Test
void stringAndCommentTest() throws IOException, CheckstyleException {
testRecipe("upperell", "StringAndComments");
void stringAndComments() throws Exception {
verify("StringAndComments");
}

@Test
void symbolicLiteralTest() throws IOException, CheckstyleException {
testRecipe("upperell", "SymbolicLiterals");
void symbolicLiteral() throws Exception {
verify("SymbolicLiterals");
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
/*xml
<module name="Checker">
<module name="com.puppycrawl.tools.checkstyle.filters.SuppressionXpathSingleFilter">
<property name="checks" value="UpperEll"/>
<property name="query" value="//NUM_LONG[@text='9223372036854775807l' or
@text='9223372036854775808l']"/>
</module>
<module name="TreeWalker">
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
</module>
</module>

*/

package org.checkstyle.autofix.recipe.upperell.complexlongliterals;

public class InputComplexLongLiterals {
private long withUnderscores = 1_000_000l;
private long multipleUnderscores = 1_234_567_890l;

private long maxLong = 9223372036854775807l;
private long minLong = -9223372036854775808l;
private long maxLong = 9223372036854775807l; //suppressed violation
private long minLong = -9223372036854775808l; //suppressed violation

private Long nullLong = null;
private Long simpleLong = 1234l;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
/*xml
<module name="Checker">
<module name="com.puppycrawl.tools.checkstyle.filters.SuppressionXpathSingleFilter">
<property name="checks" value="UpperEll"/>
<property name="query" value="//NUM_LONG[@text='9223372036854775807l' or
@text='9223372036854775808l']"/>
</module>
<module name="TreeWalker">
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
</module>
</module>

*/

package org.checkstyle.autofix.recipe.upperell.complexlongliterals;

public class OutputComplexLongLiterals {
private long withUnderscores = 1_000_000L;
private long multipleUnderscores = 1_234_567_890L;

private long maxLong = 9223372036854775807L;
private long minLong = -9223372036854775808L;
private long maxLong = 9223372036854775807l; //suppressed violation
private long minLong = -9223372036854775808l; //suppressed violation

private Long nullLong = null;
private Long simpleLong = 1234L;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/*xml
<module name="Checker">
<module name="com.puppycrawl.tools.checkstyle.filters.SuppressionXpathSingleFilter">
<property name="checks" value="UpperEll"/>
<property name="query" value="//NUM_LONG[@text='0xDEADBEFl' or @text='01234l']"/>
</module>
<module name="TreeWalker">
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
</module>
</module>

*/

package org.checkstyle.autofix.recipe.upperell.hexoctalliteral;

public class InputHexOctalLiteral {
Expand All @@ -9,7 +22,7 @@ public class InputHexOctalLiteral {

public void calculateValues() {
long hexResult = 0xDEADBEEFl + 0xDEADBEFl; //suppressed violation for 0xDEADBEFl
long octalResult = 01234l + 0xDEADBEEFl; //suppressed violation for 0xDEADBEFl
long octalResult = 01234l + 0xDEADBEEFl; //suppressed violation for 01234l
long binaryResult = 0b11110000l;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/*xml
<module name="Checker">
<module name="com.puppycrawl.tools.checkstyle.filters.SuppressionXpathSingleFilter">
<property name="checks" value="UpperEll"/>
<property name="query" value="//NUM_LONG[@text='0xDEADBEFl' or @text='01234l']"/>
</module>
<module name="TreeWalker">
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
</module>
</module>

*/

package org.checkstyle.autofix.recipe.upperell.hexoctalliteral;

public class OutputHexOctalLiteral {
Expand All @@ -9,7 +22,7 @@ public class OutputHexOctalLiteral {

public void calculateValues() {
long hexResult = 0xDEADBEEFL + 0xDEADBEFl; //suppressed violation for 0xDEADBEFl
long octalResult = 01234L + 0xDEADBEEFl; //suppressed violation for 0xDEADBEFl
long octalResult = 01234l + 0xDEADBEEFL; //suppressed violation for 01234l
long binaryResult = 0b11110000L;
}
}
129 changes: 0 additions & 129 deletions src/test/resources/org/checkstyle/autofix/recipe/upperell/report.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
</module>
</module>

*/

package org.checkstyle.autofix.recipe.upperell.stringandcomments;

public class InputStringAndComments {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
</module>
</module>

*/

package org.checkstyle.autofix.recipe.upperell.stringandcomments;

public class OutputStringAndComments {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
</module>
</module>

*/

package org.checkstyle.autofix.recipe.upperell.symbolicliterals;

public class InputSymbolicLiterals {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
</module>
</module>

*/

package org.checkstyle.autofix.recipe.upperell.symbolicliterals;

public class OutputSymbolicLiterals {
Expand Down
Loading