diff --git a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExplicitItLambdaParameter.kt b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExplicitItLambdaParameter.kt index c6076fa9bf5..852845eba2f 100644 --- a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExplicitItLambdaParameter.kt +++ b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExplicitItLambdaParameter.kt @@ -14,7 +14,7 @@ import org.jetbrains.kotlin.psi.KtLambdaExpression /** * Lambda expressions are one of the core features of the language. They often include very small chunks of * code using only one parameter. In this cases Kotlin can supply the implicit `it` parameter - * to make code more concise. It fits most usecases, but when faced larger or nested chunks of code, + * to make code more concise. It fits most use cases, but when faced larger or nested chunks of code, * you might want to add an explicit name for the parameter. Naming it just `it` is meaningless and only * makes your code misleading, especially when dealing with nested functions. * @@ -55,11 +55,16 @@ class ExplicitItLambdaParameter(val config: Config) : Rule(config) { super.visitLambdaExpression(lambdaExpression) val parameterNames = lambdaExpression.valueParameters.map { it.name } if (IT_LITERAL in parameterNames) { + val message = if (parameterNames.size == 1) { + "This explicit usage of `it` as the lambda parameter name can be omitted." + } else { + "`it` should not be used as name for a lambda parameter." + } report( CodeSmell( issue, Entity.from(lambdaExpression), - "This explicit usage of `it` as the lambda parameter name can be omitted." + message ) ) }