Skip to content

Commit

Permalink
Fix false positive for value classes in ModifierOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
eygraber committed May 21, 2021
1 parent 22eec63 commit d25098e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -211,6 +211,7 @@ If you contributed to detekt but your name is not in the list, please feel free
- [Krzysztof Kruczynski](https://github.com/krzykrucz) - Rule fix: ThrowingExceptionInMain, ExitOutsideMain
- [Paya Do](https://github.com/payathedo) - Designer for Detekt's logo
- [zmunm](https://github.com/zmunm) - New rule: ObjectLiteralToLambda
- [Eliezer Graber](https://github.com/eygraber) - Rule fix: ModifierOrder

### Mentions

Expand Down
Expand Up @@ -34,6 +34,7 @@ import org.jetbrains.kotlin.lexer.KtTokens.PUBLIC_KEYWORD
import org.jetbrains.kotlin.lexer.KtTokens.SEALED_KEYWORD
import org.jetbrains.kotlin.lexer.KtTokens.SUSPEND_KEYWORD
import org.jetbrains.kotlin.lexer.KtTokens.TAILREC_KEYWORD
import org.jetbrains.kotlin.lexer.KtTokens.VALUE_KEYWORD
import org.jetbrains.kotlin.lexer.KtTokens.VARARG_KEYWORD
import org.jetbrains.kotlin.psi.KtModifierList
import org.jetbrains.kotlin.psi.psiUtil.allChildren
Expand Down Expand Up @@ -75,6 +76,7 @@ class ModifierOrder(config: Config = Config.empty) : Rule(config) {
ENUM_KEYWORD, ANNOTATION_KEYWORD, FUN_KEYWORD,
COMPANION_KEYWORD,
INLINE_KEYWORD,
VALUE_KEYWORD,
INFIX_KEYWORD,
OPERATOR_KEYWORD,
DATA_KEYWORD
Expand Down
Expand Up @@ -121,5 +121,16 @@ class ModifierOrderSpec : Spek({
assertThat(subject.compileAndLint(code)).isEmpty()
}
}

context("value class") {

it("should not report correctly ordered modifiers") {
val code = """
@JvmInline
private value class Foo(val bar: Int)
"""
assertThat(subject.compileAndLint(code)).isEmpty()
}
}
}
})

0 comments on commit d25098e

Please sign in to comment.