Skip to content

Commit a64c1d5

Browse files
Issue #371: Upgrade checkstyle dependency
1 parent ffbb554 commit a64c1d5

15 files changed

Lines changed: 24 additions & 28 deletions

File tree

pom.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
<properties>
3535
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36-
<checkstyle.version>10.4</checkstyle.version>
36+
<checkstyle.version>13.3.0</checkstyle.version>
3737
<maven.checkstyle.plugin.version>3.2.0</maven.checkstyle.plugin.version>
3838
<maven.compiler.source>17</maven.compiler.source>
3939
<maven.compiler.target>17</maven.compiler.target>
@@ -115,9 +115,7 @@
115115
<includeResources>false</includeResources>
116116
<includeTestResources>false</includeTestResources>
117117
<includeTestSourceDirectory>true</includeTestSourceDirectory>
118-
<configLocation>
119-
https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-${checkstyle.version}/config/checkstyle_checks.xml
120-
</configLocation>
118+
<configLocation>google_checks.xml</configLocation>
121119
<propertiesLocation>config/checkstyle.properties</propertiesLocation>
122120
<failOnViolation>true</failOnViolation>
123121
<logViolationsToConsole>true</logViolationsToConsole>

src/main/java/com/puppycrawl/tools/checkstyle/filters/JavaPatchFilterElement.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public boolean accept(TreeWalkerAuditEvent event) {
185185
* @return true if it is matching
186186
*/
187187
private boolean isFileNameMatching(TreeWalkerAuditEvent event) {
188-
String eventFileName = event.getFileName();
188+
String eventFileName = event.fileName();
189189
boolean result = eventFileName != null;
190190

191191
if (result) {
@@ -225,7 +225,7 @@ private boolean isNeverSuppressCheck(TreeWalkerAuditEvent event) {
225225
*/
226226
private boolean isLineMatching(TreeWalkerAuditEvent event) {
227227
boolean result = false;
228-
if (event.getViolation() != null) {
228+
if (event.violation() != null) {
229229
result = lineMatching(event.getLine());
230230
}
231231
return result;
@@ -337,7 +337,7 @@ private static boolean containsShortName(Set<String> checkNameSet,
337337
}
338338

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

@@ -352,7 +352,7 @@ private static String getCheckShortName(TreeWalkerAuditEvent event) {
352352
* @return DetailAST event's corresponding ast node
353353
*/
354354
private static DetailAST getEventAst(TreeWalkerAuditEvent event) {
355-
DetailAST curNode = event.getRootAst();
355+
DetailAST curNode = event.rootAst();
356356
DetailAST eventAst = null;
357357
while (curNode != null) {
358358
if (isMatchingAst(curNode, event)) {

src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionJavaPatchFilterTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected String getPatchFileLocation() {
3434
}
3535

3636
@Override
37-
protected String getPackageLocation() {
37+
public String getPackageLocation() {
3838
return "com/puppycrawl/tools/checkstyle/filters/suppressionjavapatchfilter/";
3939
}
4040

@@ -57,13 +57,11 @@ public void testNonExistentPatchFileWithFalseOptional() throws Exception {
5757
testByConfig("Optional/false/defaultContextConfig.xml");
5858
}
5959
catch (CheckstyleException ex) {
60-
assertEquals("cannot initialize module TreeWalker - "
61-
+ "cannot initialize module "
62-
+ "com.puppycrawl.tools.checkstyle.filters.SuppressionJavaPatchFilter "
63-
+ "- an error occurred when loading patch file "
64-
+ getPatchFileLocation() + "Optional/false//defaultContext.patch",
65-
ex.getMessage(),
66-
"Invalid error message");
60+
assertEquals(
61+
"cannot initialize module TreeWalker - cannot initialize module "
62+
+ "com.puppycrawl.tools.checkstyle.filters.SuppressionJavaPatchFilter",
63+
ex.getMessage()
64+
);
6765
}
6866
}
6967

src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionPatchFilterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected String getPatchFileLocation() {
3030
}
3131

3232
@Override
33-
protected String getPackageLocation() {
33+
public String getPackageLocation() {
3434
return "com/puppycrawl/tools/checkstyle/filters/suppressionpatchfilter/";
3535
}
3636

src/test/java/com/puppycrawl/tools/checkstyle/jgit/GitDiffOnOpenSourceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
public class GitDiffOnOpenSourceTest extends AbstractModuleTestSupport {
3737

3838
@Override
39-
protected String getPackageLocation() {
39+
public String getPackageLocation() {
4040
return "com/puppycrawl/tools/checkstyle/filters/";
4141
}
4242

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Test.java:0: Required pattern '// This code is copyrighted\n// \(c\) MyCompany' missing in file.
1+
Test.java:1: Required pattern '// This code is copyrighted\n// \(c\) MyCompany' missing in file.
Original file line numberDiff line numberDiff line change
@@ -1 +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'.
1+
Test.java:7:5: All overloaded methods should be placed next to each other. Previous overloaded method located at line '5'.
Original file line numberDiff line numberDiff line change
@@ -1 +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'.
1+
Test.java:15:5: All overloaded methods should be placed next to each other. Previous overloaded method located at line '13'.
Original file line numberDiff line numberDiff line change
@@ -1 +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'.
1+
Test.java:15:5: All overloaded methods should be placed next to each other. Previous overloaded method located at line '13'.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Test.java:7: <p> tag should be preceded with an empty line.
1+
Test.java:7:4: <p> tag should be preceded with an empty line.

0 commit comments

Comments
 (0)