mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
JavaScript: Autoformat all QL files.
This commit is contained in:
@@ -15,8 +15,13 @@
|
||||
import javascript
|
||||
|
||||
from JSDocParamTag parm, string missing
|
||||
where // JSDoc comments in externs files are not necessarily meant for human readers, so don't complain
|
||||
not parm.getFile().getATopLevel().isExterns() and
|
||||
(not exists(parm.getName()) and missing = "name" or
|
||||
(not exists(parm.getDescription()) or parm.getDescription().regexpMatch("\\s*")) and missing = "description")
|
||||
select parm, "@param tag is missing " + missing + "."
|
||||
where
|
||||
// JSDoc comments in externs files are not necessarily meant for human readers, so don't complain
|
||||
not parm.getFile().getATopLevel().isExterns() and
|
||||
(
|
||||
not exists(parm.getName()) and missing = "name"
|
||||
or
|
||||
(not exists(parm.getDescription()) or parm.getDescription().regexpMatch("\\s*")) and
|
||||
missing = "description"
|
||||
)
|
||||
select parm, "@param tag is missing " + missing + "."
|
||||
|
||||
@@ -14,13 +14,14 @@
|
||||
import javascript
|
||||
|
||||
from Function f, JSDoc doc, JSDocParamTag tag, string parmName
|
||||
where doc = f.getDocumentation() and
|
||||
tag = doc.getATag() and
|
||||
parmName = tag.getName() and
|
||||
tag.documentsSimpleName() and
|
||||
not exists (f.getParameterByName(parmName)) and
|
||||
// don't report functions without declared parameters that use `arguments`
|
||||
not (f.getNumParameter() = 0 and f.usesArgumentsObject()) and
|
||||
// don't report a violation in ambiguous cases
|
||||
strictcount(JSDoc d | d = f.getDocumentation() and d.getATag() instanceof JSDocParamTag) = 1
|
||||
select tag, "@param tag refers to non-existent parameter " + parmName + "."
|
||||
where
|
||||
doc = f.getDocumentation() and
|
||||
tag = doc.getATag() and
|
||||
parmName = tag.getName() and
|
||||
tag.documentsSimpleName() and
|
||||
not exists(f.getParameterByName(parmName)) and
|
||||
// don't report functions without declared parameters that use `arguments`
|
||||
not (f.getNumParameter() = 0 and f.usesArgumentsObject()) and
|
||||
// don't report a violation in ambiguous cases
|
||||
strictcount(JSDoc d | d = f.getDocumentation() and d.getATag() instanceof JSDocParamTag) = 1
|
||||
select tag, "@param tag refers to non-existent parameter " + parmName + "."
|
||||
|
||||
@@ -14,13 +14,14 @@
|
||||
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 a violation in ambiguous cases
|
||||
strictcount(JSDoc d | d = f.getDocumentation() and d.getATag() instanceof JSDocParamTag) = 1
|
||||
select parm, "Parameter " + v.getName() + " is not documented."
|
||||
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 a violation in ambiguous cases
|
||||
strictcount(JSDoc d | d = f.getDocumentation() and d.getATag() instanceof JSDocParamTag) = 1
|
||||
select parm, "Parameter " + v.getName() + " is not documented."
|
||||
|
||||
@@ -136,4 +136,4 @@ predicate knownTagType(string tp) {
|
||||
|
||||
from JSDocTag tag
|
||||
where not knownTagType(tag.getTitle())
|
||||
select tag, "Unknown tag type '" + tag.getTitle() + "'."
|
||||
select tag, "Unknown tag type '" + tag.getTitle() + "'."
|
||||
|
||||
Reference in New Issue
Block a user