Skip to content

Commit d77b04f

Browse files
committed
Issue #502: update to LTS 9.9; cleanup deprecations
1 parent 8462c9e commit d77b04f

File tree

45 files changed

+354
-1202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+354
-1202
lines changed

.circleci/config.yml

Lines changed: 8 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,17 @@
11
version: 2
22

33
jobs:
4-
build-project:
4+
sonarcloud:
55
docker:
6-
- image: cimg/openjdk:11.0.16
6+
- image: cimg/openjdk:17.0
77

88
steps:
99
- checkout
10-
- run: mvn -e --no-transfer-progress package -Pno-validations
11-
- persist_to_workspace:
12-
root: /home/circleci
13-
paths:
14-
- project
15-
16-
execute-sonar:
17-
docker:
18-
- image: sonarqube:9.0-community
19-
working_directory: ~/repo
20-
21-
environment:
22-
# Customize the JVM maximum heap limit
23-
MAVEN_OPTS: -Xmx3200m
24-
25-
steps:
26-
- attach_workspace:
27-
at: /root
10+
- run: |
11+
sudo apt-get update
12+
sudo apt-get install -y jq
2813
- run:
29-
name: Install packages
30-
command: apk add maven
31-
- run:
32-
name: Copy jar
33-
command: |
34-
cp /root/project/target/checkstyle-sonar-plugin*.jar \
35-
/opt/sonarqube/extensions/plugins/
36-
- run:
37-
name: Start SonarQube web service and execute maven SonarQube build
38-
command: |
39-
# start SonarQube web server
40-
cd /opt/sonarqube/
41-
./bin/run.sh &
42-
until grep "SonarQube is up" logs/sonar.log; \
43-
do sleep 10 && echo "Waiting for web server to come up..."; \
44-
done
45-
46-
# Note that we cannot separate "start SonarQube web server" above from
47-
# this step, as we would kill web server when step is complete.
48-
cd /root/project
49-
mvn -e --no-transfer-progress sonar:sonar -Dsonar.login=admin -Dsonar.password=admin
50-
- store_artifacts:
51-
path: /root/project/target/sonar/checkstyle-result.xml
52-
- run:
53-
name: Check logs for error
54-
command: grep "ERROR" /opt/sonarqube/logs/* || test $? = 1
55-
56-
sonarqube:
57-
docker:
58-
- image: checkstyle/jdk-11-groovy-git-mvn:11.0.13__3.0.9__2.25.1__3.6.3
59-
60-
steps:
61-
- checkout
62-
- run: apt-get install -y jq
63-
- run:
64-
name: Run sonarqube
14+
name: Run Sonarcloud analysis
6515
command: |
6616
export PR_NUMBER=$CIRCLE_PR_NUMBER
6717
export PR_BRANCH_NAME=$CIRCLE_BRANCH
@@ -71,15 +21,8 @@ jobs:
7121
workflows:
7222
version: 2
7323

74-
sonarqube:
24+
sonarcloud-analysis:
7525
jobs:
76-
- sonarqube:
26+
- sonarcloud:
7727
context:
7828
- sonarqube
79-
80-
build-sonar:
81-
jobs:
82-
- build-project
83-
- execute-sonar:
84-
requires:
85-
- build-project

.github/workflows/sonar-checkstyle-workflows.yml

Lines changed: 73 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,88 @@ on:
77
pull_request:
88

99
jobs:
10-
mvn-install-java-11:
10+
mvn-install:
11+
name: Maven Install
1112
runs-on: ubuntu-latest
13+
strategy:
14+
max-parallel: 4
15+
matrix:
16+
java-version: ['11', '17']
17+
1218
steps:
13-
- uses: actions/checkout@v2
14-
- name: Set up JDK 11
15-
uses: actions/setup-java@v1
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up JDK
22+
uses: actions/setup-java@v4
1623
with:
17-
java-version: 11
18-
- name: install
19-
run: "./.ci/ci.sh install"
24+
java-version: ${{ matrix.java-version }}
25+
distribution: 'temurin'
26+
27+
- run: "./.ci/ci.sh install"
28+
29+
# depreacted for now since SQ removed the application ZIP files needed for the integration tests
30+
# integration-tests:
31+
# runs-on: ubuntu-latest
32+
# steps:
33+
# - uses: actions/checkout@v2
34+
# - name: Set up JDK 11
35+
# uses: actions/setup-java@v1
36+
# with:
37+
# java-version: 11
38+
# - name: run integration tests
39+
# run: "./.ci/ci.sh integration-tests"
2040

21-
integration-tests:
41+
nondex:
42+
name: Maven Nondex
2243
runs-on: ubuntu-latest
44+
strategy:
45+
max-parallel: 4
46+
matrix:
47+
java-version: ['11', '17']
48+
2349
steps:
24-
- uses: actions/checkout@v2
25-
- name: Set up JDK 11
26-
uses: actions/setup-java@v1
50+
- uses: actions/checkout@v4
51+
52+
- name: Set up JDK
53+
uses: actions/setup-java@v4
2754
with:
28-
java-version: 11
29-
- name: run integration tests
30-
run: "./.ci/ci.sh integration-tests"
55+
java-version: ${{ matrix.java-version }}
56+
distribution: 'temurin'
3157

32-
nondex:
58+
- run: "./.ci/ci.sh nondex"
59+
60+
execute-sonarqube-plugin:
61+
name: Execute SonarQube Plugin
3362
runs-on: ubuntu-latest
63+
3464
steps:
35-
- uses: actions/checkout@v2
36-
- name: Set up JDK 11
37-
uses: actions/setup-java@v1
65+
- name: Checkout code
66+
uses: actions/checkout@v4
67+
68+
- name: Set up JDK 17
69+
uses: actions/setup-java@v4
3870
with:
39-
java-version: 11
40-
- name: install
41-
run: "./.ci/ci.sh nondex"
71+
java-version: '17'
72+
distribution: 'temurin'
73+
74+
- name: Build Jar
75+
run: mvn -e --no-transfer-progress package -Pno-validations
76+
77+
- name: Run SonarQube
78+
run: docker run -d --name sonarqube -p 9000:9000 -v ${{ github.workspace }}/repo/target/:/opt/sonarqube/extensions/plugins/ sonarqube:9.9-community
79+
- name: Check SonarQube is Up
80+
run: |
81+
while [[ ! `curl -s http://localhost:9000/api/system/status` =~ "UP" ]]; do
82+
echo "Waiting for web server to come up..."
83+
sleep 10
84+
done
85+
86+
- name: Execute SonarQube analysis
87+
run: |
88+
mvn -e --no-transfer-progress sonar:sonar -Dsonar.login=admin -Dsonar.password=admin
4289
90+
- name: Check logs for error
91+
run: docker logs sonarqube | grep "ERROR" || test $? = 1
92+
93+
- name: Cleanup
94+
run: docker stop sonarqube

.travis.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ An Official announcement of project transfer - https://groups.google.com/d/topic
1515

1616
This plugin provides coding rules from [Checkstyle](http://checkstyle.sourceforge.net/).
1717

18-
Compatibility matrix from Sonar team: https://docs.sonarqube.org/latest/instance-administration/plugin-version-matrix/
18+
Compatibility matrix from Sonar team: https://docs.sonarsource.com/sonarqube/latest/instance-administration/plugin-version-matrix/
1919

2020
Compatibility matrix from checkstyle team:
2121

config/import-control.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<allow class="com.puppycrawl.tools.checkstyle.api.AuditEvent"/>
1717
<allow class="com.puppycrawl.tools.checkstyle.api.AuditListener"/>
18-
<allow class="com.puppycrawl.tools.checkstyle.api.AutomaticBean"/>
18+
<allow class="com.puppycrawl.tools.checkstyle.AbstractAutomaticBean"/>
1919
<allow class="com.puppycrawl.tools.checkstyle.api.CheckstyleException"/>
2020
<allow class="com.puppycrawl.tools.checkstyle.api.Configuration"/>
2121
<allow class="com.puppycrawl.tools.checkstyle.api.SeverityLevel"/>

config/sevntu-suppressions.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
<suppress checks="AvoidModifiersForTypes" files=".*[\\/]src[\\/]main[\\/]"/>
1414
<!-- END of legacy code -->
1515

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

config/suppressions.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
<suppress checks="IllegalCatch" files=".*[\\/]src[\\/]main[\\/]"/>
1212
<!-- END of legacy code -->
1313

14-
<!-- parsing of xml imply reference attribute names, does not make sense to move all to special variables -->
15-
<suppress checks="MultipleStringLiterals" files="CheckstyleProfileImporter\.java"/>
1614
<!-- till https://github.com/checkstyle/sonar-checkstyle/issues/135 -->
1715
<suppress checks="MultipleStringLiterals" files=".*[\\/]CheckstylePlugin\.java"/>
1816
<!-- messing test code with such optimization does not make sense , readability will decrease -->

pom.xml

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494

9595
<properties>
9696
<checkstyle.version>10.12.5</checkstyle.version>
97-
<sonar.version>8.9.0.43852</sonar.version>
98-
<sonar-java.version>7.2.0.26923</sonar-java.version>
97+
<sonar.version>9.9.4.87374</sonar.version>
98+
<sonar.api-version>9.9.0.229</sonar.api-version>
9999
<maven.sevntu.checkstyle.plugin.version>1.44.1</maven.sevntu.checkstyle.plugin.version>
100100
<!-- it should be a version of checkstyle that is compatible/compiled with sevntu -->
101101
<maven.sevntu.checkstyle.plugin.checkstyle.version>
@@ -158,9 +158,9 @@
158158
<version>32.0.0-jre</version>
159159
</dependency>
160160
<dependency>
161-
<groupId>org.sonarsource.sonarqube</groupId>
161+
<groupId>org.sonarsource.api.plugin</groupId>
162162
<artifactId>sonar-plugin-api</artifactId>
163-
<version>${sonar.version}</version>
163+
<version>${sonar.api-version}</version>
164164
<scope>provided</scope>
165165
</dependency>
166166
<dependency>
@@ -558,6 +558,13 @@
558558
<goal>report</goal>
559559
</goals>
560560
</execution>
561+
<execution>
562+
<id>report</id>
563+
<phase>prepare-package</phase>
564+
<goals>
565+
<goal>report</goal>
566+
</goals>
567+
</execution>
561568
<execution>
562569
<id>default-check</id>
563570
<goals>
@@ -573,7 +580,6 @@
573580
<exclude>org.sonar.plugins.checkstyle.CheckstyleExecutor</exclude>
574581
<exclude>org.sonar.plugins.checkstyle.CheckstyleSeverityUtils</exclude>
575582
<exclude>org.sonar.plugins.checkstyle.CheckstyleConfiguration</exclude>
576-
<exclude>org.sonar.plugins.checkstyle.CheckstyleProfileImporter</exclude>
577583
<exclude>org.sonar.plugins.checkstyle.CheckstyleRulesDefinition</exclude>
578584
<exclude>org.sonar.plugins.checkstyle.metadata.CheckstyleMetadata</exclude>
579585
<exclude>org.sonar.plugins.checkstyle.metadata.CheckUtil</exclude>
@@ -682,24 +688,6 @@
682688
</limit>
683689
</limits>
684690
</rule>
685-
<rule>
686-
<element>CLASS</element>
687-
<includes>
688-
<include>org.sonar.plugins.checkstyle.CheckstyleProfileImporter</include>
689-
</includes>
690-
<limits>
691-
<limit>
692-
<counter>LINE</counter>
693-
<value>COVEREDRATIO</value>
694-
<minimum>1.0</minimum>
695-
</limit>
696-
<limit>
697-
<counter>BRANCH</counter>
698-
<value>COVEREDRATIO</value>
699-
<minimum>0.96</minimum>
700-
</limit>
701-
</limits>
702-
</rule>
703691
<rule>
704692
<element>CLASS</element>
705693
<includes>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.slf4j.Logger;
2626
import org.slf4j.LoggerFactory;
2727
import org.sonar.api.ExtensionPoint;
28-
import org.sonar.api.batch.ScannerSide;
2928
import org.sonar.api.batch.fs.FileSystem;
3029
import org.sonar.api.batch.fs.InputFile;
3130
import org.sonar.api.batch.rule.ActiveRule;
@@ -34,6 +33,7 @@
3433
import org.sonar.api.batch.sensor.issue.NewIssue;
3534
import org.sonar.api.batch.sensor.issue.NewIssueLocation;
3635
import org.sonar.api.rule.RuleKey;
36+
import org.sonar.api.scanner.ScannerSide;
3737

3838
import com.google.common.annotations.VisibleForTesting;
3939
import com.puppycrawl.tools.checkstyle.api.AuditEvent;

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
import org.slf4j.Logger;
3434
import org.slf4j.LoggerFactory;
3535
import org.sonar.api.ExtensionPoint;
36-
import org.sonar.api.batch.ScannerSide;
3736
import org.sonar.api.batch.fs.FilePredicates;
3837
import org.sonar.api.batch.fs.FileSystem;
3938
import org.sonar.api.batch.fs.InputFile;
4039
import org.sonar.api.batch.rule.ActiveRules;
40+
import org.sonar.api.scanner.ScannerSide;
4141

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

6161
public CheckstyleConfiguration(
62+
org.sonar.api.config.Configuration conf,
63+
ActiveRules activeRules,
64+
FileSystem fileSystem) {
65+
this.conf = conf;
66+
confExporter = new CheckstyleProfileExporter(conf);
67+
this.activeRules = activeRules;
68+
this.fileSystem = fileSystem;
69+
}
70+
71+
// used for unit testing
72+
protected CheckstyleConfiguration(
6273
org.sonar.api.config.Configuration conf,
6374
CheckstyleProfileExporter confExporter,
6475
ActiveRules activeRules,

0 commit comments

Comments
 (0)