implicit_deep_exprstmt
- Value
trueorfalse- Default
true- See also
go_deeper_expr
In a statement pattern, an expression statement such as finish() also matches a statement that contains the expression: result = finish() or log(finish()). It depends on go_deeper_expr, and has no effect when that option is false.
With implicit_deep_exprstmt: false, it matches the statement finish() only.
A pattern made of a single expression is not a statement pattern: it matches the expression wherever it occurs, regardless of this option.
Examples
A call whose result is used
The rule start-then-finish turns the option off.
steps.yaml
rules: - id: start-then-finish-default pattern: | start() ... finish() message: finish() follows start() languages: [python] severity: WARNING - id: start-then-finish pattern: | start() ... finish() message: finish() follows start() languages: [python] severity: WARNING options: implicit_deep_exprstmt: falsesteps.py
def assigned(): # ruleid: start-then-finish-default start() result = finish()def passed_on(): # ruleid: start-then-finish-default start() log(finish())def plain(): # ruleid: start-then-finish-default, start-then-finish start() finish()Command and result
$ opengrep test .
2/2: ✓ All tests passed
No tests for fixes found.