Skip to content

Commit 8ea7a28

Browse files
committed
Python: Unexpose fields as suggested.
1 parent 758b6bd commit 8ea7a28

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

python/ql/src/semmle/python/functions/ModificationOfParameterWithDefaultCustomizations.qll

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,23 +144,20 @@ module ModificationOfParameterWithDefault {
144144
* A data-flow node that is known to be either truthy or falsey.
145145
*
146146
* It handles the cases `if x` and `if not x`.
147-
*
147+
*
148148
* For example, in the following code, `this` will be the `x` that is printed,
149149
* which we will know is truthy:
150-
*
150+
*
151151
* ```py
152152
* if x:
153153
* print(x)
154154
* ```
155155
*/
156156
private class MustBe extends DataFlow::Node {
157-
DataFlow::GuardNode guard;
158-
NameNode guarded;
159-
boolean branch;
160157
boolean truthy;
161158

162159
MustBe() {
163-
(
160+
exists(DataFlow::GuardNode guard, NameNode guarded, boolean branch |
164161
// case: if x
165162
guard = guarded and
166163
branch = truthy
@@ -169,13 +166,14 @@ module ModificationOfParameterWithDefault {
169166
guard.(UnaryExprNode).getNode().getOp() instanceof Not and
170167
guarded = guard.(UnaryExprNode).getOperand() and
171168
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+
)
179177
)
180178
}
181179
}

0 commit comments

Comments
 (0)