Introduce "Boolean literal arguments" inspection #KT-2029 Fixed

This commit is contained in:
Toshiaki Kameyama
2018-10-24 11:58:59 +03:00
committed by Mikhail Glukhikh
parent aa9e48b9b6
commit 0d7116aa5d
21 changed files with 248 additions and 17 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.BooleanLiteralArgumentInspection
@@ -0,0 +1,6 @@
// PROBLEM: none
fun foo(a: Boolean, b: Boolean, c: Boolean) {}
fun test(b: Boolean) {
foo(true, true, b<caret>)
}
@@ -0,0 +1,7 @@
// HIGHLIGHT: GENERIC_ERROR_OR_WARNING
// FIX: Add 'c =' to argument
fun foo(a: Boolean, b: Boolean, c: Boolean) {}
fun test() {
foo(true, true, true<caret>)
}
@@ -0,0 +1,7 @@
// HIGHLIGHT: GENERIC_ERROR_OR_WARNING
// FIX: Add 'c =' to argument
fun foo(a: Boolean, b: Boolean, c: Boolean) {}
fun test() {
foo(true, true, c = true)
}
@@ -0,0 +1,7 @@
// HIGHLIGHT: GENERIC_ERROR_OR_WARNING
// FIX: Add names to call arguments
fun foo(a: Boolean, b: Boolean, c: Boolean) {}
fun test() {
foo(true, true<caret>, true)
}
@@ -0,0 +1,7 @@
// HIGHLIGHT: GENERIC_ERROR_OR_WARNING
// FIX: Add names to call arguments
fun foo(a: Boolean, b: Boolean, c: Boolean) {}
fun test() {
foo(a = true, b = true, c = true)
}
@@ -0,0 +1,7 @@
// HIGHLIGHT: GENERIC_ERROR_OR_WARNING
// FIX: Add 'b =' to argument
fun foo(a: Boolean, b: Boolean, c: Boolean) {}
fun test() {
foo(true, <caret>true, c = true)
}
@@ -0,0 +1,7 @@
// HIGHLIGHT: GENERIC_ERROR_OR_WARNING
// FIX: Add 'b =' to argument
fun foo(a: Boolean, b: Boolean, c: Boolean) {}
fun test() {
foo(true, b = true, c = true)
}
@@ -0,0 +1,7 @@
// HIGHLIGHT: GENERIC_ERROR_OR_WARNING
// FIX: Add names to call arguments
fun foo(a: Boolean, b: Boolean, c: Boolean) {}
fun test() {
foo(<caret>true, true, c = true)
}
@@ -0,0 +1,7 @@
// HIGHLIGHT: GENERIC_ERROR_OR_WARNING
// FIX: Add names to call arguments
fun foo(a: Boolean, b: Boolean, c: Boolean) {}
fun test() {
foo(a = true, b = true, c = true)
}
@@ -0,0 +1,7 @@
// PROBLEM: none
// DISABLE-ERRORS
fun foo(vararg a: Int, b: Boolean) {}
fun test() {
foo(1, 2, 3, true<caret>)
}
@@ -0,0 +1,6 @@
// PROBLEM: none
fun foo(a: Boolean, b: Boolean, c: Boolean) {}
fun test() {
foo(true, true, c = true<caret>)
}
@@ -0,0 +1,7 @@
// PROBLEM: none
fun foo(a: Boolean, vararg b: Int) {}
fun test() {
foo(true<caret>, 1, 2, 3)
}
@@ -0,0 +1,6 @@
// PROBLEM: none
fun foo(a: Boolean, b: Boolean, c: Int) {}
fun test(b: Boolean) {
foo(true, true, 1<caret>)
}
@@ -0,0 +1,3 @@
public class JavaClass {
void foo(boolean b) {}
}
@@ -0,0 +1,4 @@
// PROBLEM: none
fun test() {
JavaClass().foo(false<caret>)
}