-
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
ktlint 0.48.1 doesn't use experimental rules if .editorconfig
is empty
#1768
Comments
I'll join with a related question: how should API consumers configure the rules? The API looks like passing
This inconsistency seems confusing from the API usage perspective, IMO. Perhaps it'd make sense to keep the API straightforward, and make it responsibility of the wrappers (like CLI or Kotlinter) to properly filter out experimental rules based on the tool configuration? |
I will come back on this issue next week earliest. I am having holidays and do not have to my laptop. |
This indeed is not correct. It will be fixed with #1772. It is not strictly related to the editorconfig being empty but whether property
Indeed, the file name used for code snippets should not cause a violation by the filename rule. Will be fixed with #1778.
This is the most difficult part of the issue to answer. I do understand that both of you advocate that all rules provided by the API Consumer have to be respected (e.g. to be run automatically). However, from the viewpoint of Ktlint, the end user (e.g. the developer who uses ktlint, kotlinter, or any other KtLint API consumer) should be in control on enabling or disabling experimental rules. This can best be done by providing the EditorConfigDefault value as shown below:
If the user has set property If you do want to ignore the value of
I have been thinking about this as well but disregarded it in the end. Some projects use multiple Above explanation has also been added to the changelog via #1778 for other API Consumers. |
@mateuszkwiecinski @lwasyl Can you please try the latest snapshot of ktlint (https://pinterest.github.io/ktlint/install/snapshot-build/) to check if this helps? |
@paul-dingemans I tested latest snapshot locally, and it seems to behave in an expected way 👍
🙏 |
Tnx for confirmation. I will do some more tests and prepare for the |
We're trying to upgrade kotlinter to use the latest version and our tests caught the plugin doesn't respect experimental rules.
Here's the smallest repro I was able to come up with:
Expected Behavior
filename
rule shouldn't fail forCode.CodeSnippet
Observed Behavior
If the editorconfig is empty, the test fails because ktlint doesn't run experimental checks against the code snippet. If the editorconfig contains any overrides the test passes. It seems like the VisitorProvider#isEnabled doesn't work well if the consumer has empty editorconfig.
Also, please note the
check(!failedRules.contains("filename"))
check, which I believe is a separate issue, the code currently emitsLintError(line=1, col=1, ruleId=filename, detail=File name 'file.kt' should conform PascalCase)
which I believe comes from here. Linting aCode.CodeSnipped
shouldn't probably result in anfilename
error.Steps to Reproduce
☝️
In the repro, while debugging the code here, the repro fails only when
ruleExecutionContext.editorConfigProperties
is empty here. Otherwise, experimental rulesets work as expectedYour Environment
.editorconfig
settings - it has to be emptyThe text was updated successfully, but these errors were encountered: