-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add NewLineAfterSuperCall
Rule
#25
Conversation
super.visitNamedFunction(function) | ||
function.bodyBlockExpression?.statements?.forEachIndexed { index, statement -> | ||
if (statement.text?.startsWith("super") == true) { | ||
if (statement.nextSibling.text.contains("\n\n")) return |
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.
there's likely a cleaner way to do this, but I am not super on top of detekt APIs so for now sticking with this as it works!
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.
Thanks a lot for the update @hackertronix ! 🚀
Left a couple of small suggestions, good to go after checking them.
To make it the whole package, you can publish a new version and update Todoist afterwards. 🙏
override fun visitNamedFunction(function: KtNamedFunction) { | ||
super.visitNamedFunction(function) | ||
function.bodyBlockExpression?.statements?.forEachIndexed { index, statement -> | ||
if (statement.text?.startsWith("super") == true) { |
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.
Should we check here for super.
(i.e. with the dot at the end), just for extra safety ?
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.
good catch
|
||
override fun visitNamedFunction(function: KtNamedFunction) { | ||
super.visitNamedFunction(function) | ||
function.bodyBlockExpression?.statements?.forEachIndexed { index, statement -> |
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.
A bit ironic but ... Can we add an empty line here, please? 😇😅
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.
LOL
import org.junit.jupiter.api.Test | ||
|
||
@KotlinCoreEnvironmentTest | ||
internal class NewLineAfterSuperCallTest(private val env: KotlinCoreEnvironment) { |
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.
👏
@pedrodanielcsantos mentioned a formatting issue on my PR
So I've created a new rule to ensure we don't forget about it 🙂