--dryrun
- Accepted by
opengrep scan- Also spelled
--no-dryrun- Default
false- See also
--autofix,--replacement,fix
Prevents --autofix from writing to the files. The text output shows each fix on a fix: line, and the files are not changed. Without --autofix, the flag has no effect. --no-dryrun turns it off.
Examples
Seeing a fix without applying it
fix.yaml
rules: - id: use-is-none pattern: $X == None fix: $X is None message: use "is None" languages: [python] severity: WARNINGapp.py
if x == None: passCommand and result
$ opengrep scan -q --config fix.yaml --autofix --dryrun app.py
app.py
warn use-is-none
use "is None"
1: if (x is None):
fix: (x is None)
$ cat app.py
if x == None:
pass
$ opengrep scan --config fix.yaml --autofix app.py > /dev/null 2>&1
$ cat app.py
if (x is None):
passThe output shows the line as it would be after the fix. The file changes only when --autofix runs without --dryrun.