Skip to content
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

Mark new AnnotationRule finding from 0.47.0 as non correctable #5343

Closed
arturbosch opened this issue Sep 23, 2022 · 2 comments · Fixed by #5398
Closed

Mark new AnnotationRule finding from 0.47.0 as non correctable #5343

arturbosch opened this issue Sep 23, 2022 · 2 comments · Fixed by #5398
Assignees
Labels
feature good first issue Issue that is easy to pickup for people that are new to the project help wanted

Comments

@arturbosch
Copy link
Member

Expected Behavior

https://github.com/pinterest/ktlint/blob/6265d7f7b16ced7405f3c3f83cffb2c30ada1df5/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/AnnotationRule.kt#L108-L116

Current Behavior

0.47.0 update is missing

Context

IJ plugin should not report KtLint findings which are not corrected as "auto correctable".
See #5324

@arturbosch arturbosch added help wanted feature good first issue Issue that is easy to pickup for people that are new to the project labels Sep 23, 2022
@sanggggg
Copy link
Contributor

sanggggg commented Oct 9, 2022

@arturbosch If you are not working on, can I work on this issue?

And I have a question,
ktlint tells us whether the rule is auto-correctable or not by canBeAutoCorrected parameter in emit callback, so is it okay to solve this issue by using this value?

private fun beforeVisitChildNodes(node: ASTNode) {
wrapping.beforeVisitChildNodes(node, autoCorrect) { offset, errorMessage, canBeAutoCorrected ->
emit.invoke(offset, errorMessage, canBeAutoCorrected)
}
}
private fun afterVisitChildNodes(node: ASTNode) {
wrapping.afterVisitChildNodes(node, autoCorrect) { offset, errorMessage, canBeAutoCorrected ->
emit.invoke(offset, errorMessage, canBeAutoCorrected)
}
}

ktlint's declaration of canBeAutoCorrected parameter in emit lambda

Currently checking whether the rule is auto-correctable or not by overriden function FormattingRule::canBeCorrectedByKtLint. But I think replacing it with canBeAutoCorrected parameter in emit callback can solve this problem more consistently with ktlint. (and do not need manual synchronizing)

// KtLint has rules which prompts the user to manually correct issues e.g. Filename and PackageName.
protected open fun canBeCorrectedByKtLint(message: String): Boolean = true

I also checked that current behaviors of FormattingRule::canBeCorrectedByKtLint in each implementation rules are exactly same as ktlint(0.47.1)'s canBeAutoCorrected parameter in emit lambda. (except for AnnotationRule)

@arturbosch
Copy link
Member Author

arturbosch commented Oct 9, 2022

Oh, you are totally right. In line 92 the _ parameter can be used for this.
Yes, I introduced unnecessary complexity here :/.
@Sangggg Yes, please. You can work on it.
RulesWhichCantBeCorrectedSpec are the testcases which would be still green I think :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature good first issue Issue that is easy to pickup for people that are new to the project help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants