-
Notifications
You must be signed in to change notification settings - Fork 510
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
Expose information about files/resources that will be accessed when invoking ktlint
#1446
Comments
I think, it would be not that difficult to provide a new API. Do I understand correctly that the request API would look something like: input: path to a source file I have two concerns though:
|
Hey @paul-dingemans! Sorry for a late reply 😬
As you probably saw my take on working around the issue, that's exactly what my proposal does, and I believe reading files is the only reasonable option, that's how editorconfig files work 🤷
I'm not sure if I fully understood this point. Your concern is about the new API methods you consider exposing? Or will it affect "regular" Regarding the API proposal:
My availability is limited recently, but I'll be happy to give an early feedback and test all changes you're about to propose :) |
The new API method will access the file system. The regular
Only files that are read by ktlint are the
The
This actually has already been released in KtLint 0.47.0.
Sure, no problem. |
All clear then! Thank you 🙏
Nice, I clearly focused too much on other api changes and missed that part of the release notes. Thanks for pointing that out. I can confirm I tested that locally and it works in an expected way 🚀 |
…inting or formatting a given path Closes pinterest#1446
@mateuszkwiecinski Can you please have a look at the PR (at least at the changelog)? |
* Add API for retrieving the list of files that will be accessed when linting or formatting a given path Closes #1446
…accessed Closes pinterest#1446 Closes pinterest#1659
Originally requested in: #1434 (comment)
Gradle Tasks should explicitly list their inputs. When a plugins like
ktlint-gradle
orkotlinter-gradle
want to use ktlint they try to guess which resources will be used byktlint
, i.e. which.editorconfig
files will be used : https://github.com/JLLeitschuh/ktlint-gradle/blob/ddd465e28d77b879384886e1eef5666ebe518b4d/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/PluginUtil.kt#L56Missing input declaration leads to bugs like jeremymailen/kotlinter-gradle#233 and as they try to guess and mimic
ktlint
behavior the new code becomes susceptible to bugs like JLLeitschuh/ktlint-gradle#575.I'm not sure what I'm asking specifically, but it would be nice to have a set of public utilities to identify
ktlint
dependencies (filesktlint
will access when invoked?).Expected Behavior
As a
ktlint
Gradle wrapper maintainer, I know which files will be accessed before actually invokingKtlint#lint
Current Behavior
Currently, there is no way to know which files/resources
ktlint
will read when invoked, which results in plugins trying to guess which files should be observed by Gradle to ensure build correctness.Additional information
If I'm not mistaken, ktlint uses external dependency,
EditorConfigLoader
which automagically reads all related properties for a given file location, but from Gradle Plugin perspective specific properties don't matter, so it can't be really used.The text was updated successfully, but these errors were encountered: