@@ -144,23 +144,20 @@ module ModificationOfParameterWithDefault {
144
144
* A data-flow node that is known to be either truthy or falsey.
145
145
*
146
146
* It handles the cases `if x` and `if not x`.
147
- *
147
+ *
148
148
* For example, in the following code, `this` will be the `x` that is printed,
149
149
* which we will know is truthy:
150
- *
150
+ *
151
151
* ```py
152
152
* if x:
153
153
* print(x)
154
154
* ```
155
155
*/
156
156
private class MustBe extends DataFlow:: Node {
157
- DataFlow:: GuardNode guard ;
158
- NameNode guarded ;
159
- boolean branch ;
160
157
boolean truthy ;
161
158
162
159
MustBe ( ) {
163
- (
160
+ exists ( DataFlow :: GuardNode guard , NameNode guarded , boolean branch |
164
161
// case: if x
165
162
guard = guarded and
166
163
branch = truthy
@@ -169,13 +166,14 @@ module ModificationOfParameterWithDefault {
169
166
guard .( UnaryExprNode ) .getNode ( ) .getOp ( ) instanceof Not and
170
167
guarded = guard .( UnaryExprNode ) .getOperand ( ) and
171
168
branch = truthy .booleanNot ( )
172
- ) and
173
- // guard controls this
174
- guard .controlsBlock ( this .asCfgNode ( ) .getBasicBlock ( ) , branch ) and
175
- // there is a definition tying the guarded value to this
176
- exists ( EssaDefinition def |
177
- AdjacentUses:: useOfDef ( def , this .asCfgNode ( ) ) and
178
- AdjacentUses:: useOfDef ( def , guarded )
169
+ |
170
+ // guard controls this
171
+ guard .controlsBlock ( this .asCfgNode ( ) .getBasicBlock ( ) , branch ) and
172
+ // there is a definition tying the guarded value to this
173
+ exists ( EssaDefinition def |
174
+ AdjacentUses:: useOfDef ( def , this .asCfgNode ( ) ) and
175
+ AdjacentUses:: useOfDef ( def , guarded )
176
+ )
179
177
)
180
178
}
181
179
}
0 commit comments