Merge pull request #150 from asger-semmle/ts-asi-bug

Approved by xiemaisi
This commit is contained in:
semmle-qlci
2018-09-05 21:22:29 +01:00
committed by GitHub
5 changed files with 20 additions and 2 deletions

View File

@@ -45,4 +45,5 @@ class OmittedArrayElement extends ArrayExpr {
}
from OmittedArrayElement ae
where not ae.getFile().getFileType().isTypeScript() // ignore quirks in TypeScript tokenizer
select ae, "Avoid omitted array elements."

View File

@@ -36,7 +36,8 @@ where s.hasSemicolonInserted() and
asi = strictcount(Stmt ss | asi(sc, ss, true)) and
nstmt = strictcount(Stmt ss | asi(sc, ss, _)) and
perc = ((1-asi/nstmt)*100).floor() and
perc >= 90
perc >= 90 and
not s.getFile().getFileType().isTypeScript() // ignore some quirks in the TypeScript tokenizer
select (LastLineOf)s, "Avoid automated semicolon insertion " +
"(" + perc + "% of all statements in $@ have an explicit semicolon).",
sc, "the enclosing " + sctype

View File

@@ -39,6 +39,7 @@ where misleadingIndentationCandidate(ctrl, s1, s2) and
f.hasIndentation(ctrlStartLine, indent, _) and
f.hasIndentation(startLine1, indent, _) and
f.hasIndentation(startLine2, indent, _) and
not s2 instanceof EmptyStmt
not s2 instanceof EmptyStmt and
not f.getFileType().isTypeScript() // ignore quirks in TypeScript tokenizer
select (FirstLineOf)s2, "The indentation of this statement suggests that it is controlled by $@, while in fact it is not.",
(FirstLineOf)ctrl, "this statement"

View File

@@ -0,0 +1,12 @@
function foo(arg) {
console.log(arg);
console.log(arg);
console.log(arg);
console.log(arg);
console.log(arg);
console.log(arg);
console.log(arg);
console.log(arg);
console.log(arg);
console.log(`Unknown option '${arg}'.`);
}