Ktlint with android multimodule project

Hello,

ALM: Github
CI: Circle CI
Command: ./gradlew sonar
Language: Kotlin

We are using ktlint on our project and I notice that for example the rule standard:no-consecutive-blank-lines is effectively brought up in my branch summary but not the standard:max-line-length.

Is it something expected ?

That leads me to another question, should we, in an android multi module context, generate a ktlint report for each modules ? or the consolidated one at the root should work ? (like in the example below)

Example of ktlint report send to Sonarcloud:

[
    {
        "file": "app/file1.kts",
        "errors": [
            {
                "line": 97,
                "column": 1,
                "message": "Needless blank line(s)",
                "rule": "standard:no-consecutive-blank-lines"
            }
        ]
    },
    {
        "file": "module/file2.kt",
        "errors": [
            {
                "line": 198,
                "column": 1,
                "message": "Exceeded max line length (120)",
                "rule": "standard:max-line-length"
            },
            {
                "line": 209,
                "column": 1,
                "message": "Exceeded max line length (120)",
                "rule": "standard:max-line-length"
            }
        ]
    }
]

Hi,

Welcome to the community!

In your example report, the missing issues are reported on one file while the issue that shows up as expected is reported on a different file. Could you try this with all the issues on the same file to make sure this is about the rules and not the files?

 
Thx,
Ann

Hello,

Thanks for taking a look at my issue.

Finally I managed to understand what was happening and this is silly…

I was making ktlint errors in my local code and start the sonar task locally also, but I was not committing and pushing my code to our github repository, so I suppose there is some check toward the remote commit before displaying the issue on Sonarcloud UI.

So when I commit and push the code with the ktlint problem it is now displayed.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.