You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If file paths are passed in the command line, and path of one file is a subpath of another file, then ktlint only reports issues of the file with the shortest path.
then only the issues of the AnotherBadClass.kt are reported.
This only happens if one's file path is a substring of another's file path. In the example above: /src/main/java/org/example/bug is a substring of src/main/java/org/example/bugtest. The case would also reproduce on the following paths of the second file:
ktlint "src/main/java/org/example/bugtest/SampleBadClass.kt" "src/main/java/org/example/bug/AnotherGoodClass.kt" reports no issues (issues in SampleBadClass found before are now not reported):
ktlint "src/main/java/org/example/bugtest/SampleBadClass.kt" "src/main/java/org/example/bug/AnotherBadClass.kt" reports only issues from AnotherBadClass.kt (issues in SampleBadClass found before are again not reported):
The bug also reproduces if multiple wildcards are used: ktlint "src/main/java/org/example/bug/*.kt" "src/main/java/org/example/bugtest/*.kt" only reports issues from AnotherBadClass.kt skipping SampleBadClass.kt:
ktlint gradle plugin runs ktlint exaclty like in the examples above, specifying a path to every single file. That currently leads to inconsistent reports between ktlint command line run (without file paths) and gradlew ktlintCheck.
Your Environment
Version of ktlint used: 0.39.0
Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): command line
Version of Gradle used (if applicable):
Operating System and version: macOS 10.15.7
The text was updated successfully, but these errors were encountered:
The current workaround kills any ability to use negated globs (begin with "!") because it is only additive with the results. I have forked the klob library and fixed the issue and published a package to bintray for now, as well as submitted pull requests to the original project. The new package was just approved for inclusion into jcenter under the artifact io.codetactics.klob:klob:0.2.1.
I will also submit a pull request to revert the workaround commit, with a small addition to also skip hidden files similar to the default paths. By my testing, this will allow inclusive & exclusive globs, while also correcting this issue at the root of the problem.
Observed Behavior
If file paths are passed in the command line, and path of one file is a subpath of another file, then
ktlint
only reports issues of the file with the shortest path.For example if there're 2 files with issues:
/src/main/java/org/example/bugtest/SampleBadClass.kt
/src/main/java/org/example/bug/AnotherBadClass.kt
then only the issues of the
AnotherBadClass.kt
are reported.This only happens if one's file path is a substring of another's file path. In the example above:
/src/main/java/org/example/bug
is a substring ofsrc/main/java/org/example/bugtest
. The case would also reproduce on the following paths of the second file:/src/main/java/org/example/bugtes/AnotherBadClass.kt
/src/main/java/org/example/bugte/AnotherBadClass.kt
/src/main/java/org/example/b/AnotherBadClass.kt
If the file with the shortest path doesn't have issues or that file doesn't exist then no issues are reported at all:
/src/main/java/org/example/bugtest/SampleBadClass.kt
/src/main/java/org/example/bug/NonExistingFile.kt
Expected Behavior
Issues from all files are correctly reported
Steps to Reproduce
Files setup
/src/main/java/org/example/bugtest/SampleBadClass.kt
:/src/main/java/org/example/bug/AnotherBadClass.kt
:/src/main/java/org/example/bug/AnotherGoodClass.kt
:Check results
ktlint "src/main/java/org/example/bugtest/SampleBadClass.kt"
finds issues as expected:ktlint "src/main/java/org/example/bugtest/SampleBadClass.kt" "src/main/java/org/example/bug/AnotherGoodClass.kt"
reports no issues (issues inSampleBadClass
found before are now not reported):ktlint "src/main/java/org/example/bugtest/SampleBadClass.kt" "src/main/java/org/example/bug/AnotherBadClass.kt"
reports only issues fromAnotherBadClass.kt
(issues inSampleBadClass
found before are again not reported):The bug also reproduces if multiple wildcards are used:
ktlint "src/main/java/org/example/bug/*.kt" "src/main/java/org/example/bugtest/*.kt"
only reports issues fromAnotherBadClass.kt
skippingSampleBadClass.kt
:Additional info
ktlint gradle plugin runs
ktlint
exaclty like in the examples above, specifying a path to every single file. That currently leads to inconsistent reports betweenktlint
command line run (without file paths) andgradlew ktlintCheck
.Your Environment
The text was updated successfully, but these errors were encountered: