Skip to content

Commit da2bf59

Browse files
committedNov 9, 2017
Issue checkstyle#4284: disallow junit.framework package in test code
1 parent c7ef5be commit da2bf59

File tree

6 files changed

+21
-1
lines changed

6 files changed

+21
-1
lines changed
 

‎config/ant-phase-verify.xml

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<property key="checkstyle.header.file" file="config/java.header"/>
3636
<property key="checkstyle.regexp.header.file" file="config/java_regexp.header"/>
3737
<property key="checkstyle.importcontrol.file" file="config/import-control.xml"/>
38+
<property key="checkstyle.importcontroltest.file" file="config/import-control-test.xml"/>
3839
<property key="checkstyle.suppressions.file"
3940
file="config/suppressions.xml"/>
4041
</checkstyle>

‎config/build.xml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<property key="checkstyle.header.file" file="config/java.header"/>
3838
<property key="checkstyle.regexp.header.file" file="config/java_regexp.header"/>
3939
<property key="checkstyle.importcontrol.file" file="config/import-control.xml"/>
40+
<property key="checkstyle.importcontroltest.file" file="config/import-control-test.xml"/>
4041
<property key="checkstyle.suppressions.file"
4142
file="config/suppressions.xml"/>
4243
</checkstyle>

‎config/checkstyle_checks.xml

+6
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,15 @@
329329
</module>
330330
<module name="IllegalImport"/>
331331
<module name="ImportControl">
332+
<property name="id" value="ImportControlMain"/>
332333
<property name="file" value="${checkstyle.importcontrol.file}"/>
333334
<property name="path" value="^.*[\\/]src[\\/]main[\\/].*$"/>
334335
</module>
336+
<module name="ImportControl">
337+
<property name="id" value="ImportControlTest"/>
338+
<property name="file" value="${checkstyle.importcontroltest.file}"/>
339+
<property name="path" value="^.*[\\/]src[\\/]test[\\/].*$"/>
340+
</module>
335341
<module name="ImportOrder">
336342
<property name="groups" value="/^java\./,javax,org"/>
337343
<property name="ordered" value="true"/>

‎config/import-control-test.xml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE import-control PUBLIC
3+
"-//Puppy Crawl//DTD Import Control 1.3//EN"
4+
"http://checkstyle.sourceforge.net/dtds/import_control_1_3.dtd">
5+
6+
<import-control pkg="com.puppycrawl.tools.checkstyle">
7+
8+
<allow pkg=".*" regex="true" />
9+
10+
<disallow pkg="junit.framework" />
11+
12+
</import-control>

‎config/suppressions.xml

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
<suppress checks="NPathComplexity" files="[\\/]XdocsPagesTest\.java"/>
2929
<suppress checks="IllegalCatch" files="[\\/]internal[\\/].*[\\/]\w+Util\.java"/>
3030
<suppress checks="EmptyBlock" files=".*[\\/]src[\\/]test[\\/]"/>
31-
<suppress checks="ImportControl" files=".*[\\/]src[\\/](test|it)[\\/]"/>
3231
<suppress checks="Javadoc" files=".*[\\/]src[\\/](test|it)[\\/]"/>
3332
<suppress checks="MagicNumber" files=".*[\\/]src[\\/](test|it)[\\/]"/>
3433
<suppress checks="AvoidStaticImport" files=".*[\\/]src[\\/](test|it)[\\/]"/>

‎src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/ConfigurationUtil.java

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public static Configuration loadConfiguration(String path) throws CheckstyleExce
4141
props.setProperty("checkstyle.header.file", "file");
4242
props.setProperty("checkstyle.regexp.header.file", "file");
4343
props.setProperty("checkstyle.importcontrol.file", "file");
44+
props.setProperty("checkstyle.importcontroltest.file", "file");
4445

4546
return loadConfiguration(path, props);
4647
}

0 commit comments

Comments
 (0)
Please sign in to comment.