Skip to content

Commit 528bfef

Browse files
committed
Upgrade to Checkstyle 8.45.1
Closes gh-275
1 parent 8b58d25 commit 528bfef

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
:release-version: 0.0.28
2-
:checkstyle-version: 8.32
2+
:checkstyle-version: 8.45.1
33
== Spring Java Format
44

55

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<ant-contrib.version>1.0b3</ant-contrib.version>
3939
<asm.version>5.2</asm.version>
4040
<assertj.version>3.8.0</assertj.version>
41-
<checkstyle.version>8.32</checkstyle.version>
41+
<checkstyle.version>8.45.1</checkstyle.version>
4242
<gradle.version>3.4</gradle.version>
4343
<groovy.version>2.4.21</groovy.version>
4444
<maven-core.version>3.5.0</maven-core.version>

spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/SpringChecks.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2020 the original author or authors.
2+
* Copyright 2017-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@
3838
import com.puppycrawl.tools.checkstyle.api.ExternalResourceHolder;
3939
import com.puppycrawl.tools.checkstyle.api.FileSetCheck;
4040
import com.puppycrawl.tools.checkstyle.api.FileText;
41-
import com.puppycrawl.tools.checkstyle.api.LocalizedMessage;
41+
import com.puppycrawl.tools.checkstyle.api.Violation;
4242
import com.puppycrawl.tools.checkstyle.filters.SuppressFilterElement;
4343

4444
import io.spring.javaformat.checkstyle.check.SpringHeaderCheck;
@@ -135,11 +135,11 @@ public void beginProcessing(String charset) {
135135

136136
@Override
137137
protected void processFiltered(File file, FileText fileText) throws CheckstyleException {
138-
SortedSet<LocalizedMessage> messages = new TreeSet<>();
138+
SortedSet<Violation> violations = new TreeSet<>();
139139
for (FileSetCheck check : this.checks) {
140-
messages.addAll(check.process(file, fileText));
140+
violations.addAll(check.process(file, fileText));
141141
}
142-
addMessages(messages);
142+
addViolations(violations);
143143
}
144144

145145
@Override

spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/filter/CheckFilter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2020 the original author or authors.
2+
* Copyright 2017-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@
2828
import com.puppycrawl.tools.checkstyle.api.Configuration;
2929
import com.puppycrawl.tools.checkstyle.api.Context;
3030
import com.puppycrawl.tools.checkstyle.api.DetailAST;
31-
import com.puppycrawl.tools.checkstyle.api.LocalizedMessage;
31+
import com.puppycrawl.tools.checkstyle.api.Violation;
3232

3333
/**
3434
* Base class for {@link AbstractCheck checks} that act as a filter for a single child.
@@ -100,14 +100,14 @@ public boolean isCommentNodesRequired() {
100100
}
101101

102102
@Override
103-
public SortedSet<LocalizedMessage> getMessages() {
104-
return this.check.getMessages();
103+
public SortedSet<Violation> getViolations() {
104+
return this.check.getViolations();
105105
}
106106

107107
@Override
108108
public void beginTree(DetailAST rootAST) {
109109
this.check.setFileContents(getFileContents());
110-
this.check.clearMessages();
110+
this.check.clearViolations();
111111
this.check.beginTree(rootAST);
112112
}
113113

spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/filter/RequiresOuterThisFilter.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2019 the original author or authors.
2+
* Copyright 2017-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
2121

2222
import com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent;
2323
import com.puppycrawl.tools.checkstyle.TreeWalkerFilter;
24-
import com.puppycrawl.tools.checkstyle.api.LocalizedMessage;
24+
import com.puppycrawl.tools.checkstyle.api.Violation;
2525

2626
/**
2727
* {@link TreeWalkerFilter} that can used to relax the {@code 'this.'} requirement when
@@ -35,9 +35,9 @@ public class RequiresOuterThisFilter implements TreeWalkerFilter {
3535

3636
@Override
3737
public boolean accept(TreeWalkerAuditEvent event) {
38-
LocalizedMessage message = event.getLocalizedMessage();
39-
if ("require.this.variable".equals(message.getKey())) {
40-
Object[] args = getArgs(message);
38+
Violation violation = event.getViolation();
39+
if ("require.this.variable".equals(violation.getKey())) {
40+
Object[] args = getArgs(violation);
4141
String prefex = (args.length > 1 ? Objects.toString(args[1]) : null);
4242
if (prefex != null && prefex.length() > 0) {
4343
return false;
@@ -46,12 +46,12 @@ public boolean accept(TreeWalkerAuditEvent event) {
4646
return true;
4747
}
4848

49-
private Object[] getArgs(LocalizedMessage message) {
49+
private Object[] getArgs(Violation violation) {
5050
if (ARGS_FIELD == null) {
5151
throw new IllegalStateException("Unable to extract message args");
5252
}
5353
try {
54-
return (Object[]) ARGS_FIELD.get(message);
54+
return (Object[]) ARGS_FIELD.get(violation);
5555
}
5656
catch (Exception ex) {
5757
return null;
@@ -60,7 +60,7 @@ private Object[] getArgs(LocalizedMessage message) {
6060

6161
private static Field getArgsField() {
6262
try {
63-
Field field = LocalizedMessage.class.getDeclaredField("args");
63+
Field field = Violation.class.getDeclaredField("args");
6464
field.setAccessible(true);
6565
return field;
6666
}

spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/AssertionsAuditListener.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import com.puppycrawl.tools.checkstyle.Definitions;
2828
import com.puppycrawl.tools.checkstyle.api.AuditEvent;
2929
import com.puppycrawl.tools.checkstyle.api.AuditListener;
30-
import com.puppycrawl.tools.checkstyle.api.LocalizedMessage;
3130
import com.puppycrawl.tools.checkstyle.api.SeverityLevel;
31+
import com.puppycrawl.tools.checkstyle.api.Violation;
3232

3333
import static org.assertj.core.api.Assertions.assertThat;
3434

@@ -110,8 +110,8 @@ private void recordLevel(AuditEvent event) {
110110
}
111111

112112
private void recordLocalizedMessage(String message, String... args) {
113-
recordMessage(new LocalizedMessage(0, Definitions.CHECKSTYLE_BUNDLE, message, args, null,
114-
LocalizedMessage.class, null).getMessage());
113+
recordMessage(new Violation(0, Definitions.CHECKSTYLE_BUNDLE, message, args, null,
114+
Violation.class, null).getViolation());
115115
}
116116

117117
private void recordMessage(String message) {

spring-javaformat/spring-javaformat-checkstyle/src/test/resources/source/SpringApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,8 @@ public void setMainApplicationClass(Class<?> mainApplicationClass) {
935935
/**
936936
* Returns whether this {@link SpringApplication} is running within a web environment.
937937
* @return {@code true} if running within a web environment, otherwise {@code false}.
938-
* @see #setWebEnvironment(boolean)
939938
* @deprecated since 2.0.0 in favor of {@link #getWebApplicationType()}
939+
* @see #setWebEnvironment(boolean)
940940
*/
941941
@Deprecated
942942
public boolean isWebEnvironment() {

0 commit comments

Comments
 (0)