From afbb944fe23b1be090ed69bfb97641be9dc2842c Mon Sep 17 00:00:00 2001 From: Vladislav Lisetskiy Date: Tue, 3 Nov 2015 18:14:30 +0300 Subject: [PATCH] Issue #1627: Make 'processJavadoc' property 'true' by default --- config/checkstyle_checks.xml | 6 +++--- .../tools/checkstyle/checks/imports/UnusedImportsCheck.java | 2 +- src/main/resources/sun_checks.xml | 4 +++- .../checkstyle/checks/imports/UnusedImportsCheckTest.java | 4 ++-- src/xdocs/config_imports.xml | 6 +++--- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/config/checkstyle_checks.xml b/config/checkstyle_checks.xml index f58dd9c4e..021f92d54 100644 --- a/config/checkstyle_checks.xml +++ b/config/checkstyle_checks.xml @@ -196,9 +196,9 @@ - - - + + + diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheck.java index 48e9a2153..a14c5a146 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheck.java @@ -74,7 +74,7 @@ public class UnusedImportsCheck extends Check { /** Flag to indicate when time to start collecting references. */ private boolean collect; /** Flag whether to process Javadoc comments. */ - private boolean processJavadoc; + private boolean processJavadoc = true; /** Set of the imports. */ private final Set imports = Sets.newHashSet(); diff --git a/src/main/resources/sun_checks.xml b/src/main/resources/sun_checks.xml index e195890fe..6ecad476f 100644 --- a/src/main/resources/sun_checks.xml +++ b/src/main/resources/sun_checks.xml @@ -103,7 +103,9 @@ - + + + diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckTest.java index e042c4f4f..ea764e018 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckTest.java @@ -46,8 +46,9 @@ public class UnusedImportsCheckTest extends BaseCheckTestSupport { } @Test - public void testDefault() throws Exception { + public void testWithoutProcessJavadoc() throws Exception { final DefaultConfiguration checkConfig = createCheckConfig(UnusedImportsCheck.class); + checkConfig.addAttribute("processJavadoc", "false"); final String[] expected = { "8:45: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports.InputImportBug"), @@ -86,7 +87,6 @@ public class UnusedImportsCheckTest extends BaseCheckTestSupport { @Test public void testProcessJavadoc() throws Exception { final DefaultConfiguration checkConfig = createCheckConfig(UnusedImportsCheck.class); - checkConfig.addAttribute("processJavadoc", "true"); final String[] expected = { "8:45: " + getCheckMessage(MSG_KEY, "com.puppycrawl.tools.checkstyle.checks.imports.InputImportBug"), diff --git a/src/xdocs/config_imports.xml b/src/xdocs/config_imports.xml index b9bf32d6e..0801a878f 100644 --- a/src/xdocs/config_imports.xml +++ b/src/xdocs/config_imports.xml @@ -1031,7 +1031,7 @@ public class SomeClass { ... }
  • Optionally: it is referenced in Javadoc comments. This check - is off by default, as it is considered bad practice to introduce + is on by default, but it is considered bad practice to introduce a compile time dependency for documentation purposes only. As an example, the import java.util.Date would be considered referenced with the Javadoc comment @@ -1070,7 +1070,7 @@ class FooBar { processJavadoc whether to process Javadoc boolean - false + true @@ -1087,7 +1087,7 @@ class FooBar {