diktat
diktat copied to clipboard
[KtLint] Diktat resolves `locations/physicalLocation/region` incorrectly for `UNUSED_IMPORT`
Describe the bug
Diktat resolves locations/physicalLocation/region for UNUSED_IMPORT always to 1:1:
{
"level": "error",
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"uri": "save-demo/src/main/kotlin/com/saveourtool/save/demo/SaveDemo.kt",
"uriBaseId": "%SRCROOT%"
},
"region": {
"startColumn": 1,
"startLine": 1
}
}
}
],
"message": {
"text": "[UNUSED_IMPORT] unused imports should be removed: org.springframework.http.ResponseEntity - unused import"
},
"ruleId": "diktat-ruleset:file-structure"
},
Expected behavior
Sarif report is generated with invalid locations/physicalLocation/region
Observed behavior
Project has diktat's issues, the gradle plugin generates a sarif report. Github doesn't show annotations with some errors, but shows for another
Steps to Reproduce
https://github.com/saveourtool/save-cloud/pull/2025
Environment information
- diktat version: 1.2.5
- build tool (maven/gradle): gradle
- how is diktat run (CLI, plugin, etc.):
- kotlin version: 1.8.10
- operating system: -
- link to a project (if your project is public): save-cloud (https://github.com/saveourtool/save-cloud/pull/2003)
Gradle plug-in is run as
gradlew --continue -Pdiktat.githubActions=true diktatCheck mergeDiktatReports
This results in this effective Gradle configuration:
diktat {
githubActions = true
}
All CI runs with Diktat 1.2.5 exhibit correct behaviour:
- https://github.com/saveourtool/save-cloud/actions/runs/4463747186/jobs/7839255430#step:4:236
- https://github.com/saveourtool/save-cloud/actions/runs/4466399580/jobs/7844541609#step:4:235
- https://github.com/saveourtool/save-cloud/actions/runs/4466564524/jobs/7844910130#step:4:231
- https://github.com/saveourtool/save-cloud/actions/runs/4467134008/jobs/7846205202#step:4:243
- https://github.com/saveourtool/save-cloud/actions/runs/4467168125/jobs/7846281771#step:4:269
- https://github.com/saveourtool/save-cloud/actions/runs/4467250509/jobs/7846469276#step:4:233
- https://github.com/saveourtool/save-cloud/actions/runs/4467296528/jobs/7846569645#step:4:238
Probably, was some intermittent error.
@0x6675636b796f75676974687562 I created a PR with diktat's issue (unused import): https://github.com/saveourtool/save-cloud/actions/runs/4470214826/jobs/7853424666 The build failed, but there is no comment about it.
And no message about failing to merge sarif report. I guess I take it from local run (sorry for misleading)
SARIF Validator generated files have proper format
GitHub generates alerts, but as security/code-scanning: https://github.com/saveourtool/save-cloud/security/code-scanning?query=is%3Aopen+pr%3A2022
Need to investigate why it not added as comments
Githiub adds Code scanning comments only to updated part of code:
diktat does detect a location for unused import incorrectly (always 1:1), that why github doesn't show it
See: https://github.com/saveourtool/save-cloud/pull/2025 for example. The latest run was updated to upload manual sarif report with a proper location
Need to check that token is a trigger to validate unused imports: probably we use a File instead of import blabla, that why location is 1:1