google-java-format icon indicating copy to clipboard operation
google-java-format copied to clipboard

Remove redundant string concatenations when unwrapping lines

Open dpursehouse opened this issue 8 years ago • 0 comments

In code that has string concatenation wrapped on multiple lines, the formatter should remove any redundant concatenations when unwrapping the line.

See this reformatting change on the gerrit project for example:

The original code:

      throw new IllegalStateException(String.format(
          "SubmitRuleEvaluator.evaluate for change %s " +
          "returned empty list for %s in %s",
          cd.getId(),
          patchSet.getId(),
          cd.change().getProject().get()));

And after reformatting:

    throw new IllegalStateException(
          String.format(
              "SubmitRuleEvaluator.evaluate for change %s " + "returned empty list for %s in %s",
              cd.getId(), patchSet.getId(), cd.change().getProject().get()));

The first parameter to String.format now has a redundant concatenation, and would be better as:

          String.format(
              "SubmitRuleEvaluator.evaluate for change %s returned empty list for %s in %s",
              cd.getId(), patchSet.getId(), cd.change().getProject().get()));

dpursehouse avatar Feb 10 '17 03:02 dpursehouse