Skip to content

Commit

Permalink
Report CastToNullableType at the cast operator instead of the whole e…
Browse files Browse the repository at this point in the history
…xpression (#5350)

Closes #5346
  • Loading branch information
arturbosch committed Sep 25, 2022
1 parent 2db2098 commit 7b73606
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Expand Up @@ -47,6 +47,6 @@ class CastToNullableType(config: Config = Config.empty) : Rule(config) {

val message = "Use the safe cast ('as? ${nullableTypeElement.innerType?.text}')" +
" instead of 'as ${nullableTypeElement.text}'."
report(CodeSmell(issue, Entity.from(expression), message))
report(CodeSmell(issue, Entity.from(operationReference), message))
}
}
Expand Up @@ -16,7 +16,7 @@ class CastToNullableTypeSpec {
""".trimIndent()
val findings = subject.compileAndLint(code)
assertThat(findings).hasSize(1)
assertThat(findings).hasStartSourceLocation(2, 22)
assertThat(findings).hasStartSourceLocation(2, 24)
assertThat(findings[0]).hasMessage("Use the safe cast ('as? String') instead of 'as String?'.")
}

Expand Down

0 comments on commit 7b73606

Please sign in to comment.