Commits
Click on a commit to change the comparison rangefeat: implement partials_as_hits feature for LCOV parser
This commit adds support for the partials_as_hits configuration option to the LCOV parser,
bringing it in line with other coverage parsers (JaCoCo, Cobertura, Go).
## Changes Made
### Core Implementation
- **lcov.py**: Added partials_as_hits configuration reading and conversion logic
- **_process_file()**: Updated to accept partials_as_hits parameter
- **Branch processing**: Convert partial coverage (e.g., '1/2') to hits (1) when enabled
### Configuration Schema
- **user_schema.py**: Added LCOV parser configuration validation
- Supports: parsers.lcov.partials_as_hits (boolean, default: false)
### Test Coverage
- **test_lcov.py**: Added comprehensive test cases:
- test_lcov_partials_as_hits_enabled(): Tests conversion of partials to hits
- test_lcov_partials_as_hits_disabled(): Tests default behavior preservation
- test_lcov_partials_as_hits_mixed_coverage(): Tests mixed scenarios
- **test_validation.py**: Added schema validation tests
### Documentation
- **LCOV_PARTIALS_AS_HITS.md**: Comprehensive feature documentation including:
- Implementation details and logic
- Usage examples and migration guide
- Consistency with other parsers
- Test coverage overview
## Behavior
### With partials_as_hits: true
- '1/2' partial coverage → 1 (hit)
- '2/3' partial coverage → 1 (hit)
- '2/2' full hit → '2/2' (unchanged)
- '0/2' miss → '0/2' (unchanged)
### With partials_as_hits: false (default)
- All coverage types remain unchanged (backward compatible)
## Configuration Example
## Implementation Details
- Follows established patterns from JaCoCo, Cobertura, and Go parsers
- Minimal performance impact (single boolean check per branch line)
- Comprehensive test coverage with realistic LCOV data
- Backward compatible (defaults to false)
Closes: #[issue-number] (if applicable)
Co-authored-by: TDD Implementation Process fix: preserve branch coverage type in LCOV partials_as_hits
Critical bug fix addressing incorrect branch counting when partials_as_hits is enabled.
## Problem
When partials_as_hits was enabled, partial branches were converted from:
- coverage: '1/2' -> 1 ✅ (correct)
- coverage_type: CoverageType.branch -> CoverageType.line ❌ (incorrect)
This caused get_line_totals() to exclude converted partials from branch counts
since it only counts lines with type='b' (CoverageType.branch maps to 'b').
## Solution
- Keep coverage_type as CoverageType.branch for converted partials
- This maintains proper branch counting: line.type = 'b'
- Aligns behavior with JaCoCo parser (preserves branch type)
- Ensures accurate branch coverage metrics
## Changes
- lcov.py: Remove incorrect coverage_type change to CoverageType.line
- test_lcov.py: Update test expectations to expect 'b' type for converted partials
- LCOV_PARTIALS_AS_HITS.md: Correct documentation
## Verification
- Converted partials now maintain branch type for proper counting
- Tests updated to reflect correct behavior
- Branch coverage metrics will be accurate
Fixes: Branch count inconsistency when partials_as_hits enabled
Severity: Critical - affects coverage metrics accuracy style: apply ruff formatting to test_lcov.py
Auto-formatting applied by pre-commit hooks to match project style guidelines.
The tuple formatting was changed to multi-line format for better readability. style: apply ruff formatting to LCOV tests
Auto-formatting applied by pre-commit hooks:
- Remove trailing whitespace after triple quotes
- Multi-line format for long tuple in test_lcov_partials_as_hits_mixed_coverage
This prevents CI formatting loops by applying the formatting locally. fix: add boolean type casting for LCOV partials_as_hits config
- Fix issue where string 'false' would be truthy in YAML config
- Add robust boolean casting to handle 'false', 'true', '0', '1', etc.
- Add test to verify string 'false' correctly behaves as boolean False
- Refactor tests to eliminate duplication using class properties
- Move repeated LCOV test data to PARTIAL_BRANCH_LCOV_DATA class property
- Add reusable partial_test_path_fixer static method
This prevents configuration bugs where users specify boolean values as
strings in YAML, ensuring partials_as_hits works correctly regardless
of how the boolean is specified in the configuration. Add .cursor to .gitignore Empty commit to trigger CI - investigating flaky test Delete LCOV_PARTIALS_AS_HITS.md17 days ago
by drazisil-codecov Delete .gitignore17 days ago
by drazisil-codecov restore .gitignore17 days ago
by drazisil-codecov