Apply suggestions from code review

Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
This commit is contained in:
yoff
2021-09-03 14:23:57 +02:00
committed by GitHub
parent a855074588
commit c6eb795e76
2 changed files with 9 additions and 3 deletions

View File

@@ -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 }
}

View File

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