Skip to content

Commit

Permalink
Update dependencies to use on SonarQube 10.7 version
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasz-strzelecki-vml committed Oct 29, 2024
1 parent 1966e63 commit 5a8e0be
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

strategy:
matrix:
java-version: [ 11 ]
java-version: [ 17 ]

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-instalation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
matrix:
sonarqube-image:
- 'sonarqube:9.9-community'
- 'sonarqube:10.7-community'
- 'sonarqube:lts-community'
- 'sonarqube:latest'
fail-fast: false
Expand All @@ -40,7 +40,7 @@ jobs:
uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: 'adopt'
cache: maven
- run: mvn clean package
Expand Down
2 changes: 1 addition & 1 deletion local-docker-image/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ name: sonar-local

services:
sonar-local:
image: sonarqube:9.9-community
image: sonarqube:10.7-community
build:
context: .
ports:
Expand Down
67 changes: 13 additions & 54 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@

<properties>
<htl.version>1.1.2-1.4.0</htl.version>
<sonar.html.version>3.15.0.5107</sonar.html.version>
<sonar.java.plugin>7.30.1.34514</sonar.java.plugin>
<sonar.html.version>3.16.0.5274</sonar.html.version>
<sonar.java.plugin>8.5.0.37199</sonar.java.plugin>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.pluginApiVersion>10.11.0.2468</sonar.pluginApiVersion>
<sonar.pluginApiImplVersion>10.3.0.82913</sonar.pluginApiImplVersion>
<sonar.pluginApiImplVersion>10.7.0.96327</sonar.pluginApiImplVersion>
<sonar.testingHarnessVersion>10.7.0.96327</sonar.testingHarnessVersion>
<sonar.javaCheksTestkitVersion>7.30.1.34514</sonar.javaCheksTestkitVersion>
<jdk.min.version>11</jdk.min.version>
<sonar.javaCheksTestkitVersion>8.5.0.37199</sonar.javaCheksTestkitVersion>
<jdk.min.version>17</jdk.min.version>
<sonar.sources>src/main/java</sonar.sources>
<coveralls.repo.token>4rVf3NGV0jyQ3EGrc8L86oEDoHWm6MgDD</coveralls.repo.token>
<tagName>v${project.version}</tagName>
Expand All @@ -138,50 +138,16 @@
</dependency>
<dependency>
<artifactId>sonar-html-plugin</artifactId>
<exclusions>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
</exclusions>
<groupId>org.sonarsource.html</groupId>
<version>${sonar.html.version}</version>
</dependency>
<dependency>
<artifactId>sslr-squid-bridge</artifactId>
<exclusions>
<exclusion>
<artifactId>sslr-core</artifactId>
<groupId>org.codehaus.sonar.sslr</groupId>
</exclusion>
<exclusion>
<artifactId>sonar-plugin-api</artifactId>
<groupId>org.codehaus.sonar</groupId>
</exclusion>
<exclusion>
<artifactId>sslr-xpath</artifactId>
<groupId>org.codehaus.sonar.sslr</groupId>
</exclusion>
<exclusion>
<artifactId>jcl-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
<groupId>org.sonarsource.sslr-squid-bridge</groupId>
<version>2.6.1</version>
<artifactId>sonar-analyzer-commons</artifactId>
<groupId>org.sonarsource.analyzer-commons</groupId>
<version>2.14.0.3087</version>
</dependency>
<dependency>
<artifactId>sonar-java-plugin</artifactId>
<exclusions>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
</exclusions>
<groupId>org.sonarsource.java</groupId>
<type>sonar-plugin</type>
<version>${sonar.java.plugin}</version>
Expand Down Expand Up @@ -256,12 +222,6 @@
<scope>test</scope>
<version>${sonar.javaCheksTestkitVersion}</version>
</dependency>
<dependency>
<artifactId>sonar-analyzer-commons</artifactId>
<groupId>org.sonarsource.analyzer-commons</groupId>
<scope>test</scope>
<version>2.14.0.3087</version>
</dependency>
<dependency>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
Expand Down Expand Up @@ -350,19 +310,18 @@
<pluginKey>aemrules</pluginKey>
<pluginClass>com.vml.aemrules.AemRulesSonarPlugin</pluginClass>
<pluginApiMinVersion>9.9</pluginApiMinVersion>
<pluginIssueTrackerUrl>https://github.com/wttech/AEM-Rules-for-SonarQube/issues
</pluginIssueTrackerUrl>
<pluginSourcesUrl>https://github.com/wttech/AEM-Rules-for-SonarQube/tree/${tagName}
</pluginSourcesUrl>
<pluginIssueTrackerUrl>https://github.com/wttech/AEM-Rules-for-SonarQube/issues</pluginIssueTrackerUrl>
<pluginSourcesUrl>https://github.com/wttech/AEM-Rules-for-SonarQube/tree/${tagName}</pluginSourcesUrl>
<pluginUrl>https://github.com/wttech/AEM-Rules-for-SonarQube</pluginUrl>
<sonarLintSupported>true</sonarLintSupported>
<skipDependenciesPackaging>true</skipDependenciesPackaging>
<requiredForLanguages>java</requiredForLanguages>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<version>3.6.0</version>
<configuration>
<shadedArtifactAttached>false</shadedArtifactAttached>
<minimizeJar>true</minimizeJar>
Expand All @@ -382,7 +341,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<release>11</release>
<release>17</release>
</configuration>
</plugin>
<plugin>
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/com/vml/aemrules/htl/AnalysisException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*-
* #%L
* AEM Rules for SonarQube
* %%
* Copyright (C) 2015-2024 VML
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.vml.aemrules.htl;

public class AnalysisException extends RuntimeException {

public AnalysisException(String message) {
super(message);
}

public AnalysisException(String message, Throwable cause) {
super(message, cause);
}

}
3 changes: 1 addition & 2 deletions src/main/java/com/vml/aemrules/htl/HtlFilesAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,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.squidbridge.ProgressReport;
import org.sonar.squidbridge.api.AnalysisException;
import org.sonarsource.analyzer.commons.ProgressReport;

import java.io.IOException;
import java.io.InterruptedIOException;
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/com/vml/aemrules/htl/HtlSensor.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@
import org.sonar.api.rule.RuleKey;
import org.sonar.plugins.html.node.Node;
import org.sonar.plugins.html.visitor.HtmlSourceCode;
import org.sonar.squidbridge.ProgressReport;
import org.sonarsource.analyzer.commons.ProgressReport;

import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
Expand Down Expand Up @@ -75,9 +74,8 @@ public void execute(SensorContext context) {
FilePredicate htlFilePredicate = HtlFilePredicateProvider.createFilePredicate(configuration, context);
Iterable<InputFile> inputFiles = context.fileSystem().inputFiles(htlFilePredicate);

Collection<File> files = StreamSupport.stream(inputFiles.spliterator(), false)
.map(InputFile::uri)
.map(File::new)
Collection<String> files = StreamSupport.stream(inputFiles.spliterator(), false)
.map(InputFile::filename)
.collect(Collectors.toList());

ProgressReport progressReport = new ProgressReport("Report about progress of HTL analyzer",
Expand Down Expand Up @@ -109,8 +107,7 @@ private HtlScanner setupScanner() {
for (HtlCheck check : checks.getAll()) {
RuleKey ruleKey = checks.ruleKeyFor(check);
check.setRuleKey(ruleKey);
if (check instanceof DefaultHtlVisitor) {
DefaultHtlVisitor nodeVisitor = (DefaultHtlVisitor) check;
if (check instanceof DefaultHtlVisitor nodeVisitor) {
scanner.addVisitor(nodeVisitor);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public void register(RegistrarContext registrarContext) {
private List<Class<? extends JavaCheck>> checkClasses() {
return JavaRulesList.getJavaChecks().stream()
.filter(checkClass -> shouldRegister(aemVersion, checkClass))
.collect(Collectors.toList());
.toList();
}

private List<Class<? extends JavaCheck>> testCheckClasses() {
return JavaRulesList.getJavaTestChecks().stream()
.filter(checkClass -> shouldRegister(aemVersion, checkClass))
.collect(Collectors.toList());
.toList();
}

private boolean shouldRegister(String aemVersion, Class<? extends JavaCheck> checkClass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private void givenMethodInvocationTree(String codeToParse) {

private CompilationUnitTree parse(String source) {
List<File> classpath = Arrays.asList(new File(TEST_CLASSES_FILEPATH), new File(CLASSES_FILEPATH));
return JParser.parse(JParserConfig.Mode.FILE_BY_FILE.create(new JavaVersionImpl(11), classpath).astParser(), JAVA_VERSION, UNIT_NAME, source);
return JParser.parse(JParserConfig.Mode.FILE_BY_FILE.create(new JavaVersionImpl(17), classpath).astParser(), JAVA_VERSION, UNIT_NAME, source);
}

}

0 comments on commit 5a8e0be

Please sign in to comment.