Skip to content

Commit cc6281b

Browse files
authored
Merge pull request #31 from stepstone-tech/sonar-9.0
release version 2.2.0
2 parents a509e5d + ab27282 commit cc6281b

File tree

16 files changed

+213
-508
lines changed

16 files changed

+213
-508
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,37 @@ name: CI
55

66
on:
77
push:
8-
branches: [ master, sonar-9 ]
8+
branches: [ master, sonar-9, sonar-9.0 ]
99
pull_request:
10-
branches: [ master ]
10+
types: [opened, synchronize, reopened]
1111

1212
jobs:
1313
build:
1414

1515
runs-on: ubuntu-latest
16-
1716
steps:
1817
- uses: actions/checkout@v2
19-
- name: Set up JDK 8
18+
with:
19+
fetch-depth: 0
20+
- name: Set up JDK 11
2021
uses: actions/setup-java@v2
2122
with:
22-
java-version: '8'
2323
distribution: 'adopt'
24-
cache: maven
25-
- name: Build with Maven
26-
run: mvn -B package --file pom.xml
24+
java-version: '11'
25+
- name: Cache SonarCloud packages
26+
uses: actions/cache@v1
27+
with:
28+
path: ~/.sonar/cache
29+
key: ${{ runner.os }}-sonar
30+
restore-keys: ${{ runner.os }}-sonar
31+
- name: Cache Maven packages
32+
uses: actions/cache@v1
33+
with:
34+
path: ~/.m2
35+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
36+
restore-keys: ${{ runner.os }}-m2
37+
- name: Build and analyze
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
41+
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Psonar

.travis.yml

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

Jenkinsfile

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

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ A [SonarQube plugin](http://www.sonarqube.org/) for analyzing ColdFusion code, b
1313

1414
SonarQube Version | Plugin Version
1515
------------------|---------------
16-
7.6 - 8.9 | 2.2.1
16+
9.0 - 9.1 | 2.2.0
17+
7.6 - 8.9 | 2.1.1
1718
5.6 - 7.5 | 1.5.0
1819

1920
## Running

pom.xml

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>com.stepstone.sonar.plugin</groupId>
77
<artifactId>sonar-coldfusion-plugin</artifactId>
88
<packaging>sonar-plugin</packaging>
9-
<version>2.1.1</version>
9+
<version>2.2.0</version>
1010

1111
<name>SonarQube Coldfusion Plugin</name>
1212
<description>Enables scanning of ColdFusion source files</description>
@@ -37,17 +37,18 @@
3737

3838
<properties>
3939
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
40-
<maven.compiler.source>1.8</maven.compiler.source>
41-
<maven.compiler.target>1.8</maven.compiler.target>
42-
<sonar.version>7.6</sonar.version>
40+
<maven.compiler.source>11</maven.compiler.source>
41+
<maven.compiler.target>11</maven.compiler.target>
42+
<sonar.version>9.0.0.45539</sonar.version>
4343
<cflint.version>1.5.0</cflint.version>
44+
<sonar-analyzer-commons.version>1.16.0.719</sonar-analyzer-commons.version>
4445
</properties>
4546

4647
<dependencies>
4748
<dependency>
4849
<groupId>junit</groupId>
4950
<artifactId>junit</artifactId>
50-
<version>4.13.1</version>
51+
<version>4.13.2</version>
5152
<scope>test</scope>
5253
</dependency>
5354
<dependency>
@@ -60,36 +61,50 @@
6061
<dependency>
6162
<groupId>org.assertj</groupId>
6263
<artifactId>assertj-core</artifactId>
63-
<version>3.11.1</version>
64+
<version>3.21.0</version>
6465
<scope>test</scope>
6566
</dependency>
6667

6768
<dependency>
6869
<groupId>org.sonarsource.sslr-squid-bridge</groupId>
6970
<artifactId>sslr-squid-bridge</artifactId>
70-
<version>2.7.0.377</version>
71+
<version>2.7.1.392</version>
7172
<exclusions>
7273
<exclusion>
7374
<artifactId>sonar-plugin-api</artifactId>
7475
<groupId>org.sonarsource.sonarqube</groupId>
7576
</exclusion>
7677
</exclusions>
7778
</dependency>
79+
80+
<dependency>
81+
<groupId>org.sonarsource.analyzer-commons</groupId>
82+
<artifactId>sonar-analyzer-commons</artifactId>
83+
<version>${sonar-analyzer-commons.version}</version>
84+
</dependency>
85+
7886
<!-- This will be the server API-->
7987
<dependency>
8088
<groupId>org.sonarsource.sonarqube</groupId>
8189
<artifactId>sonar-plugin-api</artifactId>
8290
<version>${sonar.version}</version>
8391
<scope>provided</scope>
8492
</dependency>
93+
94+
<dependency>
95+
<groupId>org.sonarsource.sonarqube</groupId>
96+
<artifactId>sonar-plugin-api-impl</artifactId>
97+
<version>${sonar.version}</version>
98+
<scope>test</scope>
99+
</dependency>
85100
</dependencies>
86101

87102
<build>
88103
<plugins>
89104
<plugin>
90105
<groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
91106
<artifactId>sonar-packaging-maven-plugin</artifactId>
92-
<version>1.18.0.372</version>
107+
<version>1.20.0.405</version>
93108
<extensions>true</extensions>
94109
<configuration>
95110
<pluginClass>com.stepstone.sonar.plugin.coldfusion.ColdFusionPlugin</pluginClass>
@@ -127,7 +142,7 @@
127142
<plugin>
128143
<groupId>de.jutzig</groupId>
129144
<artifactId>github-release-plugin</artifactId>
130-
<version>1.3.0</version>
145+
<version>1.4.0</version>
131146
<configuration>
132147
<description>Sonarqube Coldfusion Plugin release</description>
133148
<releaseName>${project.version}</releaseName>
@@ -158,12 +173,12 @@
158173
<plugin>
159174
<groupId>org.sonarsource.scanner.maven</groupId>
160175
<artifactId>sonar-maven-plugin</artifactId>
161-
<version>3.6.0.1398</version>
176+
<version>3.9.0.2155</version>
162177
</plugin>
163-
<plugin>
164-
<groupId>org.jacoco</groupId>
165-
<artifactId>jacoco-maven-plugin</artifactId>
166-
<version>0.8.3</version>
178+
<plugin>
179+
<groupId>org.jacoco</groupId>
180+
<artifactId>jacoco-maven-plugin</artifactId>
181+
<version>0.8.7</version>
167182
</plugin>
168183
</plugins>
169184
</pluginManagement>
@@ -182,6 +197,11 @@
182197
<goals>
183198
<goal>report</goal>
184199
</goals>
200+
<configuration>
201+
<excludes>
202+
<exclude>META-INF/runner/cflint.jar</exclude>
203+
</excludes>
204+
</configuration>
185205
</execution>
186206
</executions>
187207
</plugin>

src/main/java/com/stepstone/sonar/plugin/coldfusion/ColdFusionPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.stepstone.sonar.plugin.coldfusion;
1818

1919
import com.stepstone.sonar.plugin.coldfusion.profile.ColdFusionProfileExporter;
20-
import com.stepstone.sonar.plugin.coldfusion.profile.ColdFusionSonarWayProfileImporter;
20+
import com.stepstone.sonar.plugin.coldfusion.profile.ColdFusionSonarWayProfile;
2121
import com.stepstone.sonar.plugin.coldfusion.rules.ColdFusionSonarRulesDefinition;
2222

2323
import org.sonar.api.Plugin;
@@ -71,7 +71,7 @@ public void define(Context context) {
7171
ColdFusion.class,
7272
ColdFusionSensor.class,
7373
ColdFusionSonarRulesDefinition.class,
74-
ColdFusionSonarWayProfileImporter.class,
74+
ColdFusionSonarWayProfile.class,
7575
ColdFusionProfileExporter.class
7676
);
7777

src/main/java/com/stepstone/sonar/plugin/coldfusion/ColdFusionSensor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@
3737
import java.io.InputStreamReader;
3838
import java.nio.file.Files;
3939
import java.util.ArrayList;
40-
import java.util.List;
4140
import java.util.Collection;
41+
import java.util.List;
4242
import java.util.concurrent.Callable;
4343
import java.util.concurrent.ExecutorService;
4444
import java.util.concurrent.Executors;
4545
import java.util.concurrent.TimeUnit;
4646
import java.util.regex.Matcher;
4747
import java.util.regex.Pattern;
48+
import java.util.stream.Collectors;
4849

4950
public class ColdFusionSensor implements Sensor {
5051

@@ -90,7 +91,9 @@ private void analyze(SensorContext context) throws IOException, XMLStreamExcepti
9091

9192
private File generateCflintConfig() throws IOException, XMLStreamException {
9293
final File configFile = new File(fs.workDir(), "cflint-config.xml");
93-
new CFLintConfigExporter(ruleProfile.findByRepository(ColdFusionPlugin.REPOSITORY_KEY)).save(configFile);
94+
Collection<String> ruleKeys = ruleProfile.findByRepository(ColdFusionPlugin.REPOSITORY_KEY)
95+
.stream().map(rule -> rule.ruleKey().toString()).collect(Collectors.toList());
96+
new CFLintConfigExporter(ruleKeys).save(configFile);
9497
return configFile;
9598
}
9699

src/main/java/com/stepstone/sonar/plugin/coldfusion/cflint/CFLintConfigExporter.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
package com.stepstone.sonar.plugin.coldfusion.cflint;
1818

19-
import com.stepstone.sonar.plugin.coldfusion.ColdFusionPlugin;
20-
import org.sonar.api.batch.rule.ActiveRule;
21-
2219
import javax.xml.stream.XMLOutputFactory;
2320
import javax.xml.stream.XMLStreamException;
2421
import javax.xml.stream.XMLStreamWriter;
@@ -30,16 +27,9 @@
3027

3128
public class CFLintConfigExporter {
3229

33-
private final Collection<ActiveRule> ruleProfiles;
34-
private final String repositoryKey;
35-
36-
public CFLintConfigExporter(Collection ruleProfile) {
37-
this(ruleProfile, ColdFusionPlugin.REPOSITORY_KEY);
38-
}
39-
40-
public CFLintConfigExporter(Collection ruleProfile, String repositoryKey) {
41-
this.ruleProfiles = ruleProfile;
42-
this.repositoryKey = repositoryKey;
30+
private final Collection<String> ruleKeys;
31+
public CFLintConfigExporter(Collection<String> ruleKeys) {
32+
this.ruleKeys = ruleKeys;
4333
}
4434

4535
public void save(File configFile) throws IOException, XMLStreamException {
@@ -57,9 +47,9 @@ public void save(Writer writer) throws IOException, XMLStreamException {
5747
xtw.writeStartDocument();
5848
xtw.writeStartElement("config");
5949

60-
for (ActiveRule activeRule : ruleProfiles) {
50+
for (String ruleKey: ruleKeys) {
6151
xtw.writeStartElement("includes");
62-
xtw.writeAttribute("code", activeRule.ruleKey().toString());
52+
xtw.writeAttribute("code", ruleKey);
6353
xtw.writeEndElement();
6454
}
6555

src/main/java/com/stepstone/sonar/plugin/coldfusion/profile/ColdFusionProfileExporter.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
import com.stepstone.sonar.plugin.coldfusion.ColdFusionPlugin;
2121
import com.stepstone.sonar.plugin.coldfusion.cflint.CFLintConfigExporter;
2222
import org.sonar.api.profiles.ProfileExporter;
23-
import org.sonar.api.batch.rule.ActiveRules;
2423
import org.sonar.api.profiles.RulesProfile;
2524

2625
import javax.xml.stream.XMLStreamException;
2726
import java.io.IOException;
2827
import java.io.Writer;
28+
import java.util.Collection;
29+
import java.util.stream.Collectors;
2930

3031
public class ColdFusionProfileExporter extends ProfileExporter {
3132

@@ -37,19 +38,13 @@ public ColdFusionProfileExporter() {
3738
@Override
3839
public void exportProfile(RulesProfile ruleProfile, Writer writer) {
3940
try {
40-
new CFLintConfigExporter(ruleProfile.getActiveRulesByRepository(ColdFusionPlugin.REPOSITORY_KEY)).save(writer);
41+
Collection<String> ruleKeys = ruleProfile.getActiveRulesByRepository(ColdFusionPlugin.REPOSITORY_KEY)
42+
.stream().map(rule -> rule.getRule().ruleKey().rule())
43+
.collect(Collectors.toList());
44+
new CFLintConfigExporter(ruleKeys).save(writer);
4145
} catch (IOException | XMLStreamException e) {
4246
Throwables.propagate(e);
4347
}
4448
}
4549

46-
public void exportProfile(ActiveRules activeRules, Writer writer) {
47-
try {
48-
new CFLintConfigExporter(activeRules.findByRepository(ColdFusionPlugin.REPOSITORY_KEY)).save(writer);
49-
} catch (IOException | XMLStreamException e) {
50-
Throwables.propagate(e);
51-
}
52-
53-
}
54-
5550
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Copyright 2016 StepStone GmbH
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package com.stepstone.sonar.plugin.coldfusion.profile;
18+
19+
import com.stepstone.sonar.plugin.coldfusion.ColdFusionPlugin;
20+
import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition;
21+
import org.sonarsource.analyzer.commons.BuiltInQualityProfileJsonLoader;
22+
23+
public class ColdFusionSonarWayProfile implements BuiltInQualityProfilesDefinition {
24+
25+
private static final String PROFILE_NAME = "Sonar way";
26+
private static final String DEFAULT_PROFILE_PATH = "com/stepstone/sonar/plugin/coldfusion/profile.json";
27+
28+
@Override
29+
public void define(Context context) {
30+
NewBuiltInQualityProfile profile = context.createBuiltInQualityProfile(PROFILE_NAME, ColdFusionPlugin.LANGUAGE_KEY);
31+
BuiltInQualityProfileJsonLoader.load(profile, ColdFusionPlugin.REPOSITORY_KEY, DEFAULT_PROFILE_PATH);
32+
profile.done();
33+
}
34+
}

0 commit comments

Comments
 (0)