Skip to content

coverage: exclude contract declarations from line coverage#770

Open
dguido wants to merge 1 commit intomasterfrom
dev/exclude-contract-from-coverage
Open

coverage: exclude contract declarations from line coverage#770
dguido wants to merge 1 commit intomasterfrom
dev/exclude-contract-from-coverage

Conversation

@dguido
Copy link
Copy Markdown
Member

@dguido dguido commented Jan 22, 2026

Summary

  • Exclude contract declaration lines from coverage calculations
  • Contract/library/interface/abstract contract declarations are not executable code
  • Previously these lines were counted, causing misleading coverage percentages (e.g., 97% instead of 100%)

Implementation

  • Added ContractDeclarationLines map to SourceFileAnalysis to track declaration line indices
  • Parse ContractDefinition nodes from AST during source analysis to identify declaration lines
  • Skip marking declaration lines as active/executable in analyzeContractSourceCoverage

Fixes #286

Test plan

  • Build passes: go build ./...
  • Existing tests pass (no dedicated coverage tests exist)
  • Manual verification: Run medusa on a contract and verify declaration lines are not counted

🤖 Generated with Claude Code

Contract declaration lines (contract, library, interface, abstract contract)
are not executable code but were being counted in coverage calculations.
This caused misleading coverage percentages where contracts with 100%
actual code coverage would show less because the declaration line was
counted as uncovered.

This change:
- Adds ContractDeclarationLines map to SourceFileAnalysis to track
  which line indices contain contract declarations
- Parses ContractDefinition nodes from AST to identify declaration lines
- Skips marking contract declaration lines as active/executable in
  analyzeContractSourceCoverage

Fixes #286

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dguido dguido force-pushed the dev/exclude-contract-from-coverage branch from c4bc794 to 1a892e4 Compare January 22, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove contract XXX statement in coverage

1 participant