I am trying CodeQL Action + detekt. I can upload t...
# detekt
j
I am trying CodeQL Action + detekt. I can upload the sarif file without problems and it detects where are the code smells, but I get this error:
Copy code
Preview unavailable
Sorry, we couldn't find this file in the repository.
I am using it in a multiplatform project, can be related?
g
Sorry, we couldn’t find this file in the repository.
mmm do you have the path of the file?
j
Copy code
- name: Upload code analysis reports
        if: ${{ matrix.os == 'ubuntu-latest' && always() }}
        uses: github/codeql-action/upload-sarif@v1
        with:
          sarif_file: build/reports/detekt/detekt.sarif
An example adding a magic number
it is correct
but GitHub doesn't show it, but it knows there are errors
and what errors
I am using non root packages, but having the file in the root, can be that the problem?
b
Did you provide the base path to detekt? If you do, detekt, probably, will use it instead of an absolute path.
j
I didn't, I have to check how to do that. But this should not be done by Detekt automatically? If I have 100 modules, I have to do that manually, and every time I add a new one, I have to remember to include it.
Being the official code convention I think it should be supported by default, I will try the base path fix to confirm that is the issue and I will file an issue.
I am checking the sarif generated and it is showing the correct uri
When the file is on root
When the file is in an specific folder which follow the same package
btw in both cases fails. The problems are in the commonMain
c
Since
basePath
is newly introduced, it is not yet the default behavior for 1.16
You will probably need to add
Copy code
detekt {
    basePath = rootProject.projectDir
}
You can verify this is working to check if the sarif output includes
originalUriBaseIds
j
I will try, thank you 🙂
Yeah, it is working,
basePath = rootProject.projectDir.path
Do you think this should be fixed by default?
👍 1
b
I remember that we had that idea and we decide to do it later for some reason. But I think that we forget
c
The plan is to add the option in 1.16 and turn it on by default in later version.
j
I am going to play with the source dirs removing the need of using src, main or kotlin to get a project structure like this one (supposing a multiplatform project)
Copy code
project/common/Platform.kt
project/commonTest/PlatformTest.kt
project/ios/Platform.kt
project/iosTest/AnotherTest.kt
project/jvm/Platform.kt
project/jvmTest/AnotherTest.kt
...
project/build.gradle.kts
Platform.kt (or whatever) will have a package which folders doesnt exist as I mentioned in this thread. Can I have problems or detekt will works perfectly?
I think it is working perfectly (at least html output)
Sarif looks good I think too
b
If you use the type solving it should work. If you find something strange open an issue.
121 Views