Skip to content

chore: exclude barrel files from coverage reporting#315

Merged
kurtdoherty merged 1 commit intomainfrom
exclude-barrel-files-from-coverage
Feb 13, 2025
Merged

chore: exclude barrel files from coverage reporting#315
kurtdoherty merged 1 commit intomainfrom
exclude-barrel-files-from-coverage

Conversation

@kurtdoherty
Copy link
Contributor

@kurtdoherty kurtdoherty commented Feb 13, 2025

Context

In some recent work, we saw the addition of test coverage for a barrel file (a file, usually named index.ts, that simply re-exports code from other modules) in order to increase the reported coverage percentage above our minimum threshold.

As the discussion suggests, doing this is just "gaming the system." We don't want to add tests for the sake of our coverage metrics as that approach will lead to low-value, high-maintenance tests, and undermine the value coverage metrics are meant to provide: namely, the identification of possible risk in our code.

Instead of simply adding test coverage against a module that does not need tests (like barrel files), we should be assessing whether there's any meaningful coverage gaps being reported. Barrel files are not a meaningful gap.

This PR

Currently, our coverage metrics are tracking coverage for barrel files. These files will never have test coverage, so we they should not be included in our coverage reports.

The risk of excluding all index.ts files is that we do not strictly know whether the file is a barrel file, or if it does contain code we want coverage metrics for. Personally, I don't think this risk outweighs the annoyance of barrel files dragging our real coverage metrics down and would prefer to rely on the convention that index.ts files should only ever be barrel files.

This PR also scouts two issues with the recent Chip/ChipGroup work:

  • The ChipGroupItem test module was incorrectly named;
  • The Chip component was missing coverage for the onClick callback being called when the chip is enabled.

@kurtdoherty kurtdoherty force-pushed the exclude-barrel-files-from-coverage branch from 853eb95 to 73d28ec Compare February 13, 2025 23:06
@kurtdoherty kurtdoherty marked this pull request as ready for review February 13, 2025 23:07
@codacy-production
Copy link

codacy-production bot commented Feb 13, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 9d190ef1
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (9d190ef) Report Missing Report Missing Report Missing
Head commit (73d28ec) 4222 3815 90.36%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#315) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@kurtdoherty kurtdoherty merged commit 3ffe2a9 into main Feb 13, 2025
6 checks passed
@kurtdoherty kurtdoherty deleted the exclude-barrel-files-from-coverage branch February 13, 2025 23:16
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.

2 participants