diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2013-01-08 11:11:20 -0800 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2013-01-08 11:11:20 -0800 |
commit | b56ea2a18f232d79481e778085fd64e8ae486fc3 (patch) | |
tree | 44e1f6eb4864a45033f865b74fe783e3d784dd6a /plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/infinite_recursion | |
download | idea-b56ea2a18f232d79481e778085fd64e8ae486fc3.tar.gz |
Snapshot of commit d5ec1d5018ed24f1b4f32b1d09df6dbd7e2fc425
from branch master of git://git.jetbrains.org/idea/community.git
Diffstat (limited to 'plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/infinite_recursion')
2 files changed, 203 insertions, 0 deletions
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/infinite_recursion/InfiniteRecursion.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/infinite_recursion/InfiniteRecursion.java new file mode 100644 index 000000000000..7a04c43427b4 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/infinite_recursion/InfiniteRecursion.java @@ -0,0 +1,143 @@ +package com.siyeh.igtest.bugs.infinite_recursion; + +import com.intellij.psi.PsiClass; + +import java.util.List; +import java.io.IOException; +import java.io.File; + +public class InfiniteRecursion +{ + public void foo() + { + new InfiniteRecursion().foo(); + } + + public void bar() + { + foo(); + } + + public int baz() + { + return baz(); + } + + public int bazoom() + { + if(foobar()) + { + return bazoom(); + } + return 3; + } + + public void bazoomvoid() + { + if(foobar()) + { + bazoomvoid(); + } + } + + public int barangus() + { + while(foobar()) + { + return barangus(); + } + return 3; + } + + public int barangoo() + { + do + { + return barangoo(); + } + while(foobar()); + } + + public int bazoomer() + { + if(foobar()) + { + return bazoomer(); + } + else + { + return bazoomer() + 3; + } + } + + public boolean foobar() + { + return false && foobar(); + } + + public boolean foobarangus() + { + return foobarangus() && false; + } + + public int bangem(PsiClass aClass) + { + final PsiClass superClass = aClass.getSuperClass(); + if(superClass ==null) + { + return 0; + } + else + { + return bangem(aClass)+1; + } + } + + private boolean foo(final PsiClass superClass) + { + return superClass ==null; + } + + public int getInheritanceDepth(PsiClass aClass) + { + final PsiClass superClass = aClass.getSuperClass(); + if(superClass == null) + { + return 0; + } + else + { + return getInheritanceDepth(superClass) + 1; + } + } + + void rec(List pageConfig) { + try { + new File("c:/").getCanonicalFile(); + } catch (IOException e) { + + } + for (int j = 0; j < pageConfig.size(); j++) { + List pc = (List) pageConfig.get(j); + rec(pc); + } + } + + void foo1() { + for (;true && true || false;) { + foo1(); + } + } + + void foo2() { + if (true || false) { + foo2(); + } + } + + void bar1() { + while (true || false) { + bar1(); + } + } +} diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/infinite_recursion/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/infinite_recursion/expected.xml new file mode 100644 index 000000000000..9f9c5dd54de5 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/infinite_recursion/expected.xml @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> +<problems> + <problem> + <file>InfiniteRecursion.java</file> + <line>21</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Infinite recursion</problem_class> + <description>Method <code>baz()</code> recurses infinitely, and can only end by throwing an exception #loc</description> + </problem> + + <problem> + <file>InfiniteRecursion.java</file> + <line>52</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Infinite recursion</problem_class> + <description>Method <code>barangoo()</code> recurses infinitely, and can only end by throwing an exception #loc + </description> + </problem> + + <problem> + <file>InfiniteRecursion.java</file> + <line>61</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Infinite recursion</problem_class> + <description>Method <code>bazoomer()</code> recurses infinitely, and can only end by throwing an exception #loc + </description> + </problem> + + <problem> + <file>InfiniteRecursion.java</file> + <line>78</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Infinite recursion</problem_class> + <description>Method <code>foobarangus()</code> recurses infinitely, and can only end by throwing an exception #loc + </description> + </problem> + + + <problem> + <file>InfiniteRecursion.java</file> + <line>126</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Infinite recursion</problem_class> + <description>Method <code>foo1()</code> recurses infinitely, and can only end by throwing an exception #loc</description> + </problem> + + <problem> + <file>InfiniteRecursion.java</file> + <line>132</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Infinite recursion</problem_class> + <description>Method <code>foo2()</code> recurses infinitely, and can only end by throwing an exception #loc</description> + </problem> + + + + + <problem> + <file>InfiniteRecursion.java</file> + <line>138</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Infinite recursion</problem_class> + <description>Method <code>bar1()</code> recurses infinitely, and can only end by throwing an exception #loc</description> + </problem> + + +</problems>
\ No newline at end of file |