gantsign/ktlint-maven-plugin

Maven plugin complaining about trailing commas when those checks are disabled

binkley opened this issue · 6 comments

tl;dr -- The Maven plugin mishandles trailing comma settings

Given this .editorconfig in my Maven project root:

[*.{kt,kts}]
ktlint_code_style = official
ktlint_disabled_rules = trailing-comma-on-call-site, trailing-comma-on-declaration-site

When I run Ktlint command line tool as ktlint 'src/**/*.kt' (version 0.47.0, latest as of this post), it produces no complaints, and ktlint -F 'src/**/*.kt' produces no file changes.

When I run with the Ktlint Maven plugin, the report or check goals complain about trailing commas both for call and declaration sites.

The pom.xml runs the plugin like this ("ktlint-maven-plugin.version" is set to 1.15.0):

            <plugin>
                <groupId>com.github.gantsign.maven</groupId>
                <artifactId>ktlint-maven-plugin</artifactId>
                <version>${ktlint-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>format</goal>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

I was previously able to disable other rules using .editorconfig (such as "import-ordering" to work around IntelliJ being non-standard -- the irony).

If it's not noise, here is what ./mvnw -X ktlint:check tells me (chopped down to just the part starting up Ktlint). I didn't spot anything special I should play with in my pom.xml:

[DEBUG] Configuring mojo 'com.github.gantsign.maven:ktlint-maven-plugin:1.15.0:check' with basic configurator -->
[DEBUG]   (f) android = false
[DEBUG]   (f) basedir = /Users/boxley/src/kt/kotlin-spring-boot-hateoas-database
[DEBUG]   (f) encoding = UTF-8
[DEBUG]   (f) experimental = false
[DEBUG]   (f) failOnViolation = true
[DEBUG]   (f) includeScripts = true
[DEBUG]   (f) includeSources = true
[DEBUG]   (f) includeTestSources = true
[DEBUG]   (f) packaging = jar
[DEBUG]   (f) scriptRoots = [/Users/boxley/src/kt/kotlin-spring-boot-hateoas-database]
[DEBUG]   (f) scriptsIncludes = [*.kts]
[DEBUG]   (f) skip = false
[DEBUG]   (f) sourceRoots = [/Users/boxley/src/kt/kotlin-spring-boot-hateoas-database/src/main/kotlin]
[DEBUG]   (f) sourcesIncludes = [**/*.kt]
[DEBUG]   (f) testSourceRoots = [/Users/boxley/src/kt/kotlin-spring-boot-hateoas-database/src/test/kotlin]
[DEBUG]   (f) testSourcesIncludes = [**/*.kt]
[DEBUG]   (f) verbose = true

I rechecked, and the only .editorconfig file is at my project root.

I have the same issue.

It seems that version 1.15.0 ignores ktlint_disabled_rules or disabled_rules property

ktlint v0.47.0 command-line tool respects the disabled_rules in the .editorconfig file. The issue is only with the maven-plugin 1.15.0.
Version 1.14.0 is working fine

@binkley thanks for reporting this issue, you can find the fix in version 1.15.1 of the plugin.

Apologies if this is covered elsewhere. I checked https://github.com/gantsign/ktlint-maven-plugin and didn't see anything on the front page on changes in this area.

@freemanjp Lots of warnings that I should use ktlint_disabled_rules rather than disabled_rules. Is this expected?

And version 1.15.1 is just what I was looking for. It unblocks me on multiple Kotlin projects for upgrading the plugin.