ktlint-gradle icon indicating copy to clipboard operation
ktlint-gradle copied to clipboard

Baseline file not created

Open ebrowne72 opened this issue 3 years ago • 5 comments

Using v10.1.0.

I have an Android project with many modules. In the main project build script we have the following:

subprojects {
    apply plugin: 'org.jlleitschuh.gradle.ktlint'

    // Global ktlint config
    ktlint {
        enableExperimentalRules.set(true)
        baseline.set(file("my-project-ktlint-baseline.xml"))
        outputColorName = "RED"
        outputToConsole = true
        verbose = true
        reporters {
            reporter "checkstyle"
        }
        filter {
            // Exclude generated files
            exclude("**/build/**")
            exclude("**/KtAnalyticsEvents.kt")
        }
    }
}

When I run the ktlintCheck task, the baseline file is not created.

ebrowne72 avatar Jun 03 '21 16:06 ebrowne72

Baseline is generated using special task - ktlintGenerateBaseline. Will add it to project readme.

Tapchicoma avatar Jun 03 '21 17:06 Tapchicoma

Cool, that worked.

But why did it create an empty baseline file in config/ktlint?

ebrowne72 avatar Jun 03 '21 20:06 ebrowne72

If you don't have any codestyle violations baseline will be empty.

Tapchicoma avatar Jun 03 '21 20:06 Tapchicoma

But why does it create the config/ktlint folder just to put an empty baseline file in it?

ebrowne72 avatar Jun 03 '21 21:06 ebrowne72

Yes, make sense to not generate baseline file if there are no lint errors present.

Tapchicoma avatar Jun 15 '21 20:06 Tapchicoma

hello everyone, how do I make ktlint not generate this file? I'm having problems running on my machine, with the following error: Exception in thread "main" java.io.FileNotFoundException: C:\Users\Path (Access is denied) however I have all permissions and I am admin of the machine :(

gabitheiss avatar Feb 10 '23 17:02 gabitheiss

@gabitheiss please open a new issue and include a stack trace

JLLeitschuh avatar Apr 04 '23 22:04 JLLeitschuh