From 9d785e2b697e6075ffabfd512e7b6b29f894ceb3 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Wed, 3 Apr 2019 16:55:03 -0700 Subject: [PATCH] Don't replace forbidden pattern failures when found (#40710) This commit fixes a bug in forbidden patterns where the failures for a file replace the failures from the previous files instead of extending them. --- .../elasticsearch/gradle/precommit/ForbiddenPatternsTask.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/precommit/ForbiddenPatternsTask.java b/buildSrc/src/main/java/org/elasticsearch/gradle/precommit/ForbiddenPatternsTask.java index d68985ff17a..7361b78ad07 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/precommit/ForbiddenPatternsTask.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/precommit/ForbiddenPatternsTask.java @@ -111,13 +111,13 @@ public class ForbiddenPatternsTask extends DefaultTask { .collect(Collectors.toList()); String path = getProject().getRootProject().getProjectDir().toURI().relativize(f.toURI()).toString(); - failures = invalidLines.stream() + failures.addAll(invalidLines.stream() .map(l -> new AbstractMap.SimpleEntry<>(l+1, lines.get(l))) .flatMap(kv -> patterns.entrySet().stream() .filter(p -> Pattern.compile(p.getValue()).matcher(kv.getValue()).find()) .map(p -> "- " + p.getKey() + " on line " + kv.getKey() + " of " + path) ) - .collect(Collectors.toList()); + .collect(Collectors.toList())); } if (failures.isEmpty() == false) { throw new GradleException("Found invalid patterns:\n" + String.join("\n", failures));