pmd: fix #254 False+ : UnusedImport with Javadoc @throws
This commit is contained in:
1 parent
60aa0b1778
commit
144a4e152d
4 files changed
+12
-2
No files matched your search
@@ -16,6 +16,7 @@ New Java rule:
|
||||
|
||||
????? ??, 2013 - 5.0.4:
|
||||
|
||||
Fixed bug 254: False+ : UnusedImport with Javadoc @throws
|
||||
Fixed bug 1080: net.sourceforge.pmd.cpd.CPDTest test failing
|
||||
Fixed bug 1081: Regression: CPD skipping all files when using relative paths
|
||||
Fixed bug 1082: CPD performance issue on larger projects
|
||||
|
||||
@@ -50,6 +50,7 @@ public class UnusedImportsRule extends AbstractJavaRule {
|
||||
* {@linkplain package.class#member label}
|
||||
* {@link package.class#member label}
|
||||
* {@value package.class#field}
|
||||
* @throws package.class label
|
||||
*/
|
||||
private static final Pattern SEE_PATTERN = Pattern.compile(
|
||||
"@see\\s+(\\p{Alpha}\\p{Alnum}*)[\\s#]");
|
||||
@@ -60,7 +61,10 @@ public class UnusedImportsRule extends AbstractJavaRule {
|
||||
private static final Pattern VALUE_PATTERN = Pattern.compile(
|
||||
"\\{@value\\s+(\\p{Alpha}\\p{Alnum}*)[\\s#\\}]");
|
||||
|
||||
private static final Pattern[] PATTERNS = { SEE_PATTERN, LINK_PATTERNS, VALUE_PATTERN };
|
||||
private static final Pattern THROWS_PATTERN = Pattern.compile(
|
||||
"@throws\\s+(\\p{Alpha}\\p{Alnum}*)");
|
||||
|
||||
private static final Pattern[] PATTERNS = { SEE_PATTERN, LINK_PATTERNS, VALUE_PATTERN, THROWS_PATTERN };
|
||||
|
||||
private void visitComments(ASTCompilationUnit node) {
|
||||
if (imports.isEmpty()) {
|
||||
|
||||
+2
@@ -225,11 +225,13 @@ import edu.umd.cs.findbugs.annotations.NonNull;
|
||||
<code><![CDATA[
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class Test {
|
||||
/**
|
||||
* {@link ArrayList#add(Object)}
|
||||
* @see Collections
|
||||
* @throws NoSuchElementException no such element
|
||||
*/
|
||||
String[] getList() { }
|
||||
}
|
||||
|
||||
+4
-1
@@ -156,7 +156,7 @@ public class Foo {
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
imports used in javadoc comment
|
||||
imports used in javadoc comment, see also bug #254
|
||||
]]></description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
@@ -164,12 +164,15 @@ import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.File;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class Foo {
|
||||
/**
|
||||
* {@linkplain List list}
|
||||
* {@link ArrayList arraylist}
|
||||
* {@value Calendar#DATE}
|
||||
* @see File
|
||||
* @throws NoSuchElementException no such element
|
||||
*/
|
||||
public void test() {}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user