Skip to content

Commit afbb944

Browse files
committed
Issue #1627: Make 'processJavadoc' property 'true' by default
1 parent 8f5317d commit afbb944

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

config/checkstyle_checks.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@
196196
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
197197
</module>
198198
<module name="TypeName"/>
199-
<module name="UnusedImports">
200-
<property name="processJavadoc" value="true"/>
201-
</module>
199+
<module name="UnusedImports"/>
200+
201+
202202
<module name="UpperEll"/>
203203
<module name="VisibilityModifier"/>
204204
<module name="WhitespaceAfter"/>

src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheck.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public class UnusedImportsCheck extends Check {
7474
/** Flag to indicate when time to start collecting references. */
7575
private boolean collect;
7676
/** Flag whether to process Javadoc comments. */
77-
private boolean processJavadoc;
77+
private boolean processJavadoc = true;
7878

7979
/** Set of the imports. */
8080
private final Set<FullIdent> imports = Sets.newHashSet();

src/main/resources/sun_checks.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@
103103
<module name="AvoidStarImport"/>
104104
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
105105
<module name="RedundantImport"/>
106-
<module name="UnusedImports"/>
106+
<module name="UnusedImports">
107+
<property name="processJavadoc" value="false"/>
108+
</module>
107109

108110
<!-- Checks for Size Violations. -->
109111
<!-- See http://checkstyle.sf.net/config_sizes.html -->

src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ protected String getNonCompilablePath(String filename) throws IOException {
4646
}
4747

4848
@Test
49-
public void testDefault() throws Exception {
49+
public void testWithoutProcessJavadoc() throws Exception {
5050
final DefaultConfiguration checkConfig = createCheckConfig(UnusedImportsCheck.class);
51+
checkConfig.addAttribute("processJavadoc", "false");
5152
final String[] expected = {
5253
"8:45: " + getCheckMessage(MSG_KEY,
5354
"com.puppycrawl.tools.checkstyle.checks.imports.InputImportBug"),
@@ -86,7 +87,6 @@ public void testDefault() throws Exception {
8687
@Test
8788
public void testProcessJavadoc() throws Exception {
8889
final DefaultConfiguration checkConfig = createCheckConfig(UnusedImportsCheck.class);
89-
checkConfig.addAttribute("processJavadoc", "true");
9090
final String[] expected = {
9191
"8:45: " + getCheckMessage(MSG_KEY,
9292
"com.puppycrawl.tools.checkstyle.checks.imports.InputImportBug"),

src/xdocs/config_imports.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ public class SomeClass { ... }
10311031
</li>
10321032
<li>
10331033
<b>Optionally:</b> it is referenced in Javadoc comments. This check
1034-
is off by default, as it is considered bad practice to introduce
1034+
is on by default, but it is considered bad practice to introduce
10351035
a compile time dependency for documentation purposes only.
10361036
As an example, the import <code>java.util.Date</code> would be
10371037
considered referenced with the Javadoc comment
@@ -1070,7 +1070,7 @@ class FooBar {
10701070
<td>processJavadoc</td>
10711071
<td>whether to process Javadoc</td>
10721072
<td><a href="property_types.html#boolean">boolean</a></td>
1073-
<td><code>false</code></td>
1073+
<td><code>true</code></td>
10741074
</tr>
10751075
</table>
10761076
</subsection>
@@ -1087,7 +1087,7 @@ class FooBar {
10871087
<subsection name="Example of Usage">
10881088
<ul>
10891089
<li>
1090-
<a href="https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/sun_checks.xml#L106">
1090+
<a href="https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/sun_checks.xml#L106-L108">
10911091
Sun Style</a>
10921092
</li>
10931093
<li>

0 commit comments

Comments
 (0)