Skip to content

Commit 5953e71

Browse files
committed
Issue #559: update checkstyle to 10.26.1
1 parent 11bd09e commit 5953e71

13 files changed

+44
-39
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Compatibility matrix from Checkstyle:
1717

1818
| Checkstyle Plugin | Sonar min | Sonar max | Checkstyle | Jdk |
1919
|-------------------|-----------|-----------|------------|-----|
20+
| 10.26.1 | 9.9 | 10.7+ | 10.26.1 | 11 |
2021
| 10.23.0 | 9.9 | 10.7+ | 10.23.0 | 11 |
2122
| 10.21.4 | 9.9 | 10.7+ | 10.21.4 | 11 |
2223
| 10.21.1 | 9.9 | 10.7+ | 10.21.1 | 11 |

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@
9393
</ciManagement>
9494

9595
<properties>
96-
<checkstyle.version>10.23.0</checkstyle.version>
96+
<checkstyle.version>10.26.1</checkstyle.version>
9797
<sonar.version>9.9.4.87374</sonar.version>
9898
<sonar.api-version>9.9.0.229</sonar.api-version>
9999
<maven.sevntu.checkstyle.plugin.version>1.44.1</maven.sevntu.checkstyle.plugin.version>
100100
<!-- it should be a version of checkstyle that is compatible/compiled with sevntu -->
101101
<maven.sevntu.checkstyle.plugin.checkstyle.version>
102-
10.23.0
102+
10.26.1
103103
</maven.sevntu.checkstyle.plugin.checkstyle.version>
104104
<antrun.plugin.version>3.1.0</antrun.plugin.version>
105105
<checkstyle.configLocation>https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-${checkstyle.version}/config/checkstyle-checks.xml</checkstyle.configLocation>

src/main/java/org/sonar/plugins/checkstyle/CheckstyleAuditListener.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,17 @@ static String getRuleKey(AuditEvent event) {
134134
try {
135135
key = event.getModuleId();
136136
}
137-
catch (Exception ex) {
137+
catch (Exception exception) {
138138
LOG.warn("AuditEvent is created incorrectly. Exception happen during getModuleId()",
139-
ex);
139+
exception);
140140
}
141141
if (StringUtils.isBlank(key)) {
142142
try {
143143
key = event.getSourceName();
144144
}
145-
catch (Exception ex) {
145+
catch (Exception exception) {
146146
LOG.warn("AuditEvent is created incorrectly."
147-
+ "Exception happen during getSourceName()", ex);
147+
+ "Exception happen during getSourceName()", exception);
148148
}
149149
}
150150
return key;
@@ -157,8 +157,9 @@ static String getMessage(AuditEvent event) {
157157
result = event.getMessage();
158158

159159
}
160-
catch (Exception ex) {
161-
LOG.warn("AuditEvent is created incorrectly. Exception happen during getMessage()", ex);
160+
catch (Exception exception) {
161+
LOG.warn("AuditEvent is created incorrectly. Exception happen during getMessage()",
162+
exception);
162163
result = null;
163164
}
164165
return result;
@@ -173,8 +174,9 @@ static int getLineId(AuditEvent event) {
173174
result = eventLine;
174175
}
175176
}
176-
catch (Exception ex) {
177-
LOG.warn("AuditEvent is created incorrectly. Exception happen during getLine()", ex);
177+
catch (Exception exception) {
178+
LOG.warn("AuditEvent is created incorrectly. Exception happen during getLine()",
179+
exception);
178180
}
179181
return result;
180182
}

src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ public File getXmlDefinitionFile() {
9494
writer.flush();
9595
return xmlFile;
9696
}
97-
catch (IOException ex) {
97+
catch (IOException exception) {
9898
throw new IllegalStateException("Fail to save the Checkstyle configuration to "
99-
+ xmlFile.getPath(), ex);
99+
+ xmlFile.getPath(), exception);
100100

101101
}
102102
}

src/main/java/org/sonar/plugins/checkstyle/CheckstyleExecutor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ private void executeWithClassLoader() {
108108
.map(inputFile -> new File(inputFile.uri()))
109109
.collect(Collectors.toList()));
110110
}
111-
catch (Exception ex) {
112-
throw new IllegalStateException("Can not execute Checkstyle", ex);
111+
catch (Exception exception) {
112+
throw new IllegalStateException("Can not execute Checkstyle", exception);
113113
}
114114
finally {
115115
checker.destroy();
@@ -124,8 +124,8 @@ static void close(Closeable closeable) {
124124
try {
125125
closeable.close();
126126
}
127-
catch (IOException ex) {
128-
throw new IllegalStateException("failed to close object", ex);
127+
catch (IOException exception) {
128+
throw new IllegalStateException("failed to close object", exception);
129129
}
130130
}
131131

@@ -141,9 +141,9 @@ URL getUrl(URI uri) {
141141
try {
142142
return uri.toURL();
143143
}
144-
catch (MalformedURLException ex) {
144+
catch (MalformedURLException exception) {
145145
throw new IllegalStateException("Fail to create the project classloader. "
146-
+ "Classpath element is invalid: " + uri, ex);
146+
+ "Classpath element is invalid: " + uri, exception);
147147
}
148148
}
149149
}

src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public void exportProfile(ActiveRules activeRules, Writer writer) {
6565
.findByRepository(CheckstyleConstants.REPOSITORY_KEY));
6666
generateXml(writer, activeRulesByConfigKey);
6767
}
68-
catch (IOException ex) {
69-
throw new IllegalStateException("Fail to export active rules.", ex);
68+
catch (IOException exception) {
69+
throw new IllegalStateException("Fail to export active rules.", exception);
7070
}
7171

7272
}

src/main/java/org/sonar/plugins/checkstyle/metadata/CheckstyleMetadata.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ private Class<?> getClass(String checkName) {
159159
try {
160160
return Class.forName(checkName, true, loader);
161161
}
162-
catch (ClassNotFoundException ex) {
162+
catch (ClassNotFoundException exception) {
163163
throw new IllegalStateException("exception occured during getClass for " + checkName,
164-
ex);
164+
exception);
165165
}
166166
}
167167

@@ -320,8 +320,9 @@ private static String getRuleTag(String checkPackage,
320320
try (InputStream inputStream = CheckstyleMetadata.class.getResourceAsStream(fileName)) {
321321
sonarRulePropertyLoader = mapper.readValue(inputStream, SonarRulePropertyLoader.class);
322322
}
323-
catch (IOException ex) {
324-
throw new IllegalStateException("Exception during yaml loading of " + fileName, ex);
323+
catch (IOException exception) {
324+
throw new IllegalStateException("Exception during yaml loading of " + fileName,
325+
exception);
325326
}
326327
final Map<String, SonarRulePropertyLoader.AdditionalRuleProperties> additionalDetails =
327328
new HashMap<>();

src/main/java/org/sonar/plugins/checkstyle/metadata/ModuleFactory.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,18 @@ public static AbstractCheck getCheck(String checkName) {
3939
final Set<String> packageNames = PackageNamesLoader.getPackageNames(classLoader);
4040
packageObjectFactory = new PackageObjectFactory(packageNames, classLoader);
4141
}
42-
catch (CheckstyleException ex) {
42+
catch (CheckstyleException exception) {
4343
throw new IllegalStateException("exception happened during initialization of"
44-
+ " PackageObjectFactory while loading of " + checkName, ex);
44+
+ " PackageObjectFactory while loading of " + checkName, exception);
4545
}
4646
}
4747

4848
try {
4949
return (AbstractCheck) packageObjectFactory.createModule(checkName);
5050
}
51-
catch (CheckstyleException ex) {
52-
throw new IllegalStateException("exception occured during load of " + checkName, ex);
51+
catch (CheckstyleException exception) {
52+
throw new IllegalStateException("exception occured during load of " + checkName,
53+
exception);
5354
}
5455
}
5556
}

src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ public void exportProfile(ActiveRules activeRules, Writer writer) {
167167
try {
168168
writer.write("<conf/>");
169169
}
170-
catch (IOException ex) {
171-
throw new IllegalStateException(ex);
170+
catch (IOException exception) {
171+
throw new IllegalStateException(exception);
172172
}
173173
}
174174
}

src/test/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ public void activeRulesThrowsException() {
181181
new DefaultActiveRules(Collections.emptyList()), new IoExceptionWriter());
182182
Assert.fail("IOException while writing should not be ignored");
183183
}
184-
catch (IllegalStateException ex) {
185-
Assertions.assertThat(ex.getMessage()).isEqualTo("Fail to export active rules.");
184+
catch (IllegalStateException exception) {
185+
Assertions.assertThat(exception.getMessage()).isEqualTo("Fail to export active rules.");
186186
}
187187
}
188188

0 commit comments

Comments
 (0)