google / google/google-java-format

Remove redundant string concatenations when unwrapping lines

Ouverte
#122 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
non-whitespace
Langage dominant
Java
Étoiles
6.2k
Forks
937
Merge moyen
6 min
PR mergées (30 j)
3

Description

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](https://gerrit-review.googlesource.com/#/c/91444/7/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java) 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()));
```

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.