diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/imports/UnusedImportsRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/imports/UnusedImportsRule.java index 295ae9f364..ae567c41db 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/imports/UnusedImportsRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/imports/UnusedImportsRule.java @@ -49,14 +49,15 @@ public class UnusedImportsRule extends AbstractJavaRule { * @see package.class#member(param, param) label * {@linkplain package.class#member(param, param) label} * {@link package.class#member(param, param) label} + * {@link package.class#field} * {@value package.class#field} * @throws package.class label */ private static final Pattern SEE_PATTERN = Pattern.compile( - "@see\\s+(\\p{Alpha}\\p{Alnum}*)(?:#\\p{Alnum}*\\(([\\w\\s,]*)\\))?"); + "@see\\s+(\\p{Alpha}\\p{Alnum}*)(?:#\\p{Alnum}*(?:\\(([\\w\\s,]*)\\))?)?"); private static final Pattern LINK_PATTERNS = Pattern.compile( - "\\{@link(?:plain)?\\s+(\\p{Alpha}\\p{Alnum}*)(?:#\\p{Alnum}*\\(([.\\w\\s,]*)\\))?[\\s\\}]"); + "\\{@link(?:plain)?\\s+(\\p{Alpha}\\p{Alnum}*)(?:#\\p{Alnum}*(?:\\(([.\\w\\s,]*)\\))?)?[\\s\\}]"); private static final Pattern VALUE_PATTERN = Pattern.compile( "\\{@value\\s+(\\p{Alpha}\\p{Alnum}*)[\\s#\\}]"); diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/imports/xml/UnusedImports.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/imports/xml/UnusedImports.xml index d2a38009f3..fef595762a 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/imports/xml/UnusedImports.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/imports/xml/UnusedImports.xml @@ -290,6 +290,27 @@ public class FooTest { public static void main(String[] args) { System.out.println(PI); } +} + ]]> + + + + #1465 False Positve UnusedImports with javadoc @link + 0 + + * An agent is active if it has not posted a {@link AgentStateChangeEvent} containing {@link AgentState#TERMINATED}. + * + * @return agent handles. + * @see OtherState#TERMINATED + */ + Iterable getAgentHandles(); } ]]> diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/typeresolution/xml/UnusedImports.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/typeresolution/xml/UnusedImports.xml index b456944e64..bbd2fbadc0 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/typeresolution/xml/UnusedImports.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/typeresolution/xml/UnusedImports.xml @@ -212,6 +212,27 @@ public class FooTest { public static void main(String[] args) { System.out.println(PI); } +} + ]]> + + + + #1465 False Positve UnusedImports with javadoc @link + 0 + + * An agent is active if it has not posted a {@link AgentStateChangeEvent} containing {@link AgentState#TERMINATED}. + * + * @return agent handles. + * @see OtherState#TERMINATED + */ + Iterable getAgentHandles(); } ]]> diff --git a/src/site/markdown/overview/changelog.md b/src/site/markdown/overview/changelog.md index 1789a772a6..118d4ae442 100644 --- a/src/site/markdown/overview/changelog.md +++ b/src/site/markdown/overview/changelog.md @@ -32,6 +32,8 @@ * [#1449](https://sourceforge.net/p/pmd/bugs/1449/): false positive when casting a variable to short * java-design/AccessorClassGeneration: * [#1452](https://sourceforge.net/p/pmd/bugs/1452/): ArrayIndexOutOfBoundsException with Annotations for AccessorClassGenerationRule +* java-imports/UnusedImports: + * [#1465](https://sourceforge.net/p/pmd/bugs/1465/): False Positve UnusedImports with javadoc @link * java-junit/TestClassWithoutTestCases: * [#1453](https://sourceforge.net/p/pmd/bugs/1453/): Test Class Without Test Cases gives false positive * java-unusedcode/UnusedFormalParameter: