Skip to content

Commit 9c10308

Browse files
rnveachmuhlba91
authored andcommitted
infra: upgrade verify checkstyle version to 10
1 parent a7ba973 commit 9c10308

File tree

6 files changed

+60
-40
lines changed

6 files changed

+60
-40
lines changed

config/import-control-test.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
"-//Checkstyle//DTD ImportControl Configuration 1.4//EN"
44
"https://checkstyle.org/dtds/import_control_1_4.dtd">
55

6-
<import-control pkg="org.sonar.plugins.checkstyle">
6+
<import-control
7+
pkg="(|
8+
|org\.sonar\.plugins\.checkstyle|
9+
|org\.checkstyle\.plugins\.sonar)"
10+
regex="true">
711

812
<allow pkg=".*" regex="true" />
913

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@
9898
<sonar.version>8.9.0.43852</sonar.version>
9999
<sonar-java.version>7.2.0.26923</sonar-java.version>
100100
<maven.checkstyle.plugin.version>3.1.2</maven.checkstyle.plugin.version>
101-
<maven.sevntu.checkstyle.plugin.version>1.40.0</maven.sevntu.checkstyle.plugin.version>
101+
<maven.sevntu.checkstyle.plugin.version>1.42.0</maven.sevntu.checkstyle.plugin.version>
102102
<!-- it should be a version of checkstyle that is compatible/compiled with sevntu -->
103103
<maven.sevntu.checkstyle.plugin.checkstyle.version>
104-
8.35
104+
10.0
105105
</maven.sevntu.checkstyle.plugin.checkstyle.version>
106106
<maven.jacoco.plugin.version>0.8.5</maven.jacoco.plugin.version>
107107
<java.version>11</java.version>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public CheckstyleExecutor(CheckstyleConfiguration configuration,
6363

6464
/**
6565
* Execute Checkstyle and return the generated XML report.
66+
*
6667
* @noinspection TooBroadScope
6768
*/
6869
public void execute(SensorContext context) {

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

Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction;
3535
import org.sonar.api.server.rule.RuleParamType;
3636
import org.sonar.api.server.rule.RulesDefinition;
37+
import org.sonar.plugins.checkstyle.metadata.SonarRulePropertyLoader.AdditionalRuleProperties;
3738

3839
import com.fasterxml.jackson.databind.DeserializationFeature;
3940
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -95,44 +96,55 @@ public void createRulesWithMetadata() {
9596

9697
metadataRepo.entrySet().stream()
9798
.filter(entry -> entry.getValue().getModuleType() == ModuleType.CHECK)
98-
.forEach(check -> {
99-
final ModuleDetails moduleDetails = check.getValue();
100-
final boolean isTemplate = isTemplateRule(moduleDetails);
101-
final String fullCheckName = getFullCheckName(moduleDetails.getName());
102-
final String fullQualifiedName = moduleDetails.getFullQualifiedName();
103-
final RulesDefinition.NewRule rule;
104-
if (isTemplate) {
105-
rule = repository
106-
.createRule(fullQualifiedName + "template")
107-
.setName(fullCheckName + " Template");
108-
}
109-
else {
110-
rule = repository
111-
.createRule(fullQualifiedName)
112-
.setName(fullCheckName);
113-
}
114-
rule.setHtmlDescription(moduleDetails.getDescription())
115-
.setInternalKey(getInternalKey(moduleDetails))
116-
.setSeverity("MINOR")
117-
.setStatus(RuleStatus.READY);
118-
if (!NO_SQALE.contains(rule.key())) {
119-
rule.setDebtRemediationFunction(debtRemediationFunction);
120-
}
121-
final String tag = getRuleTag(moduleDetails.getFullQualifiedName(),
122-
additionalRuleData.get(check.getKey()));
123-
if (tag != null) {
124-
rule.setTags(tag);
125-
}
126-
if (isTemplate) {
127-
rule.setTemplate(true);
128-
}
99+
.forEach(check -> forEachCheck(check, additionalRuleData, debtRemediationFunction));
100+
}
129101

130-
for (ModulePropertyDetails property : moduleDetails.getProperties()) {
131-
constructParams(moduleDetails.getName(),
132-
rule.createParam(property.getName()),
133-
property);
134-
}
135-
});
102+
/**
103+
* Processing to do when examining each check found.
104+
*
105+
* @param check The check to do processing on.
106+
* @param additionalRuleData The additional rule data to save.
107+
* @param debtRemediationFunction The remediation function to use.
108+
*/
109+
private void forEachCheck(Map.Entry<String, ModuleDetails> check,
110+
Map<String, AdditionalRuleProperties> additionalRuleData,
111+
DebtRemediationFunction debtRemediationFunction) {
112+
final ModuleDetails moduleDetails = check.getValue();
113+
final boolean isTemplate = isTemplateRule(moduleDetails);
114+
final String fullCheckName = getFullCheckName(moduleDetails.getName());
115+
final String fullQualifiedName = moduleDetails.getFullQualifiedName();
116+
final RulesDefinition.NewRule rule;
117+
if (isTemplate) {
118+
rule = repository
119+
.createRule(fullQualifiedName + "template")
120+
.setName(fullCheckName + " Template");
121+
}
122+
else {
123+
rule = repository
124+
.createRule(fullQualifiedName)
125+
.setName(fullCheckName);
126+
}
127+
rule.setHtmlDescription(moduleDetails.getDescription())
128+
.setInternalKey(getInternalKey(moduleDetails))
129+
.setSeverity("MINOR")
130+
.setStatus(RuleStatus.READY);
131+
if (!NO_SQALE.contains(rule.key())) {
132+
rule.setDebtRemediationFunction(debtRemediationFunction);
133+
}
134+
final String tag = getRuleTag(moduleDetails.getFullQualifiedName(),
135+
additionalRuleData.get(check.getKey()));
136+
if (tag != null) {
137+
rule.setTags(tag);
138+
}
139+
if (isTemplate) {
140+
rule.setTemplate(true);
141+
}
142+
143+
for (ModulePropertyDetails property : moduleDetails.getProperties()) {
144+
constructParams(moduleDetails.getName(),
145+
rule.createParam(property.getName()),
146+
property);
147+
}
136148
}
137149

138150
/**
@@ -222,6 +234,7 @@ else if ("anyTokenTypesSet".equals(paramType)) {
222234
/**
223235
* This check is required since the PARAM_TYPE column has size 512, and exceeding it
224236
* will result in an error in DB updates
237+
*
225238
* @param values array of values
226239
* @return true if the size has exceeded the limit
227240
*/

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public void before() {
7878

7979
/**
8080
* We do suppression to keep code the same in view
81+
*
8182
* @noinspection TooBroadScope
8283
*/
8384
@Test

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public void getUrlException() throws URISyntaxException {
105105

106106
/**
107107
* We do suppression as we need to cache value initialLocale
108+
*
108109
* @noinspection TooBroadScope
109110
*/
110111
@Test

0 commit comments

Comments
 (0)