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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Compatibility matrix from Checkstyle:

| Checkstyle Plugin | Sonar min | Sonar max | Checkstyle | Jdk |
|-------------------|-----------|-----------|------------|-----|
| 10.26.1 | 9.9 | 10.7+ | 10.26.1 | 11 |
| 10.23.0 | 9.9 | 10.7+ | 10.23.0 | 11 |
| 10.21.4 | 9.9 | 10.7+ | 10.21.4 | 11 |
| 10.21.1 | 9.9 | 10.7+ | 10.21.1 | 11 |
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@
</ciManagement>

<properties>
<checkstyle.version>10.23.0</checkstyle.version>
<checkstyle.version>10.26.1</checkstyle.version>
<sonar.version>9.9.4.87374</sonar.version>
<sonar.api-version>9.9.0.229</sonar.api-version>
<maven.sevntu.checkstyle.plugin.version>1.44.1</maven.sevntu.checkstyle.plugin.version>
<!-- it should be a version of checkstyle that is compatible/compiled with sevntu -->
<maven.sevntu.checkstyle.plugin.checkstyle.version>
10.23.0
10.26.1
</maven.sevntu.checkstyle.plugin.checkstyle.version>
<antrun.plugin.version>3.1.0</antrun.plugin.version>
<checkstyle.configLocation>https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-${checkstyle.version}/config/checkstyle-checks.xml</checkstyle.configLocation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,17 @@ static String getRuleKey(AuditEvent event) {
try {
key = event.getModuleId();
}
catch (Exception ex) {
catch (Exception exception) {
LOG.warn("AuditEvent is created incorrectly. Exception happen during getModuleId()",
ex);
exception);
}
if (StringUtils.isBlank(key)) {
try {
key = event.getSourceName();
}
catch (Exception ex) {
catch (Exception exception) {
LOG.warn("AuditEvent is created incorrectly."
+ "Exception happen during getSourceName()", ex);
+ "Exception happen during getSourceName()", exception);
}
}
return key;
Expand All @@ -157,8 +157,9 @@ static String getMessage(AuditEvent event) {
result = event.getMessage();

}
catch (Exception ex) {
LOG.warn("AuditEvent is created incorrectly. Exception happen during getMessage()", ex);
catch (Exception exception) {
LOG.warn("AuditEvent is created incorrectly. Exception happen during getMessage()",
exception);
result = null;
}
return result;
Expand All @@ -173,8 +174,9 @@ static int getLineId(AuditEvent event) {
result = eventLine;
}
}
catch (Exception ex) {
LOG.warn("AuditEvent is created incorrectly. Exception happen during getLine()", ex);
catch (Exception exception) {
LOG.warn("AuditEvent is created incorrectly. Exception happen during getLine()",
exception);
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public File getXmlDefinitionFile() {
writer.flush();
return xmlFile;
}
catch (IOException ex) {
catch (IOException exception) {
throw new IllegalStateException("Fail to save the Checkstyle configuration to "
+ xmlFile.getPath(), ex);
+ xmlFile.getPath(), exception);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ private void executeWithClassLoader() {
.map(inputFile -> new File(inputFile.uri()))
.collect(Collectors.toList()));
}
catch (Exception ex) {
throw new IllegalStateException("Can not execute Checkstyle", ex);
catch (Exception exception) {
throw new IllegalStateException("Can not execute Checkstyle", exception);
}
finally {
checker.destroy();
Expand All @@ -124,8 +124,8 @@ static void close(Closeable closeable) {
try {
closeable.close();
}
catch (IOException ex) {
throw new IllegalStateException("failed to close object", ex);
catch (IOException exception) {
throw new IllegalStateException("failed to close object", exception);
}
}

Expand All @@ -141,9 +141,9 @@ URL getUrl(URI uri) {
try {
return uri.toURL();
}
catch (MalformedURLException ex) {
catch (MalformedURLException exception) {
throw new IllegalStateException("Fail to create the project classloader. "
+ "Classpath element is invalid: " + uri, ex);
+ "Classpath element is invalid: " + uri, exception);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public void exportProfile(ActiveRules activeRules, Writer writer) {
.findByRepository(CheckstyleConstants.REPOSITORY_KEY));
generateXml(writer, activeRulesByConfigKey);
}
catch (IOException ex) {
throw new IllegalStateException("Fail to export active rules.", ex);
catch (IOException exception) {
throw new IllegalStateException("Fail to export active rules.", exception);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ private Class<?> getClass(String checkName) {
try {
return Class.forName(checkName, true, loader);
}
catch (ClassNotFoundException ex) {
catch (ClassNotFoundException exception) {
throw new IllegalStateException("exception occured during getClass for " + checkName,
ex);
exception);
}
}

Expand Down Expand Up @@ -320,8 +320,9 @@ private static String getRuleTag(String checkPackage,
try (InputStream inputStream = CheckstyleMetadata.class.getResourceAsStream(fileName)) {
sonarRulePropertyLoader = mapper.readValue(inputStream, SonarRulePropertyLoader.class);
}
catch (IOException ex) {
throw new IllegalStateException("Exception during yaml loading of " + fileName, ex);
catch (IOException exception) {
throw new IllegalStateException("Exception during yaml loading of " + fileName,
exception);
}
final Map<String, SonarRulePropertyLoader.AdditionalRuleProperties> additionalDetails =
new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@ public static AbstractCheck getCheck(String checkName) {
final Set<String> packageNames = PackageNamesLoader.getPackageNames(classLoader);
packageObjectFactory = new PackageObjectFactory(packageNames, classLoader);
}
catch (CheckstyleException ex) {
catch (CheckstyleException exception) {
throw new IllegalStateException("exception happened during initialization of"
+ " PackageObjectFactory while loading of " + checkName, ex);
+ " PackageObjectFactory while loading of " + checkName, exception);
}
}

try {
return (AbstractCheck) packageObjectFactory.createModule(checkName);
}
catch (CheckstyleException ex) {
throw new IllegalStateException("exception occured during load of " + checkName, ex);
catch (CheckstyleException exception) {
throw new IllegalStateException("exception occured during load of " + checkName,
exception);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ public void exportProfile(ActiveRules activeRules, Writer writer) {
try {
writer.write("<conf/>");
}
catch (IOException ex) {
throw new IllegalStateException(ex);
catch (IOException exception) {
throw new IllegalStateException(exception);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ public void activeRulesThrowsException() {
new DefaultActiveRules(Collections.emptyList()), new IoExceptionWriter());
Assert.fail("IOException while writing should not be ignored");
}
catch (IllegalStateException ex) {
Assertions.assertThat(ex.getMessage()).isEqualTo("Fail to export active rules.");
catch (IllegalStateException exception) {
Assertions.assertThat(exception.getMessage()).isEqualTo("Fail to export active rules.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void test() {
// such number should not change during checkstyle version upgrade
assertThat(duplicatedRuleWithTemplate).hasSize(0);
// all new Rules should fall in this group
assertThat(rulesWithDuplicateTemplate).hasSize(192);
assertThat(rulesWithDuplicateTemplate).hasSize(195);

for (RulesDefinition.Rule rule : rules) {
assertThat(rule.key()).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public void testToSeverityWrongString() {
CheckstyleSeverityUtils.toSeverity("nothing");
Assert.fail("IOException while writing should not be ignored");
}
catch (IllegalArgumentException ex) {
assertThat(ex.getMessage()).isEqualTo("Priority not supported: nothing");
catch (IllegalArgumentException exception) {
assertThat(exception.getMessage()).isEqualTo("Priority not supported: nothing");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public static String getResourceContent(String path) {
return Resources.toString(Resources.getResource(CheckstyleTestUtils.class, path),
Charsets.UTF_8);
}
catch (IOException ex) {
throw new IllegalArgumentException("Could not load resource " + path, ex);
catch (IOException exception) {
throw new IllegalArgumentException("Could not load resource " + path, exception);
}
}

Expand All @@ -53,8 +53,8 @@ public static void assertSimilarXml(String expectedXml, String xml) {
try {
diff = XMLUnit.compareXML(xml, expectedXml);
}
catch (SAXException | IOException ex) {
throw new IllegalArgumentException("Could not run XML comparison", ex);
catch (SAXException | IOException exception) {
throw new IllegalArgumentException("Could not run XML comparison", exception);
}
final String message = "Diff: " + diff + CharUtils.LF + "XML: " + xml;
assertTrue(message, diff.similar());
Expand Down