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 2, 2024
1 parent 8462c9e commit 142a90b
Show file tree
Hide file tree
Showing 43 changed files with 379 additions and 1,144 deletions.
75 changes: 31 additions & 44 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,57 @@
version: 2

jobs:
build-project:
docker:
- image: cimg/openjdk:11.0.16

steps:
- checkout
- run: mvn -e --no-transfer-progress package -Pno-validations
- persist_to_workspace:
root: /home/circleci
paths:
- project

execute-sonar:
docker:
- image: sonarqube:9.0-community
- image: cimg/openjdk:17.0
working_directory: ~/repo

environment:
# Customize the JVM maximum heap limit
MAVEN_OPTS: -Xmx3200m

steps:
- attach_workspace:
at: /root
- checkout
- setup_remote_docker
- run:
name: Install packages
command: apk add maven
name: Build Jar
command: mvn -e --no-transfer-progress package -Pno-validations
- run:
name: Copy jar
name: Start SonarQube
command: |
cp /root/project/target/checkstyle-sonar-plugin*.jar \
/opt/sonarqube/extensions/plugins/
docker run -d --name sonarqube -p 9000:9000 -v ~/repo/target/:/opt/sonarqube/extensions/plugins/ sonarqube:9.9-community
ssh -fNT -L 127.0.0.1:9000:127.0.0.1:9000 -S /tmp/.remote-docker -M remote-docker
# wait for SQ web server to come up
while [[ ! `curl -s http://localhost:9000/api/system/status` =~ "UP" ]]; do
echo "Waiting for web server to come up..."
sleep 10
done
- run:
name: Start SonarQube web service and execute maven SonarQube build
name: Execute SonarQube analysis
command: |
# start SonarQube web server
cd /opt/sonarqube/
./bin/run.sh &
until grep "SonarQube is up" logs/sonar.log; \
do sleep 10 && echo "Waiting for web server to come up..."; \
done
# Note that we cannot separate "start SonarQube web server" above from
# this step, as we would kill web server when step is complete.
cd /root/project
mvn -e --no-transfer-progress sonar:sonar -Dsonar.login=admin -Dsonar.password=admin
- store_artifacts:
path: /root/project/target/sonar/checkstyle-result.xml
path: ~/repo/target/sonar/checkstyle-result.xml
- run:
name: Check logs for error
command: grep "ERROR" /opt/sonarqube/logs/* || test $? = 1
command: |
docker logs sonarqube | grep "ERROR" || test $? = 1
- run:
name: Cleanup
command: ssh -S /tmp/.remote-docker -O exit remote-docker

sonarqube:
sonarcloud:
docker:
- image: checkstyle/jdk-11-groovy-git-mvn:11.0.13__3.0.9__2.25.1__3.6.3
- image: cimg/openjdk:17.0

steps:
- checkout
- run: apt-get install -y jq
- run: |
sudo apt-get update
sudo apt-get install -y jq
- run:
name: Run sonarqube
name: Run Sonarcloud analysis
command: |
export PR_NUMBER=$CIRCLE_PR_NUMBER
export PR_BRANCH_NAME=$CIRCLE_BRANCH
Expand All @@ -71,15 +61,12 @@ jobs:
workflows:
version: 2

sonarqube:
sonarcloud-analysis:
jobs:
- sonarqube:
- sonarcloud:
context:
- sonarqube

build-sonar:
check-sonarqube-plugin:
jobs:
- build-project
- execute-sonar:
requires:
- build-project
- execute-sonar
97 changes: 76 additions & 21 deletions .github/workflows/sonar-checkstyle-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,91 @@ on:
pull_request:

jobs:
mvn-install-java-11:
mvn-install:
name: Install
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
java-version: ['11', '17']

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
- uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 11
- name: install
run: "./.ci/ci.sh install"
java-version: ${{ matrix.java-version }}
distribution: 'temurin'

- run: "./.ci/ci.sh install"

# 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"

integration-tests:
nondex:
name: Nondex
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
java-version: ['11', '17']

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
- uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 11
- name: run integration tests
run: "./.ci/ci.sh integration-tests"
java-version: ${{ matrix.java-version }}
distribution: 'temurin'

nondex:
- run: "./.ci/ci.sh nondex"

execute-sonarqube-plugin:
name: Execute SonarQube Plugin
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Build Jar
run: mvn -e --no-transfer-progress package -Pno-validations

- name: Run SonarQube
run: docker run -d --name sonarqube -p 9000:9000 -v ${{ github.workspace }}/repo/target/:/opt/sonarqube/extensions/plugins/ sonarqube:9.9-community
- name: Check SonarQube is Up
run: |
while [[ ! `curl -s http://localhost:9000/api/system/status` =~ "UP" ]]; do
echo "Waiting for web server to come up..."
sleep 10
done
- name: Execute SonarQube analysis
run: |
mvn -e --no-transfer-progress sonar:sonar -Dsonar.login=admin -Dsonar.password=admin
- name: Archive Checkstyle Results
uses: actions/upload-artifact@v4
with:
java-version: 11
- name: install
run: "./.ci/ci.sh nondex"
name: checkstyle-result
path: target/sonar/checkstyle-result.xml

- name: Check logs for error
run: docker logs sonarqube | grep "ERROR" || test $? = 1
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
Loading

0 comments on commit 142a90b

Please sign in to comment.