{"library":"diff-cover","title":"Diff-Cover","description":"Diff-Cover is a command-line tool that enhances code review by reporting test coverage and linting violations specifically on new or modified lines within a Git diff. It compares an XML coverage report (e.g., Cobertura, Clover, JaCoCo, or LCov format) with the output of `git diff` to highlight lines that lack test coverage or contain quality issues. The library is currently at version 10.2.0 and maintains an active release cadence with frequent updates and dependency bumps.","status":"active","version":"10.2.0","language":"en","source_language":"en","source_url":"https://github.com/Bachmann1234/diff-cover","tags":["testing","coverage","linting","code-quality","git","cli","code-review"],"install":[{"cmd":"pip install diff-cover","lang":"bash","label":"Basic Installation"},{"cmd":"pip install diff-cover[flake8,mypy,pylint,ruff]","lang":"bash","label":"With Common Quality Checkers"}],"dependencies":[{"reason":"Commonly used Python test runner to generate coverage reports, typically in XML format.","package":"coverage.py","optional":false},{"reason":"Pytest plugin for generating coverage reports.","package":"pytest-cov","optional":false},{"reason":"Optional quality checker for Python code.","package":"flake8","optional":true},{"reason":"Optional static type checker for Python.","package":"mypy","optional":true},{"reason":"Optional static code analyzer for Python.","package":"pylint","optional":true},{"reason":"Optional fast Python linter, supports Pylint output format for diff-cover.","package":"ruff","optional":true}],"imports":[],"quickstart":{"code":"git init\n# Create some dummy files and commits for a diff\necho \"def func1():\\n    pass\" > file1.py\ngit add file1.py\ngit commit -m \"Initial commit\"\n\necho \"def func2():\\n    return 1 # new line\" >> file1.py\ngit add file1.py\ngit commit -m \"Add func2\"\n\n# Run your tests with coverage and generate an XML report\n# (Requires pytest-cov and pytest to be installed)\n# For a real project, this would run actual tests\npytest --cov=. --cov-report=xml --ignore=file1.py\n\n# Now, run diff-cover on the generated coverage.xml against the latest diff\n# This example might report 'No lines with coverage information in this diff.'\n# if the dummy coverage report doesn't perfectly align with the diff.\n# In a real scenario, `pytest --cov` would cover the changed lines.\ndiff-cover coverage.xml","lang":"bash","description":"This quickstart demonstrates the core functionality of `diff-cover`. First, ensure you have a Git repository and a `coverage.xml` report generated by a tool like `coverage.py` or `pytest-cov`. The `diff-cover` command then compares this report against your Git changes to identify uncovered or problematic lines in the diff."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or newer. If you must use Python 3.9 or older, pin `diff-cover<10.0.0`.","message":"Version 10.1.0 updated the minimum required Python version to `>=3.10`. Version 10.0.0 explicitly dropped support for Python 3.9 while adding support for Python 3.14. Users on older Python versions (e.g., 3.9 or earlier) must upgrade their Python environment or use an older `diff-cover` version.","severity":"breaking","affected_versions":">=10.0.0"},{"fix":"Ensure `diff-cover` is run from the same working directory where the coverage report (e.g., `coverage.xml`) was generated. Verify that file paths in the coverage report align with your Git repository structure. Consider updating to `diff-cover>=10.2.0` for improved subfolder handling.","message":"`diff-cover` relies on source file paths matching exactly between the coverage report and the Git diff. Mismatched relative paths are a common cause of 'No lines with coverage information in this diff.' errors. Version 10.2.0 added support for converting violation paths to relative paths for subfolder support. Version 9.7.2 fixed file name matching on Windows.","severity":"gotcha","affected_versions":"All versions, improved in 9.7.2, 10.2.0"},{"fix":"Use the `--expand-coverage-report` argument (available for XML reports) to add lines not appearing in the coverage report to them, allowing for a more comprehensive diff coverage analysis. Be aware this workaround assumes coverage tools report untested statements with 0 hits.","message":"`diff-cover` may not accurately analyze changes within multi-line statements because coverage reports typically list code statements rather than every changed line. This can lead to lines changed in the diff not being reported in coverage.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review existing configurations for `include` and `exclude` patterns. Update them to either a string or a list of strings, ensuring they work as intended with the new normalized behavior.","message":"In version 10.0.0, the `include` and `exclude` arguments were normalized to accept both a string or a list. While this is generally an improvement, older configurations expecting only one type might behave unexpectedly if not reviewed.","severity":"deprecated","affected_versions":">=10.0.0"},{"fix":"Upgrade to `diff-cover>=9.7.1` to ensure proper compatibility with Ruff, especially with newer versions of Ruff. If unable to upgrade, you might need to configure Ruff to output in a Pylint-compatible format explicitly.","message":"Older versions of `diff-cover` had compatibility issues with Ruff, particularly when Ruff versions >= 0.12.9 were used, requiring a forced Pylint output format. While fixed in v9.7.0 and v9.7.1, users integrating Ruff should be aware.","severity":"gotcha","affected_versions":"<9.7.1"}],"env_vars":null,"last_verified":"2026-04-05T00:00:00.000Z","next_check":"2026-07-04T00:00:00.000Z"}