Skip to content

Commit 74fecfc

Browse files
authored
[DE-1049] SonarCloud (#11)
* SonarCloud configuration * updated dependencies versions * jacoco * spotbugs * fix CI * fix plugin
1 parent 8ce633e commit 74fecfc

File tree

5 files changed

+159
-27
lines changed

5 files changed

+159
-27
lines changed

.circleci/config.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,27 @@ jobs:
117117
command: mvn test -Dtest.graph.type=<<parameters.graphType>> <<parameters.args>>
118118
- store_cache
119119

120+
sonar:
121+
executor: 'j21'
122+
steps:
123+
- timeout
124+
- checkout
125+
- setup_remote_docker
126+
- start-db
127+
- load_cache
128+
- restore_cache:
129+
name: Restore Sonar cache
130+
key: sonar-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/maven_cache_seed" }}
131+
- run:
132+
name: Analyze
133+
command: mvn verify -Dtest.graph.type=simple org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=arangodb_arangodb-tinkerpop-provider -Pstatic-code-analysis
134+
- save_cache:
135+
name: Save Sonar cache
136+
key: sonar-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/maven_cache_seed" }}
137+
paths:
138+
- ~/.sonar/cache
139+
- store_cache
140+
120141
test-demo:
121142
executor: 'j21'
122143
steps:
@@ -212,6 +233,13 @@ workflows:
212233
args:
213234
- '-Dtest.ssl'
214235

236+
sonar:
237+
when:
238+
not: <<pipeline.parameters.docker-img>>
239+
jobs:
240+
- sonar:
241+
name: sonar
242+
215243
test-adb-topology:
216244
when: <<pipeline.parameters.docker-img>>
217245
jobs:

dev-README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# dev-README
2+
3+
## Start DB
4+
```
5+
./docker/start_db.sh
6+
```
7+
8+
## SonarCloud
9+
Check results [here](https://sonarcloud.io/project/overview?id=arangodb_arangodb-tinkerpop-provider).
10+
11+
## check dependencies updates
12+
```shell
13+
mvn versions:display-dependency-updates -Pstatic-code-analysis -Prelease
14+
mvn versions:display-plugin-updates -Pstatic-code-analysis -Prelease
15+
```

pom.xml

Lines changed: 81 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3232
<arangodb-java-driver.version>7.22.0-SNAPSHOT</arangodb-java-driver.version>
3333
<test.graph.type>simple</test.graph.type>
34+
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
35+
<sonar.organization>arangodb-1</sonar.organization>
36+
<sonar.java.spotbugs.reportPaths>target/spotbugsXml.xml</sonar.java.spotbugs.reportPaths>
37+
<sonar.coverage.jacoco.xmlReportPaths>site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
3438
<jpms.argLine/>
39+
<argLine/>
3540
</properties>
3641

3742
<dependencies>
@@ -90,7 +95,7 @@
9095
<dependency>
9196
<groupId>com.fasterxml.jackson</groupId>
9297
<artifactId>jackson-bom</artifactId>
93-
<version>2.19.0</version>
98+
<version>2.19.2</version>
9499
<scope>import</scope>
95100
<type>pom</type>
96101
</dependency>
@@ -141,6 +146,60 @@
141146
</properties>
142147
</profile>
143148

149+
<profile>
150+
<id>static-code-analysis</id>
151+
<build>
152+
<plugins>
153+
<plugin>
154+
<groupId>com.github.spotbugs</groupId>
155+
<artifactId>spotbugs-maven-plugin</artifactId>
156+
<version>4.9.3.2</version>
157+
<executions>
158+
<execution>
159+
<phase>compile</phase>
160+
<goals>
161+
<goal>check</goal>
162+
</goals>
163+
</execution>
164+
</executions>
165+
<dependencies>
166+
<dependency>
167+
<groupId>com.github.spotbugs</groupId>
168+
<artifactId>spotbugs</artifactId>
169+
<version>4.9.3</version>
170+
</dependency>
171+
</dependencies>
172+
<configuration>
173+
<excludeFilterFile>spotbugs/spotbugs-exclude.xml</excludeFilterFile>
174+
</configuration>
175+
</plugin>
176+
<plugin>
177+
<groupId>org.jacoco</groupId>
178+
<artifactId>jacoco-maven-plugin</artifactId>
179+
<version>0.8.13</version>
180+
<executions>
181+
<execution>
182+
<goals>
183+
<goal>prepare-agent</goal>
184+
</goals>
185+
</execution>
186+
<execution>
187+
<id>report</id>
188+
<goals>
189+
<goal>report</goal>
190+
</goals>
191+
</execution>
192+
</executions>
193+
<configuration>
194+
<formats>
195+
<format>XML</format>
196+
</formats>
197+
</configuration>
198+
</plugin>
199+
</plugins>
200+
</build>
201+
</profile>
202+
144203
<profile>
145204
<id>release</id>
146205
<build>
@@ -221,26 +280,6 @@
221280
</configuration>
222281
</plugin>
223282

224-
<plugin>
225-
<groupId>org.jacoco</groupId>
226-
<artifactId>jacoco-maven-plugin</artifactId>
227-
<version>0.8.13</version>
228-
<executions>
229-
<execution>
230-
<goals>
231-
<goal>prepare-agent</goal>
232-
</goals>
233-
</execution>
234-
<execution>
235-
<id>report</id>
236-
<phase>prepare-package</phase>
237-
<goals>
238-
<goal>report</goal>
239-
</goals>
240-
</execution>
241-
</executions>
242-
</plugin>
243-
244283
<plugin>
245284
<groupId>com.google.code.maven-replacer-plugin</groupId>
246285
<artifactId>replacer</artifactId>
@@ -289,8 +328,21 @@
289328
<plugin>
290329
<groupId>org.apache.maven.plugins</groupId>
291330
<artifactId>maven-enforcer-plugin</artifactId>
292-
<version>3.6.0</version>
331+
<version>3.6.1</version>
293332
<executions>
333+
<execution>
334+
<id>enforce-maven-version</id>
335+
<goals>
336+
<goal>enforce</goal>
337+
</goals>
338+
<configuration>
339+
<rules>
340+
<requireMavenVersion>
341+
<version>[3.6.3,)</version>
342+
</requireMavenVersion>
343+
</rules>
344+
</configuration>
345+
</execution>
294346
<execution>
295347
<id>enforce-all</id>
296348
<goals>
@@ -306,9 +358,6 @@
306358
<scopes>compile</scopes>
307359
<maxJdkVersion>1.8</maxJdkVersion>
308360
</enforceBytecodeVersion>
309-
<requireMavenVersion>
310-
<version>[3.5.3,)</version>
311-
</requireMavenVersion>
312361
<requirePluginVersions/>
313362
<requireExplicitDependencyScope/>
314363
</rules>
@@ -369,7 +418,7 @@
369418
<plugin>
370419
<groupId>org.codehaus.mojo</groupId>
371420
<artifactId>flatten-maven-plugin</artifactId>
372-
<version>1.7.1</version>
421+
<version>1.7.2</version>
373422
<configuration>
374423
<flattenMode>oss</flattenMode>
375424
</configuration>
@@ -409,6 +458,12 @@
409458
</descriptors>
410459
</configuration>
411460
</plugin>
461+
462+
<plugin>
463+
<groupId>org.sonarsource.scanner.maven</groupId>
464+
<artifactId>sonar-maven-plugin</artifactId>
465+
<version>5.1.0.4751</version>
466+
</plugin>
412467
</plugins>
413468

414469
<pluginManagement>

spotbugs/spotbugs-exclude.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- This file specifies a spotbugs filter for excluding reports that
3+
should not be considered errors.
4+
The format of this file is documented at:
5+
https://spotbugs.readthedocs.io/en/latest/filter.html
6+
When possible, please specify the full names of the bug codes,
7+
using the pattern attribute, to make it clearer what reports are
8+
being suppressed. You can find a listing of codes at:
9+
https://spotbugs.readthedocs.io/en/latest/bugDescriptions.html
10+
-->
11+
12+
<FindBugsFilter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
13+
xmlns="https://github.com/spotbugs/filter/3.0.0"
14+
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/release-3.1/spotbugs/etc/findbugsfilter.xsd">
15+
16+
<Match>
17+
<Bug pattern="EI_EXPOSE_REP"/>
18+
</Match>
19+
20+
<Match>
21+
<Bug pattern="EI_EXPOSE_REP2"/>
22+
</Match>
23+
24+
<Match>
25+
<Bug pattern="CT_CONSTRUCTOR_THROW"/>
26+
</Match>
27+
28+
<Match>
29+
<Class name="com.arangodb.tinkerpop.gremlin.jsr223.ArangoDBGremlinPlugin"/>
30+
<Bug pattern="SING_SINGLETON_HAS_NONPRIVATE_CONSTRUCTOR"/>
31+
</Match>
32+
33+
</FindBugsFilter>

src/main/java/com/arangodb/tinkerpop/gremlin/utils/ArangoDBUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.arangodb.tinkerpop.gremlin.structure.ArangoDBGraphConfig;
2121
import com.arangodb.tinkerpop.gremlin.PackageVersion;
2222

23+
import java.io.Serializable;
2324
import java.util.*;
2425
import java.util.regex.Matcher;
2526
import java.util.regex.Pattern;
@@ -89,7 +90,7 @@ public static void checkVersion(String version) {
8990
}
9091
}
9192

92-
private static class VersionComparator implements Comparator<String> {
93+
private static class VersionComparator implements Comparator<String>, Serializable {
9394
@Override
9495
public int compare(String a, String b) {
9596
Objects.requireNonNull(a);

0 commit comments

Comments
 (0)