diff --git a/docs/codeql/codeql-language-guides/javadoc.rst b/docs/codeql/codeql-language-guides/javadoc.rst index 7e16cc6ce36c..0e456bb35beb 100644 --- a/docs/codeql/codeql-language-guides/javadoc.rst +++ b/docs/codeql/codeql-language-guides/javadoc.rst @@ -88,7 +88,7 @@ It's now easy to add another conjunct to the ``where`` clause, restricting the q from Callable c, ParamTag pt where c.getDoc().getJavadoc() = pt.getParent() and - not c.getAParameter().hasName(pt.getParamName()) + not c.getAParameter().hasName(pt.getParamName().regexpReplaceAll(",|:|\\.","")) select pt, "Spurious @param tag." Example: Finding spurious @throws tags diff --git a/java/ql/src/Advisory/Documentation/SpuriousJavadocParam.ql b/java/ql/src/Advisory/Documentation/SpuriousJavadocParam.ql index 88c100b86931..8e876c2a144b 100644 --- a/java/ql/src/Advisory/Documentation/SpuriousJavadocParam.ql +++ b/java/ql/src/Advisory/Documentation/SpuriousJavadocParam.ql @@ -10,22 +10,24 @@ import java -from Callable callable, ParamTag paramTag, string what, string msg +from Callable callable, ParamTag paramTag, string what, string msg, string paramTagName where callable.(Documentable).getJavadoc().getAChild() = paramTag and (if callable instanceof Constructor then what = "constructor" else what = "method") and - if exists(paramTag.getParamName()) + paramTagName = paramTag.getParamName().regexpReplaceAll(",|:|\\.","") and + if exists(paramTagName) then // The tag's value is neither matched by a callable parameter name ... - not callable.getAParameter().getName() = paramTag.getParamName() and + not callable.getAParameter().getName() = paramTagName and // ... nor by a type parameter name. not exists(TypeVariable tv | tv.getGenericCallable() = callable | - "<" + tv.getName() + ">" = paramTag.getParamName() + "<" + tv.getName() + ">" = paramTagName ) and msg = - "@param tag \"" + paramTag.getParamName() + "\" does not match any actual parameter of " + + "@param tag \"" + paramTagName + "\" does not match any actual parameter of " + what + " \"" + callable.getName() + "()\"." else // The tag has no value at all. msg = "This @param tag does not have a value." select paramTag, msg +