pmd: fix #254 False+ : UnusedImport with Javadoc @throws
This commit is contained in:
parent
3901ad7ddb
commit
7494011999
@ -1,5 +1,6 @@
|
||||
????? ??, 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()) {
|
||||
|
@ -218,4 +218,23 @@ import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
|
||||
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>bug #254 False+ : UnusedImport with Javadoc @link</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<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() { }
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
@ -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() {}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user