reference Rule options

go_deeper_expr

Value
true or false
Default
true
See also
implicit_deep_exprstmt, go_deeper_stmt

This option lets matching look inside expressions in two places:

With go_deeper_expr: false, both match only at the top level: <... e ...> matches e itself, and finish() matches the statement finish().

Examples

A condition that contains the check

The rule admin-branch turns the option off.

branch.yaml
rules:  - id: admin-branch-default    pattern: |      if <... user.is_admin ...>:          ...    message: branch on admin rights    languages: [python]    severity: WARNING  - id: admin-branch    pattern: |      if <... user.is_admin ...>:          ...    message: branch on admin rights    languages: [python]    severity: WARNING    options:      go_deeper_expr: false
branch.py
def view(user, ok):    # ruleid: admin-branch-default, admin-branch    if user.is_admin:        pass    # ruleid: admin-branch-default    if ok and user.is_admin:        pass
Command and result
$ opengrep test .
2/2: ✓ All tests passed
No tests for fixes found.