-
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
Fix negated globs passed to CLI are no longer worked. #1061
Conversation
@thecoden could you take a look on this PR and check it? |
I've taken a look through the code and so far it looks good to me. I'm going to try to find some time to check it out and run it as well. Thank you for your attention to this issue. |
ca27b3a
to
5070059
Compare
Hi @Tapchicoma, I've pulled and done some comparison with our branch and cleaned up our branch a bit to make the differences easier to see. I can submit a pull request if that makes it easier for you to see and pull what you want from it of course. The main differences in our solution are:
Otherwise yours appears to function per your spec as well from check out and I hope we've been helpful. On future improvements, we will be more efficient as it took quite a bit to get the project set up and testing on our end. Oh, and Happy New Year! |
@thecoden thank you for your review 👏
Yeah, this is the thing I want to add to this PR before merging it.
Interesting, now sure that this scenario should be supported 🤔 But on the second though may happen 🤔 I will take another look on your implementation 👍 |
Thank you @Tapchicoma, I'm sorry for the delay. For some reason I'm not getting my github alerts for any of this conversation or repo so I missed it. One more difference I just caught as well, is that we added support for the Something we also should have done is converted the |
Probably I will not add
That is a nice improvement - will add it as well 👍 |
With a developer tool, and it being directly supported in the PathMatcher, I figured leave regex because it is essentially more complete / flexible than glob, but the decision is yours sir and can always be enabled later easily.
👍 Thank you and I agree. Little things like compiled regexes do make a big performance difference over time. I'm not into pre-optimization per se, but really creating the regex once should be default practice anyway since it is immutable anyway. |
@Tapchicoma #1084 looks related. It would be great if you can resolve the conflicts or let me know if I can be of any help. Thanks. |
5070059
to
6d5cb82
Compare
6d5cb82
to
42a155b
Compare
Migrate method to get all mathing globs files to use internally 'PathMatcher' and 'FileVisitor' instead of using klob dependency. Fix negated globs passed to CLI are no longer worked.
42a155b
to
acab4fc
Compare
This is very problematic for large codebases. Our pre-commit hook attempts to pass an explicit list of files to ktlint. Unfortunately, ktlint now walks over our entire codebase to filter those files in, and so our pre-commit hook now takes about 40 seconds rather than completing in under 1 second. Is there some way we can pass an explicit list of files and bypass this directory crawl? |
Same – we used to pass changed files to ktlint in 0.40.0 to get out results in a snap, and have to wait 15-20 seconds with 0.41.0. It seems to me that the addressing negated blobs by doing a full crawl doesn't make sense in the general case. Also, I don't think this implementation respects the order of the globs (e.g. |
return kotlinFiles | ||
.map(Path::toFile) | ||
val result = mutableListOf<Path>() | ||
Files.walkFileTree( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
walking an entire huge project from the root to see what matches the globs is hugely inefficient.
Each glob should be expanded instead via Files.newDirectoryStream()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looked over the Klob code and it has a lot of optimizations that should be used and was ironically extracted out of ktlint 🤔
I'll put up a PR that pulls in the Klob code since that handles negated globs as well.
hmm..this was added after this PR to handle the case of passing in a list of files w/o any filetree walking: |
Description
Migrate method to get all mathing globs files to use internally
PathMatcher
andFileVisitor
instead of using klob dependency.Fixes #999
Checklist
CHANGELOG.md
is updated