Skip to content

Commit

Permalink
Issue #502: update to LTS 9.9; cleanup deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
muhlba91 committed Mar 1, 2024
1 parent 8462c9e commit 7056481
Show file tree
Hide file tree
Showing 43 changed files with 285 additions and 1,092 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
jobs:
build-project:
docker:
- image: cimg/openjdk:11.0.16
- image: cimg/openjdk:17.0.10

steps:
- checkout
Expand All @@ -15,7 +15,7 @@ jobs:

execute-sonar:
docker:
- image: sonarqube:9.0-community
- image: sonarqube:9.9-community
working_directory: ~/repo

environment:
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/sonar-checkstyle-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ jobs:
- name: install
run: "./.ci/ci.sh install"

integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: run integration tests
run: "./.ci/ci.sh integration-tests"
# depreacted for now since SQ removed the application ZIP files needed for the integration tests
# integration-tests:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Set up JDK 11
# uses: actions/setup-java@v1
# with:
# java-version: 11
# - name: run integration tests
# run: "./.ci/ci.sh integration-tests"

nondex:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion config/import-control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<allow class="com.puppycrawl.tools.checkstyle.api.AuditEvent"/>
<allow class="com.puppycrawl.tools.checkstyle.api.AuditListener"/>
<allow class="com.puppycrawl.tools.checkstyle.api.AutomaticBean"/>
<allow class="com.puppycrawl.tools.checkstyle.AbstractAutomaticBean"/>
<allow class="com.puppycrawl.tools.checkstyle.api.CheckstyleException"/>
<allow class="com.puppycrawl.tools.checkstyle.api.Configuration"/>
<allow class="com.puppycrawl.tools.checkstyle.api.SeverityLevel"/>
Expand Down
3 changes: 0 additions & 3 deletions config/sevntu-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
<suppress checks="AvoidModifiersForTypes" files=".*[\\/]src[\\/]main[\\/]"/>
<!-- END of legacy code -->


<!-- parsing of xml imply reference attribute names, does not make sense to move all to special variables -->
<suppress checks="MultipleStringLiteralsExtended" files="CheckstyleProfileImporter\.java"/>
<!-- till https://github.com/checkstyle/sonar-checkstyle/issues/135 -->
<suppress checks="MultipleStringLiteralsExtended" files="CheckstylePlugin\.java"/>

Expand Down
2 changes: 0 additions & 2 deletions config/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
<suppress checks="IllegalCatch" files=".*[\\/]src[\\/]main[\\/]"/>
<!-- END of legacy code -->

<!-- parsing of xml imply reference attribute names, does not make sense to move all to special variables -->
<suppress checks="MultipleStringLiterals" files="CheckstyleProfileImporter\.java"/>
<!-- till https://github.com/checkstyle/sonar-checkstyle/issues/135 -->
<suppress checks="MultipleStringLiterals" files=".*[\\/]CheckstylePlugin\.java"/>
<!-- messing test code with such optimization does not make sense , readability will decrease -->
Expand Down
34 changes: 11 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@

<properties>
<checkstyle.version>10.12.5</checkstyle.version>
<sonar.version>8.9.0.43852</sonar.version>
<sonar-java.version>7.2.0.26923</sonar-java.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>
Expand Down Expand Up @@ -158,9 +158,9 @@
<version>32.0.0-jre</version>
</dependency>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<groupId>org.sonarsource.api.plugin</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>${sonar.version}</version>
<version>${sonar.api-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -558,6 +558,13 @@
<goal>report</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
Expand All @@ -573,7 +580,6 @@
<exclude>org.sonar.plugins.checkstyle.CheckstyleExecutor</exclude>
<exclude>org.sonar.plugins.checkstyle.CheckstyleSeverityUtils</exclude>
<exclude>org.sonar.plugins.checkstyle.CheckstyleConfiguration</exclude>
<exclude>org.sonar.plugins.checkstyle.CheckstyleProfileImporter</exclude>
<exclude>org.sonar.plugins.checkstyle.CheckstyleRulesDefinition</exclude>
<exclude>org.sonar.plugins.checkstyle.metadata.CheckstyleMetadata</exclude>
<exclude>org.sonar.plugins.checkstyle.metadata.CheckUtil</exclude>
Expand Down Expand Up @@ -682,24 +688,6 @@
</limit>
</limits>
</rule>
<rule>
<element>CLASS</element>
<includes>
<include>org.sonar.plugins.checkstyle.CheckstyleProfileImporter</include>
</includes>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>1.0</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.96</minimum>
</limit>
</limits>
</rule>
<rule>
<element>CLASS</element>
<includes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.ExtensionPoint;
import org.sonar.api.batch.ScannerSide;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.rule.ActiveRule;
Expand All @@ -34,6 +33,7 @@
import org.sonar.api.batch.sensor.issue.NewIssue;
import org.sonar.api.batch.sensor.issue.NewIssueLocation;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.scanner.ScannerSide;

import com.google.common.annotations.VisibleForTesting;
import com.puppycrawl.tools.checkstyle.api.AuditEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.ExtensionPoint;
import org.sonar.api.batch.ScannerSide;
import org.sonar.api.batch.fs.FilePredicates;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.scanner.ScannerSide;

import com.google.common.annotations.VisibleForTesting;
import com.puppycrawl.tools.checkstyle.ConfigurationLoader;
Expand All @@ -59,6 +59,17 @@ public class CheckstyleConfiguration {
private final FileSystem fileSystem;

public CheckstyleConfiguration(
org.sonar.api.config.Configuration conf,
ActiveRules activeRules,
FileSystem fileSystem) {
this.conf = conf;
confExporter = new CheckstyleProfileExporter(conf);
this.activeRules = activeRules;
this.fileSystem = fileSystem;
}

// used for unit testing
protected CheckstyleConfiguration(
org.sonar.api.config.Configuration conf,
CheckstyleProfileExporter confExporter,
ActiveRules activeRules,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.ExtensionPoint;
import org.sonar.api.batch.ScannerSide;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.scanner.ScannerSide;

import com.google.common.annotations.VisibleForTesting;
import com.puppycrawl.tools.checkstyle.AbstractAutomaticBean;
import com.puppycrawl.tools.checkstyle.Checker;
import com.puppycrawl.tools.checkstyle.PackageNamesLoader;
import com.puppycrawl.tools.checkstyle.XMLLogger;
import com.puppycrawl.tools.checkstyle.api.AutomaticBean;

@ExtensionPoint
@ScannerSide
Expand Down Expand Up @@ -98,16 +97,16 @@ private void executeWithClassLoader() {
LOG.info("Checkstyle output report: {}", xmlReport.getAbsolutePath());
xmlOutput = FileUtils.openOutputStream(xmlReport);
checker.addListener(
new XMLLogger(xmlOutput, AutomaticBean.OutputStreamOptions.CLOSE));
new XMLLogger(xmlOutput, AbstractAutomaticBean.OutputStreamOptions.CLOSE));
}

checker.setCharset(configuration.getCharset().name());
checker.configure(configuration.getCheckstyleConfiguration());
checker.process(configuration
.getSourceFiles()
.stream()
.map(InputFile::file)
.collect(Collectors.toList()));
.stream()
.map(inputFile -> new File(inputFile.uri()))
.collect(Collectors.toList()));
}
catch (Exception ex) {
throw new IllegalStateException("Can not execute Checkstyle", ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,22 @@ public static List getExtensions() {
.name("Checker Filters")
.description(CHECKER_FILTERS_DESCRIPTION)
.type(PropertyType.TEXT)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE).build(),
.onQualifiers(Qualifiers.PROJECT, Qualifiers.PROJECT).build(),
PropertyDefinition.builder(CheckstyleConstants.TREEWALKER_FILTERS_KEY)
.defaultValue(CheckstyleConstants.TREEWALKER_FILTERS_DEFAULT_VALUE)
.category(CHECKSTYLE_CATEGORY_NAME)
.subCategory(CHECKSTYLE_SUB_CATEGORY_NAME)
.name("Treewalker Filters")
.description(TREEWALKER_FILTERS_DESCRIPTION)
.type(PropertyType.TEXT)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE).build(),
.onQualifiers(Qualifiers.PROJECT, Qualifiers.PROJECT).build(),
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, Qualifiers.MODULE)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.PROJECT)
.build(),
PropertyDefinition.builder(CheckstyleConfiguration.PROPERTY_GENERATE_XML)
.defaultValue("false").category(CHECKSTYLE_CATEGORY_NAME)
Expand All @@ -101,7 +101,6 @@ public static List getExtensions() {

CheckstyleSensor.class, CheckstyleConfiguration.class,
CheckstyleExecutor.class, CheckstyleAuditListener.class,
CheckstyleProfileExporter.class, CheckstyleProfileImporter.class,
CheckstyleRulesDefinition.class);
}

Expand Down
Loading

0 comments on commit 7056481

Please sign in to comment.