20
20
package com .google .checkstyle .test .base ;
21
21
22
22
import java .io .IOException ;
23
- import java .util .ArrayList ;
24
- import java .util .Arrays ;
25
- import java .util .HashSet ;
26
- import java .util .List ;
27
23
import java .util .Properties ;
28
24
import java .util .Set ;
29
25
30
26
import org .checkstyle .base .AbstractItModuleTestSupport ;
31
27
32
28
import com .puppycrawl .tools .checkstyle .ConfigurationLoader ;
33
- import com .puppycrawl .tools .checkstyle .DefaultConfiguration ;
34
29
import com .puppycrawl .tools .checkstyle .PropertiesExpander ;
35
- import com .puppycrawl .tools .checkstyle .TreeWalker ;
36
30
import com .puppycrawl .tools .checkstyle .api .CheckstyleException ;
37
31
import com .puppycrawl .tools .checkstyle .api .Configuration ;
38
32
import com .puppycrawl .tools .checkstyle .internal .utils .CheckUtil ;
@@ -46,26 +40,6 @@ public abstract class AbstractGoogleModuleTestSupport extends AbstractItModuleTe
46
40
47
41
private static final Set <Class <?>> CHECKSTYLE_MODULES ;
48
42
49
- private static final Set <String > CHECKER_CHILDREN = new HashSet <>(Arrays .asList (
50
- "BeforeExecutionExclusionFileFilter" ,
51
- "SeverityMatchFilter" ,
52
- "SuppressionFilter" ,
53
- "SuppressionSingleFilter" ,
54
- "SuppressWarningsFilter" ,
55
- "SuppressWithNearbyTextFilter" ,
56
- "SuppressWithPlainTextCommentFilter" ,
57
- "JavadocPackage" ,
58
- "NewlineAtEndOfFile" ,
59
- "UniqueProperties" ,
60
- "OrderedProperties" ,
61
- "RegexpMultiline" ,
62
- "RegexpSingleline" ,
63
- "RegexpOnFilename" ,
64
- "FileLength" ,
65
- "LineLength" ,
66
- "FileTabCharacter"
67
- ));
68
-
69
43
static {
70
44
try {
71
45
final Properties properties = new Properties ();
@@ -103,42 +77,6 @@ protected ModuleCreationOption findModuleCreationOption(String moduleName) {
103
77
return moduleCreationOption ;
104
78
}
105
79
106
- /**
107
- * Returns {@link Configuration} instance for the given module name.
108
- * This implementation uses {@link #getModuleConfig(String, String)} method inside.
109
- *
110
- * @param moduleName module name.
111
- * @return {@link Configuration} instance for the given module name.
112
- */
113
- protected static Configuration getModuleConfig (String moduleName ) {
114
- return getModuleConfig (moduleName , null );
115
- }
116
-
117
- /**
118
- * Returns {@link Configuration} instance for the given module name.
119
- * This implementation uses {@link #getModuleConfig(String)} method inside.
120
- *
121
- * @param moduleName module name.
122
- * @param moduleId module id.
123
- * @return {@link Configuration} instance for the given module name.
124
- * @throws IllegalStateException if there is a problem retrieving the module or config.
125
- */
126
- protected static Configuration getModuleConfig (String moduleName , String moduleId ) {
127
- return getModuleConfig (CONFIGURATION , moduleName , moduleId );
128
- }
129
-
130
- /**
131
- * Returns a list of all {@link Configuration} instances for the given module IDs.
132
- *
133
- * @param moduleIds module IDs.
134
- * @return List of {@link Configuration} instances.
135
- * @throws CheckstyleException if there is an error with the config.
136
- */
137
- protected static List <Configuration > getModuleConfigsByIds (String ... moduleIds )
138
- throws CheckstyleException {
139
- return getModuleConfigsByIds (CONFIGURATION , moduleIds );
140
- }
141
-
142
80
/**
143
81
* Performs verification of the file with the given file path against the whole config.
144
82
*
@@ -148,62 +86,4 @@ protected static List<Configuration> getModuleConfigsByIds(String... moduleIds)
148
86
protected void verifyWithWholeConfig (String filePath ) throws Exception {
149
87
verifyWithItConfig (CONFIGURATION , filePath );
150
88
}
151
-
152
- // until https://github.com/checkstyle/checkstyle/issues/15214
153
- /**
154
- * Performs verification of the file with the given file path against config.
155
- * It uses the specified list of modules to load them from config for validation.
156
- *
157
- * @param listOfModules list of modules to load from config.
158
- * @param filePath file path to verify.
159
- * @throws Exception if exception occurs during verification process.
160
- */
161
- protected final void verifyWithConfigParser (String [] listOfModules ,
162
- String filePath ) throws Exception {
163
- final DefaultConfiguration rootConfig = new DefaultConfiguration (ROOT_MODULE_NAME );
164
- final DefaultConfiguration treeWalkerConfig =
165
- new DefaultConfiguration (TreeWalker .class .getSimpleName ());
166
-
167
- for (String module : listOfModules ) {
168
- final List <Configuration > children =
169
- getConfigChildren (module );
170
- if (CHECKER_CHILDREN .contains (module )) {
171
- for (Configuration child : children ) {
172
- rootConfig .addChild (child );
173
- }
174
- }
175
- else {
176
- for (Configuration child : children ) {
177
- treeWalkerConfig .addChild (child );
178
- }
179
- }
180
- }
181
-
182
- if (treeWalkerConfig .getChildren ().length > 0 ) {
183
- rootConfig .addChild (treeWalkerConfig );
184
- }
185
-
186
- verifyWithItConfig (rootConfig , filePath );
187
- }
188
-
189
- /**
190
- * Gets the specified children module(s) from the config.
191
- *
192
- * @param module the children module to get. It can be either a module name or module id.
193
- * @return list of children modules.
194
- * @throws CheckstyleException if there is a problem for getting the module.
195
- */
196
- private static List <Configuration > getConfigChildren (String module )
197
- throws CheckstyleException {
198
- final List <Configuration > children = new ArrayList <>();
199
-
200
- try {
201
- children .add (getModuleConfig (module ));
202
- }
203
- catch (IllegalStateException ex ) {
204
- children .addAll (getModuleConfigsByIds (module ));
205
- }
206
-
207
- return children ;
208
- }
209
89
}
0 commit comments