From f03a147fe307c3f96810e9e66447d9eaced6c4dd Mon Sep 17 00:00:00 2001 From: Pavel Dolgov Date: Fri, 8 Jul 2016 22:28:21 +0300 Subject: [PATCH] Java inspection: fixed test data for TooBroadScopeInspection (IDEA-157727) --- .../igtest/dataflow/scope/TooBroadScope.java | 22 ++--- .../siyeh/igtest/dataflow/scope/expected.xml | 81 +++++++++++++++++++ .../dataflow/TooBroadScopeInspectionTest.java | 18 +---- 3 files changed, 95 insertions(+), 26 deletions(-) create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/scope/expected.xml diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/scope/TooBroadScope.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/scope/TooBroadScope.java index 6b45d6f66368..2020f9539e88 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/scope/TooBroadScope.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/scope/TooBroadScope.java @@ -8,7 +8,7 @@ public class TooBroadScope public void test() { // Example #1 { - Collection list = null; //scope too broad + Collection list = null; //scope too broad { list = new ArrayList(); list.add(new Integer(0)); @@ -18,7 +18,7 @@ public class TooBroadScope // Example #2 { - Collection list; // scope too broad + Collection list; // scope too broad list = new ArrayList(); list.add(new Integer(0)); } @@ -26,14 +26,14 @@ public class TooBroadScope // Example #3 { - Collection list = null; // nope + Collection list = null; // nope list = new ArrayList(); list.add(new Integer(0)); } } public void join() { - String test; + String test; test = "asdf"; } @@ -112,7 +112,7 @@ public class TooBroadScope } void forLoop() { - int i = 0; + int i = 0; for ( ; i < 10; i++) { System.out.println(i); } @@ -134,7 +134,7 @@ public class TooBroadScope } void useConstant() { - int yes = NON_STATIC_CONSTANT; + int yes = NON_STATIC_CONSTANT; System.out.println(); System.out.println(); System.out.println(); @@ -152,27 +152,27 @@ public class TooBroadScope private final String[] EMPTY = {}; private final String[] ONE = {"one"}; void abc() { - String[] strings = EMPTY; + String[] strings = EMPTY; System.out.println(); System.out.println(); System.out.println(strings); - List list = new ArrayList<>(Arrays.asList(EMPTY)); + List list = new ArrayList<>(Arrays.asList(EMPTY)); System.out.println(); System.out.println(); System.out.println(list); - String[] ss = new String[10]; + String[] ss = new String[10]; System.out.println(); System.out.println(); System.out.println(ss); - String[] ss2 = new String[] {""}; + String[] ss2 = new String[] {""}; System.out.println(); System.out.println(); System.out.println(ss2); - String[] ss3 = {}; + String[] ss3 = {}; System.out.println(); System.out.println(); System.out.println(ss3); diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/scope/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/scope/expected.xml new file mode 100644 index 000000000000..36f937ffd526 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/scope/expected.xml @@ -0,0 +1,81 @@ + + + + + TooBroadScope.java + 11 + Scope of variable is too broad + Scope of variable <code>list</code> is too broad #loc + + + + TooBroadScope.java + 21 + Scope of variable is too broad + Scope of variable <code>list</code> is too broad #loc + + + + TooBroadScope.java + 29 + Scope of variable is too broad + Scope of variable <code>list</code> is too broad #loc + + + + TooBroadScope.java + 36 + Scope of variable is too broad + Scope of variable <code>test</code> is too broad #loc + + + + TooBroadScope.java + 115 + Scope of variable is too broad + Scope of variable <code>i</code> is too broad #loc + + + + TooBroadScope.java + 137 + Scope of variable is too broad + Scope of variable <code>yes</code> is too broad #loc + + + + TooBroadScope.java + 155 + Scope of variable is too broad + Scope of variable <code>strings</code> is too broad #loc + + + + TooBroadScope.java + 160 + Scope of variable is too broad + Scope of variable <code>list</code> is too broad #loc + + + + TooBroadScope.java + 165 + Scope of variable is too broad + Scope of variable <code>ss</code> is too broad #loc + + + + TooBroadScope.java + 170 + Scope of variable is too broad + Scope of variable <code>ss2</code> is too broad #loc + + + + TooBroadScope.java + 175 + Scope of variable is too broad + Scope of variable <code>ss3</code> is too broad #loc + + + \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/dataflow/TooBroadScopeInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/dataflow/TooBroadScopeInspectionTest.java index c575cafcdc36..129fe2debc3e 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/dataflow/TooBroadScopeInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/dataflow/TooBroadScopeInspectionTest.java @@ -1,22 +1,10 @@ package com.siyeh.ig.dataflow; -import com.intellij.codeInspection.InspectionProfileEntry; import com.siyeh.ig.IGInspectionTestCase; -import com.siyeh.ig.LightInspectionTestCase; - -public class TooBroadScopeInspectionTest extends LightInspectionTestCase { +public class TooBroadScopeInspectionTest extends IGInspectionTestCase { public void testTooBroadScope() { - doTest(); - } - - @Override - protected InspectionProfileEntry getInspection() { - return new TooBroadScopeInspection(); - } - - @Override - protected String getBasePath() { - return "/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/scope"; + final TooBroadScopeInspection inspection = new TooBroadScopeInspection(); + doTest("com/siyeh/igtest/dataflow/scope", inspection); } } \ No newline at end of file