Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
### What's done:
* Review
  • Loading branch information
kgevorkyan committed Sep 5, 2023
1 parent 9e9f38f commit 3ed6314
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,19 @@ class PreviewAnnotationRule(configRules: List<RulesConfig>) : DiktatRule(
?.getChildren(KtTokens.MODIFIER_KEYWORDS)
?.toList()

val isContainOpenOrAbstractKeyword = modifiersList?.any {
it.elementType in listOf(OPEN_KEYWORD, ABSTRACT_KEYWORD)
val isMethodAbstract = modifiersList?.any {
it.elementType == ABSTRACT_KEYWORD
}

// private modifier is not applicable for abstract and open methods
// so search only those, which can be replaced via `private`
if (isContainOpenOrAbstractKeyword == true) {
// private modifier is not applicable for abstract methods
if (isMethodAbstract == true) {
return
}

// these modifiers could be safely replaced via `private`
val modifierForReplacement = modifiersList?.firstOrNull {
it.elementType in listOf(
PUBLIC_KEYWORD, PROTECTED_KEYWORD, INTERNAL_KEYWORD
PUBLIC_KEYWORD, PROTECTED_KEYWORD, INTERNAL_KEYWORD, OPEN_KEYWORD
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private fun BannerPreview3() {}
private fun BannerPreview4() {}

@Preview
open fun BannerPreview5() {}
private fun BannerPreview5() {}

@Preview
final private fun BannerPreview6() {}

0 comments on commit 3ed6314

Please sign in to comment.