Commit a2fc5b67 authored by Roman.Ivanov's avatar Roman.Ivanov
Browse files

fix tests for foreach formatting

parent 301141e6
Branches unavailable Tags unavailable
No related merge requests found
Showing with 49 additions and 49 deletions
+49 -49
class Foo {
{
List list;
for (String s : list) {
for (String s: list) {
<caret>
}
}
......
......@@ -3,7 +3,7 @@ class Test2 {
void foo(final List<PatchLogger> loggers) {
final PatchLogger logger = logger1 -> {
for (PatchLogger logger2 : loggers) {
for (PatchLogger logger2: loggers) {
logger2.logOperation(logger1);
}
};
......
......@@ -3,7 +3,7 @@ class Test2 {
void foo(final List<PatchLogger> loggers) {
final PatchLogger logger = s -> {
for (PatchLogger logger1 : loggers) {
for (PatchLogger logger1: loggers) {
logger1.logOperation(s);
}
};
......
......@@ -3,7 +3,7 @@ import java.lang.annotation.Annotation;
// "Iterate" "true"
class Test {
void foo() {
for (Annotation annotation : getClass().getAnnotations()) {
for (Annotation annotation: getClass().getAnnotations()) {
}
......
......@@ -3,7 +3,7 @@ import java.lang.annotation.Annotation;
// "Iterate" "true"
class Test {
void foo() {
for (Annotation annotation : getClass().getAnnotations()) {
for (Annotation annotation: getClass().getAnnotations()) {
}
......
......@@ -7,7 +7,7 @@ public class Main {
public void test(Map<String, String[]> map) {
List<String> result = new ArrayList<>();
map.entrySet().stream().filter(entry -> entry.getKey().startsWith("x")).map(Map.Entry::getValue).forEach(arr -> {
for (String str : arr) {
for (String str: arr) {
result.add(str.trim() + arr.length);
}
});
......
......@@ -6,9 +6,9 @@ import static java.util.Arrays.asList;
public class Main {
public static boolean test(List<List<String>> list) {
for (List<String> x : list) {
for (List<String> x: list) {
if (x != null) {
for (String s : x) {
for (String s: x) {
if (!s.startsWith("a")) {
return false;
}
......@@ -19,7 +19,7 @@ public class Main {
}
private static boolean testEqEq(List<String> list) {
for (String s : list) {
for (String s: list) {
if (s.trim() != s.toLowerCase()) {
return false;
}
......@@ -30,9 +30,9 @@ public class Main {
public static void testIf(List<List<String>> list) {
boolean b = true;
OUTER:
for (List<String> x : list) {
for (List<String> x: list) {
if (x != null) {
for (String s : x) {
for (String s: x) {
if (!s.startsWith("a")) {
b = false;
break OUTER;
......@@ -46,7 +46,7 @@ public class Main {
}
boolean testNot(String... strings) {
for (String s : strings) {
for (String s: strings) {
if (s != null) {
if (!s.startsWith("xyz")) {
return true;
......@@ -58,7 +58,7 @@ public class Main {
public void testVar(List<Integer> list) {
boolean x = false;
for (Integer i : list) {
for (Integer i: list) {
if (i <= 2) {
x = true;
break;
......
......@@ -6,9 +6,9 @@ import static java.util.Arrays.asList;
public class Main {
public static boolean test(List<List<String>> list) {
for (List<String> x : list) {
for (List<String> x: list) {
if (x != null) {
for (String s : x) {
for (String s: x) {
if (s.startsWith("a")) {
return true;
}
......@@ -19,7 +19,7 @@ public class Main {
}
String testTernary(String[] strings) {
for (String s : strings) {
for (String s: strings) {
if (s != null) {
if (!s.startsWith("xyz")) {
return "s";
......
......@@ -5,7 +5,7 @@ import java.util.List;
public class Main {
public boolean testCond(List<String> list) {
for (String s : list) {
for (String s: list) {
if (s.isEmpty()) {
return list.stream().anyMatch(Objects::isNull);
}
......
......@@ -6,7 +6,7 @@ import java.util.List;
public class Main {
public boolean testCond(List<String> list) {
boolean x = false;
for (String s : list) {
for (String s: list) {
if (s.isEmpty()) {
x = list.stream().anyMatch(Objects::isNull);
break;
......
......@@ -6,7 +6,7 @@ import java.util.List;
public class Main {
public boolean testCond(List<String> list) {
boolean b = true;
for (String s : list) {
for (String s: list) {
if (s.isEmpty()) {
b = false;
break;
......
......@@ -5,7 +5,7 @@ import java.util.List;
public class Main {
public boolean testCond(List<String> list) {
for (String s : list) {
for (String s: list) {
if (s.isEmpty()) {
return false;
}
......
......@@ -9,7 +9,7 @@ public class Main {
long count = 0L;
Set<Integer> uniqueValues = new HashSet<>();
long toSkip = 1;
for (Integer integer : new Integer[]{1, 2, 3, 2, 3}) {
for (Integer integer: new Integer[]{1, 2, 3, 2, 3}) {
if (toSkip > 0) {
toSkip--;
continue;
......
......@@ -7,7 +7,7 @@ public class Main {
private static OptionalDouble testDouble(long... numbers) {
double sum = 0;
long count = 0;
for (long x : numbers) {
for (long x: numbers) {
if (x > 0) {
double v = x;
sum += v;
......@@ -20,7 +20,7 @@ public class Main {
private static OptionalDouble testInt(int... numbers) {
long sum = 0;
long count = 0;
for (int x : numbers) {
for (int x: numbers) {
if (x > 0) {
sum += x;
count++;
......@@ -32,7 +32,7 @@ public class Main {
private static OptionalDouble testLong(long... numbers) {
long sum = 0;
long count = 0;
for (long x : numbers) {
for (long x: numbers) {
if (x > 0) {
sum += x;
count++;
......
......@@ -12,7 +12,7 @@ import java.util.stream.Stream;
public class Main {
public static void main(String[] args) {
List<String> list = Arrays.asList("a", "b", "c", "d");
for (String o : list) {
for (String o: list) {
if (!o.isEmpty()) {
System.out.println("Peek: " + o);
System.out.println("Peek2: " + o);
......@@ -33,7 +33,7 @@ public class Main {
}
}
for (String s : list) {
for (String s: list) {
if ("b".equals(s)) {
System.out.println("Found:");
System.out.println(s);
......@@ -41,7 +41,7 @@ public class Main {
}
}
Optional<String> found = Optional.empty();
for (String qq : list) {
for (String qq: list) {
if ("b".equals(qq)) {
found = Optional.of(qq);
break;
......@@ -54,7 +54,7 @@ public class Main {
});
StringBuilder res = new StringBuilder();
for (String str : list) {
for (String str: list) {
if (str != null) {
str = "[" + str + "]";
res.append(str);
......@@ -63,7 +63,7 @@ public class Main {
System.out.println(res);
long count = 0L;
for (String n : list) {
for (String n: list) {
if (!"a".equals(n)) {
for (int i = 0; i < 3; i++) {
System.out.println("In flatmap idx: " + i);
......@@ -76,7 +76,7 @@ public class Main {
}
void test(List<String> list) {
for (String x : list) {
for (String x: list) {
if (x.isEmpty()) continue;
System.out.println(x);
}
......
......@@ -8,7 +8,7 @@ import java.util.stream.Collectors;
public class Main {
private static List<Integer> test(int[] numbers) {
List<Integer> list = new ArrayList<>();
for (int number : numbers) {
for (int number: numbers) {
Integer integer = number;
list.add(integer);
}
......
......@@ -14,7 +14,7 @@ public class Main {
public static OptionalInt min(IndexSet<?> set) {
boolean seen = false;
int best = 0;
for (Index index : set.asList()) {
for (Index index: set.asList()) {
int asInteger = index.asInteger();
if (!seen || asInteger < best) {
seen = true;
......
......@@ -7,7 +7,7 @@ import java.util.Objects;
public class Main {
private static void test(List<String> list) {
StringBuilder sb = new StringBuilder();
for (String str : list) {
for (String str: list) {
if (str != null) {
sb.append(str);
}
......
......@@ -19,7 +19,7 @@ public class Main {
private void collect() {
List<CharSequence> list = new ArrayList<>();
for (CharSequence charSequence : getListExtends()) {
for (CharSequence charSequence: getListExtends()) {
if (charSequence != null) {
list.add(charSequence);
}
......@@ -30,7 +30,7 @@ public class Main {
private void collect2() {
List<List<? extends CharSequence>> list = new ArrayList<>();
for (CharSequence charSequence : getListExtends()) {
for (CharSequence charSequence: getListExtends()) {
List<? extends CharSequence> charSequences = asList(charSequence);
list.add(charSequences);
}
......@@ -44,7 +44,7 @@ public class Main {
private void collectCustomList() {
MyList<? extends List<? extends CharSequence>> res2 =
new MyList<>();
for (CharSequence charSequence : getListExtends()) {
for (CharSequence charSequence: getListExtends()) {
List<? extends CharSequence> charSequences = asList(charSequence);
res2.add(charSequences);
}
......@@ -60,7 +60,7 @@ public class Main {
private void collectGroupingByCustomList() {
Map<Integer, MyList2<? extends Number, CharSequence>> result = new HashMap<>();
for (CharSequence x : getList()) {
for (CharSequence x: getList()) {
result.computeIfAbsent(x.length(), k -> createMyList2()).add(x);
}
Map<Integer, ? extends MyList2<? extends Number, ? extends CharSequence>> map =
......@@ -70,7 +70,7 @@ public class Main {
private void collectToMap() {
Map<CharSequence, List<? extends CharSequence>> result = new HashMap<>();
for (CharSequence charSequence : getList()) {
for (CharSequence charSequence: getList()) {
if (charSequence != null) {
if (result.put(charSequence, asList(charSequence)) != null) {
throw new IllegalStateException("Duplicate key");
......
......@@ -8,7 +8,7 @@ public class Main {
public void testAveragingDouble(String... list) {
double sum = 0;
long count = 0;
for (String s : list) {
for (String s: list) {
if (s != null) {
sum += 1.0 / s.length();
count++;
......@@ -20,7 +20,7 @@ public class Main {
public void testAveragingInt(String... list) {
long sum = 0;
long count = 0;
for (String s : list) {
for (String s: list) {
if (s != null) {
sum += s.length();
count++;
......@@ -31,7 +31,7 @@ public class Main {
public static long testCounting(List<String> strings) {
long count = 0L;
for (String s : strings) {
for (String s: strings) {
if (!s.isEmpty()) {
count++;
}
......@@ -42,7 +42,7 @@ public class Main {
public static Optional<String> testMaxBy(List<String> strings) {
boolean seen = false;
String best = null;
for (String s : strings) {
for (String s: strings) {
if (!s.isEmpty()) {
if (!seen || s.compareTo(best) > 0) {
seen = true;
......@@ -56,7 +56,7 @@ public class Main {
public static Optional<String> testReducing1(List<String> list) {
boolean seen = false;
String acc = null;
for (String s : list) {
for (String s: list) {
if (!seen) {
seen = true;
acc = s;
......@@ -69,7 +69,7 @@ public class Main {
public static String testReducing2(List<String> list) {
String acc = "";
for (String s : list) {
for (String s: list) {
acc = acc + s;
}
return acc;
......@@ -77,7 +77,7 @@ public class Main {
static Integer testReducing3() {
Integer totalLength = 0;
for (String s : Arrays.asList("a", "bb", "ccc")) {
for (String s: Arrays.asList("a", "bb", "ccc")) {
Integer length = s.length();
totalLength = totalLength + length;
}
......@@ -86,7 +86,7 @@ public class Main {
public static DoubleSummaryStatistics testSummarizingDouble(List<String> strings) {
DoubleSummaryStatistics stat = new DoubleSummaryStatistics();
for (String str : strings) {
for (String str: strings) {
if (str != null) {
stat.accept(str.length() / 2.0);
}
......@@ -96,7 +96,7 @@ public class Main {
public static Double testSummingDouble(List<String> strings) {
double sum = 0.0;
for (String string : strings) {
for (String string: strings) {
if (string != null) {
sum += string.length();
}
......@@ -106,7 +106,7 @@ public class Main {
private static TreeSet<Integer> testToCollection() {
TreeSet<Integer> integers = new TreeSet<>();
for (int i : new int[]{4, 2, 1}) {
for (int i: new int[]{4, 2, 1}) {
Integer integer = i;
integers.add(integer);
}
......@@ -116,7 +116,7 @@ public class Main {
// Unresolved reference
void f(Collection<? extends Foo> c) {
R treeSet = new TreeSet();
for (Foo foo : c) {
for (Foo foo: c) {
treeSet.add(foo);
}
Set<Foo> uniqueDescriptors = treeSet;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment