Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
path: ~/.m2/repository
key: maven-cache-${{ hashFiles('**/pom.xml') }}

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 17
java-version: 21

- name: Build with Maven
run: mvn -e --no-transfer-progress install
1 change: 1 addition & 0 deletions config/checkstyle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ checkstyle.header.file=https://raw.githubusercontent.com/checkstyle/checkstyle/m
checkstyle.regexp.header.file=https://raw.githubusercontent.com/checkstyle/checkstyle/master/config/java-regexp.header
checkstyle.importcontrol.file=config/import-control.xml
checkstyle.importcontroltest.file=config/import-control-test.xml
checkstyle.java.version=21
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<checkstyle.version>10.4</checkstyle.version>
<checkstyle.version>13.3.0</checkstyle.version>
<maven.checkstyle.plugin.version>3.2.0</maven.checkstyle.plugin.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<junit.version>5.9.1</junit.version>
</properties>

Expand Down Expand Up @@ -116,7 +116,7 @@
<includeTestResources>false</includeTestResources>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<configLocation>
https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-${checkstyle.version}/config/checkstyle_checks.xml
https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-${checkstyle.version}/config/checkstyle-checks.xml
</configLocation>
<propertiesLocation>config/checkstyle.properties</propertiesLocation>
<failOnViolation>true</failOnViolation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ public GeneratePatchFile(String repoPath, String testerPath,
.readEnvironment().findGitDir().build();
git = new Git(repository);
}
catch (IOException ex) {
ex.printStackTrace();
catch (IOException exception) {
exception.printStackTrace();
}
diffReportDirName = new File(".").getAbsoluteFile().getParent() + "/DiffReport";
}
Expand Down Expand Up @@ -406,8 +406,8 @@ private void generateSummaryIndexHtml() {
out.write("</h2>\n</body></html>");

}
catch (IOException ex) {
ex.printStackTrace();
catch (IOException exception) {
exception.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public boolean accept(TreeWalkerAuditEvent event) {
* @return true if it is matching
*/
private boolean isFileNameMatching(TreeWalkerAuditEvent event) {
String eventFileName = event.getFileName();
String eventFileName = event.fileName();
boolean result = eventFileName != null;

if (result) {
Expand Down Expand Up @@ -225,7 +225,7 @@ private boolean isNeverSuppressCheck(TreeWalkerAuditEvent event) {
*/
private boolean isLineMatching(TreeWalkerAuditEvent event) {
boolean result = false;
if (event.getViolation() != null) {
if (event.violation() != null) {
result = lineMatching(event.getLine());
}
return result;
Expand Down Expand Up @@ -337,7 +337,7 @@ private static boolean containsShortName(Set<String> checkNameSet,
}

private static String getCheckName(TreeWalkerAuditEvent event) {
final String[] checkNames = event.getViolation().getSourceName().split("\\.");
final String[] checkNames = event.violation().getSourceName().split("\\.");
return checkNames[checkNames.length - 1];
}

Expand All @@ -352,7 +352,7 @@ private static String getCheckShortName(TreeWalkerAuditEvent event) {
* @return DetailAST event's corresponding ast node
*/
private static DetailAST getEventAst(TreeWalkerAuditEvent event) {
DetailAST curNode = event.getRootAst();
DetailAST curNode = event.rootAst();
DetailAST eventAst = null;
while (curNode != null) {
if (isMatchingAst(curNode, event)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@
import com.puppycrawl.tools.checkstyle.utils.FilterUtil;

/**
* <p>
* Filter {@code SuppressionJavaPatchFilter} rejects audit events for Check violations
* according to a patch file.
* </p>
*
* @since 8.34
*/
Expand Down Expand Up @@ -108,6 +106,7 @@ public class SuppressionJavaPatchFilter extends AutomaticBean implements
* Setter to specify the location of the patch file.
*
* @param fileName name of the patch file.
* @since 8.34
*/
public void setFile(String fileName) {
file = fileName;
Expand All @@ -117,6 +116,7 @@ public void setFile(String fileName) {
* Setter to control if only consider added lines in file.
*
* @param strategy tells if only consider added lines is add, should be added or changed.
* @since 8.34
*/
public void setStrategy(String strategy) {
this.strategy = Strategy.valueOf(strategy.toUpperCase());
Expand All @@ -131,6 +131,8 @@ public void setStrategy(String strategy) {
* to their parent abstract nodes
* to get their child nodes,
* split by comma
*
* @since 8.34
*/
public void setCheckNamesForContextStrategyByTokenOrParentSet(
String checkNamesForContextStrategyByTokenOrParentSet) {
Expand All @@ -148,6 +150,7 @@ public void setCheckNamesForContextStrategyByTokenOrParentSet(
* to their ancestor abstract nodes
* to get their child nodes,
* split by comma
* @since 8.34
*/
public void setCheckNamesForContextStrategyByTokenOrAncestorSet(
String checkNamesForContextStrategyByTokenOrAncestorSet) {
Expand All @@ -161,6 +164,7 @@ public void setCheckNamesForContextStrategyByTokenOrAncestorSet(
*
* @param supportContextStrategyChecks string has user defined checks that support
* context strategy
* @since 8.34
*/
public void setSupportContextStrategyChecks(String supportContextStrategyChecks) {
final String[] checksArray = supportContextStrategyChecks.split(COMMA);
Expand All @@ -173,6 +177,7 @@ public void setSupportContextStrategyChecks(String supportContextStrategyChecks)
*
* @param neverSuppressedChecks string has user defined Checks to never suppress
* if files are touched, split by comma
* @since 8.34
*/
public void setNeverSuppressedChecks(String neverSuppressedChecks) {
final String[] checksArray = neverSuppressedChecks.split(COMMA);
Expand All @@ -186,6 +191,7 @@ public void setNeverSuppressedChecks(String neverSuppressedChecks) {
* and file is not found, the filter accept all audit events.
*
* @param optional tells if config file existence is optional.
* @since 8.34
*/
public void setOptional(boolean optional) {
this.optional = optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@
import com.puppycrawl.tools.checkstyle.utils.FilterUtil;

/**
* <p>
* Filter {@code SuppressionFilter} rejects audit events for Check violations according to a
* patch file.
* </p>
*
* @since 8.34
*/
Expand Down Expand Up @@ -87,6 +85,7 @@ public class SuppressionPatchFilter extends AutomaticBean
* Setter to specify the location of the patch file.
*
* @param fileName name of the patch file.
* @since 8.34
*/
public void setFile(String fileName) {
file = fileName;
Expand All @@ -96,6 +95,7 @@ public void setFile(String fileName) {
* Setter to control if only consider added lines in file.
*
* @param strategy tells if only consider added lines is add, should be added or changed.
* @since 8.34
*/
public void setStrategy(String strategy) {
this.strategy = Strategy.valueOf(strategy.toUpperCase());
Expand All @@ -106,6 +106,7 @@ public void setStrategy(String strategy) {
*
* @param neverSuppressedChecks string has user defined Checks to never suppress
* if files are touched, split by comma
* @since 8.34
*/
public void setNeverSuppressedChecks(String neverSuppressedChecks) {
final String[] checksArray = neverSuppressedChecks.split(COMMA);
Expand All @@ -119,6 +120,7 @@ public void setNeverSuppressedChecks(String neverSuppressedChecks) {
* and file is not found, the filter accept all audit events.
*
* @param optional tells if config file existence is optional.
* @since 8.34
*/
public void setOptional(boolean optional) {
this.optional = optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ private static boolean isTreeWalkerChecksMatching(AuditEvent event) {
}
return result;
}
catch (ClassNotFoundException ex) {
throw new IllegalStateException("Class " + sourceName + " not found", ex);
catch (ClassNotFoundException exception) {
throw new IllegalStateException("Class " + sourceName + " not found", exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected String getPatchFileLocation() {
}

@Override
protected String getPackageLocation() {
public String getPackageLocation() {
return "com/puppycrawl/tools/checkstyle/filters/suppressionjavapatchfilter/";
}

Expand All @@ -56,14 +56,12 @@ public void testNonExistentPatchFileWithFalseOptional() throws Exception {
try {
testByConfig("Optional/false/defaultContextConfig.xml");
}
catch (CheckstyleException ex) {
assertEquals("cannot initialize module TreeWalker - "
+ "cannot initialize module "
+ "com.puppycrawl.tools.checkstyle.filters.SuppressionJavaPatchFilter "
+ "- an error occurred when loading patch file "
+ getPatchFileLocation() + "Optional/false//defaultContext.patch",
ex.getMessage(),
"Invalid error message");
catch (CheckstyleException exception) {
assertEquals(
"cannot initialize module TreeWalker - cannot initialize module "
+ "com.puppycrawl.tools.checkstyle.filters.SuppressionJavaPatchFilter",
exception.getMessage()
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected String getPatchFileLocation() {
}

@Override
protected String getPackageLocation() {
public String getPackageLocation() {
return "com/puppycrawl/tools/checkstyle/filters/suppressionpatchfilter/";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public class GitDiffOnOpenSourceTest extends AbstractModuleTestSupport {

@Override
protected String getPackageLocation() {
public String getPackageLocation() {
return "com/puppycrawl/tools/checkstyle/filters/";
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Test.java:0: Required pattern '// This code is copyrighted\n// \(c\) MyCompany' missing in file.
Test.java:1: Required pattern '// This code is copyrighted\n// \(c\) MyCompany' missing in file.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Test.java:7:5: All overloaded methods should be placed next to each other. Placing non-overloaded methods in between overloaded methods with the same type is a violation. Previous overloaded method located at line '5'.
Test.java:7:5: All overloaded methods should be placed next to each other. Previous overloaded method located at line '5'.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Test.java:15:5: All overloaded methods should be placed next to each other. Placing non-overloaded methods in between overloaded methods with the same type is a violation. Previous overloaded method located at line '13'.
Test.java:15:5: All overloaded methods should be placed next to each other. Previous overloaded method located at line '13'.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Test.java:15:5: All overloaded methods should be placed next to each other. Placing non-overloaded methods in between overloaded methods with the same type is a violation. Previous overloaded method located at line '13'.
Test.java:15:5: All overloaded methods should be placed next to each other. Previous overloaded method located at line '13'.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Test.java:7: <p> tag should be preceded with an empty line.
Test.java:7:4: <p> tag should be preceded with an empty line.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Test.java:8: <p> tag should be preceded with an empty line.
Test.java:8:4: <p> tag should be preceded with an empty line.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Test.java:8: <p> tag should be preceded with an empty line.
Test.java:8:4: <p> tag should be preceded with an empty line.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Test.java:4: Summary javadoc is missing.
Test.java:4:8: Summary javadoc is missing.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Test.java:9: Summary javadoc is missing.
Test.java:9:8: Summary javadoc is missing.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Test.java:4: Summary javadoc is missing.
Test.java:4:8: Summary javadoc is missing.