-
Notifications
You must be signed in to change notification settings - Fork 506
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
Exclusive / Negated Globs No Longer Work #999
Comments
Unfortunately I've missed this case in my fix 😒 I am considering replacing |
All good @Tapchicoma . For now, I have published an artifact to jcenter to fix the klob issue and I am prepping a pull request to go back to the simpler code using the new artifact. We also submitted pull requests to the original klob author of course so you could switch back to that dependency should you choose to do so. If you'd like, I will also work on the replacement using the PathMatcher as you mentioned. |
In addition to the previous fix, we now have a class that uses PathMatcher and the kotlin File.walkTopDown() method to visit the tree. It uses relative paths and works well, but PathMatcher has some slight differences in behavior compared to Klob. Mainly, the path We could leave this if you are happy with that behavior or attempt a replacement of */ in patterns, but I can see where it could be convenient to match only files in at least one directory down instead of assuming the root directory matches when you have a I have started creating unit tests for this, based on Klob, which is how I discovered the behavior difference. Please let me know how to proceed. See the following branch / commit: Thank you! |
I have further updated our Path Matcher / Vistor branch to have better documentation, receive the baseDirectory as a parameter to the getFiles() method, allowing for manual matching against a single path for testing, etc. and, allowed for regex support, which is supported by the standard PathMatcher. By default, patterns are assumed to be glob, but if you pass a pattern in such as Please let us know next steps to move these items forward if you would like to take this direction. Thank you again for an awesome tool! |
interesting, I would assume Will check your changes and see how it works 👍 |
Hi @Tapchicoma , Sorry for the delayed response. Yes, the code defaults to |
* Remove klob dependency as this was replaced with custom implementation in ktlint 0.41.0 via pinterest#999. * Remove unused libs.kotlin.compiler dependency
Expected Behavior
When I run ktlint with
**/*.kt
&!**/generated/**
, all files in any subfolder of a folder named generated should be excluded.Observed Behavior
After many tests, and reviewing the code, negated patterns are completely ineffective.
Steps to Reproduce
**/*.kt
&!**/generated/**
patterns and note that files in the generated folder are still listed.Your Environment
Gradle, Linux
Solution
This issue was originally caused by the workaround in issue #942 Instead of using the Glob.from(vararg pattern) method, it iterates each pattern, collecting all the matching files, which prevents the exclusion pattern from working.
I have fixed the original issue in the
klob
dependency so that the workaround is no longer necessary. I will submit a pull request of the correction to ktlint.The text was updated successfully, but these errors were encountered: