Why you should care
Nullable boolean can be null, or having a value "true" or "false".var a: Boolean? // a is a nullable boolean
if ((a != null) && (a == true)) { ... } else { ... }
if ( a ?: false ) { ... } else { .... }
if ( a == true ) { ... } else { .... }
How we detect
CAST Highlight counts one occurrence each time the pattern ?:true or ?:false is encountered.References
https://kotlinlang.org/docs/coding-conventions.html https://riptutorial.com/kotlin/example/30735/elvis-operator----- https://github.com/Kotlin/kotlin-style-guide/issues/18About CAST and Highlight’s Code Insights
Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.
For reference only. For the complete details please refer the original article
https://doc.casthighlight.com/alt_badnullablecheck-use-instead-dealing-nullable-boolean/
https://doc.casthighlight.com/alt_badnullablecheck-use-instead-dealing-nullable-boolean/
Comments