reference Flags

--emacs

Accepted by
opengrep scan, opengrep ci
See also
--vim, --json, --output, --files-with-matches, --emacs-output

Prints one line per finding:

PATH:LINE:COL:SEVERITY(RULE_ID):MATCHED_LINES:MESSAGE

The severity is that of the rule, in lower case. This is the format that Emacs compilation-mode and similar tools parse, so that each finding links to its location.

--emacs-output writes the same lines to a file, in addition to the output on standard output. Only one format can be printed to standard output, so --emacs cannot be combined with --json, --vim, --sarif and the other formats.

Examples

One line per finding

rule.yaml
rules:  - id: find-eval    pattern: eval(...)    message: found eval    languages: [python]    severity: WARNING
app.py
eval(1)
Command and result
$ opengrep scan -q --config rule.yaml --emacs app.py
app.py:1:1:warning(find-eval):eval(1):found eval
$ opengrep scan --config rule.yaml --emacs-output findings.txt app.py > /dev/null 2>&1
$ cat findings.txt
app.py:1:1:warning(find-eval):eval(1):found eval