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

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
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 this pull request may close these issues.

None yet

1 participant