Skip to content

Commit 0b6cca2

Browse files
authored
Move to sq10 (#77)
* Bump sonar-api and use junit5 * more junit5 tests * Move to slf4j for logging * bump dependencies versions * Format specifiers used instead of string concatenation * invoke method conditionnaly * review formatting * JUnit5 test classes and methods should have default package visibility * modifiers for junit5 * lines formatting * align to new impact model * use containsEntry in assertions
1 parent 8768766 commit 0b6cca2

File tree

116 files changed

+3330
-2630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+3330
-2630
lines changed

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
106106
### 4. Permanent Ban
107107

108108
**Community Impact**: Demonstrating a pattern of violation of community
109-
standards, including sustained inappropriate behavior, harassment of an
109+
standards, including sustained inappropriate behavior, harassment of an
110110
individual, or aggression toward or disparagement of classes of individuals.
111111

112112
**Consequence**: A permanent ban from any sort of public interaction within

FAQ.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#FAQ
22

3-
43
* ### How do I build the plugin from source
54

65
This project is built with Maven
76
Use : `mvn clean package`
87

98
* ### Can I use this plugin on SonarCloud ?
109

11-
SonarCloud is a little different to SonarQube in that it doesn’t currently provide the ability to add third-party plugins like `Sonar rust`.
10+
SonarCloud is a little different to SonarQube in that it doesn’t currently provide the ability to add third-party
11+
plugins like `Community rust`.
1212

1313
* ### Can I use this plugin on SonarLint ?
1414

@@ -20,7 +20,8 @@ You don't. The (free) Community edition v7.9+ is compatible (and so are Commerci
2020

2121
* ### Can I scan my Rust source code from a CI/CD pipeline ? Can I get Pull Requests decoration ?
2222

23-
There is nothing specific for this plugin. Any CI pipeline which allows a SonarQube analysis can trigger an analysis on a Rust project
23+
There is nothing specific for this plugin. Any CI pipeline which allows a SonarQube analysis can trigger an analysis on
24+
a Rust project
2425
The only requirement is that the `Community Rust` plugin is installed on your SonarQube instance
2526

2627
* ### Does this Community Rust plugin provide a built-in Quality Profile ?
@@ -33,14 +34,16 @@ Yes, the issues on other languages will be detected by their respective language
3334

3435
* ### How do I reach out for issues, feature requests or questions not listed here ?
3536

36-
- Issues / Feature requests specific to this plugin can be tracked after you [create a Github issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-issues/creating-an-issue)
37-
- Issues that are related to SonarQube behaviour should be reported in their [Community forum](https://community.sonarsource.com/)
37+
- Issues / Feature requests specific to this plugin can be tracked after
38+
you [create a Github issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-issues/creating-an-issue)
39+
- Issues that are related to SonarQube behaviour should be reported in
40+
their [Community forum](https://community.sonarsource.com/)
3841
- Private material (like source files failing to be parsed) can be sent at community-rust@pm.me
3942

4043

4144
* ### How can I contribute to improving/fixing this plugin ?
4245

43-
We would love to have more contributors.
46+
We would love to have more contributors.
4447
Please read this nice [article](https://gist.github.com/MarcDiethelm/7303312) to get ideas how you can help
4548

4649

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
| | |
2-
| --- | --- |
3-
| [![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=elegoff_sonar-rust&metric=alert_status)](https://sonarcloud.io/dashboard?id=elegoff_sonar-rust) | ![Coverage](https://sonarcloud.io/api/project_badges/measure?project=elegoff_sonar-rust&metric=coverage) |
4-
| [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)|[Download latest release](https://github.com/elegoff/sonar-rust/releases) |
1+
| | |
2+
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|
3+
| [![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=elegoff_sonar-rust&metric=alert_status)](https://sonarcloud.io/dashboard?id=elegoff_sonar-rust) | ![Coverage](https://sonarcloud.io/api/project_badges/measure?project=elegoff_sonar-rust&metric=coverage) |
4+
| [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) | [Download latest release](https://github.com/elegoff/sonar-rust/releases) |
55

66
## SonarQube plugin for Rust (Community)
77

88
The plugin enables analysis of Rust language within [SonarQube](https://www.sonarqube.org), which is an open platform to
9-
manage code quality.
9+
manage code quality.
1010

1111
### Compatibility with SonarQube versions :
1212

13-
|SonarQube | Rust plugin |
14-
|----------|--------------|
15-
| > 9.9 LTS| not tested |
16-
| 9.9 LTS | 0.2.1 |
17-
| 8.9 - 9.9| 0.1.0 |
18-
| <8.9 | not supported|
13+
| SonarQube | Rust plugin |
14+
|-----------|---------------|
15+
| > 9.9 LTS | not tested |
16+
| 9.9 LTS | 0.2.1 |
17+
| 8.9 - 9.9 | 0.1.0 |
18+
| <8.9 | not supported |
1919

2020
It leverages [Clippy lints](https://rust-lang.github.io/rust-clippy/master/) to raise issues against coding
2121
rules, [LCOV](https://wiki.documentfoundation.org/Development/Lcov)

community-rust-checks/pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<artifactId>community-rust-frontend</artifactId>
2222
<version>${project.version}</version>
2323
</dependency>
24-
<!-- provided by SonarQube -->
25-
<dependency>
24+
<!-- provided by SonarQube -->
25+
<dependency>
2626
<groupId>org.sonarsource.api.plugin</groupId>
2727
<artifactId>sonar-plugin-api</artifactId>
2828
<scope>provided</scope>
@@ -37,10 +37,10 @@
3737
<artifactId>sonar-analyzer-test-commons</artifactId>
3838
</dependency>
3939

40-
<!-- test dependencies -->
41-
<dependency>
42-
<groupId>junit</groupId>
43-
<artifactId>junit</artifactId>
40+
<!-- test dependencies -->
41+
<dependency>
42+
<groupId>org.junit.jupiter</groupId>
43+
<artifactId>junit-jupiter-api</artifactId>
4444
</dependency>
4545
<dependency>
4646
<groupId>org.assertj</groupId>

community-rust-checks/src/main/java/org/elegoff/rust/checks/FunctionParametersCountCheck.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222

2323
import com.sonar.sslr.api.AstNode;
2424
import com.sonar.sslr.api.AstNodeType;
25-
import java.util.Collections;
26-
import java.util.Set;
2725
import org.sonar.check.Rule;
2826
import org.sonar.check.RuleProperty;
2927
import org.sonar.rust.RustGrammar;
3028

29+
import java.util.Collections;
30+
import java.util.Set;
31+
3132
@Rule(key = "FunctionParametersCount")
3233
public class FunctionParametersCountCheck extends RustCheck {
3334

community-rust-checks/src/test/java/org/elegoff/rust/checks/CheckListTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
*/
2121
package org.elegoff.rust.checks;
2222

23-
import org.junit.Test;
23+
import org.junit.jupiter.api.Test;
24+
2425

2526
import static org.assertj.core.api.Assertions.assertThat;
2627

27-
public class CheckListTest {
28+
class CheckListTest {
2829

2930
@Test
30-
public void testSize() {
31+
void testSize() {
3132
assertThat(CheckList.getRustChecks()).hasSize(3);
3233
}
3334
}

community-rust-checks/src/test/java/org/elegoff/rust/checks/EmptyEnumCheckTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@
2020
*/
2121
package org.elegoff.rust.checks;
2222

23-
import org.junit.Test;
24-
2523
import java.io.File;
24+
import org.junit.jupiter.api.Test;
2625

27-
public class EmptyEnumCheckTest {
26+
class EmptyEnumCheckTest {
2827

29-
@Test
30-
public void test() {
31-
RustCheckVerifier.verify(new File("src/test/resources/checks/empty_enum.rs"), new EmptyEnumCheck());
32-
}
28+
@Test
29+
void test() {
30+
RustCheckVerifier.verify(new File("src/test/resources/checks/empty_enum.rs"), new EmptyEnumCheck());
31+
}
3332
}

community-rust-checks/src/test/java/org/elegoff/rust/checks/FunctionParametersCountCheckTest.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,20 @@
2020
*/
2121
package org.elegoff.rust.checks;
2222

23-
import org.junit.Test;
24-
2523
import java.io.File;
24+
import org.junit.jupiter.api.Test;
2625

27-
public class FunctionParametersCountCheckTest {
28-
@Test
29-
public void test() {
30-
RustCheckVerifier.verify(new File("src/test/resources/checks/function_params_count.rs"), new FunctionParametersCountCheck());
31-
}
26+
class FunctionParametersCountCheckTest {
27+
@Test
28+
void test() {
29+
RustCheckVerifier.verify(new File("src/test/resources/checks/function_params_count.rs"), new FunctionParametersCountCheck());
30+
}
3231

33-
@Test
34-
public void custom() {
35-
FunctionParametersCountCheck check = new FunctionParametersCountCheck();
36-
check.maximumParameterCount = 10;
32+
@Test
33+
void custom() {
34+
FunctionParametersCountCheck check = new FunctionParametersCountCheck();
35+
check.maximumParameterCount = 10;
3736

38-
RustCheckVerifier.verifyNoIssueIgnoringExpected(new File("src/test/resources/checks/function_params_count.rs"), check);
39-
}
37+
RustCheckVerifier.verifyNoIssueIgnoringExpected(new File("src/test/resources/checks/function_params_count.rs"), check);
38+
}
4039
}

community-rust-checks/src/test/java/org/elegoff/rust/checks/LineLengthCheckTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@
2020
*/
2121
package org.elegoff.rust.checks;
2222

23-
import org.junit.Test;
23+
import org.junit.jupiter.api.Test;
2424

2525
import java.io.File;
2626

27-
public class LineLengthCheckTest {
28-
@Test
29-
public void test() {
30-
RustCheckVerifier.verify(new File("src/test/resources/checks/line_length.rs"), new LineLengthCheck());
31-
}
27+
class LineLengthCheckTest {
28+
@Test
29+
void test() {
30+
RustCheckVerifier.verify(new File("src/test/resources/checks/line_length.rs"), new LineLengthCheck());
31+
}
3232

33-
@Test
34-
public void custom() {
35-
LineLengthCheck check = new LineLengthCheck();
36-
check.maximumLineLength = 119;
37-
RustCheckVerifier.verify(new File("src/test/resources/checks/line_length_119.rs"), check);
38-
}
33+
@Test
34+
void custom() {
35+
LineLengthCheck check = new LineLengthCheck();
36+
check.maximumLineLength = 119;
37+
RustCheckVerifier.verify(new File("src/test/resources/checks/line_length_119.rs"), check);
38+
}
3939
}

community-rust-checks/src/test/java/org/elegoff/rust/checks/RustCheckVerifier.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@
3838
import org.sonarsource.analyzer.commons.checks.verifier.SingleFileVerifier;
3939

4040
public class RustCheckVerifier {
41-
public static void verify(File file, RustCheck check) {
41+
static void verify(File file, RustCheck check) {
4242
createVerifier(file, check, true, Integer.MAX_VALUE).assertOneOrMoreIssues();
4343
}
4444

45-
public static void verifyWithMarginRight(File file, RustCheck check, int marginRight) {
45+
static void verifyWithMarginRight(File file, RustCheck check, int marginRight) {
4646
createVerifier(file, check, true, marginRight).assertOneOrMoreIssues();
4747
}
4848

49-
public static void verifyNoIssue(File file, RustCheck check) {
49+
static void verifyNoIssue(File file, RustCheck check) {
5050
createVerifier(file, check, true, Integer.MAX_VALUE).assertNoIssues();
5151
}
5252

53-
public static void verifyNoIssueIgnoringExpected(File file, RustCheck check) {
53+
static void verifyNoIssueIgnoringExpected(File file, RustCheck check) {
5454
createVerifier(file, check, false, Integer.MAX_VALUE).assertNoIssues();
5555
}
5656

0 commit comments

Comments
 (0)