Report warning on unused entities that can be renamed to _

Currently it's all about lambda parameters/destructuring entries

 #KT-14347 In Progress
This commit is contained in:
Denis Zharkov
2016-10-13 16:44:27 +03:00
parent a9fcee098d
commit 4c69416f2b
56 changed files with 123 additions and 121 deletions
@@ -8,7 +8,7 @@ class C {
}
fun test() {
for ((x, <!UNUSED_VARIABLE!>y<!>) in C()) {
for ((<!UNUSED_VARIABLE!>x<!>, <!UNUSED_VARIABLE!>y<!>) in C()) {
}
}
@@ -8,7 +8,7 @@ class C {
}
fun test() {
for ((x: Double, <!UNUSED_VARIABLE!>y<!>: Int) in <!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH, COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>C()<!>) {
for ((<!UNUSED_VARIABLE!>x<!>: Double, <!UNUSED_VARIABLE!>y<!>: Int) in <!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH, COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>C()<!>) {
}
}
}
@@ -9,7 +9,7 @@ class C {
}
fun test() {
for ((x, <!UNUSED_VARIABLE!>y<!>) in <!COMPONENT_FUNCTION_AMBIGUITY!>C()<!>) {
for ((<!UNUSED_VARIABLE!>x<!>, <!UNUSED_VARIABLE!>y<!>) in <!COMPONENT_FUNCTION_AMBIGUITY!>C()<!>) {
}
}
}
@@ -7,7 +7,7 @@ class C {
}
fun test() {
for ((x, <!UNUSED_VARIABLE!>y<!>) in <!COMPONENT_FUNCTION_MISSING!>C()<!>) {
for ((<!UNUSED_VARIABLE!>x<!>, <!UNUSED_VARIABLE!>y<!>) in <!COMPONENT_FUNCTION_MISSING!>C()<!>) {
}
}
@@ -6,7 +6,7 @@ fun useDeclaredVariables() {
}
fun checkersShouldRun() {
for ((@A a, _)<!SYNTAX!><!>) {
for ((@A <!UNUSED_VARIABLE!>a<!>, _)<!SYNTAX!><!>) {
}
}
@@ -8,7 +8,7 @@ class C {
}
fun test() {
for ((x, <!UNUSED_VARIABLE!>y<!>) in C()) {
for ((<!UNUSED_VARIABLE!>x<!>, <!UNUSED_VARIABLE!>y<!>) in C()) {
}
}
@@ -8,7 +8,7 @@ class C {
}
fun test() {
for ((x: Int, <!UNUSED_VARIABLE!>y<!>: Double) in C()) {
for ((<!UNUSED_VARIABLE!>x<!>: Int, <!UNUSED_VARIABLE!>y<!>: Double) in C()) {
}
}
@@ -8,7 +8,7 @@ class C {
}
fun test() {
for ((<!REDECLARATION!>x<!>, <!NAME_SHADOWING, REDECLARATION, UNUSED_VARIABLE!>x<!>) in C()) {
for ((<!REDECLARATION, UNUSED_VARIABLE!>x<!>, <!NAME_SHADOWING, REDECLARATION, UNUSED_VARIABLE!>x<!>) in C()) {
}
}
@@ -7,7 +7,7 @@ class C {
}
fun test() {
for ((x) in C()) {
for ((<!UNUSED_VARIABLE!>x<!>) in C()) {
}
}
}
@@ -5,7 +5,7 @@ fun useDeclaredVariables() {
}
fun checkersShouldRun() {
val (@A a, _) = <!UNRESOLVED_REFERENCE!>unresolved<!>
val (@A <!UNUSED_VARIABLE!>a<!>, _) = <!UNRESOLVED_REFERENCE!>unresolved<!>
}
annotation class A
@@ -5,7 +5,7 @@ fun useDeclaredVariables() {
}
fun checkersShouldRun() {
<!INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION!>val (@A a, _)<!>
<!INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION!>val (@A <!UNUSED_VARIABLE!>a<!>, _)<!>
}
annotation class A
@@ -43,6 +43,8 @@ fun test() {
val (_, <!NAME_SHADOWING, REDECLARATION!>`_`<!>) = A()
foo(<!TYPE_MISMATCH!>_<!>, y)
val (<!UNUSED_VARIABLE!>unused<!>, _) = A()
}
fun foo(<!UNUSED_PARAMETER!>x<!>: Int, <!UNUSED_PARAMETER!>y<!>: String) {}