From 3e6d1d088f38f2e0087f43a5a13d0c7fd519420c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp?= Date: Thu, 22 Sep 2022 14:05:50 +0100 Subject: [PATCH] CanBeNonNullable: explain why the rule does what it does. (#5332) --- .../arturbosch/detekt/rules/style/CanBeNonNullable.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullable.kt b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullable.kt index a65ed2e7ceb..0899daab16c 100644 --- a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullable.kt +++ b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullable.kt @@ -62,6 +62,14 @@ import org.jetbrains.kotlin.types.isNullable * This rule inspects variables marked as nullable and reports which could be * declared as non-nullable instead. * + * It's preferred to not have functions that do "nothing". + * A function that does nothing when the value is null hides the logic, + * so it should not allow null values in the first place. + * It is better to move the null checks up around the calls, + * instead of having it inside the function. + * + * This could lead to less nullability overall in the codebase. + * * * class A { * var a: Int? = 5