Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven plugin complaining about trailing commas when those checks are disabled #507

Closed
binkley opened this issue Aug 22, 2022 · 6 comments · Fixed by #509
Closed

Maven plugin complaining about trailing commas when those checks are disabled #507

binkley opened this issue Aug 22, 2022 · 6 comments · Fixed by #509

Comments

@binkley
Copy link

binkley commented Aug 22, 2022

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).

@binkley
Copy link
Author

binkley commented Aug 22, 2022

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

@binkley
Copy link
Author

binkley commented Aug 22, 2022

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

@michael-wirth
Copy link

I have the same issue.

It seems that version 1.15.0 ignores ktlint_disabled_rules or disabled_rules property

@michael-wirth
Copy link

michael-wirth commented Aug 24, 2022

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

freemanjp added a commit that referenced this issue Aug 28, 2022
Was only looking in the current module.

Fixes #507
Fixes #508
freemanjp added a commit that referenced this issue Aug 28, 2022
Was only looking in the current module.

Fixes #507
Fixes #508
@freemanjp
Copy link
Member

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

@binkley
Copy link
Author

binkley commented Sep 5, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants