1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.puppycrawl.tools.checkstyle;
21
22 import static com.google.common.truth.Truth.assertWithMessage;
23
24 import java.io.ByteArrayInputStream;
25 import java.io.ByteArrayOutputStream;
26 import java.io.File;
27 import java.io.IOException;
28 import java.io.InputStreamReader;
29 import java.io.LineNumberReader;
30 import java.nio.charset.StandardCharsets;
31 import java.nio.file.Path;
32 import java.text.MessageFormat;
33 import java.util.ArrayList;
34 import java.util.Arrays;
35 import java.util.Collections;
36 import java.util.HashMap;
37 import java.util.List;
38 import java.util.Locale;
39 import java.util.Map;
40 import java.util.ResourceBundle;
41 import java.util.stream.Collectors;
42
43 import com.google.common.collect.ImmutableMap;
44 import com.google.common.collect.Maps;
45 import com.puppycrawl.tools.checkstyle.LocalizedMessage.Utf8Control;
46 import com.puppycrawl.tools.checkstyle.api.AuditListener;
47 import com.puppycrawl.tools.checkstyle.api.Configuration;
48 import com.puppycrawl.tools.checkstyle.api.DetailAST;
49 import com.puppycrawl.tools.checkstyle.bdd.InlineConfigParser;
50 import com.puppycrawl.tools.checkstyle.bdd.TestInputConfiguration;
51 import com.puppycrawl.tools.checkstyle.bdd.TestInputViolation;
52 import com.puppycrawl.tools.checkstyle.internal.utils.BriefUtLogger;
53 import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil;
54 import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
55 import com.puppycrawl.tools.checkstyle.utils.ModuleReflectionUtil;
56 import com.puppycrawl.tools.checkstyle.xpath.RootNode;
57
58 public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport {
59
60 protected static final String ROOT_MODULE_NAME = Checker.class.getSimpleName();
61
62 private final ByteArrayOutputStream stream = new ByteArrayOutputStream();
63
64
65
66
67
68
69 protected final ByteArrayOutputStream getStream() {
70 return stream;
71 }
72
73
74
75
76
77
78 protected final BriefUtLogger getBriefUtLogger() {
79 return new BriefUtLogger(stream);
80 }
81
82
83
84
85
86
87
88
89 protected static DefaultConfiguration createModuleConfig(Class<?> clazz) {
90 return new DefaultConfiguration(clazz.getName());
91 }
92
93
94
95
96
97
98
99
100 protected final Checker createChecker(Configuration moduleConfig)
101 throws Exception {
102 final String moduleName = moduleConfig.getName();
103 final Checker checker = new Checker();
104 checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader());
105
106 if (ROOT_MODULE_NAME.equals(moduleName)) {
107 checker.configure(moduleConfig);
108 }
109 else {
110 configureChecker(checker, moduleConfig);
111 }
112
113 checker.addListener(getBriefUtLogger());
114 return checker;
115 }
116
117
118
119
120
121
122
123
124 protected void configureChecker(Checker checker, Configuration moduleConfig) throws Exception {
125 final Class<?> moduleClass = Class.forName(moduleConfig.getName());
126
127 final Configuration config;
128 if (ModuleReflectionUtil.isCheckstyleTreeWalkerCheck(moduleClass)
129 || ModuleReflectionUtil.isTreeWalkerFilterModule(moduleClass)) {
130 config = createTreeWalkerConfig(moduleConfig);
131 }
132 else {
133 config = createRootConfig(moduleConfig);
134 }
135 checker.configure(config);
136 }
137
138
139
140
141
142
143
144
145
146 protected static DefaultConfiguration createTreeWalkerConfig(Configuration config) {
147 final DefaultConfiguration rootConfig =
148 new DefaultConfiguration(ROOT_MODULE_NAME);
149 final DefaultConfiguration twConf = createModuleConfig(TreeWalker.class);
150
151 rootConfig.addProperty("charset", StandardCharsets.UTF_8.name());
152 rootConfig.addChild(twConf);
153 twConf.addChild(config);
154 return rootConfig;
155 }
156
157
158
159
160
161
162
163 protected static DefaultConfiguration createRootConfig(Configuration config) {
164 final DefaultConfiguration rootConfig = new DefaultConfiguration(ROOT_MODULE_NAME);
165 if (config != null) {
166 rootConfig.addChild(config);
167 }
168 return rootConfig;
169 }
170
171
172
173
174
175
176
177
178
179 protected final String getNonCompilablePath(String filename) throws IOException {
180 return new File("src/" + getResourceLocation()
181 + "/resources-noncompilable/" + getPackageLocation() + "/"
182 + filename).getCanonicalPath();
183 }
184
185
186
187
188
189
190
191
192 protected RootNode getRootNodeForNonCompilable(String fileName) throws Exception {
193 final File file = new File(getNonCompilablePath(fileName));
194 final DetailAST rootAst = JavaParser.parseFile(file, JavaParser.Options.WITHOUT_COMMENTS);
195 return new RootNode(rootAst);
196 }
197
198
199
200
201
202
203
204
205 protected final String getUriString(String filename) {
206 return new File("src/test/resources/" + getPackageLocation() + "/" + filename).toURI()
207 .toString();
208 }
209
210
211
212
213
214
215
216
217
218
219
220 protected final void verifyFilterWithInlineConfigParser(String filePath,
221 String[] expectedUnfiltered,
222 String... expectedFiltered)
223 throws Exception {
224 final TestInputConfiguration testInputConfiguration =
225 InlineConfigParser.parseWithFilteredViolations(filePath);
226 final DefaultConfiguration configWithoutFilters =
227 testInputConfiguration.createConfigurationWithoutFilters();
228 final List<TestInputViolation> violationsWithoutFilters =
229 new ArrayList<>(testInputConfiguration.getViolations());
230 violationsWithoutFilters.addAll(testInputConfiguration.getFilteredViolations());
231 Collections.sort(violationsWithoutFilters);
232 verifyViolations(configWithoutFilters, filePath, violationsWithoutFilters);
233 verify(configWithoutFilters, filePath, expectedUnfiltered);
234 final DefaultConfiguration configWithFilters =
235 testInputConfiguration.createConfiguration();
236 verifyViolations(configWithFilters, filePath, testInputConfiguration.getViolations());
237 verify(configWithFilters, filePath, expectedFiltered);
238 }
239
240
241
242
243
244
245
246
247
248
249 protected final void verifyWithInlineXmlConfig(String filePath, String... expected)
250 throws Exception {
251 final TestInputConfiguration testInputConfiguration =
252 InlineConfigParser.parseWithXmlHeader(filePath);
253 final Configuration xmlConfig =
254 testInputConfiguration.getXmlConfiguration();
255 verifyViolations(xmlConfig, filePath, testInputConfiguration.getViolations());
256 verify(xmlConfig, filePath, expected);
257 }
258
259
260
261
262
263
264
265
266
267
268 protected final void verifyWithInlineConfigParser(String filePath, String... expected)
269 throws Exception {
270 final TestInputConfiguration testInputConfiguration =
271 InlineConfigParser.parse(filePath);
272 final DefaultConfiguration parsedConfig =
273 testInputConfiguration.createConfiguration();
274 final List<String> actualViolations = getActualViolationsForFile(parsedConfig, filePath);
275 verifyViolations(filePath, testInputConfiguration.getViolations(), actualViolations);
276 assertWithMessage("Violations for %s differ.", filePath)
277 .that(actualViolations)
278 .containsExactlyElementsIn(expected);
279 }
280
281
282
283
284
285
286
287
288
289
290
291
292 protected final void verifyWithInlineConfigParser(String filePath1,
293 String filePath2,
294 String... expected)
295 throws Exception {
296 final TestInputConfiguration testInputConfiguration1 =
297 InlineConfigParser.parse(filePath1);
298 final DefaultConfiguration parsedConfig =
299 testInputConfiguration1.createConfiguration();
300 final TestInputConfiguration testInputConfiguration2 =
301 InlineConfigParser.parse(filePath2);
302 verifyViolations(parsedConfig, filePath1, testInputConfiguration1.getViolations());
303 verifyViolations(parsedConfig, filePath2, testInputConfiguration2.getViolations());
304 verify(createChecker(parsedConfig),
305 new File[] {new File(filePath1), new File(filePath2)},
306 filePath1,
307 expected);
308 }
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323 protected final void verifyWithInlineConfigParser(String filePath1,
324 String filePath2,
325 List<String> expectedFromFile1,
326 List<String> expectedFromFile2)
327 throws Exception {
328 final TestInputConfiguration testInputConfiguration = InlineConfigParser.parse(filePath1);
329 final DefaultConfiguration parsedConfig = testInputConfiguration.createConfiguration();
330 final TestInputConfiguration testInputConfiguration2 = InlineConfigParser.parse(filePath2);
331 final DefaultConfiguration parsedConfig2 = testInputConfiguration.createConfiguration();
332 final File[] inputs = {new File(filePath1), new File(filePath2)};
333 verifyViolations(parsedConfig, filePath1, testInputConfiguration.getViolations());
334 verifyViolations(parsedConfig2, filePath2, testInputConfiguration2.getViolations());
335 verify(createChecker(parsedConfig), inputs, ImmutableMap.of(
336 filePath1, expectedFromFile1,
337 filePath2, expectedFromFile2));
338 }
339
340
341
342
343
344
345
346
347
348
349
350
351 protected final void verifyWithInlineConfigParserSeparateConfigAndTarget(String fileWithConfig,
352 String targetFile,
353 String... expected)
354 throws Exception {
355 final TestInputConfiguration testInputConfiguration1 =
356 InlineConfigParser.parse(fileWithConfig);
357 final DefaultConfiguration parsedConfig =
358 testInputConfiguration1.createConfiguration();
359 final List<TestInputViolation> inputViolations =
360 InlineConfigParser.getViolationsFromInputFile(targetFile);
361 final List<String> actualViolations = getActualViolationsForFile(parsedConfig, targetFile);
362 verifyViolations(targetFile, inputViolations, actualViolations);
363 assertWithMessage("Violations for %s differ.", targetFile)
364 .that(actualViolations)
365 .containsExactlyElementsIn(expected);
366 }
367
368
369
370
371
372
373
374
375
376
377
378
379 protected final void verifyFilterWithInlineConfigParserSeparateConfigAndTarget(
380 String fileWithConfig,
381 String targetFilePath,
382 String[] expectedUnfiltered,
383 String... expectedFiltered)
384 throws Exception {
385 final TestInputConfiguration testInputConfiguration =
386 InlineConfigParser.parseWithFilteredViolations(fileWithConfig);
387 final DefaultConfiguration configWithoutFilters =
388 testInputConfiguration.createConfigurationWithoutFilters();
389 final List<TestInputViolation> violationsWithoutFilters = new ArrayList<>(
390 InlineConfigParser.getFilteredViolationsFromInputFile(targetFilePath));
391 violationsWithoutFilters.addAll(
392 InlineConfigParser.getViolationsFromInputFile(targetFilePath));
393 Collections.sort(violationsWithoutFilters);
394 verifyViolations(configWithoutFilters, targetFilePath, violationsWithoutFilters);
395 verify(configWithoutFilters, targetFilePath, expectedUnfiltered);
396 final DefaultConfiguration configWithFilters =
397 testInputConfiguration.createConfiguration();
398 final List<TestInputViolation> violationsWithFilters =
399 InlineConfigParser.getViolationsFromInputFile(targetFilePath);
400 verifyViolations(configWithFilters, targetFilePath, violationsWithFilters);
401 verify(configWithFilters, targetFilePath, expectedFiltered);
402 }
403
404
405
406
407
408
409
410
411
412
413 protected void verifyWithInlineConfigParserTwice(String filePath, String... expected)
414 throws Exception {
415 final TestInputConfiguration testInputConfiguration =
416 InlineConfigParser.parse(filePath);
417 final DefaultConfiguration parsedConfig =
418 testInputConfiguration.createConfiguration();
419 verifyViolations(parsedConfig, filePath, testInputConfiguration.getViolations());
420 verify(parsedConfig, filePath, expected);
421 }
422
423
424
425
426
427
428
429
430
431
432
433
434 protected void verifyWithInlineConfigParserAndLogger(String inputFile,
435 String expectedReportFile,
436 AuditListener logger,
437 ByteArrayOutputStream outputStream)
438 throws Exception {
439 final TestInputConfiguration testInputConfiguration =
440 InlineConfigParser.parse(inputFile);
441 final DefaultConfiguration parsedConfig =
442 testInputConfiguration.createConfiguration();
443 final List<File> filesToCheck = Collections.singletonList(new File(inputFile));
444 final String basePath = Path.of("").toAbsolutePath().toString();
445
446 final Checker checker = createChecker(parsedConfig);
447 checker.setBasedir(basePath);
448 checker.addListener(logger);
449 checker.process(filesToCheck);
450
451 verifyContent(expectedReportFile, outputStream);
452 }
453
454
455
456
457
458
459
460
461
462
463
464
465 protected final void verifyWithInlineConfigParserAndDefaultLogger(String inputFile,
466 String expectedOutputFile,
467 AuditListener logger,
468 ByteArrayOutputStream outputStream)
469 throws Exception {
470 final TestInputConfiguration testInputConfiguration =
471 InlineConfigParser.parseWithXmlHeader(inputFile);
472 final Configuration parsedConfig =
473 testInputConfiguration.getXmlConfiguration();
474 final List<File> filesToCheck = Collections.singletonList(new File(inputFile));
475 final String basePath = Path.of("").toAbsolutePath().toString();
476
477 final Checker checker = createChecker(parsedConfig);
478 checker.setBasedir(basePath);
479 checker.addListener(logger);
480 checker.process(filesToCheck);
481
482 verifyCleanedMessageContent(expectedOutputFile, outputStream, basePath);
483 }
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502 protected final void verifyWithInlineConfigParserAndDefaultLogger(String inputFile,
503 String expectedInfoFile,
504 String expectedErrorFile,
505 AuditListener logger,
506 ByteArrayOutputStream infoStream,
507 ByteArrayOutputStream errorStream)
508 throws Exception {
509 final TestInputConfiguration testInputConfiguration =
510 InlineConfigParser.parseWithXmlHeader(inputFile);
511 final Configuration parsedConfig =
512 testInputConfiguration.getXmlConfiguration();
513 final List<File> filesToCheck = Collections.singletonList(new File(inputFile));
514 final String basePath = Path.of("").toAbsolutePath().toString();
515
516 final Checker checker = createChecker(parsedConfig);
517 checker.setBasedir(basePath);
518 checker.addListener(logger);
519 checker.process(filesToCheck);
520
521 verifyContent(expectedInfoFile, infoStream);
522 verifyCleanedMessageContent(expectedErrorFile, errorStream, basePath);
523 }
524
525
526
527
528
529
530
531
532
533
534
535
536 protected final void verify(Configuration config, String fileName, String... expected)
537 throws Exception {
538 verify(createChecker(config), fileName, fileName, expected);
539 }
540
541
542
543
544
545
546
547
548
549
550
551
552
553 protected void verify(Checker checker, String fileName, String... expected)
554 throws Exception {
555 verify(checker, fileName, fileName, expected);
556 }
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571 protected final void verify(Checker checker,
572 String processedFilename,
573 String messageFileName,
574 String... expected)
575 throws Exception {
576 verify(checker,
577 new File[] {new File(processedFilename)},
578 messageFileName, expected);
579 }
580
581
582
583
584
585
586
587
588
589
590
591 protected void verify(Checker checker,
592 File[] processedFiles,
593 String messageFileName,
594 String... expected)
595 throws Exception {
596 final Map<String, List<String>> expectedViolations = new HashMap<>();
597 expectedViolations.put(messageFileName, Arrays.asList(expected));
598 verify(checker, processedFiles, expectedViolations);
599 }
600
601
602
603
604
605
606
607
608
609 protected final void verify(Checker checker,
610 File[] processedFiles,
611 Map<String, List<String>> expectedViolations)
612 throws Exception {
613 stream.flush();
614 stream.reset();
615 final List<File> theFiles = new ArrayList<>();
616 Collections.addAll(theFiles, processedFiles);
617 checker.process(theFiles);
618
619
620 final Map<String, List<String>> actualViolations = getActualViolations();
621 final Map<String, List<String>> realExpectedViolations =
622 Maps.filterValues(expectedViolations, input -> !input.isEmpty());
623
624 assertWithMessage("Files with expected violations and actual violations differ.")
625 .that(actualViolations.keySet())
626 .isEqualTo(realExpectedViolations.keySet());
627
628 realExpectedViolations.forEach((fileName, violationList) -> {
629 assertWithMessage("Violations for %s differ.", fileName)
630 .that(actualViolations.get(fileName))
631 .containsExactlyElementsIn(violationList);
632 });
633
634 checker.destroy();
635 }
636
637
638
639
640
641
642
643
644 protected final void verifyWithLimitedResources(String fileName, String... expected)
645 throws Exception {
646 TestUtil.getResultWithLimitedResources(() -> {
647 verifyWithInlineConfigParser(fileName, expected);
648 return null;
649 });
650 assertWithMessage("Verify should complete successfully.")
651 .that((Object) null)
652 .isNull();
653 }
654
655
656
657
658
659
660
661
662 protected final void execute(Configuration config, String... filenames) throws Exception {
663 final Checker checker = createChecker(config);
664 final List<File> files = Arrays.stream(filenames)
665 .map(File::new)
666 .toList();
667 checker.process(files);
668 checker.destroy();
669 }
670
671
672
673
674
675
676
677
678 protected static void execute(Checker checker, String... filenames) throws Exception {
679 final List<File> files = Arrays.stream(filenames)
680 .map(File::new)
681 .toList();
682 checker.process(files);
683 checker.destroy();
684 }
685
686
687
688
689
690
691
692
693
694 private void verifyViolations(Configuration config,
695 String file,
696 List<TestInputViolation> testInputViolations)
697 throws Exception {
698 final List<String> actualViolations = getActualViolationsForFile(config, file);
699 final List<Integer> actualViolationLines = actualViolations.stream()
700 .map(violation -> violation.substring(0, violation.indexOf(':')))
701 .map(Integer::valueOf)
702 .toList();
703 final List<Integer> expectedViolationLines = testInputViolations.stream()
704 .map(TestInputViolation::getLineNo)
705 .toList();
706 assertWithMessage("Violation lines for %s differ.", file)
707 .that(actualViolationLines)
708 .isEqualTo(expectedViolationLines);
709 for (int index = 0; index < actualViolations.size(); index++) {
710 assertWithMessage("Actual and expected violations differ.")
711 .that(actualViolations.get(index))
712 .matches(testInputViolations.get(index).toRegex());
713 }
714 }
715
716
717
718
719
720
721
722
723 private static void verifyViolations(String file,
724 List<TestInputViolation> testInputViolations,
725 List<String> actualViolations) {
726 final List<Integer> actualViolationLines = actualViolations.stream()
727 .map(violation -> violation.substring(0, violation.indexOf(':')))
728 .map(Integer::valueOf)
729 .toList();
730 final List<Integer> expectedViolationLines = testInputViolations.stream()
731 .map(TestInputViolation::getLineNo)
732 .toList();
733 assertWithMessage("Violation lines for %s differ.", file)
734 .that(actualViolationLines)
735 .isEqualTo(expectedViolationLines);
736 for (int index = 0; index < actualViolations.size(); index++) {
737 assertWithMessage("Actual and expected violations differ.")
738 .that(actualViolations.get(index))
739 .matches(testInputViolations.get(index).toRegex());
740 }
741 }
742
743
744
745
746
747
748
749
750 private static void verifyContent(
751 String expectedOutputFile,
752 ByteArrayOutputStream outputStream) throws IOException {
753 final String expectedContent = readFile(expectedOutputFile);
754 final String actualContent =
755 toLfLineEnding(outputStream.toString(StandardCharsets.UTF_8));
756 assertWithMessage("Content should match")
757 .that(actualContent)
758 .isEqualTo(expectedContent);
759 }
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780 private static void verifyCleanedMessageContent(
781 String expectedOutputFile,
782 ByteArrayOutputStream outputStream,
783 String basePath) throws IOException {
784 final String expectedContent = readFile(expectedOutputFile);
785 final String rawActualContent =
786 toLfLineEnding(outputStream.toString(StandardCharsets.UTF_8));
787
788 final String cleanedActualContent = rawActualContent.lines()
789 .filter(line -> {
790 return line.startsWith("[")
791 || line.contains("Starting audit...")
792 || line.contains("Audit done.");
793 })
794 .map(line -> line.replace(basePath, ""))
795 .map(line -> line.replace('\\', '/'))
796 .collect(Collectors.joining("\n", "", "\n"));
797
798 assertWithMessage("Content should match")
799 .that(cleanedActualContent)
800 .isEqualTo(expectedContent);
801 }
802
803
804
805
806
807
808
809
810
811 private List<String> getActualViolationsForFile(Configuration config,
812 String file) throws Exception {
813 stream.flush();
814 stream.reset();
815 final List<File> files = Collections.singletonList(new File(file));
816 final Checker checker = createChecker(config);
817 checker.process(files);
818 final Map<String, List<String>> actualViolations =
819 getActualViolations();
820 checker.destroy();
821 return actualViolations.getOrDefault(file, new ArrayList<>());
822 }
823
824
825
826
827
828
829
830
831
832 private Map<String, List<String>> getActualViolations() throws IOException {
833
834 try (ByteArrayInputStream inputStream =
835 new ByteArrayInputStream(stream.toByteArray());
836 LineNumberReader lnr = new LineNumberReader(
837 new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
838 final Map<String, List<String>> actualViolations = new HashMap<>();
839 for (String line = lnr.readLine(); line != null;
840 line = lnr.readLine()) {
841 if ("Audit done.".equals(line) || line.contains("at com")) {
842 break;
843 }
844
845
846 final String[] actualViolation = line.split("(?<=.{2}):", 2);
847 final String actualViolationFileName = actualViolation[0];
848 final String actualViolationMessage = actualViolation[1];
849
850 actualViolations
851 .computeIfAbsent(actualViolationFileName, key -> new ArrayList<>())
852 .add(actualViolationMessage);
853 }
854
855 return actualViolations;
856 }
857 }
858
859
860
861
862
863
864
865
866
867 protected final String getCheckMessage(String messageKey, Object... arguments) {
868 return internalGetCheckMessage(getMessageBundle(), messageKey, arguments);
869 }
870
871
872
873
874
875
876
877
878
879
880 protected static String getCheckMessage(
881 Class<?> clazz, String messageKey, Object... arguments) {
882 return internalGetCheckMessage(getMessageBundle(clazz.getName()), messageKey, arguments);
883 }
884
885
886
887
888
889
890
891
892
893
894 private static String internalGetCheckMessage(
895 String messageBundle, String messageKey, Object... arguments) {
896 final ResourceBundle resourceBundle = ResourceBundle.getBundle(
897 messageBundle,
898 Locale.ROOT,
899 Thread.currentThread().getContextClassLoader(),
900 new Utf8Control());
901 final String pattern = resourceBundle.getString(messageKey);
902 final MessageFormat formatter = new MessageFormat(pattern, Locale.ROOT);
903 return formatter.format(arguments);
904 }
905
906
907
908
909
910
911 private String getMessageBundle() {
912 final String className = getClass().getName();
913 return getMessageBundle(className);
914 }
915
916
917
918
919
920
921
922 private static String getMessageBundle(String className) {
923 final String messageBundle;
924 final String messages = "messages";
925 final int endIndex = className.lastIndexOf('.');
926 final Map<String, String> messageBundleMappings = new HashMap<>();
927 messageBundleMappings.put("SeverityMatchFilterExamplesTest",
928 "com.puppycrawl.tools.checkstyle.checks.naming.messages");
929
930 if (endIndex < 0) {
931 messageBundle = messages;
932 }
933 else {
934 final String packageName = className.substring(0, endIndex);
935 if ("com.puppycrawl.tools.checkstyle.filters".equals(packageName)) {
936 messageBundle = messageBundleMappings.get(className.substring(endIndex + 1));
937 }
938 else {
939 messageBundle = packageName + "." + messages;
940 }
941 }
942 return messageBundle;
943 }
944
945
946
947
948
949
950
951
952 protected static String[] removeSuppressed(String[] actualViolations,
953 String... suppressedViolations) {
954 final List<String> actualViolationsList =
955 Arrays.stream(actualViolations).collect(Collectors.toCollection(ArrayList::new));
956 actualViolationsList.removeAll(Arrays.asList(suppressedViolations));
957 return actualViolationsList.toArray(CommonUtil.EMPTY_STRING_ARRAY);
958 }
959
960 }