Skip to content
New issue

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

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

Already on GitHub? # to your account

Globs like "**/*.kt" should also match files in current directory #1533

Merged
merged 9 commits into from
Jul 17, 2022

Conversation

paul-dingemans
Copy link
Collaborator

Description

The "**/*.kt" glob did not match files with extension ".kt" in the current dir, but only in sub directories due to the way how a glob was always converted to an absolute path.

Given a workdir contain a file that results in some lint violations:

~/workdir/src/main/kotlin $ ls      
Foo.kt

Get the lint violations without explicit patterns:

~/workdir/src/main/kotlin $ ktlint-0.45.2 *.kt --relative
Foo.kt:1:1: Unnecessary import (no-unused-imports)
Foo.kt:2:1: Missing space after // (comment-spacing)

Get the lint violations with explicit pattern *.kt:

~/workdir/src/main/kotlin $ ktlint-0.45.2 *.kt --relative
Foo.kt:1:1: Unnecessary import (no-unused-imports)
Foo.kt:2:1: Missing space after // (comment-spacing)

Get the lint violations with explicit pattern **/*.kt:

~/workdir/src/main/kotlin $ ktlint-0.45.2 **/*.kt --relative
<NO OUTPUT>

Get the lint violations with explicit pattern **/*.kt from the parent directory:

~/workdir/src/main/kotlin $ cd ..
~/workdir/src/main $ ktlint-0.45.2 **/*.kt --relative
kotlin/Foo.kt:1:1: Unnecessary import (no-unused-imports)
kotlin/Foo.kt:2:1: Missing space after // (comment-spacing)

Checklist

  • PR description added
  • tests are added
  • CHANGELOG.md is updated

In case of adding a new rule:

  • README.md is updated
  • Rule has been applied on Ktlint itself and violations are fixed

@paul-dingemans paul-dingemans added this to the 0.47.0 milestone Jul 14, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant