Python: `--threshold` is ignored with `--no-coverage`

Open Beginner friendly
#10 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
cli

Research direction

The bug is in _threshold_status in src/crapper/cli.py around line 294, which finds no scores when --no-coverage is set and so exits 0. Reproduce with crapper --no-coverage --threshold 1 src/demo/cc.py and check the exit code. Done means either comparing the threshold against CC when coverage is off, or rejecting --threshold combined with --no-coverage, and the chosen behaviour is covered by a test.

Written by the indexing model from the issue text.

Description

With --no-coverage every CRAP is nil, _threshold_status (src/crapper/cli.py:294) finds no scores, and the run exits 0 whatever the complexity.

crapper --no-coverage --threshold 1 src/demo/cc.py; echo $?        # 0, functions have CC 2-3
crapper --use-existing-coverage --threshold 1 src/demo/cov.py; echo $?   # 2, as expected

cc.py and cov.py are the files from #9 and #8.

Expected: either compare the threshold with CC when coverage is off (CRAP = CC at 100% coverage is the lower bound), or reject --threshold together with --no-coverage. A silent 0 lets a gate pass that never ran.

Environment: Linux x86_64, Python 3.11.13, tree-sitter 0.26.0, tree-sitter-language-pack 1.22.1, crapper 6fd92c4.

Dominant language
Python
Stars
255
Forks
101
Avg merge
7m
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from unclebob/crapper

All issues in unclebob/crapper

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.