{"id":43002672,"url":"https://github.com/mcp-tool-shop-org/code-covered","last_synced_at":"2026-02-27T01:00:58.180Z","repository":{"id":335118538,"uuid":"1144241371","full_name":"mcp-tool-shop-org/code-covered","owner":"mcp-tool-shop-org","description":"Find coverage gaps and generate the tests you're missing","archived":false,"fork":false,"pushed_at":"2026-02-23T13:26:18.000Z","size":191,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-23T20:56:29.212Z","etag":null,"topics":["code-coverage","coverage-gaps","developer-tools","pytest","python","test-generation","testing"],"latest_commit_sha":null,"homepage":"https://mcp-tool-shop-org.github.io/code-covered/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcp-tool-shop-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["mcp-tool-shop"]}},"created_at":"2026-01-28T13:17:28.000Z","updated_at":"2026-02-23T13:27:31.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mcp-tool-shop-org/code-covered","commit_stats":null,"previous_names":["mcp-tool-shop/code-covered"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mcp-tool-shop-org/code-covered","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcp-tool-shop-org%2Fcode-covered","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcp-tool-shop-org%2Fcode-covered/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcp-tool-shop-org%2Fcode-covered/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcp-tool-shop-org%2Fcode-covered/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcp-tool-shop-org","download_url":"https://codeload.github.com/mcp-tool-shop-org/code-covered/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcp-tool-shop-org%2Fcode-covered/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29879896,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T23:51:21.483Z","status":"ssl_error","status_checked_at":"2026-02-26T23:50:46.793Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-coverage","coverage-gaps","developer-tools","pytest","python","test-generation","testing"],"created_at":"2026-01-31T04:10:08.592Z","updated_at":"2026-02-27T01:00:58.169Z","avatar_url":"https://github.com/mcp-tool-shop-org.png","language":"Python","funding_links":["https://github.com/sponsors/mcp-tool-shop"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"README.ja.md\"\u003e日本語\u003c/a\u003e | \u003ca href=\"README.zh.md\"\u003e中文\u003c/a\u003e | \u003ca href=\"README.es.md\"\u003eEspañol\u003c/a\u003e | \u003ca href=\"README.fr.md\"\u003eFrançais\u003c/a\u003e | \u003ca href=\"README.hi.md\"\u003eहिन्दी\u003c/a\u003e | \u003ca href=\"README.it.md\"\u003eItaliano\u003c/a\u003e | \u003ca href=\"README.pt-BR.md\"\u003ePortuguês (BR)\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/code-covered/readme.png\" alt=\"code-covered\" width=\"400\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/mcp-tool-shop-org/code-covered/actions/workflows/ci.yml\"\u003e\u003cimg src=\"https://github.com/mcp-tool-shop-org/code-covered/actions/workflows/ci.yml/badge.svg\" alt=\"CI\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://pypi.org/project/code-covered/\"\u003e\u003cimg src=\"https://img.shields.io/pypi/v/code-covered\" alt=\"PyPI\"\u003e\u003c/a\u003e\n  \u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-blue\" alt=\"MIT License\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://mcp-tool-shop-org.github.io/code-covered/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Landing_Page-live-blue\" alt=\"Landing Page\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n**Find coverage gaps and suggest what tests to write.**\n\nPart of [MCP Tool Shop](https://mcp-tool-shop.github.io/) -- practical developer tools that stay out of your way.\n\n## Why code-covered?\n\nCoverage tools tell you *what* lines aren't tested. `code-covered` tells you *what tests to write*. It reads your `coverage.json`, walks the AST to understand context (exception handlers, branches, loops), and generates prioritized test stubs you can drop straight into your test suite. Zero runtime dependencies -- just stdlib.\n\n## The Problem\n\n```\n$ pytest --cov=myapp\nName                 Stmts   Miss  Cover\n----------------------------------------\nmyapp/validator.py      47     12    74%\n```\n\n74% coverage. 12 lines missing. But *which* 12 lines? And what tests would cover them?\n\n## The Solution\n\n```\n$ code-covered coverage.json\n\n============================================================\ncode-covered\n============================================================\nCoverage: 74.5% (35/47 lines)\nFiles analyzed: 1 (1 with gaps)\n\nMissing tests: 4\n  [!!] CRITICAL: 2\n  [!]  HIGH: 2\n\nTop suggestions:\n  1. [!!] test_validator_validate_input_handles_exception\n       In validate_input() lines 23-27 - when ValueError is raised\n\n  2. [!!] test_validator_parse_data_raises_error\n       In parse_data() lines 45-45 - raise ParseError\n\n  3. [! ] test_validator_validate_input_when_condition_false\n       In validate_input() lines 31-33 - when len(data) == 0 is False\n\n  4. [! ] test_validator_process_when_condition_true\n       In process() lines 52-55 - when config.strict is True\n```\n\n## Installation\n\n```bash\npip install code-covered\n```\n\n## Quick Start\n\n### For Users\n\n```bash\n# 1. Run your tests with coverage JSON output\npytest --cov=myapp --cov-report=json\n\n# 2. Find what tests you're missing\ncode-covered coverage.json\n\n# 3. Generate test stubs\ncode-covered coverage.json -o tests/test_gaps.py\n```\n\n### For Developers\n\n```bash\n# Clone the repository\ngit clone https://github.com/mcp-tool-shop-org/code-covered.git\ncd code-covered\n\n# Create and activate virtual environment\npython -m venv .venv\nsource .venv/bin/activate  # On Windows: .venv\\Scripts\\activate\n\n# Install in development mode with dev dependencies\npip install -e \".[dev]\"\n\n# Run tests\npytest -v\n\n# Run with coverage\npytest --cov=analyzer --cov=mcp_code_covered --cov=cli --cov-report=term-missing\n\n# Run linting\nruff check analyzer mcp_code_covered cli.py tests\n\n# Run type checking\npyright analyzer mcp_code_covered cli.py tests\n```\n\n## Features\n\n### Priority Levels\n\n| Priority | What it means | Example |\n|----------|---------------|---------|\n| **Critical** | Exception handlers, raise statements | `except ValueError:` never triggered |\n| **High** | Conditional branches | `if x \u003e 0:` branch never taken |\n| **Medium** | Function bodies, loops | Loop body never entered |\n| **Low** | Other uncovered code | Module-level statements |\n\n### Test Templates\n\nEach suggestion includes a ready-to-use test template:\n\n```python\ndef test_validate_input_handles_exception():\n    \"\"\"Test that validate_input handles ValueError.\"\"\"\n    # Arrange: Set up conditions to trigger ValueError\n    # TODO: Mock dependencies to raise ValueError\n\n    # Act\n    result = validate_input()  # TODO: Add args\n\n    # Assert: Verify exception was handled correctly\n    # TODO: Add assertions\n```\n\n### Setup Hints\n\nDetects common patterns and suggests what to mock:\n\n```\nHints: Mock HTTP requests with responses or httpx, Use @pytest.mark.asyncio decorator\n```\n\n## CLI Reference\n\n```bash\n# Basic usage\ncode-covered coverage.json\n\n# Show full templates\ncode-covered coverage.json -v\n\n# Filter by priority\ncode-covered coverage.json --priority critical\n\n# Limit results\ncode-covered coverage.json --limit 5\n\n# Write test stubs to file\ncode-covered coverage.json -o tests/test_missing.py\n\n# Specify source root (if coverage paths are relative)\ncode-covered coverage.json --source-root ./src\n\n# JSON output for CI pipelines\ncode-covered coverage.json --format json\n```\n\n### Exit Codes\n\n| Code | Meaning |\n|------|---------|\n| 0 | Success (gaps found or no gaps) |\n| 1 | Error (file not found, parse error) |\n\n### JSON Output\n\nUse `--format json` for CI integration:\n\n```json\n{\n  \"coverage_percent\": 74.5,\n  \"files_analyzed\": 3,\n  \"files_with_gaps\": 1,\n  \"suggestions\": [\n    {\n      \"test_name\": \"test_validator_validate_input_handles_exception\",\n      \"priority\": \"critical\",\n      \"covers_lines\": [23, 24, 25, 26, 27],\n      \"block_type\": \"exception_handler\"\n    }\n  ]\n}\n```\n\n## Python API\n\n```python\nfrom analyzer import find_coverage_gaps, print_coverage_gaps\n\n# Find gaps\nsuggestions, warnings = find_coverage_gaps(\"coverage.json\")\n\n# Print formatted output\nprint_coverage_gaps(suggestions)\n\n# Or process programmatically\nfor s in suggestions:\n    print(f\"{s.priority}: {s.test_name}\")\n    print(f\"  Covers lines {s.covers_lines}\")\n    print(f\"  Template:\\n{s.code_template}\")\n```\n\n## How It Works\n\n1. **Parse coverage.json** -- Reads the JSON report from `pytest-cov`\n2. **AST Analysis** -- Parses source files to understand code structure\n3. **Context Detection** -- Identifies what each uncovered block does:\n   - Is it an exception handler?\n   - Is it a conditional branch?\n   - What function/class is it in?\n4. **Template Generation** -- Creates specific test templates based on context\n5. **Prioritization** -- Ranks by importance (error paths \u003e branches \u003e other)\n\n## License\n\nMIT -- see [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcp-tool-shop-org%2Fcode-covered","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcp-tool-shop-org%2Fcode-covered","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcp-tool-shop-org%2Fcode-covered/lists"}