-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Description
Problem
When the Rust project is located in a subdirectory, the sonar-scanner is unable to resolve the path, resulting in the warning:
WARN Failed to resolve 1 file path(s) in Clippy report. No issues imported related to file(s): src/main.rs
Related
The PR 66 introduced the FileAdjustor
, which takes the path from the message:spans:file_name
property of the generated clippy report. The file name seems to be relative to the project root.
Possible solution
One could consider the target:src_path
property from the report as well, to find the source files.
An example report that shows the properties:
{
"reason": "compiler-message",
"package_id": "path+file:///builds/user/ci-test/rust/quality_test#0.1.0",
"manifest_path": "/builds/user/ci-test/rust/quality_test/Cargo.toml",
"target": {
"kind": [
"bin"
],
"crate_types": [
"bin"
],
"name": "quality_test",
"src_path": "/builds/user/ci-test/rust/quality_test/src/main.rs",
"edition": "2021",
"doc": true,
"doctest": false,
"test": true
},
"message": {
"rendered": "warning: unneeded `return` statement\n --> src/main.rs:2:5\n |\n2 | return &val[12..50];\n | ^^^^^^^^^^^^^^^^^^^\n |\n = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return\n = note: `#[warn(clippy::needless_return)]` on by default\nhelp: remove `return`\n |\n2 - return &val[12..50];\n2 + &val[12..50]\n |\n\n",
"$message_type": "diagnostic",
"children": [
{
"children": [],
"code": null,
"level": "help",
"message": "for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return",
"rendered": null,
"spans": []
},
{
"children": [],
"code": null,
"level": "note",
"message": "`#[warn(clippy::needless_return)]` on by default",
"rendered": null,
"spans": []
},
{
"children": [],
"code": null,
"level": "help",
"message": "remove `return`",
"rendered": null,
"spans": [
{
"byte_end": 53,
"byte_start": 34,
"column_end": 24,
"column_start": 5,
"expansion": null,
"file_name": "src/main.rs",
"is_primary": true,
"label": null,
"line_end": 2,
"line_start": 2,
"suggested_replacement": "&val[12..50]",
"suggestion_applicability": "MachineApplicable",
"text": [
{
"highlight_end": 24,
"highlight_start": 5,
"text": " return &val[12..50];"
}
]
},
{
"byte_end": 54,
"byte_start": 53,
"column_end": 25,
"column_start": 24,
"expansion": null,
"file_name": "src/main.rs",
"is_primary": true,
"label": null,
"line_end": 2,
"line_start": 2,
"suggested_replacement": "",
"suggestion_applicability": "MachineApplicable",
"text": [
{
"highlight_end": 25,
"highlight_start": 24,
"text": " return &val[12..50];"
}
]
}
]
}
],
"code": {
"code": "clippy::needless_return",
"explanation": null
},
"level": "warning",
"message": "unneeded `return` statement",
"spans": [
{
"byte_end": 53,
"byte_start": 34,
"column_end": 24,
"column_start": 5,
"expansion": null,
"file_name": "src/main.rs",
"is_primary": true,
"label": null,
"line_end": 2,
"line_start": 2,
"suggested_replacement": null,
"suggestion_applicability": null,
"text": [
{
"highlight_end": 24,
"highlight_start": 5,
"text": " return &val[12..50];"
}
]
}
]
}
}
Metadata
Metadata
Assignees
Labels
No labels