JavaScript: Autoformat all QL files.

This commit is contained in:
Max Schaefer
2019-01-07 10:15:45 +00:00
parent aa6b89dc34
commit 31bb39a810
380 changed files with 9957 additions and 13923 deletions

View File

@@ -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 + "."

View File

@@ -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 + "."

View File

@@ -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."

View File

@@ -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() + "'."