]> git.uio.no Git - ifi-stolz-refaktor.git/blobdiff - software/no.uio.ifi.refaktor.examples/examples/src/searchBased/Main.java
Adding checks for return statements. (A lot.)
[ifi-stolz-refaktor.git] / software / no.uio.ifi.refaktor.examples / examples / src / searchBased / Main.java
index 670e6d0e505da5a091fe37e87ef6844dfbdda97f..208d0e1b5870827297137ebd21c308ac90a6427c 100644 (file)
@@ -15,11 +15,11 @@ public abstract class Main {
                a.b.c.b.bar();
                b.c.a.foo();
        }
-       
+
        private void emptyMethod() {
                // Keep empty
        }
-       
+
        private boolean searchableMethod() {
                A a = new A();
                B b = new B();
@@ -30,7 +30,7 @@ public abstract class Main {
                b.c.crap();
                return true;
        }
-       
+
        protected abstract void iAmAbstract();
 
        /*
@@ -39,16 +39,16 @@ public abstract class Main {
        private void iAmPrefixedWithAMultilineComment() {
                return;
        }
-       
+
        // A single line comment. (Leave this above a method with Javadoc attached!)
-       
+
        /**
         * This is Javadoc.
         */
        private void iHaveJavadocAttachedButThereIsAlsoASingleLineCommentAboveMe() {
                return;
        }
-       
+
        private void iAmAnOverloadedMethod(DuplicateType type) {
                return;
        }
@@ -56,8 +56,101 @@ public abstract class Main {
        private void iAmAnOverloadedMethod(A.DuplicateType type) {
                return;
        }
-       
+
        private void iHaveATooSimpleBodyToBeConsidered() {
                b.bar();
        }
+
+       private String iHaveAConditionalWithAReturnStatement() {
+               // Do not touch me
+               if ("A".equals("B"))
+                       return b.c.moreCrap();
+               return "NO";
+       }
+
+       private String iHaveAConditionalWithAnElseAndAllBranchesEndInReturn() {
+               // Do not touch me
+               try {
+                       if ("A".equals("B"))
+                               return b.c.moreCrap();
+                       else
+                               return b.c.crap();
+               } catch (Exception e) {
+                       System.err.println("finally!");
+               }
+               return "test";
+       }
+
+       private String iHaveAConditionalWithAnElseAndNotAllBranchesEndInReturn() {
+               // Do not touch me
+               if ("A".equals("B"))
+                       return b.c.moreCrap();
+               else
+                       System.out.println("crap");
+               return "NO";
+       }
+
+       private String iHaveAComplexConditionalWithAnElseAndAllBranchesEndInReturn() {
+               // Do not touch me
+               try {
+                       if ("A".equals("B")) {
+                               return b.c.moreCrap();
+                       } else {
+                               if ("C".equals("D")) {
+                                       return b.c.moreCrap();
+                               } else if ("A".equals("A")) {
+                                       return b.c.moreCrap();
+                               } else {
+                                       return b.c.crap();
+                               }
+                       }
+               } catch (Exception e) {
+                       System.err.println("finally!");
+               }
+               return "test";
+       }
+
+       private String iHaveAComplexConditionalWithAnElseAndNotAllBranchesEndInReturn() {
+               // Do not touch me
+               if ("A".equals("B")) {
+                       if ("C".equals("D")) {
+                               return b.c.moreCrap();
+                       } else if ("A".equals("A")) {
+                               return b.c.moreCrap();
+                       } 
+               } else {
+                       return b.c.moreCrap();
+               }
+               return "NO";
+       }
+
+       private String iHaveReturnInsideWhile() {
+               // Do not touch me
+               boolean bool = true;
+               while(bool) {
+                       if (bool)
+                               bool = false;
+                       return b.c.moreCrap();
+               }
+               return b.c.moreCrap();
+       }
+
+       private String iHaveReturnInsideFor() {
+               // Do not touch me
+               for(int i = 0; i < 3; i++) {
+                       if (i == 1)
+                               return b.c.moreCrap();
+               }
+               return b.c.moreCrap();
+       }
+
+       private String iHaveReturnInsideCatch() {
+               // Do not touch me
+               try {
+                       System.out.print("test");
+               } catch (Exception e) {
+                       return b.c.moreCrap();
+               }
+               return b.c.moreCrap();
+       }
 }
\ No newline at end of file