Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for excluding functions from coverage with attribute #2593

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

benjaminfuchs
Copy link

@benjaminfuchs benjaminfuchs commented Dec 21, 2024

PR Summary

Fixes #2268

This pull request introduces support for excluding functions from code coverage analysis using the [ExcludeFromCodeCoverageAttribute()] attribute.

Changes:

  • Updated the Get-CommandsInFile function to skip AST nodes within functions marked with [ExcludeFromCodeCoverageAttribute()].
  • Added IsExcludedByAttribute to check if a function has the exclusion attribute applied, either fully qualified or resolved through using namespace.
  • Implemented Get-NamespacesFromScript to identify and apply using namespace declarations for resolving unqualified attribute names (not sure if similar logic already exists in the codebase).
  • Updated tests to verify exclusion functionality.

PR Checklist

  • PR has meaningful title
  • Summary describes changes
  • PR is ready to be merged
    • If not, use the arrow next to Create Pull Request to mark it as a draft. PR can be marked Ready for review when it's ready.
  • Tests are added/update (if required)
  • Documentation is updated/added (if required)

@benjaminfuchs
Copy link
Author

If the approach is valid, I'll refine the tests and add proper documentation. Feedback is welcome!

@benjaminfuchs benjaminfuchs force-pushed the feature/exclude-attribute-coverage branch 3 times, most recently from 99eb66a to 1c9dd96 Compare December 21, 2024 22:37
@benjaminfuchs benjaminfuchs force-pushed the feature/exclude-attribute-coverage branch from 1c9dd96 to d1c84df Compare December 21, 2024 22:58
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.

Allow [ExcludeFromCodeCoverage()] on the param() block to exclude a function from code coverage
1 participant