Skip to content

Commit

Permalink
Add alternate compliant code
Browse files Browse the repository at this point in the history
  • Loading branch information
atulgpt committed Jan 11, 2023
1 parent eeb49ee commit 8afd51c
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ import org.jetbrains.kotlin.utils.addToStdlib.ifTrue
*
* <compliant>
* fun foo(bar: Any?) {
* val x = checkNotNull(bar) as String
* }
*
* // Alternative
* fun foo(bar: Any?) {
* val x = (bar ?: error("null assertion message")) as String
* }
* </compliant>
*/
@RequiresTypeResolution
@Suppress("ReturnCount")
class CastNullableToNonNullableType(config: Config = Config.empty) : Rule(config) {
override val issue: Issue = Issue(
javaClass.simpleName,
Expand All @@ -43,6 +47,7 @@ class CastNullableToNonNullableType(config: Config = Config.empty) : Rule(config
Debt.FIVE_MINS
)

@Suppress("ReturnCount")
override fun visitBinaryWithTypeRHSExpression(expression: KtBinaryExpressionWithTypeRHS) {
super.visitBinaryWithTypeRHSExpression(expression)

Expand Down

0 comments on commit 8afd51c

Please sign in to comment.