Reports expressions with a repeating pattern which could be replaced with Stream API or String.join().

Example:


  boolean allStartWith(String a, String b, String c, String d, String prefix) {
    return a.startsWith(prefix) && b.startsWith(prefix) && c.startsWith(prefix) && d.startsWith(prefix);
  }

After the quick-fix is applied:


  boolean foo(String a, String b, String c, String d, String prefix) {
    return Stream.of(a, b, c, d).allMatch(s -> s.startsWith(prefix));
  }

Example:


  String joinAll(String a, String b, String c, String d) {
    return a + "," + b + "," + c + "," + d;
  }

After the quick-fix is applied:


  String joinAll(String a, String b, String c, String d) {
    return String.join(",", a, b, c, d);
  }

This inspection only reports if the language level of the project or module is 8 or higher.

New in 2018.2