mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
Merge branch 'master' into pseudo-random-bytes
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
import javascript
|
||||
import semmle.javascript.RestrictedLocations
|
||||
|
||||
predicate isRepeatedDependency(AngularJS::InjectableFunction f, string name, ASTNode location) {
|
||||
exists(int i, int j | i < j and
|
||||
@@ -20,4 +21,4 @@ predicate isRepeatedDependency(AngularJS::InjectableFunction f, string name, AST
|
||||
from AngularJS::InjectableFunction f, ASTNode node, string name
|
||||
where isRepeatedDependency(f, name, node) and
|
||||
not count(f.asFunction().getParameterByName(name)) > 1 // avoid duplicating reports from js/duplicate-parameter-name
|
||||
select f, "This function has a duplicate dependency '$@'.", node, name
|
||||
select (FirstLineOf)f.asFunction(), "This function has a duplicate dependency '$@'.", node, name
|
||||
|
||||
@@ -10,8 +10,9 @@
|
||||
*/
|
||||
|
||||
import javascript
|
||||
import semmle.javascript.RestrictedLocations
|
||||
|
||||
from AngularJS::InjectableFunction f, ASTNode explicitInjection
|
||||
where count(f.getAnExplicitDependencyInjection()) > 1 and
|
||||
explicitInjection = f.getAnExplicitDependencyInjection()
|
||||
select f.asFunction(), "This function has $@ defined in multiple places.", explicitInjection, "dependency injections"
|
||||
select (FirstLineOf)f.asFunction(), "This function has $@ defined in multiple places.", explicitInjection, "dependency injections"
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
import javascript
|
||||
import Declarations.UnusedParameter
|
||||
import semmle.javascript.RestrictedLocations
|
||||
|
||||
predicate isUnusedParameter(Function f, string msg, Parameter parameter) {
|
||||
exists(Variable pv |
|
||||
@@ -36,4 +37,4 @@ predicate isMissingParameter(AngularJS::InjectableFunction f, string msg, ASTNod
|
||||
|
||||
from AngularJS::InjectableFunction f, string message, ASTNode location
|
||||
where isUnusedParameter(f.asFunction(), message, location) or isMissingParameter(f, message, location)
|
||||
select location, message
|
||||
select (FirstLineOf)location, message
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
import javascript
|
||||
import UnusedParameter // local library
|
||||
import UnusedParameter
|
||||
|
||||
from Parameter p
|
||||
where isAnAccidentallyUnusedParameter(p)
|
||||
|
||||
@@ -46,7 +46,9 @@ predicate isUnused(Function f, Parameter p, Variable pv, int i) {
|
||||
// functions without a body cannot use their parameters
|
||||
f.hasBody() and
|
||||
// field parameters are used to initialize a field
|
||||
not p instanceof FieldParameter
|
||||
not p instanceof FieldParameter and
|
||||
// common convention: parameters with leading underscore are intentionally unused
|
||||
pv.getName().charAt(0) != "_"
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,9 @@ class UnusedLocal extends LocalVariable {
|
||||
not exists(FunctionExpr fe | this = fe.getVariable()) and
|
||||
not exists(ClassExpr ce | this = ce.getVariable()) and
|
||||
not exists(ExportDeclaration ed | ed.exportsAs(this, _)) and
|
||||
not exists(LocalVarTypeAccess type | type.getVariable() = this)
|
||||
not exists(LocalVarTypeAccess type | type.getVariable() = this) and
|
||||
// common convention: variables with leading underscore are intentionally unused
|
||||
getName().charAt(0) != "_"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user