import java.util.*; public class ExtractMethodRecommender { List> simpleWithPrecedingComment() { // Create list // Comment List list = new ArrayList<>(); list.add("one"); list.add("two"); list.add("three"); list.add("four"); List list2 = new ArrayList<>(); list2.add("v1"); list2.add("v2"); list2.add("v3"); list2.add("v4"); return List.of(list, list2); } List> simpleWithPrecedingCommentSuppress() { // Create list // Comment //noinspection ExtractMethodRecommender List list = new ArrayList<>(); list.add("one"); list.add("two"); list.add("three"); list.add("four"); List list2 = new ArrayList<>(); list2.add("v1"); list2.add("v2"); list2.add("v3"); list2.add("v4"); return List.of(list, list2); } List> avoidSplitting() { List list = new ArrayList<>(); list.add("one"); list.add("two"); list.add("three"); list.add("four"); List list2 = new ArrayList<>(); list2.add("v1"); list2.add("v2"); list2.add("v3"); list2.add("v4"); list.add("five"); return List.of(list, list2); } String grabReturnMaxArgs(int x, boolean a, boolean b, boolean c) { if (x > 100) { String s = "Hello! "; s += x; s += a; return s; } if (x > 50) { String s = "Hello! "; s += x; s += a; s += b; return s; } if (x > 20) { String s = "Hello! "; s += x; s += a; s += b; s += c; return s; } return "Negative"; } void dontGrabUnrelated(int x) { String s = "hello"; s+=x; if (x < 0) { throw new IllegalArgumentException(); } System.out.println(s); System.out.println(x); } void dontGrabUnrelated2(int x) { if (x < 0) { throw new IllegalArgumentException(); } String s = "hello"; s+=x; System.out.println(s); System.out.println(x); } void setSequence() { Date d = new Date(); d.setHours(12); d.setMinutes(34); d.setSeconds(56); System.out.println("Date is: "); System.out.println(d); } void setSequence2() { Date d = new Date(); d.setHours(12); d.setMinutes(34); d.setSeconds(56); System.out.println(d); } String varAnonymousClass() { System.out.println("hello"); System.out.println("hello"); System.out.println("hello"); System.out.println("hello"); System.out.println("hello"); var anon = new Runnable() { String result; public void run() { result = "Hello"; } }; anon.run(); anon.run(); return anon.result; } String varLocalClass() { class Local implements Runnable { String result; public void run() { result = "Hello"; } } System.out.println("hello"); System.out.println("hello"); System.out.println("hello"); System.out.println("hello"); System.out.println("hello"); var anon = new Local(); anon.run(); anon.run(); anon.run(); anon.run(); anon.run(); anon.run(); return anon.result; } static class Nested implements Runnable { String result; public void run() { result = "Hello"; } } String varNestedClass() { System.out.println("hello"); System.out.println("hello"); System.out.println("hello"); System.out.println("hello"); System.out.println("hello"); var anon = new Nested(); anon.run(); anon.run(); anon.run(); anon.run(); anon.run(); anon.run(); return anon.result; } }