Reports loops which can be replaced with stream API calls using lambda expressions. This converts code from an imperative style to a more functional one, as well as making it more compact.

Example:


  boolean check(List<String> data) {
    for (String e : data) {
      String trimmed = e.trim();
      if (!trimmed.startsWith("xyz")) {
        return false;
      }
    }
    return true;
  }

After the quick fix is applied the result looks like:


  boolean check(List<String> data) {
    return data.stream().map(String::trim).allMatch(trimmed -> trimmed.startsWith("xyz"));
  }

This inspection only reports if the configured language level is 8 or higher.