Skip to content

Commit 5490f6e

Browse files
committed
Add coverage report
1 parent d85c7e1 commit 5490f6e

File tree

9 files changed

+88
-595
lines changed

9 files changed

+88
-595
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ is available on the SonarQube Marketplace
4343

4444
## Analysis parameter
4545

46-
Add parameter `sonar.rust.clippy.reportPaths=<clippy report file>`
46+
Add parameter `sonar.rust.clippy.reportPaths=<clippy report file>`
47+
48+
## Analyze this plugin with SonarQube
49+
50+
`mvn -Pcoverage clean install sonar:sonar`

pom.xml

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<mockito.version>2.21.0</mockito.version>
2121
<assertj-core.version>3.15.0</assertj-core.version>
2222
<jacoco.version>0.8.4</jacoco.version>
23+
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
2324
</properties>
2425

2526
<issueManagement>
@@ -130,50 +131,91 @@
130131
<version>${jacoco.version}</version>
131132
<scope>test</scope>
132133
</dependency>
133-
134-
<!-- provided dependencies -->
135-
<dependency>
136-
<groupId>org.sonarsource.sonarqube</groupId>
137-
<artifactId>sonar-plugin-api</artifactId>
138-
<version>${sonar.version}</version>
139-
<scope>provided</scope>
140-
</dependency>
141134
</dependencies>
142135

143136
<build>
137+
<pluginManagement>
138+
<plugins>
139+
<plugin>
140+
<groupId>org.apache.maven.plugins</groupId>
141+
<artifactId>maven-javadoc-plugin</artifactId>
142+
<configuration>
143+
<source>8</source>
144+
</configuration>
145+
</plugin>
146+
<plugin>
147+
<groupId>org.apache.maven.plugins</groupId>
148+
<artifactId>maven-surefire-plugin</artifactId>
149+
<version>${maven-surefire-plugin.version}</version>
150+
</plugin>
151+
<plugin>
152+
<groupId>org.apache.maven.plugins</groupId>
153+
<artifactId>maven-project-info-reports-plugin</artifactId>
154+
<version>2.9</version>
155+
</plugin>
156+
</plugins>
157+
</pluginManagement>
144158
<plugins>
145159
<plugin>
146160
<groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
147161
<artifactId>sonar-packaging-maven-plugin</artifactId>
148162
<version>1.18.0.372</version>
149163
<extensions>true</extensions>
150164
<configuration>
151-
<pluginKey>rust</pluginKey>
165+
<pluginKey>rustlint</pluginKey>
152166
<pluginClass>org.elegoff.plugins.rust.RustPlugin</pluginClass>
153167
</configuration>
154168
</plugin>
155169
<plugin>
156170
<groupId>org.apache.maven.plugins</groupId>
157171
<artifactId>maven-compiler-plugin</artifactId>
158-
<version>3.5.1</version>
172+
<version>3.6.0</version>
159173
<configuration>
160174
<source>${jdk.min.version}</source>
161175
<target>${jdk.min.version}</target>
176+
<encoding>${project.build.sourceEncoding}</encoding>
177+
</configuration>
178+
</plugin>
179+
<plugin>
180+
<groupId>org.apache.maven.plugins</groupId>
181+
<artifactId>maven-surefire-plugin</artifactId>
182+
<configuration>
183+
<includes>
184+
<include>**/*Test.java</include>
185+
</includes>
162186
</configuration>
163187
</plugin>
164188
<plugin>
165-
<!-- UTF-8 bundles are not supported by Java, so they must be converted during build -->
166-
<groupId>org.codehaus.mojo</groupId>
167-
<artifactId>native2ascii-maven-plugin</artifactId>
168-
<version>1.0-beta-1</version>
189+
<groupId>org.apache.maven.plugins</groupId>
190+
<artifactId>maven-source-plugin</artifactId>
191+
<version>3.0.1</version>
169192
<executions>
170193
<execution>
171194
<goals>
172-
<goal>native2ascii</goal>
195+
<goal>jar-no-fork</goal>
173196
</goals>
174197
</execution>
175198
</executions>
176199
</plugin>
200+
<plugin>
201+
<groupId>org.apache.maven.plugins</groupId>
202+
<artifactId>maven-javadoc-plugin</artifactId>
203+
<version>3.1.0</version>
204+
<executions>
205+
<execution>
206+
<phase>prepare-package</phase>
207+
<goals>
208+
<goal>javadoc</goal>
209+
</goals>
210+
</execution>
211+
</executions>
212+
<configuration>
213+
<!-- optional -->
214+
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
215+
<!-- to show the private methods in the javadoc -->
216+
<show>private</show>
217+
</configuration>
218+
</plugin>
177219
<plugin>
178220
<groupId>com.mycila.maven-license-plugin</groupId>
179221
<artifactId>maven-license-plugin</artifactId>
@@ -204,7 +246,7 @@
204246
</build>
205247
<profiles>
206248
<profile>
207-
<id>audit</id>
249+
<id>coverage</id>
208250
<build>
209251
<plugins>
210252
<plugin>

src/main/java/org/elegoff/plugins/rust/clippy/ClippyJsonReportReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private void onResult(JSONObject result) {
8181
if (code == null) return;
8282
clippyIssue.ruleKey = (String) code.get("code");
8383
JSONArray spans = (JSONArray) message.get("spans");
84-
if ((spans == null) || spans.size() == 0) return;
84+
if ((spans == null) || spans.isEmpty()) return;
8585
JSONObject span = (JSONObject) spans.get(0);
8686
clippyIssue.filePath = (String) span.get("file_name");
8787
clippyIssue.message = (String) message.get("message");

src/main/java/org/elegoff/plugins/rust/languages/RustLanguage.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,28 @@ private String[] filterEmptyStrings(String[] stringArray) {
6464
return nonEmptyStrings.toArray(new String[nonEmptyStrings.size()]);
6565
}
6666

67+
@Override
68+
public boolean equals(Object o) {
69+
if (this == o) {
70+
return true;
71+
}
72+
if (!(o instanceof RustLanguage)) {
73+
return false;
74+
}
75+
RustLanguage that = (RustLanguage) o;
76+
return KEY.equals(that.getKey());
77+
78+
}
79+
80+
@Override
81+
public int hashCode() {
82+
return KEY.hashCode();
83+
}
84+
85+
@Override
86+
public String toString() {
87+
return NAME;
88+
}
89+
90+
6791
}

src/main/java/org/elegoff/plugins/rust/linecounter/LineCountData.java

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

src/main/java/org/elegoff/plugins/rust/linecounter/LineCountParser.java

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

0 commit comments

Comments
 (0)