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 |
|-------------------|-----------|-----------|------------|-----|
| 14.3.0 | 25.2 | 26.4+ | 14.3.0 | 21 |
| 13.8.0 | 25.2 | 26.4+ | 13.8.0 | 21 |
| 13.7.0 | 25.2 | 26.4+ | 13.7.0 | 21 |
| 13.4.1 | 25.2 | 26.4+ | 13.4.1 | 21 |
Expand Down
2 changes: 2 additions & 0 deletions config/pmd-main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<exclude name="AvoidFileStream"/>
<exclude name="ClassNamingConventions"/>
<exclude name="TooManyMethods"/>
<!-- Jackson instantiates SonarRulePropertyLoader through its private constructor -->
<exclude name="MissingStaticMethodInNonInstantiatableClass"/>
Comment on lines +20 to +21
</rule>

</ruleset>
2 changes: 2 additions & 0 deletions config/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@
<suppress checks="MagicNumber" files=".*[\\/]src[\\/]test[\\/]"/>
<suppress checks="AnonInnerLength" files=".*[\\/]src[\\/]test[\\/]"/>
<suppress checks="ClassDataAbstractionCoupling" files=".*[\\/]src[\\/]test[\\/]"/>
<suppress checks="MissingCtor" files=".*[\\/]src[\\/]test[\\/]"/>
<suppress checks="MissingCtor" files=".*[\\/]src[\\/]it[\\/]"/>
<suppress checks="TrailingComment" files=".*[\\/]Checkstyle(RulesDefinition|Metadata)\.java"/>
</suppressions>
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
</ciManagement>

<properties>
<checkstyle.version>13.8.0</checkstyle.version>
<checkstyle.version>14.3.0</checkstyle.version>
<sonar.version>25.2.0.102705</sonar.version>
<sonar.api-version>11.1.0.2693</sonar.api-version>
<maven.sevntu.checkstyle.plugin.version>1.44.1</maven.sevntu.checkstyle.plugin.version>
Expand All @@ -102,7 +102,7 @@
13.8.0
</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>
<checkstyle.configLocation>https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-${maven.sevntu.checkstyle.plugin.checkstyle.version}/config/checkstyle-checks.xml</checkstyle.configLocation>
<checkstyle.sevntu.configLocation>https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-${maven.sevntu.checkstyle.plugin.checkstyle.version}/config/checkstyle-sevntu-checks.xml</checkstyle.sevntu.configLocation>
<checkstyle.sevntu.cache.file>${project.build.outputDirectory}/sevntu.cache</checkstyle.sevntu.cache.file>
<maven.jacoco.plugin.version>0.8.14</maven.jacoco.plugin.version>
Expand Down Expand Up @@ -392,29 +392,29 @@
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>7.24.0</version>
<version>7.28.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>
<version>7.24.0</version>
<version>7.28.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-javascript</artifactId>
<version>7.24.0</version>
<version>7.28.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-jsp</artifactId>
<version>7.24.0</version>
<version>7.28.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.9.8.3</version>
<version>4.10.4.1</version>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
Expand Down
2 changes: 2 additions & 0 deletions src/it/java/org/checkstyle/plugins/sonar/CheckJarTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.junit.jupiter.api.Test;

class CheckJarTest {

private static final String MATCHER = ".*checkstyle-sonar-plugin-"
+ "\\d+\\.\\d+(.\\d+)?(-SNAPSHOT)?\\.jar";

Expand All @@ -45,4 +46,5 @@ void testJarPresence() throws IOException {
.toList();
assertFalse(files.isEmpty(), "Jar should exists");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,5 @@ private String retrieveToken() {
}
return token;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
@ExtensionPoint
@ScannerSide
public class CheckstyleConfiguration {

public static final String PROPERTY_GENERATE_XML = "sonar.checkstyle.generateXml";

private static final Logger LOG = LoggerFactory.getLogger(CheckstyleConfiguration.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ public final class CheckstyleConstants {

private CheckstyleConstants() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
@ExtensionPoint
@ScannerSide
public class CheckstyleExecutor {

public static final String PROPERTIES_PATH =
"/org/sonar/plugins/checkstyle/checkstyle-plugin.properties";

Expand Down Expand Up @@ -150,4 +151,5 @@ URL getUrl(URI uri) {
+ "Classpath element is invalid: " + uri, exception);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.sonar.api.resources.Qualifiers;

public final class CheckstylePlugin implements Plugin {

private static final String CHECKSTYLE_CATEGORY_NAME = "java";
private static final String CHECKSTYLE_SUB_CATEGORY_NAME = "Checkstyle";

Expand Down Expand Up @@ -76,7 +77,7 @@
.name("Checker Filters")
.description(CHECKER_FILTERS_DESCRIPTION)
.type(PropertyType.TEXT)
.onQualifiers(Qualifiers.PROJECT).build(),

Check warning on line 80 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Execute SonarQube Plugin (21, latest)

onQualifiers(java.lang.String,java.lang.String...) in org.sonar.api.config.PropertyDefinition.Builder has been deprecated and marked for removal

Check warning on line 80 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Execute SonarQube Plugin (21, latest)

org.sonar.api.resources.Qualifiers in org.sonar.api.resources has been deprecated and marked for removal

Check warning on line 80 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Maven Install (21)

onQualifiers(java.lang.String,java.lang.String...) in org.sonar.api.config.PropertyDefinition.Builder has been deprecated and marked for removal

Check warning on line 80 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Maven Install (21)

org.sonar.api.resources.Qualifiers in org.sonar.api.resources has been deprecated and marked for removal

Check warning on line 80 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Maven Nondex (21)

onQualifiers(java.lang.String,java.lang.String...) in org.sonar.api.config.PropertyDefinition.Builder has been deprecated and marked for removal

Check warning on line 80 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Maven Nondex (21)

org.sonar.api.resources.Qualifiers in org.sonar.api.resources has been deprecated and marked for removal

Check warning on line 80 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Execute SonarQube Plugin (21, 26.1.0.118079-community)

onQualifiers(java.lang.String,java.lang.String...) in org.sonar.api.config.PropertyDefinition.Builder has been deprecated and marked for removal

Check warning on line 80 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Execute SonarQube Plugin (21, 26.1.0.118079-community)

org.sonar.api.resources.Qualifiers in org.sonar.api.resources has been deprecated and marked for removal

Check warning on line 80 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Integration Tests (21)

onQualifiers(java.lang.String,java.lang.String...) in org.sonar.api.config.PropertyDefinition.Builder has been deprecated and marked for removal

Check warning on line 80 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Integration Tests (21)

org.sonar.api.resources.Qualifiers in org.sonar.api.resources has been deprecated and marked for removal
PropertyDefinition.builder(CheckstyleConstants.TREEWALKER_FILTERS_KEY)
.defaultValue(CheckstyleConstants.TREEWALKER_FILTERS_DEFAULT_VALUE)
.category(CHECKSTYLE_CATEGORY_NAME)
Expand All @@ -84,14 +85,14 @@
.name("Treewalker Filters")
.description(TREEWALKER_FILTERS_DESCRIPTION)
.type(PropertyType.TEXT)
.onQualifiers(Qualifiers.PROJECT).build(),

Check warning on line 88 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Execute SonarQube Plugin (21, latest)

onQualifiers(java.lang.String,java.lang.String...) in org.sonar.api.config.PropertyDefinition.Builder has been deprecated and marked for removal

Check warning on line 88 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Execute SonarQube Plugin (21, latest)

org.sonar.api.resources.Qualifiers in org.sonar.api.resources has been deprecated and marked for removal

Check warning on line 88 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Maven Install (21)

onQualifiers(java.lang.String,java.lang.String...) in org.sonar.api.config.PropertyDefinition.Builder has been deprecated and marked for removal

Check warning on line 88 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Maven Install (21)

org.sonar.api.resources.Qualifiers in org.sonar.api.resources has been deprecated and marked for removal

Check warning on line 88 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Maven Nondex (21)

onQualifiers(java.lang.String,java.lang.String...) in org.sonar.api.config.PropertyDefinition.Builder has been deprecated and marked for removal

Check warning on line 88 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Maven Nondex (21)

org.sonar.api.resources.Qualifiers in org.sonar.api.resources has been deprecated and marked for removal

Check warning on line 88 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Execute SonarQube Plugin (21, 26.1.0.118079-community)

onQualifiers(java.lang.String,java.lang.String...) in org.sonar.api.config.PropertyDefinition.Builder has been deprecated and marked for removal

Check warning on line 88 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Execute SonarQube Plugin (21, 26.1.0.118079-community)

org.sonar.api.resources.Qualifiers in org.sonar.api.resources has been deprecated and marked for removal

Check warning on line 88 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Integration Tests (21)

onQualifiers(java.lang.String,java.lang.String...) in org.sonar.api.config.PropertyDefinition.Builder has been deprecated and marked for removal

Check warning on line 88 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Integration Tests (21)

org.sonar.api.resources.Qualifiers in org.sonar.api.resources has been deprecated and marked for removal
PropertyDefinition.builder(CheckstyleConstants.CHECKER_TAB_WIDTH)
.category(CHECKSTYLE_CATEGORY_NAME)
.subCategory(CHECKSTYLE_SUB_CATEGORY_NAME)
.name("Tab Width")
.description(CHECKER_TAB_WIDTH_DESCRIPTION)
.type(PropertyType.INTEGER)
.onQualifiers(Qualifiers.PROJECT)

Check warning on line 95 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Execute SonarQube Plugin (21, latest)

onQualifiers(java.lang.String,java.lang.String...) in org.sonar.api.config.PropertyDefinition.Builder has been deprecated and marked for removal

Check warning on line 95 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Execute SonarQube Plugin (21, latest)

org.sonar.api.resources.Qualifiers in org.sonar.api.resources has been deprecated and marked for removal

Check warning on line 95 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Maven Install (21)

onQualifiers(java.lang.String,java.lang.String...) in org.sonar.api.config.PropertyDefinition.Builder has been deprecated and marked for removal

Check warning on line 95 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Maven Install (21)

org.sonar.api.resources.Qualifiers in org.sonar.api.resources has been deprecated and marked for removal

Check warning on line 95 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Maven Nondex (21)

onQualifiers(java.lang.String,java.lang.String...) in org.sonar.api.config.PropertyDefinition.Builder has been deprecated and marked for removal

Check warning on line 95 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Maven Nondex (21)

org.sonar.api.resources.Qualifiers in org.sonar.api.resources has been deprecated and marked for removal

Check warning on line 95 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Execute SonarQube Plugin (21, 26.1.0.118079-community)

onQualifiers(java.lang.String,java.lang.String...) in org.sonar.api.config.PropertyDefinition.Builder has been deprecated and marked for removal

Check warning on line 95 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Execute SonarQube Plugin (21, 26.1.0.118079-community)

org.sonar.api.resources.Qualifiers in org.sonar.api.resources has been deprecated and marked for removal

Check warning on line 95 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Integration Tests (21)

onQualifiers(java.lang.String,java.lang.String...) in org.sonar.api.config.PropertyDefinition.Builder has been deprecated and marked for removal

Check warning on line 95 in src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

View workflow job for this annotation

GitHub Actions / Integration Tests (21)

org.sonar.api.resources.Qualifiers in org.sonar.api.resources has been deprecated and marked for removal
.build(),
PropertyDefinition.builder(CheckstyleConfiguration.PROPERTY_GENERATE_XML)
.defaultValue("false").category(CHECKSTYLE_CATEGORY_NAME)
Expand All @@ -108,4 +109,5 @@
public void define(final Context context) {
context.addExtensions(getExtensions());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ public void exportProfile(ActiveRules activeRules, Writer writer) {

}

private void generateXml(Writer writer, Map<String,
List<ActiveRule>> activeRulesByConfigKey) throws IOException {
private void generateXml(Writer writer,
Map<String, List<ActiveRule>> activeRulesByConfigKey)
throws IOException {
appendXmlHeader(writer);
appendTabWidth(writer);
appendCustomFilters(writer);
Expand All @@ -99,7 +100,8 @@ private void appendTabWidth(Writer writer) throws IOException {
}

private static void appendCheckerModules(Writer writer,
Map<String, List<ActiveRule>> activeRulesByConfigKey) throws IOException {
Map<String, List<ActiveRule>> activeRulesByConfigKey)
throws IOException {
for (Map.Entry<String, List<ActiveRule>> entry : activeRulesByConfigKey.entrySet()) {
final String configKey = entry.getKey();
if (!isInTreeWalker(configKey)) {
Expand All @@ -112,7 +114,8 @@ private static void appendCheckerModules(Writer writer,
}

private void appendTreeWalker(Writer writer,
Map<String, List<ActiveRule>> activeRulesByConfigKey) throws IOException {
Map<String, List<ActiveRule>> activeRulesByConfigKey)
throws IOException {
writer.append("<module name=\"TreeWalker\">");
if (isSuppressWarningsEnabled()) {
writer.append("<module name=\"SuppressWarningsHolder\"/> ");
Expand Down Expand Up @@ -189,7 +192,8 @@ private static void appendModule(Writer writer, ActiveRule activeRule)
writer.append(CLOSE_MODULE);
}

private static void appendRuleParameters(Writer writer, ActiveRule activeRule)
private static void appendRuleParameters(Writer writer,
ActiveRule activeRule)
throws IOException {
for (Map.Entry<String, String> param : activeRule.params().entrySet()) {
if (StringUtils.isNotBlank(param.getValue())) {
Expand All @@ -199,7 +203,8 @@ private static void appendRuleParameters(Writer writer, ActiveRule activeRule)
}

private static void appendModuleProperty(Writer writer, String propertyKey,
@Nullable String propertyValue) throws IOException {
@Nullable String propertyValue)
throws IOException {
if (StringUtils.isNotBlank(propertyValue)) {
writer.append("<property name=\"");
writer.append(StringEscapeUtils.escapeXml10(propertyKey));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ public void define(Context context) {

repository.done();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.sonar.api.scanner.sensor.ProjectSensor;

public class CheckstyleSensor implements ProjectSensor {

private static final String CHECKSTYLE_ENABLED = "sonar.checkstyle.enabled";
private static final Logger LOG = LoggerFactory.getLogger(CheckstyleSensor.class);

Expand Down Expand Up @@ -54,4 +55,5 @@ public void execute(SensorContext context) {
public String toString() {
return getClass().getSimpleName();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ public static String toSeverity(String priority) {
throw new IllegalArgumentException("Priority not supported: " + priority);
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.puppycrawl.tools.checkstyle.utils.TokenUtil;

public final class CheckUtil {

private CheckUtil() {
}

Expand Down Expand Up @@ -71,4 +72,5 @@ private static String getTokens(Function<Integer, String> function,
.map(function)
.collect(Collectors.joining(","));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import com.puppycrawl.tools.checkstyle.meta.XmlMetaReader;

public class CheckstyleMetadata {

private static final List<String> NO_SQALE = ImmutableList.of(
"com.puppycrawl.tools.checkstyle.checks.TranslationCheck",
"com.puppycrawl.tools.checkstyle.checks.TodoCommentCheck",
Expand Down Expand Up @@ -364,4 +365,5 @@ private static String getInternalKey(ModuleDetails moduleDetails) {
}
return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;

public final class ModuleFactory {

private static PackageObjectFactory packageObjectFactory;

private ModuleFactory() {
Expand All @@ -53,4 +54,5 @@ public static AbstractCheck getCheck(String checkName) {
exception);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@
import java.util.Collections;
import java.util.List;

public class SonarRulePropertyLoader {
public final class SonarRulePropertyLoader {

private List<AdditionalRuleProperties> rules;

private SonarRulePropertyLoader() {
Comment on lines +26 to +30
}

/**
* Retrieves the list of rules.
*
Expand All @@ -44,10 +48,13 @@ public void setRules(List<AdditionalRuleProperties> rules) {
this.rules = new ArrayList<>(rules);
}

public static class AdditionalRuleProperties {
public static final class AdditionalRuleProperties {
private String rule;
private String tag;

private AdditionalRuleProperties() {
}

/**
* Retrieves the rule.
*
Expand Down Expand Up @@ -84,4 +91,5 @@ public void setTag(String tag) {
this.tag = tag;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,5 @@ private ActiveRule setupRule(String repo, String key) {
CheckstyleAuditListenerTest.class.getCanonicalName()))).thenReturn(rule);
return rule;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,5 @@ public String templateRuleKey() {
return templateActiveRuleKey;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ 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(204);
assertThat(rulesWithDuplicateTemplate).hasSize(234);

for (RulesDefinition.Rule rule : rules) {
assertThat(rule.key()).isNotNull();
Expand All @@ -102,4 +102,5 @@ void test() {
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.sonar.api.config.Configuration;

class CheckstyleSensorTest {

private static final String CHECKSTYLE_ENABLED = "sonar.checkstyle.enabled";

@Test
Expand Down Expand Up @@ -68,4 +69,5 @@ void shouldExecuteExecutorWithContext() {
void testToString() {
assertThat(new CheckstyleSensor(null).toString()).isEqualTo("CheckstyleSensor");
}

}
Loading