Repository: detekt/detekt (kotlin)

Issue:
Wrong replacement suggestion for [UnnecessaryFilter]
<!-- The bug you're experiencing might have already be reported! -->
<!-- Please search in the [issues](https://github.com/detekt/detekt/issues) before creating one. -->

## Expected Behavior
<!-- Tell us what should happen -->
List.size does not allow predicates, maybe detect means I should use count instead?
audioDeviceList.count { it.canPlay() } > 2

## Observed Behavior
val audioDeviceList: List<AudioDevice>

audioDeviceList.filter { it.canPlay() }.size > 2
'filter { it.canPlay() }' can be replaced by 'size { it.canPlay() }' [UnnecessaryFilter]

## Your Environment
<!-- Include as many relevant details about the environment you experienced the bug in -->
* Version of detekt used: 1.20

Pull request description:
Fixes #4806 

size is a property/member, not a method/function, and does not take any inputs.

Patch:
diff --git a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryFilter.kt b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryFilter.kt
index cec3ea4d15cb..7f88c7abfda4 100644
--- a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryFilter.kt
+++ b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryFilter.kt
@@ -94,7 +94,7 @@ class UnnecessaryFilter(config: Config = Config.empty) : Rule(config) {
         )
 
         private val secondCalls = listOf(
-            SecondCall(FqName("kotlin.collections.List.size")),
+            SecondCall(FqName("kotlin.collections.List.size"), "count"),
             SecondCall(FqName("kotlin.collections.List.isEmpty"), "any"),
             SecondCall(FqName("kotlin.collections.isNotEmpty"), "none"),
             SecondCall(FqName("kotlin.collections.count")),


Test patch:
diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryFilterSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryFilterSpec.kt
index ffa282759630..983b9c44526d 100644
--- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryFilterSpec.kt
+++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryFilterSpec.kt
@@ -24,7 +24,7 @@ class UnnecessaryFilterSpec(val env: KotlinCoreEnvironment) {
 
             val findings = subject.compileAndLintWithContext(env, code)
             assertThat(findings).hasSize(1)
-            assertThat(findings[0]).hasMessage("'filter { it > 1 }' can be replaced by 'size { it > 1 }'")
+            assertThat(findings[0]).hasMessage("'filter { it > 1 }' can be replaced by 'count { it > 1 }'")
         }
 
         @Test