mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Apply suggestions from code review
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
This commit is contained in:
@@ -53,7 +53,7 @@ module ModificationOfParameterWithDefault {
|
||||
}
|
||||
|
||||
/**
|
||||
* A source of remote user input, considered as a flow source.
|
||||
* A mutable default value for a parameter, considered as a flow source.
|
||||
*/
|
||||
class MutableDefaultValue extends Source {
|
||||
boolean nonEmpty;
|
||||
@@ -120,6 +120,9 @@ module ModificationOfParameterWithDefault {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An expression that is checked directly in an `if`, possibly with `not`, such as `if x:` or `if not x:`.
|
||||
*/
|
||||
private class IdentityGuarded extends Expr {
|
||||
boolean inverted;
|
||||
|
||||
@@ -136,6 +139,9 @@ module ModificationOfParameterWithDefault {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this guard has been inverted. For `if x:` the result is `false`, and for `if not x:` the result is `true`.
|
||||
*/
|
||||
boolean isInverted() { result = inverted }
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ def list_del(l = [0]):
|
||||
|
||||
# Not OK
|
||||
def append_op(l = []):
|
||||
l += 1 #$ modification=l
|
||||
l += [1, 2, 3] #$ modification=l
|
||||
return l
|
||||
|
||||
# Not OK
|
||||
@@ -123,6 +123,6 @@ def dict_update_op_nochange(d = {}):
|
||||
|
||||
# OK
|
||||
def sanitizer(l = []):
|
||||
if not l == []:
|
||||
if l:
|
||||
l.append(1) #$ SPURIOUS: modification=l
|
||||
return l
|
||||
|
||||
Reference in New Issue
Block a user