Skip to content

Commit 263e7c8

Browse files
rnveachmuhlba91
authored andcommitted
Issue #378: remove outdated checkstyle integration code
1 parent 220c64d commit 263e7c8

File tree

2 files changed

+0
-67
lines changed

2 files changed

+0
-67
lines changed

config/suppressions.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
<suppress checks="ImportControl" files=".*[\\/]src[\\/]test[\\/]"/>
1717
<!-- END of legacy code -->
1818

19-
<!-- empty file is needed for backwards compatibility -->
20-
<suppress checks="RegexpMultiline" files="checkstyle\.properties"/>
2119
<!-- parsing of xml imply reference attribute names, does not make sense to move all to special variables -->
2220
<suppress checks="MultipleStringLiterals" files="CheckstyleProfileImporter\.java"/>
2321
<!-- till https://github.com/checkstyle/sonar-checkstyle/issues/135 -->

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

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,10 @@
1919

2020
package org.sonar.plugins.checkstyle;
2121

22-
import java.io.IOException;
23-
import java.io.InputStream;
24-
import java.util.Objects;
25-
import java.util.Properties;
26-
2722
import org.sonar.api.ExtensionPoint;
2823
import org.sonar.api.batch.ScannerSide;
2924
import org.sonar.api.server.rule.RulesDefinition;
30-
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
3125
import org.sonar.plugins.checkstyle.metadata.CheckstyleMetadata;
32-
import org.sonar.squidbridge.rules.ExternalDescriptionLoader;
33-
import org.sonar.squidbridge.rules.SqaleXmlLoader;
34-
35-
import com.google.common.annotations.VisibleForTesting;
3626

3727
@ExtensionPoint
3828
@ScannerSide
@@ -43,65 +33,10 @@ public void define(Context context) {
4333
final NewRepository repository = context.createRepository(
4434
CheckstyleConstants.REPOSITORY_KEY, "java").setName(
4535
CheckstyleConstants.REPOSITORY_NAME);
46-
try {
47-
extractRulesData(repository, "/org/sonar/plugins/checkstyle/rules.xml",
48-
"/org/sonar/l10n/checkstyle/rules/checkstyle");
49-
}
50-
catch (IOException ex) {
51-
throw new IllegalStateException("Exception during extractRulesData", ex);
52-
}
5336

5437
final CheckstyleMetadata checkstyleMetadata = new CheckstyleMetadata(repository);
5538
checkstyleMetadata.createRulesWithMetadata();
5639

5740
repository.done();
5841
}
59-
60-
@VisibleForTesting
61-
static void extractRulesData(NewRepository repository, String xmlRulesFilePath,
62-
String htmlDescriptionFolder) throws IOException {
63-
final RulesDefinitionXmlLoader ruleLoader = new RulesDefinitionXmlLoader();
64-
try (InputStream resource = CheckstyleRulesDefinition.class
65-
.getResourceAsStream(xmlRulesFilePath)) {
66-
ruleLoader.load(repository, resource, "UTF-8");
67-
}
68-
ExternalDescriptionLoader.loadHtmlDescriptions(repository, // NOSONAR
69-
htmlDescriptionFolder);
70-
try (InputStream resource = CheckstyleRulesDefinition.class
71-
.getResourceAsStream("/org/sonar/l10n/checkstyle.properties")) {
72-
loadNames(repository, resource);
73-
}
74-
SqaleXmlLoader.load(repository, "/com/sonar/sqale/checkstyle-model.xml"); // NOSONAR
75-
}
76-
77-
private static void loadNames(NewRepository repository, InputStream stream) {
78-
// code taken from:
79-
// https://github.com/SonarSource/sslr-squid-bridge/blob/2.5.2/
80-
// src/main/java/org/sonar/squidbridge/rules/PropertyFileLoader.java#L46
81-
final Properties properties = new Properties();
82-
try {
83-
properties.load(stream);
84-
}
85-
catch (IOException ex) {
86-
throw new IllegalArgumentException("Could not read names from properties", ex);
87-
}
88-
89-
if (Objects.nonNull(repository.rules())) {
90-
repository.rules().forEach(rule -> {
91-
final String baseKey = "rule." + repository.key() + "." + rule.key();
92-
final String nameKey = baseKey + ".name";
93-
final String ruleName = properties.getProperty(nameKey);
94-
if (Objects.nonNull(ruleName)) {
95-
rule.setName(ruleName);
96-
}
97-
rule.params().forEach(param -> {
98-
final String paramDescriptionKey = baseKey + ".param." + param.key();
99-
final String paramDescription = properties.getProperty(paramDescriptionKey);
100-
if (Objects.nonNull(paramDescription)) {
101-
param.setDescription(paramDescription);
102-
}
103-
});
104-
});
105-
}
106-
}
10742
}

0 commit comments

Comments
 (0)