8000 Issue #16857: api: add new int process(List<Path> files) method to Ro… · checkstyle/checkstyle@dbd29bb · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit dbd29bb

Browse files
author
Vincent Potucek
committed
Issue #16857: api: add new int process(List<Path> files) method to RootModule
1 parent 7d9518e commit dbd29bb

File tree

7 files changed

+174
-0
lines changed

7 files changed

+174
-0
lines changed

.editorconfig

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_style = space
7+
insert_final_newline = true
8+
9+
[*.java]
10+
ij_continuation_indent_size = 4
11+
ij_java_binary_operation_sign_on_next_line = true
12+
ij_java_block_brace_style = end_of_line
13+
ij_java_catch_on_new_line = true
14+
ij_java_class_brace_style = end_of_line
15+
ij_java_class_count_to_use_import_on_demand = 999
16+
ij_java_do_while_brace_force = always
17+
ij_java_else_on_new_line = true
18+
ij_java_finally_on_new_line = true
19+
ij_java_for_brace_force = always
20+
ij_java_if_brace_force = always
21+
ij_java_imports_layout = $*, |, java.**, |, javax.**, |, org.**, |, com.**, |, *
22+
ij_java_keep_blank_lines_before_right_brace = 1
23+
ij_java_keep_blank_lines_between_package_declaration_and_header = 1
24+
ij_java_keep_blank_lines_in_code = 1
25+
ij_java_keep_blank_lines_in_declarations = 1
26+
ij_java_lambda_brace_style = end_of_line
27+
ij_java_method_brace_style = end_of_line
28+
ij_java_names_count_to_use_import_on_demand = 999
29+
ij_java_space_before_array_initializer_left_brace = true
30+
ij_java_space_within_empty_array_initializer_braces = false
31+
ij_java_spaces_within_array_initializer_braces = false
32+
ij_java_while_brace_force = always
33+
ij_java_wrap_comments = true
34+
indent_size = 4
35+
max_line_length = 100
36+
37+
[*.xml]
38+
ij_continuation_indent_size = 2
39+
indent_size = 2
40+
max_line_length = 160

config/.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
root = true
2+
3+
[**spotbugs-exclude.xml]
4+
max_line_length = 100

config/jsoref-spellchecker/whitelist.words

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ Edad
355355
edb
356356
ededed
357357
edef
358+
editorconfig
358359
edu
359360
Eghj
360361
Ei
@@ -567,6 +568,7 @@ ietf
567568
Igno
568569
IGNORETHIS
569570
igorminar
571+
ij
570572
Ilja
571573
illegalcatch
572574
illegalex

pom.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,49 @@
730730
</plugins>
731731
</pluginManagement>
732732
<plugins>
733+
<plugin>
734+
<groupId>org.ec4j.maven</groupId>
735+
<artifactId>editorconfig-maven-plugin</artifactId>
736+
<version>0.1.3</version>
737+
<executions>
738+
<execution>
739+
<id>editorconfig-check</id>
740+
<phase>verify</phase>
741+
<goals>
742+
<goal>check</goal>
743+
</goals>
744+
</execution>
745+
</executions>
746+
<configuration>
747+
<excludes>
748+
<exclude>**/*.javadoc</exclude>
749+
<exclude>**/*.jpeg</exclude>
750+
<exclude>.ci-temp/**</exclude>
751+
<exclude>.ci/**</exclude>
752+
<exclude>.docs/**</exclude>
753+
<exclude>.github/**</exclude>
754+
<exclude>src/main/resources/com/puppycrawl/tools/checkstyle/meta/**/*.xml</exclude>
755+
<exclude>src/main/resources/com/puppycrawl/tools/checkstyle/sarif/*.template</exclude>
756+
<exclude>src/site/xdoc/*.xml</exclude>
757+
<exclude>src/site/xdoc/checks/**/*.xml</exclude>
758+
<exclude>src/site/xdoc/filefilters/**s/*.xml</exclude>
759+
<exclude>src/site/xdoc/filefilters/beforeexecutionexclusionfilefilter.xml</exclude>
760+
<exclude>src/site/xdoc/filters/**/*.xml</exclude>
761+
<exclude>src/test/resources-noncompilable/**/*.java</exclude>
762+
<exclude>src/test/resources/com/puppycrawl/tools/checkstyle/**/*.java</exclude>
763+
<exclude>src/test/resources/com/puppycrawl/tools/checkstyle/**/*.xml</exclude>
764+
<exclude>src/test/resources/com/puppycrawl/tools/checkstyle/asttreestringprinter/InputAstTreeStringPrinterFullOfBlockCommentsCR.java</exclude>
765+
<exclude>src/test/resources/com/puppycrawl/tools/checkstyle/checks/newlineatendoffile/**/*</exclude>
766+
<exclude>src/test/resources/com/puppycrawl/tools/checkstyle/checks/uniqueproperties/InputUniquePropertiesWithDuplicates.properties</exclude>
767+
<exclude>src/test/resources/com/puppycrawl/tools/checkstyle/grammar/InputAstRegressionNewlineCrAtEndOfFile.java</exclude>
768+
<exclude>src/test/resources/com/puppycrawl/tools/checkstyle/grammar/javadoc/**/*</exclude>
769+
<exclude>src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/**/*.cpp</exclude>
770+
<exclude>src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/**/*.txt</exclude>
771+
<exclude>src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/newlineatendoffile/**/*</exclude>
772+
<exclude>src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example1.properties</exclude>
773+
</excludes>
774+
</configuration>
775+
</plugin>
733776
<plugin>
734777
<groupId>org.codehaus.plexus</groupId>
735778
<artifactId>plexus-component-metadata</artifactId>

src/test/java/com/puppycrawl/tools/checkstyle/CheckerTest.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import static com.puppycrawl.tools.checkstyle.DefaultLogger.AUDIT_STARTED_MESSAGE;
2626
import static com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck.MSG_KEY_NO_NEWLINE_EOF;
2727
import static com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck.MSG_KEY;
28+
import static org.mockito.Mockito.doReturn;
2829

2930
import java.io.BufferedReader;
3031
import java.io.ByteArrayInputStream;
@@ -57,6 +58,8 @@
5758

5859
import org.junit.jupiter.api.Test;
5960
import org.junit.jupiter.api.io.TempDir;
61+
import org.mockito.ArgumentCaptor;
62+
import org.mockito.Mockito;
6063

6164
import com.puppycrawl.tools.checkstyle.AbstractAutomaticBean.OutputStreamOptions;
6265
import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
@@ -88,6 +91,7 @@
8891
import com.puppycrawl.tools.checkstyle.internal.utils.CloseAndFlushTestByteArrayOutputStream;
8992
import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil;
9093
import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
94+
9195
import de.thetaphi.forbiddenapis.SuppressForbidden;
9296

9397
/**
@@ -898,6 +902,43 @@ public String getAbsolutePath() {
898902
}
899903
}
900904

905+
@Test
906+
public void testProcessPathCollection() throws Exception {
907+
final Checker checker = new Checker();
908+
final DebugAuditAdapter auditAdapter = new DebugAuditAdapter();
909+
checker.addListener(auditAdapter);
910+
911+
final File tempFile1 = createTempFile("test1", ".java");
912+
final File tempFile2 = createTempFile("test2", ".java");
913+
914+
final Checker spyChecker = Mockito.spy(checker);
915+
doReturn(0).when(spyChecker).process(Collections.<File>emptyList());
916+
917+
spyChecker.process(Arrays.asList(
918+
tempFile1.toPath(),
919+
tempFile2.toPath()
920+
));
921+
922+
ArgumentCaptor<List<File>> filesCaptor = ArgumentCaptor.forClass(List.class);
923+
Mockito.verify(spyChecker).process(filesCaptor.capture());
924+
List<File> processedFiles = filesCaptor.getValue();
925+
assertWithMessage("Processed files count mismatch")
926+
.that(processedFiles)
927+
.hasSize(2);
928+
assertWithMessage("First file mismatch")
929+
.that(processedFiles.get(0))
930+
.isEqualTo(tempFile1);
931+
assertWithMessage("Second file mismatch")
932+
.that(processedFiles.get(1))
933+
.isEqualTo(tempFile2);
934+
assertWithMessage("Audit started event not fired")
935+
.that(auditAdapter.wasCalled())
936+
.isTrue();
937+
assertWithMessage("Incorrect number of files processed")
938+
.that(auditAdapter.getNumFilesStarted())
939+
.isEqualTo(2);
940+
}
941+
901942
/**
902943
* It is OK to have long test method name here as it describes the test purpose.
903944
*/
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
root = true
2+
3+
[*]
4+
charset = unset
5+
end_of_line = unset
6+
indent_style = unset
7+
8+
[*.java]
9+
ij_continuation_indent_size = unset
10+
ij_java_binary_operation_sign_on_next_line = unset
11+
ij_java_block_brace_style = unset
12+
ij_java_catch_on_new_line = unset
13+
ij_java_class_brace_style = unset
14+
ij_java_class_count_to_use_import_on_demand = unset
15+
ij_java_do_while_brace_force = unset
16+
ij_java_else_on_new_line = unset
17+
ij_java_finally_on_new_line = unset
18+
ij_java_for_brace_force = unset
19+
ij_java_if_brace_force = unset
20+
ij_java_imports_layout = unset
21+
ij_java_keep_blank_lines_before_right_brace = unset
22+
ij_java_keep_blank_lines_between_package_declaration_and_header = unset
23+
ij_java_keep_blank_lines_in_code = unset
24+
ij_java_keep_blank_lines_in_declarations = unset
25+
ij_java_lambda_brace_style = unset
26+
ij_java_method_brace_style = unset
27+
ij_java_names_count_to_use_import_on_demand = unset
28+
ij_java_space_before_array_initializer_left_brace = unset
29+
ij_java_space_within_empty_array_initializer_braces = unset
30+
ij_java_spaces_within_array_initializer_braces = unset
31+
ij_java_while_brace_force = unset
32+
ij_java_wrap_comments = unset
33+
indent_size = unset
34+
max_line_length = unset
35+
36+
[*.xml]
37+
ij_continuation_indent_size = unset
38+
indent_size = unset
39+
max_line_length = unset

src/xdocs-examples/.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
root = true
2+
3+
[*.java]
4+
ij_continuation_indent_size = 2
5+
indent_size = 2

0 commit comments

Comments
 (0)
0