Skip to content

the --stats flag should note that it is unconditionally enabled when --json is used #2337

@cstyles

Description

@cstyles

What version of ripgrep are you using?

ripgrep 13.0.0
-SIMD -AVX (compiled)

How did you install ripgrep?

Homebrew

What operating system are you using ripgrep on?

macOS 12.6

Describe your bug.

When ripgrep is invoked with --json, the final line is always a stats summary. It seems like this is included implicitly whenever --json is used. However, I would expect that explicitly including --no-stats would disable the summary.

What are the steps to reproduce the behavior?

Invoke ripgrep with both the --json and --no-stats flags.

What is the actual behavior?

$ rg --debug --json --no-stats pattern file.txt
DEBUG|rg::config|crates/core/config.rs:40: /Users/cstyles/.ripgreprc: arguments loaded from config file: ["--smart-case", "--max-columns=300", "--max-columns-preview"]
DEBUG|rg::args|crates/core/args.rs:543: final argv: ["rg", "--smart-case", "--max-columns=300", "--max-columns-preview", "--debug", "--json", "--no-stats", "pattern", "file.txt"]
DEBUG|grep_regex::literal|crates/regex/src/literal.rs:109: required literals found: [Cut(PATTE), Cut(pATTE), Cut(PaTTE), Cut(paTTE), Cut(PAtTE), Cut(pAtTE), Cut(PatTE), Cut(patTE), Cut(PATtE), Cut(pATtE), Cut(PaTtE), Cut(paTtE), Cut(PAttE), Cut(pAttE), Cut(PattE), Cut(pattE), Cut(PATTe), Cut(pATTe), Cut(PaTTe), Cut(paTTe), Cut(PAtTe), Cut(pAtTe), Cut(PatTe), Cut(patTe), Cut(PATte), Cut(pATte), Cut(PaTte), Cut(paTte), Cut(PAtte), Cut(pAtte), Cut(Patte), Cut(patte)]
DEBUG|grep_regex::matcher|crates/regex/src/matcher.rs:50: extracted fast line regex: (?-u:PATTE|pATTE|PaTTE|paTTE|PAtTE|pAtTE|PatTE|patTE|PATtE|pATtE|PaTtE|paTtE|PAttE|pAttE|PattE|pattE|PATTe|pATTe|PaTTe|paTTe|PAtTe|pAtTe|PatTe|patTe|PATte|pATte|PaTte|paTte|PAtte|pAtte|Patte|patte)
DEBUG|globset|crates/globset/src/lib.rs:421: built glob set; 0 literals, 0 basenames, 12 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG|globset|crates/globset/src/lib.rs:421: built glob set; 0 literals, 4 basenames, 2 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
{"type":"begin","data":{"path":{"text":"file.txt"}}}
{"type":"match","data":{"path":{"text":"file.txt"},"lines":{"text":"pattern\n"},"line_number":2,"absolute_offset":7,"submatches":[{"match":{"text":"pattern"},"start":0,"end":7}]}}
{"type":"end","data":{"path":{"text":"file.txt"},"binary_offset":null,"stats":{"elapsed":{"secs":0,"nanos":42958,"human":"0.000043s"},"searches":1,"searches_with_match":1,"bytes_searched":21,"bytes_printed":233,"matched_lines":1,"matches":1}}}
{"data":{"elapsed_total":{"human":"0.001521s","nanos":1521416,"secs":0},"stats":{"bytes_printed":233,"bytes_searched":21,"elapsed":{"human":"0.000043s","nanos":42958,"secs":0},"matched_lines":1,"matches":1,"searches":1,"searches_with_match":1}},"type":"summary"}

What is the expected behavior?

Including the --no-stats flag should disable the stats summary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docAn issue with or an improvement to documentation.rollupA PR that has been merged with many others in a rollup.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions