summaryrefslogtreecommitdiff
path: root/plugins/InspectionGadgets/test/com/siyeh/igtest
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2013-04-01 14:41:51 -0700
committerJean-Baptiste Queru <jbq@google.com>2013-04-01 14:41:51 -0700
commit2bd2b7c2623d4266384e890271869efc044aabff (patch)
tree0b31f50e55975b6354ed458314e17b4441bb4e17 /plugins/InspectionGadgets/test/com/siyeh/igtest
parent1d526b16d476792ca7ce47616d55833115e8d6ab (diff)
downloadidea-2bd2b7c2623d4266384e890271869efc044aabff.tar.gz
Snapshot ee98b298267d0e09d2cd2f0731b6480a56dd48e7 from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: I4515f72af131fdea9fc6905a4dc0fe9532409a81
Diffstat (limited to 'plugins/InspectionGadgets/test/com/siyeh/igtest')
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/weaken_type/AutoClosableTest.java6
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/weaken_type/expected.xml7
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/assignment/assignment_to_superclass_field/AssignmentToSuperclassField.java25
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/assignment/assignment_to_superclass_field/expected.xml24
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/IgnoreResultsOfReadInspection.java23
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ignore_result_of_call/IgnoreResultOfCall.java10
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ignore_result_of_call/expected.xml9
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/result_of_object_allocation_ignored/ResultOfObjectAllocationIgnored.java (renamed from plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ResultOfObjectAllocationIgnoredInspection.java)6
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/result_of_object_allocation_ignored/expected.xml16
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/string_concatenation_missing_whitespace/Concatenations.java2
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/var_arg/PrimitiveArrayArgumentToVariableArgMethod.java (renamed from plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/var_arg/PrimitiveArrayArgumnetToVariableArgMethod.java)12
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/var_arg/expected.xml2
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/non_final_utility_class/NonFinalUtilityClass.java3
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_boolean_branch/DuplicateBooleanBranch.java8
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_boolean_branch/expected.xml16
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_condition/DuplicateCondition.java12
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_condition/expected.xml37
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/fallthru_in_switch_statement/FallthruInSwitch.java2
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/fallthru_in_switch_statement/expected.xml7
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/overly_complex_boolean_expression/OverlyComplexBooleanExpression.java13
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/overly_complex_boolean_expression/expected.xml9
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression/PointlessBooleanExpression.java (renamed from plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression_ignore_cont_const/PointlessBooleanExpression.java)7
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression/expected.xml (renamed from plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression_ignore_cont_const/expected.xml)7
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_null_check/expected.xml16
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/jdk/auto_boxing/AutoBoxing.java8
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/jdk/auto_boxing/expected.xml14
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/logging/log_statement_guarded_by_log_condition/LogStatementGuardedByLogCondition.java6
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/logging/log_statement_guarded_by_log_condition/expected.xml7
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/migration/if_switch/IfCanBeSwitch.java31
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/migration/if_switch/expected.xml13
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/migration/method_can_be_variable_arity_method/MethodCanBeVariableArity.java7
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/DivideByZero.java13
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/expected.xml16
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/implicit_numeric_conversion/ImplicitNumericConversion.java4
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/implicit_numeric_conversion/expected.xml7
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/unnecessary_explicit_numeric_cast/UnnecessaryExplicitNumericCast.java5
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_parentheses/UnnecessaryParenthesesInspection.java5
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/threading/synchronization_on_local_variable_or_method_parameter/SynchronizationOnLocalVariableOrMethodParameter.java34
-rw-r--r--plugins/InspectionGadgets/test/com/siyeh/igtest/threading/synchronization_on_local_variable_or_method_parameter/expected.xml9
39 files changed, 409 insertions, 49 deletions
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/weaken_type/AutoClosableTest.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/weaken_type/AutoClosableTest.java
index a5fe62bbe18c..3d9b0a2fd811 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/weaken_type/AutoClosableTest.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/weaken_type/AutoClosableTest.java
@@ -35,4 +35,10 @@ class AutoClosableTest2
bar.go();
}
}
+
+ void dodo() throws java.io.IOException {
+ try (java.io.Reader reader = new java.io.FileReader("/home/steve/foo.txt")) {
+ System.out.println(reader);
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/weaken_type/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/weaken_type/expected.xml
index 807c8ea762c3..599595a7163a 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/weaken_type/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/weaken_type/expected.xml
@@ -28,4 +28,11 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Type may be weakened</problem_class>
<description>Type of variable &lt;code&gt;bar&lt;/code&gt; may be weakened to 'com.siyeh.igtest.abstraction.weaken_type.AutoClosableTest2.Foo' #loc</description>
</problem>
+
+ <problem>
+ <file>AutoClosableTest.java</file>
+ <line>40</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Type may be weakened</problem_class>
+ <description>Type of variable &lt;code&gt;reader&lt;/code&gt; may be weakened to 'java.io.Closeable' #loc</description>
+ </problem>
</problems> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/assignment/assignment_to_superclass_field/AssignmentToSuperclassField.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/assignment/assignment_to_superclass_field/AssignmentToSuperclassField.java
new file mode 100644
index 000000000000..c3b0fb0380f8
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/assignment/assignment_to_superclass_field/AssignmentToSuperclassField.java
@@ -0,0 +1,25 @@
+package com.siyeh.igtest.assignment.assignment_to_superclass_field;
+
+class AssignmentToSuperclassField {
+ int i = 1;
+ int j = 2;
+ int k = 0;
+
+ AssignmentToSuperclassField() {}
+
+ AssignmentToSuperclassField(int i, int j, int k) {
+ this.i = i;
+ this.j = j;
+ this.k = k;
+ }
+}
+class B extends AssignmentToSuperclassField {
+ int z;
+
+ B() {
+ i += 3;
+ this.j = 4;
+ super.k++;
+ z = 100;
+ }
+} \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/assignment/assignment_to_superclass_field/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/assignment/assignment_to_superclass_field/expected.xml
new file mode 100644
index 000000000000..a7aa39856153
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/assignment/assignment_to_superclass_field/expected.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+
+ <problem>
+ <file>AssignmentToSuperclassField.java</file>
+ <line>20</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Constructor assigns value to field defined in superclass</problem_class>
+ <description>Assignment to field 'i' defined in superclass 'AssignmentToSuperclassField'</description>
+ </problem>
+
+ <problem>
+ <file>AssignmentToSuperclassField.java</file>
+ <line>21</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Constructor assigns value to field defined in superclass</problem_class>
+ <description>Assignment to field 'j' defined in superclass 'AssignmentToSuperclassField'</description>
+ </problem>
+
+ <problem>
+ <file>AssignmentToSuperclassField.java</file>
+ <line>22</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Constructor assigns value to field defined in superclass</problem_class>
+ <description>Assignment to field 'k' defined in superclass 'AssignmentToSuperclassField'</description>
+ </problem>
+</problems> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/IgnoreResultsOfReadInspection.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/IgnoreResultsOfReadInspection.java
deleted file mode 100644
index 010b97103504..000000000000
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/IgnoreResultsOfReadInspection.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.siyeh.igtest.bugs;
-
-import java.io.*;
-
-public class IgnoreResultsOfReadInspection
-{
- private void foo()
- {
- try
- {
- final FileInputStream stream = new FileInputStream("FOO");
- final byte[] buffer = new byte[10];
- stream.read(buffer);
- }
- catch(FileNotFoundException e)
- {
- }
- catch(IOException e)
- {
- }
-
- }
-}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ignore_result_of_call/IgnoreResultOfCall.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ignore_result_of_call/IgnoreResultOfCall.java
new file mode 100644
index 000000000000..6dbce04ce831
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ignore_result_of_call/IgnoreResultOfCall.java
@@ -0,0 +1,10 @@
+package com.siyeh.igtest.bugs.ignore_result_of_call;
+
+class IgnoreResultOfCall {
+
+ void foo(Object o, String s) {
+ o.equals(s);
+ o.equals()
+ }
+
+} \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ignore_result_of_call/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ignore_result_of_call/expected.xml
new file mode 100644
index 000000000000..7f64be4f9ef0
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ignore_result_of_call/expected.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+ <problem>
+ <file>IgnoreResultOfCall.java</file>
+ <line>6</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Result of method call ignored</problem_class>
+ <description>Result of &lt;code&gt;Object.equals()&lt;/code&gt; is ignored #loc</description>
+ </problem>
+</problems> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ResultOfObjectAllocationIgnoredInspection.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/result_of_object_allocation_ignored/ResultOfObjectAllocationIgnored.java
index 4f76d187ba20..1185f4ddb2ca 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ResultOfObjectAllocationIgnoredInspection.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/result_of_object_allocation_ignored/ResultOfObjectAllocationIgnored.java
@@ -1,8 +1,8 @@
-package com.siyeh.igtest.bugs;
+package com.siyeh.igtest.bugs.result_of_object_allocation_ignored;
-public class ResultOfObjectAllocationIgnoredInspection {
+public class ResultOfObjectAllocationIgnored {
- private ResultOfObjectAllocationIgnoredInspection() {
+ private ResultOfObjectAllocationIgnored() {
super();
}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/result_of_object_allocation_ignored/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/result_of_object_allocation_ignored/expected.xml
new file mode 100644
index 000000000000..319a29ac85b1
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/result_of_object_allocation_ignored/expected.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+ <problem>
+ <file>ResultOfObjectAllocationIgnored.java</file>
+ <line>14</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Result of object allocation ignored</problem_class>
+ <description>Result of &lt;code&gt;new Comparable&lt;String&gt;()&lt;/code&gt; is ignored #loc</description>
+ </problem>
+
+ <problem>
+ <file>ResultOfObjectAllocationIgnored.java</file>
+ <line>10</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Result of object allocation ignored</problem_class>
+ <description>Result of &lt;code&gt;new Integer()&lt;/code&gt; is ignored #loc</description>
+ </problem>
+</problems> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/string_concatenation_missing_whitespace/Concatenations.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/string_concatenation_missing_whitespace/Concatenations.java
index c3f495333a7f..5d709ccd8b4b 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/string_concatenation_missing_whitespace/Concatenations.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/string_concatenation_missing_whitespace/Concatenations.java
@@ -8,5 +8,7 @@ class Concatenations {
System.out.println("no:" + i);
System.out.println("i" + i);
System.out.println("i" + ((String)"j"));
+ System.out.println('{' + "a" + '\'');
+ String.format("aaaa%n" + "bbbb");
}
} \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/var_arg/PrimitiveArrayArgumnetToVariableArgMethod.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/var_arg/PrimitiveArrayArgumentToVariableArgMethod.java
index 1c62329ea804..aa8620ac34c1 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/var_arg/PrimitiveArrayArgumnetToVariableArgMethod.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/var_arg/PrimitiveArrayArgumentToVariableArgMethod.java
@@ -1,6 +1,6 @@
package com.siyeh.igtest.bugs.var_arg;
-public class PrimitiveArrayArgumnetToVariableArgMethod
+public class PrimitiveArrayArgumentToVariableArgMethod
{
public static void main(String[] arg)
{
@@ -15,4 +15,14 @@ public class PrimitiveArrayArgumnetToVariableArgMethod
private static void methodVarArgByteArray(byte[]... bytes)
{
}
+
+ class X<T> {
+ void method(T... t) {
+ }
+ }
+
+ void foo(byte[] bs) {
+ final X<byte[]> x = new X<byte[]>();
+ x.method(bs);
+ }
} \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/var_arg/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/var_arg/expected.xml
index c308de6db0a5..cee36b29eb4e 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/var_arg/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/var_arg/expected.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
- <file>PrimitiveArrayArgumnetToVariableArgMethod.java</file>
+ <file>PrimitiveArrayArgumentToVariableArgMethod.java</file>
<line>7</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Confusing primitive array argument to var-arg method</problem_class>
<description>Confusing primitive array argument to var-arg method #loc</description>
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/non_final_utility_class/NonFinalUtilityClass.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/non_final_utility_class/NonFinalUtilityClass.java
index d77cc0ebe49e..9d49e02351ff 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/non_final_utility_class/NonFinalUtilityClass.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/non_final_utility_class/NonFinalUtilityClass.java
@@ -7,4 +7,7 @@ class NonFinalUtilityClass {
}
final class FinalUtilityClass {
public static void foo() {}
+}
+abstract class NoUtilityClass {
+ public static void foo() {}
} \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_boolean_branch/DuplicateBooleanBranch.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_boolean_branch/DuplicateBooleanBranch.java
new file mode 100644
index 000000000000..d68b1d43e167
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_boolean_branch/DuplicateBooleanBranch.java
@@ -0,0 +1,8 @@
+package com.siyeh.igtest.controlflow.duplicate_boolean_branch;
+
+public class DuplicateBooleanBranch {
+
+ boolean x(boolean b, boolean c){
+ return b && b && c;
+ }
+} \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_boolean_branch/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_boolean_branch/expected.xml
new file mode 100644
index 000000000000..f59e83b86cf3
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_boolean_branch/expected.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+ <problem>
+ <file>DuplicateBooleanBranch.java</file>
+ <line>6</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Duplicate condition on '&amp;&amp;' or '||'</problem_class>
+ <description>Duplicate branch &lt;code&gt;b&lt;/code&gt; #loc</description>
+ </problem>
+
+ <problem>
+ <file>DuplicateBooleanBranch.java</file>
+ <line>6</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Duplicate condition on '&amp;&amp;' or '||'</problem_class>
+ <description>Duplicate branch &lt;code&gt;b&lt;/code&gt; #loc</description>
+ </problem>
+</problems> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_condition/DuplicateCondition.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_condition/DuplicateCondition.java
new file mode 100644
index 000000000000..ef047398e14f
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_condition/DuplicateCondition.java
@@ -0,0 +1,12 @@
+package com.siyeh.igtest.controlflow.duplicate_condition;
+
+public class DuplicateCondition {
+
+ void x(boolean b) {
+ if (b || b || b ) {
+
+ } else if (b) {
+
+ } else if (b) {}
+ }
+} \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_condition/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_condition/expected.xml
new file mode 100644
index 000000000000..47f1e352b5e6
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/duplicate_condition/expected.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+ <problem>
+ <file>DuplicateCondition.java</file>
+ <line>6</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Duplicate condition in 'if' statement</problem_class>
+ <description>Duplicate condition &lt;code&gt;b&lt;/code&gt; #loc</description>
+ </problem>
+
+ <problem>
+ <file>DuplicateCondition.java</file>
+ <line>6</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Duplicate condition in 'if' statement</problem_class>
+ <description>Duplicate condition &lt;code&gt;b&lt;/code&gt; #loc</description>
+ </problem>
+
+ <problem>
+ <file>DuplicateCondition.java</file>
+ <line>8</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Duplicate condition in 'if' statement</problem_class>
+ <description>Duplicate condition &lt;code&gt;b&lt;/code&gt; #loc</description>
+ </problem>
+
+ <problem>
+ <file>DuplicateCondition.java</file>
+ <line>6</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Duplicate condition in 'if' statement</problem_class>
+ <description>Duplicate condition &lt;code&gt;b&lt;/code&gt; #loc</description>
+ </problem>
+
+ <problem>
+ <file>DuplicateCondition.java</file>
+ <line>10</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Duplicate condition in 'if' statement</problem_class>
+ <description>Duplicate condition &lt;code&gt;b&lt;/code&gt; #loc</description>
+ </problem>
+</problems> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/fallthru_in_switch_statement/FallthruInSwitch.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/fallthru_in_switch_statement/FallthruInSwitch.java
index ed8501e48045..6ce4e6a7d4f1 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/fallthru_in_switch_statement/FallthruInSwitch.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/fallthru_in_switch_statement/FallthruInSwitch.java
@@ -20,7 +20,7 @@ public class FallthruInSwitch
case (4):
System.out.println("3");
case (5):
- case (6):
+ case (6): // don't warn here
System.out.println("4");
}
}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/fallthru_in_switch_statement/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/fallthru_in_switch_statement/expected.xml
index fa39d92753c6..4017e6ccf8c8 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/fallthru_in_switch_statement/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/fallthru_in_switch_statement/expected.xml
@@ -8,11 +8,4 @@
<description>&lt;code&gt;case (5):&lt;/code&gt; fall-through in 'switch' statement #loc</description>
</problem>
- <problem>
- <file>FallthruInSwitch.java</file>
- <line>23</line>
- <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Fall-through in 'switch' statement</problem_class>
- <description>&lt;code&gt;case (6):&lt;/code&gt; fall-through in 'switch' statement #loc</description>
- </problem>
-
</problems> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/overly_complex_boolean_expression/OverlyComplexBooleanExpression.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/overly_complex_boolean_expression/OverlyComplexBooleanExpression.java
new file mode 100644
index 000000000000..0bd94cfb6f81
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/overly_complex_boolean_expression/OverlyComplexBooleanExpression.java
@@ -0,0 +1,13 @@
+package com.siyeh.igtest.controlflow.overly_complex_boolean_expression;
+
+public class OverlyComplexBooleanExpression {
+
+ boolean x(boolean b) {
+ return b && b || b && b;
+ }
+
+ boolean ignore(boolean b) {
+ return b || b || b || b;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/overly_complex_boolean_expression/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/overly_complex_boolean_expression/expected.xml
new file mode 100644
index 000000000000..5af2080fb042
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/overly_complex_boolean_expression/expected.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+ <problem>
+ <file>OverlyComplexBooleanExpression.java</file>
+ <line>6</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Overly complex boolean expression</problem_class>
+ <description>Overly complex boolean expression (4 terms) #loc</description>
+ </problem>
+</problems> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression_ignore_cont_const/PointlessBooleanExpression.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression/PointlessBooleanExpression.java
index 15020be28068..0cfd2f6840ba 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression_ignore_cont_const/PointlessBooleanExpression.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression/PointlessBooleanExpression.java
@@ -28,4 +28,11 @@ class PointlessBooleanExpression {
boolean y = false || c;
boolean z = b != true;
}
+}
+class Presley {
+ void elvis(Object king) {
+ if (true && king != null && king.hashCode() > 1) {
+ // blah
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression_ignore_cont_const/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression/expected.xml
index 1d0a66df6e32..32f91701b161 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression_ignore_cont_const/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression/expected.xml
@@ -42,4 +42,11 @@
<description>&lt;code&gt;b != true&lt;/code&gt; can be simplified to '!b' #loc</description>
</problem>
+ <problem>
+ <file>PointlessBooleanExpression.java</file>
+ <line>34</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless boolean expression</problem_class>
+ <description>&lt;code&gt;true &amp;&amp; king != null &amp;&amp; king.hashCode() &gt; 1&lt;/code&gt; can be simplified to 'king != null &amp;&amp; king.hashCode() &gt; 1' #loc</description>
+ </problem>
+
</problems>
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_null_check/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_null_check/expected.xml
index 6805724ab1d6..de2c46db9665 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_null_check/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_null_check/expected.xml
@@ -4,48 +4,48 @@
<file>PointlessNullCheck.java</file>
<line>6</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless null check</problem_class>
- <description>Pointless null check can be removed</description>
+ <description>Unnecessary 'null' check</description>
</problem>
<problem>
<file>PointlessNullCheck.java</file>
<line>10</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless null check</problem_class>
- <description>Pointless null check can be removed</description>
+ <description>Unnecessary 'null' check</description>
</problem>
<problem>
<file>PointlessNullCheck.java</file>
<line>14</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless null check</problem_class>
- <description>Pointless null check can be removed</description>
+ <description>Unnecessary 'null' check</description>
</problem>
<problem>
<file>PointlessNullCheck.java</file>
<line>18</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless null check</problem_class>
- <description>Pointless null check can be removed</description>
+ <description>Unnecessary 'null' check</description>
</problem>
<problem>
<file>PointlessNullCheck.java</file>
<line>22</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless null check</problem_class>
- <description>Pointless null check can be removed</description>
+ <description>Unnecessary 'null' check</description>
</problem>
<problem>
<file>PointlessNullCheck.java</file>
<line>26</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless null check</problem_class>
- <description>Pointless null check can be removed</description>
+ <description>Unnecessary 'null' check</description>
</problem>
<problem>
<file>PointlessNullCheck.java</file>
<line>30</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless null check</problem_class>
- <description>Pointless null check can be removed</description>
+ <description>Unnecessary 'null' check</description>
</problem>
<problem>
<file>PointlessNullCheck.java</file>
<line>33</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless 'null' check</problem_class>
- <description>Pointless 'null' check can be removed</description>
+ <description>Unnecessary 'null' check</description>
</problem>
</problems>
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/jdk/auto_boxing/AutoBoxing.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/jdk/auto_boxing/AutoBoxing.java
index 796470be95c7..883b3e2e5a46 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/jdk/auto_boxing/AutoBoxing.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/jdk/auto_boxing/AutoBoxing.java
@@ -45,4 +45,12 @@ public class AutoBoxing {
Byte s = 8;
Short j = (byte)7;
}
+
+ void polyadic() {
+ Integer i = 1 + 2 + 3;
+ }
+
+ void doInstanceof(Object o) {
+ Boolean b = o instanceof String;
+ }
}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/jdk/auto_boxing/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/jdk/auto_boxing/expected.xml
index 2f40755387dc..c5867eeadea1 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/jdk/auto_boxing/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/jdk/auto_boxing/expected.xml
@@ -79,4 +79,18 @@
<description>Auto-boxing &lt;code&gt;(byte)7&lt;/code&gt; #loc</description>
</problem>
+ <problem>
+ <file>AutoBoxing.java</file>
+ <line>50</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-boxing</problem_class>
+ <description>Auto-boxing &lt;code&gt;1 + 2 + 3&lt;/code&gt; #loc</description>
+ </problem>
+
+ <problem>
+ <file>AutoBoxing.java</file>
+ <line>54</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-boxing</problem_class>
+ <description>Auto-boxing &lt;code&gt;o instanceof String&lt;/code&gt; #loc</description>
+ </problem>
+
</problems> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/logging/log_statement_guarded_by_log_condition/LogStatementGuardedByLogCondition.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/logging/log_statement_guarded_by_log_condition/LogStatementGuardedByLogCondition.java
index b8f4f8c43443..dfb8c65cc7e0 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/logging/log_statement_guarded_by_log_condition/LogStatementGuardedByLogCondition.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/logging/log_statement_guarded_by_log_condition/LogStatementGuardedByLogCondition.java
@@ -32,6 +32,10 @@ public class LogStatementGuardedByLogCondition {
}
}
+ void alternativeDebugMethodSignature(int i) {
+ LOG.debug(i, "asdfasdf");
+ }
+
static class Logger {
public Logger(String log) {
@@ -40,6 +44,8 @@ public class LogStatementGuardedByLogCondition {
public void debug(String s) {
}
+ public void debug(int i, String s) {}
+
public void trace(String s) {}
public boolean isDebug() {
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/logging/log_statement_guarded_by_log_condition/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/logging/log_statement_guarded_by_log_condition/expected.xml
index e04e666cf360..701ef7837e72 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/logging/log_statement_guarded_by_log_condition/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/logging/log_statement_guarded_by_log_condition/expected.xml
@@ -14,4 +14,11 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Log statement not guarded by log condition</problem_class>
<description>&lt;code&gt;debug()&lt;/code&gt; log statement not guarded by log condition #loc</description>
</problem>
+
+ <problem>
+ <file>LogStatementGuardedByLogCondition.java</file>
+ <line>36</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Log statement not guarded by log condition</problem_class>
+ <description>&lt;code&gt;debug()&lt;/code&gt; log statement not guarded by log condition #loc</description>
+ </problem>
</problems> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/if_switch/IfCanBeSwitch.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/if_switch/IfCanBeSwitch.java
index 8260653742c9..4b65e91cb8f2 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/if_switch/IfCanBeSwitch.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/if_switch/IfCanBeSwitch.java
@@ -1,4 +1,6 @@
-class C {
+import org.jetbrains.annotations.Nullable;
+
+class IfCanBeSwitch {
void m1(int i) { // ok
if (i == 0) System.out.println("zero"); else if (i == 1) System.out.println("one"); else System.out.println("many");
}
@@ -11,11 +13,36 @@ class C {
if (i == (byte)0) System.out.println("zero"); else if (i == (byte)1) System.out.println("one"); else System.out.println("many");
}
- void m1(int i) { // bad, long literals
+ void m2(int i) { // bad, long literals
if (i == 0L) System.out.println("zero"); else if (i == 1L) System.out.println("one"); else System.out.println("many");
}
void m2(long l) { // bad, long expression
if (l == 0) System.out.println("zero"); else if (l == 1) System.out.println("one"); else System.out.println("many");
}
+
+ void polyadic() {
+ String s = null;
+ if ("asdf".equals(s) || "addd".equals(s) || "lkjh".equals(s)) {
+ System.out.println("asdf");
+
+ } else if ("null".equals(s)) {
+ System.out.println("null");
+
+ } else {
+ System.out.println("default");
+ }
+ }
+
+ void nullable(@Nullable String s) {
+ if ("a".equals(s)) {
+ System.out.println(1);
+ } else if ("b".equals(s)) {
+ System.out.println(2);
+ } else if ("c".equals(s)) {
+ System.out.println(3);
+ } else {
+ System.out.println(4);
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/if_switch/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/if_switch/expected.xml
index 197819a78333..af78b4213567 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/if_switch/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/if_switch/expected.xml
@@ -2,21 +2,28 @@
<problems>
<problem>
<file>IfCanBeSwitch.java</file>
- <line>3</line>
+ <line>5</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' replaceable with 'switch'</problem_class>
<description>&lt;code&gt;if&lt;/code&gt; statement replaceable with 'switch' statement #loc</description>
</problem>
<problem>
<file>IfCanBeSwitch.java</file>
- <line>7</line>
+ <line>9</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' replaceable with 'switch'</problem_class>
<description>&lt;code&gt;if&lt;/code&gt; statement replaceable with 'switch' statement #loc</description>
</problem>
<problem>
<file>IfCanBeSwitch.java</file>
- <line>11</line>
+ <line>13</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' replaceable with 'switch'</problem_class>
+ <description>&lt;code&gt;if&lt;/code&gt; statement replaceable with 'switch' statement #loc</description>
+ </problem>
+
+ <problem>
+ <file>IfCanBeSwitch.java</file>
+ <line>26</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' replaceable with 'switch'</problem_class>
<description>&lt;code&gt;if&lt;/code&gt; statement replaceable with 'switch' statement #loc</description>
</problem>
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/method_can_be_variable_arity_method/MethodCanBeVariableArity.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/method_can_be_variable_arity_method/MethodCanBeVariableArity.java
index 4fd8268a94fe..db74d0cfc230 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/method_can_be_variable_arity_method/MethodCanBeVariableArity.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/method_can_be_variable_arity_method/MethodCanBeVariableArity.java
@@ -17,4 +17,11 @@ abstract class MyInputStream extends Reader {
public int read(char[] cbuf) throws IOException {
return super.read(cbuf);
}
+}
+class Sub extends MethodCanBeVariableArity {
+
+ @Override
+ public void convertMe(String[] ss) {
+ super.convertMe(ss);
+ }
} \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/DivideByZero.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/DivideByZero.java
new file mode 100644
index 000000000000..9f24ebf109ee
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/DivideByZero.java
@@ -0,0 +1,13 @@
+package com.siyeh.igtest.numeric.divide_by_zero;
+
+public class DivideByZero {
+
+ int divide(int num) {
+ return num / 3 / 0;
+ }
+
+ int rest(int num) {
+ return num % 0 % 1;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/expected.xml
new file mode 100644
index 000000000000..3a07cc5477ef
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/expected.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+ <problem>
+ <file>DivideByZero.java</file>
+ <line>6</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Division by zero</problem_class>
+ <description>Division by zero #loc</description>
+ </problem>
+
+ <problem>
+ <file>DivideByZero.java</file>
+ <line>10</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Division by zero</problem_class>
+ <description>Division by zero #loc</description>
+ </problem>
+</problems> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/implicit_numeric_conversion/ImplicitNumericConversion.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/implicit_numeric_conversion/ImplicitNumericConversion.java
index 9aa5a5a2dde8..09ee0ed4b595 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/implicit_numeric_conversion/ImplicitNumericConversion.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/implicit_numeric_conversion/ImplicitNumericConversion.java
@@ -79,4 +79,8 @@ public class ImplicitNumericConversion
int a[] = new int[b];
a[b] = (byte)1;
}
+
+ private void polyadic() {
+ long l = 1 + 2 + 3;
+ }
}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/implicit_numeric_conversion/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/implicit_numeric_conversion/expected.xml
index 3b9e14d34212..833457e3f0cb 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/implicit_numeric_conversion/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/implicit_numeric_conversion/expected.xml
@@ -168,4 +168,11 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Implicit numeric conversion</problem_class>
<description>Implicit numeric conversion of &lt;code&gt;(byte)1&lt;/code&gt; from 'byte' to 'int' #loc</description>
</problem>
+
+ <problem>
+ <file>ImplicitNumericConversion.java</file>
+ <line>84</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Implicit numeric conversion</problem_class>
+ <description>Implicit numeric conversion of &lt;code&gt;1 + 2 + 3&lt;/code&gt; from 'int' to 'long' #loc</description>
+ </problem>
</problems> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/unnecessary_explicit_numeric_cast/UnnecessaryExplicitNumericCast.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/unnecessary_explicit_numeric_cast/UnnecessaryExplicitNumericCast.java
index 60d67f02003f..9468de1baf32 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/unnecessary_explicit_numeric_cast/UnnecessaryExplicitNumericCast.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/unnecessary_explicit_numeric_cast/UnnecessaryExplicitNumericCast.java
@@ -48,4 +48,9 @@ public class UnnecessaryExplicitNumericCast {
void target(int c) {}
void target(char c) {}
void target2(int d) {}
+
+ void foo() {
+ float x = 2;
+ target((int) x); // this line complains: 'x' unnecessarily cast to 'int'
+ }
}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_parentheses/UnnecessaryParenthesesInspection.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_parentheses/UnnecessaryParenthesesInspection.java
index ce6022abc44f..70695c4e1fff 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_parentheses/UnnecessaryParenthesesInspection.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_parentheses/UnnecessaryParenthesesInspection.java
@@ -107,4 +107,9 @@ public class UnnecessaryParenthesesInspection
final Object[] objects = {(args.length - 1), 1};
return args.length > 0 && place.equals(args[(args.length - 1)]);// here are unnecessary parentheses inside args[...]
}
+
+ void uu() {
+ Object info = new Object[]{"abc"};
+ String s = (String)((Object[])info)[0];
+ }
}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/synchronization_on_local_variable_or_method_parameter/SynchronizationOnLocalVariableOrMethodParameter.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/synchronization_on_local_variable_or_method_parameter/SynchronizationOnLocalVariableOrMethodParameter.java
new file mode 100644
index 000000000000..6eaff9ad5acd
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/synchronization_on_local_variable_or_method_parameter/SynchronizationOnLocalVariableOrMethodParameter.java
@@ -0,0 +1,34 @@
+package com.siyeh.igtest.threading.synchronization_on_local_variable_or_method_parameter;
+
+class SynchronizationOnLocalVariableOrMethodParameter {
+
+ static {
+ final Object lock = new Object();
+ new Object(){{
+ synchronized (lock) {} // no warning
+ }};
+ }
+
+ interface IntegerMath {
+ int operation(int a, int b);
+ }
+ public int operateBinary(int a, int b, IntegerMath op) {
+ return op.operation(a, b);
+ }
+ public static void foo() {
+ final Object lock = new Object();
+ final SynchronizationOnLocalVariableOrMethodParameter x = new SynchronizationOnLocalVariableOrMethodParameter();
+ IntegerMath addition = (a, b) -> {
+ synchronized(lock) {return a + b;} // no warning
+ };
+ System.out.println("40 + 2 = " +
+ x.operateBinary(40, 2, addition));
+ }
+
+ void bar() {
+ final Object lock = new Object();
+ synchronized (lock) {
+
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/synchronization_on_local_variable_or_method_parameter/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/synchronization_on_local_variable_or_method_parameter/expected.xml
new file mode 100644
index 000000000000..efee019926d2
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/synchronization_on_local_variable_or_method_parameter/expected.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+ <problem>
+ <file>SynchronizationOnLocalVariableOrMethodParameter.java</file>
+ <line>30</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Synchronization on local variable or method parameter</problem_class>
+ <description>Synchronization on local variable &lt;code&gt;lock&lt;/code&gt; #loc</description>
+ </problem>
+</problems> \ No newline at end of file