Menu

#225 cli: scan --json silently ignores --quiet; pin the precedence with a test and a docs line

closed
nobody
2026-08-03
2026-08-02
Anonymous
No

Originally created by: fu351
Originally owned by: AshSgDe29071999

Behaviour

doberman scan --json --quiet prints the full JSON document — --quiet has no effect.

That's because the JSON branch returns before the quiet check ever runs (src/doberman/cli/main.py:226-245):

if as_json:
    ...
    return          # <- returns here
if not quiet:
    ...             # <- never reached when --json is passed

Is this a bug?

Probably not — JSON-wins is the sensible precedence. If you asked for machine-readable output, suppressing it would leave you with nothing, and --quiet exists to suppress the human risk map.

The problem is that nothing records that decision:

  • no test exercises the two flags together (tests/unit/test_cli_scan_json.py, tests/unit/test_cli_scan_quiet.py)
  • docs/CLI.md says nothing about it

So today the behaviour is an accident of statement order. A future refactor could reverse it and every test would stay green.

What to do

  1. Add a test invoking ["scan", "--json", "--quiet"] that asserts valid JSON is still printed and the exit code is unchanged. Put it in whichever of the two existing test files fits better.
  2. Add one line to docs/CLI.md stating the precedence: --json wins over --quiet.

Done when

A test fails if someone reorders those branches so --quiet suppresses JSON, and docs/CLI.md states the precedence.

The bar

Make sure the test can actually fail. Before opening the PR, temporarily move the if not quiet: check above the if as_json: branch and confirm your test goes red — then revert. A test that passes under both orderings isn't pinning anything.

That check matters here: two tests merged into this repo last week passed while asserting nothing at all, so "CI is green" isn't evidence on its own.

Comment here to claim it.

🤖 Generated with Claude Code

Related

Tickets: #229
Tickets: #230

Discussion

  • Anonymous

    Anonymous - 2026-08-02

    Originally posted by: AshSgDe29071999

    I'd like to pin scan --json vs --quiet precedence with a test and docs line.

     
  • Anonymous

    Anonymous - 2026-08-03
     
  • Anonymous

    Anonymous - 2026-08-03

    Ticket changed by: fu351

    • status: open --> closed
     

Log in to post a comment.