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
Implemented #523 - open function option FunctionOnlyReturningConstant #524
Conversation
|
||
fun KtModifierListOwner.isOpen() = hasModifier(KtTokens.OPEN_KEYWORD) | ||
|
||
fun KtModifierListOwner.isPublic(): Boolean { |
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.
I think we could refactor this to isPrivate
and where its used negate it?
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.
I am not quite sure if I understood you correctly.
!isPrivate() is also true for ‘protected’ and ‘internal’
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.
Agree that isPublic
is not fully correct as a method name as it checks for much more
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.
I mean that this method effectively just tests if the modifier is not private. I think it is just used once and if we change the code on that line to !isPrivate, we can delete this method.
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.
isPublic()
is used 6 times.
The method checks if the modifier is not
- private
- protected
- internal
|
||
fun KtModifierListOwner.isOpen() = hasModifier(KtTokens.OPEN_KEYWORD) | ||
|
||
fun KtModifierListOwner.isPublic(): Boolean { |
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.
Agree that isPublic
is not fully correct as a method name as it checks for much more
@@ -24,8 +25,7 @@ class RedundantVisibilityModifierRule(config: Config = Config.empty) : Rule(conf | |||
private val classVisitor = ClassVisitor() | |||
private val childrenVisitor = ChildrenVisitor() | |||
|
|||
private fun KtModifierListOwner.isExplicitlyPublicNotOverridden() = isExplicitlyPublic() | |||
&& !this.hasModifier(KtTokens.OVERRIDE_KEYWORD) | |||
private fun KtModifierListOwner.isExplicitlyPublicNotOverridden() = isExplicitlyPublic() && !isOverridden() | |||
|
|||
private fun KtModifierListOwner.isExplicitlyPublic() = this.hasModifier(KtTokens.PUBLIC_KEYWORD) |
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.
I'd move this to the new file with extensions as well. This is the true isPublic
method
No description provided.