Skip to content

Commit bd825c5

Browse files
committed
Fix clippy import unit tests
1 parent 8cc6b66 commit bd825c5

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

community-rust-plugin/src/test/java/org/elegoff/plugins/communityrust/clippy/ClippySensorTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
import static java.nio.charset.StandardCharsets.UTF_8;
5252

5353
public class ClippySensorTest{
54-
private static final String CLIPPY_FILE = "resources-project:clippy/main.rs";
54+
private static final String CLIPPY_FILE = "clippy-project:main.rs";
5555
private static final String CLIPPY_AEC="external_clippy:clippy::absurd_extreme_comparisons";
5656
private static final String CLIPPY_REPORT_TXT = "myreport.txt";
5757
private static final String UNKNOWN_KEY_REPORT = "synreport.txt";
@@ -174,14 +174,14 @@ public static void assertNoErrorWarnDebugLogs(LogTester logTester) {
174174
org.assertj.core.api.Assertions.assertThat(logTester.logs(LoggerLevel.DEBUG)).isEmpty();
175175
}
176176

177-
private static List<ExternalIssue> executeSensorImporting(int majorVersion, int minorVersion, @Nullable String fileName) throws IOException {
178-
Path baseDir = PROJECT_DIR.getParent();
179-
SensorContextTester context = SensorContextTester.create(baseDir);
177+
private static List<ExternalIssue> executeSensorImporting(int majorVersion, int minorVersion, @Nullable String reportFileName) throws IOException {
178+
//Path baseDir = PROJECT_DIR.getParent();
179+
SensorContextTester context = SensorContextTester.create(PROJECT_DIR);
180180
try (Stream<Path> fileStream = Files.list(PROJECT_DIR)) {
181-
fileStream.forEach(file -> addFileToContext(context, baseDir, file));
181+
fileStream.forEach(file -> addFileToContext(context, PROJECT_DIR, file));
182182
context.setRuntime(SonarRuntimeImpl.forSonarQube(Version.create(majorVersion, minorVersion), SonarQubeSide.SERVER, SonarEdition.DEVELOPER));
183-
if (fileName != null) {
184-
String path = PROJECT_DIR.resolve(fileName).toAbsolutePath().toString();
183+
if (reportFileName != null) {
184+
String path = PROJECT_DIR.resolve(reportFileName).toAbsolutePath().toString();
185185
context.settings().setProperty("community.rust.clippy.reportPaths", path);
186186
}
187187
clippySensor.execute(context);

community-rust-plugin/src/test/resources/clippy/myreport.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Checking clippy-issues v0.1.0 (/Users/ericlegoff/lab/clippy-issues)
2-
{"reason":"compiler-message","package_id":"clippy-issues 0.1.0 (path+file:///Users/ericlegoff/lab/clippy-issues)","target":{"kind":["bin"],"crate_types":["bin"],"name":"clippy-issues","src_path":"/Users/ericlegoff/lab/clippy-issues/src/main.rs","edition":"2018","doctest":false},"message":{"rendered":"error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false\n --> clippy/main.rs:9:8\n |\n9 | if vec.len() <= 0 {}\n | ^^^^^^^^^^^^^^\n |\n = note: `#[deny(clippy::absurd_extreme_comparisons)]` on by default\n = help: because `0` is the minimum value for this type, the case where the two sides are not equal never occurs, consider using `vec.len() == 0` instead\n = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons\n\n","children":[{"children":[],"code":null,"level":"note","message":"`#[deny(clippy::absurd_extreme_comparisons)]` on by default","rendered":null,"spans":[]},{"children":[],"code":null,"level":"help","message":"because `0` is the minimum value for this type, the case where the two sides are not equal never occurs, consider using `vec.len() == 0` instead","rendered":null,"spans":[]},{"children":[],"code":null,"level":"help","message":"for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons","rendered":null,"spans":[]}],"code":{"code":"clippy::absurd_extreme_comparisons","explanation":null},"level":"error","message":"this comparison involving the minimum or maximum element for this type contains a case that is always true or always false","spans":[{"byte_end":194,"byte_start":180,"column_end":22,"column_start":8,"expansion":null,"file_name":"clippy/main.rs","is_primary":true,"label":null,"line_end":9,"line_start":9,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":22,"highlight_start":8,"text":" if vec.len() <= 0 {}"}]}]}}
3-
{"reason":"compiler-message","package_id":"clippy-issues 0.1.0 (path+file:///Users/ericlegoff/lab/clippy-issues)","target":{"kind":["bin"],"crate_types":["bin"],"name":"clippy-issues","src_path":"/Users/ericlegoff/lab/clippy-issues/src/main.rs","edition":"2018","doctest":false},"message":{"rendered":"error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false\n --> clippy/main.rs:10:8\n |\n10 | if 100 > std::i32::MAX {}\n | ^^^^^^^^^^^^^^^^^^^\n |\n = help: because `std::i32::MAX` is the maximum value for this type, this comparison is always false\n = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons\n\n","children":[{"children":[],"code":null,"level":"help","message":"because `std::i32::MAX` is the maximum value for this type, this comparison is always false","rendered":null,"spans":[]},{"children":[],"code":null,"level":"help","message":"for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons","rendered":null,"spans":[]}],"code":{"code":"clippy::absurd_extreme_comparisons","explanation":null},"level":"error","message":"this comparison involving the minimum or maximum element for this type contains a case that is always true or always false","spans":[{"byte_end":224,"byte_start":205,"column_end":27,"column_start":8,"expansion":null,"file_name":"clippy/main.rs","is_primary":true,"label":null,"line_end":10,"line_start":10,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":27,"highlight_start":8,"text":" if 100 > std::i32::MAX {}"}]}]}}
2+
{"reason":"compiler-message","package_id":"clippy-issues 0.1.0 (path+file:///Users/ericlegoff/lab/clippy-issues)","target":{"kind":["bin"],"crate_types":["bin"],"name":"clippy-issues","src_path":"/Users/ericlegoff/lab/clippy-issues/src/main.rs","edition":"2018","doctest":false},"message":{"rendered":"error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false\n --> main.rs:9:8\n |\n9 | if vec.len() <= 0 {}\n | ^^^^^^^^^^^^^^\n |\n = note: `#[deny(clippy::absurd_extreme_comparisons)]` on by default\n = help: because `0` is the minimum value for this type, the case where the two sides are not equal never occurs, consider using `vec.len() == 0` instead\n = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons\n\n","children":[{"children":[],"code":null,"level":"note","message":"`#[deny(clippy::absurd_extreme_comparisons)]` on by default","rendered":null,"spans":[]},{"children":[],"code":null,"level":"help","message":"because `0` is the minimum value for this type, the case where the two sides are not equal never occurs, consider using `vec.len() == 0` instead","rendered":null,"spans":[]},{"children":[],"code":null,"level":"help","message":"for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons","rendered":null,"spans":[]}],"code":{"code":"clippy::absurd_extreme_comparisons","explanation":null},"level":"error","message":"this comparison involving the minimum or maximum element for this type contains a case that is always true or always false","spans":[{"byte_end":194,"byte_start":180,"column_end":22,"column_start":8,"expansion":null,"file_name":"main.rs","is_primary":true,"label":null,"line_end":9,"line_start":9,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":22,"highlight_start":8,"text":" if vec.len() <= 0 {}"}]}]}}
3+
{"reason":"compiler-message","package_id":"clippy-issues 0.1.0 (path+file:///Users/ericlegoff/lab/clippy-issues)","target":{"kind":["bin"],"crate_types":["bin"],"name":"clippy-issues","src_path":"/Users/ericlegoff/lab/clippy-issues/src/main.rs","edition":"2018","doctest":false},"message":{"rendered":"error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false\n --> main.rs:10:8\n |\n10 | if 100 > std::i32::MAX {}\n | ^^^^^^^^^^^^^^^^^^^\n |\n = help: because `std::i32::MAX` is the maximum value for this type, this comparison is always false\n = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons\n\n","children":[{"children":[],"code":null,"level":"help","message":"because `std::i32::MAX` is the maximum value for this type, this comparison is always false","rendered":null,"spans":[]},{"children":[],"code":null,"level":"help","message":"for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons","rendered":null,"spans":[]}],"code":{"code":"clippy::absurd_extreme_comparisons","explanation":null},"level":"error","message":"this comparison involving the minimum or maximum element for this type contains a case that is always true or always false","spans":[{"byte_end":224,"byte_start":205,"column_end":27,"column_start":8,"expansion":null,"file_name":"main.rs","is_primary":true,"label":null,"line_end":10,"line_start":10,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":27,"highlight_start":8,"text":" if 100 > std::i32::MAX {}"}]}]}}
44
{"reason":"compiler-message","package_id":"clippy-issues 0.1.0 (path+file:///Users/ericlegoff/lab/clippy-issues)","target":{"kind":["bin"],"crate_types":["bin"],"name":"clippy-issues","src_path":"/Users/ericlegoff/lab/clippy-issues/src/main.rs","edition":"2018","doctest":false},"message":{"rendered":"error: aborting due to 2 previous errors\n\n","children":[],"code":null,"level":"error","message":"aborting due to 2 previous errors","spans":[]}}
55
error: could not compile `clippy-issues`.
66

0 commit comments

Comments
 (0)