Files
codeql/javascript/ql/src/JSDoc/UndocumentedParameter.ql
Max Schaefer d105de81a3 JavaScript: Raise precision of UndocumentedParameter to high.
This is more consistent with the other JSDoc queries. Results are still not shown on LGTM by default, but the query can now be enabled selectively for projects that care about JSDoc.
2019-08-20 09:32:00 +01:00

28 lines
958 B
Plaintext

/**
* @name Undocumented parameter
* @description If some parameters of a function are documented by JSDoc 'param' tags while others
* are not, this may indicate badly maintained code.
* @kind problem
* @problem.severity recommendation
* @id js/jsdoc/missing-parameter
* @tags maintainability
* readability
* documentation
* @precision high
*/
import javascript
from Function f, Parameter parm, Variable v, JSDoc doc
where
parm = f.getAParameter() and
doc = f.getDocumentation() and
v = parm.getAVariable() and
// at least one parameter is documented
exists(doc.getATag().(JSDocParamTag).getDocumentedParameter()) and
// but v is not
not doc.getATag().(JSDocParamTag).getDocumentedParameter() = v and
// don't report an alert in ambiguous cases
strictcount(JSDoc d | d = f.getDocumentation() and d.getATag() instanceof JSDocParamTag) = 1
select parm, "Parameter " + v.getName() + " is not documented."