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

Annotations for ignoring code from code coverage are unintentionally ignored by default #4036

Closed
kukulich opened this issue Feb 10, 2020 · 7 comments
Assignees
Labels
type/bug Something is broken

Comments

@kukulich
Copy link
Contributor

Q A
PHPUnit version 9.0.0
PHP version 7.4.2
Installation Method Composer

Summary

@codeCoverageIgnoreStart annotation does not work.

Current behavior

coverage

How to reproduce

https://github.com/slevomat/coding-standard/blob/master/SlevomatCodingStandard/Helpers/TypeHelper.php#L24

Expected behavior

The ignored line should not be marked as not covered.

@sebastianbergmann sebastianbergmann transferred this issue from sebastianbergmann/phpunit Feb 10, 2020
@sebastianbergmann
Copy link
Owner

PHPUnit is not responsible for handling the @codeCoverageIgnoreStart etc. annotations, this component is. That is why I transferred the issue here.

@sebastianbergmann
Copy link
Owner

The code in this component that handles the @codeCoverageIgnoreStart annotation, https://github.com/sebastianbergmann/php-code-coverage/blob/8.0.0/src/CodeCoverage.php#L704 and https://github.com/sebastianbergmann/php-code-coverage/blob/8.0.0/src/CodeCoverage.php#L705, was not changed since the previous release.

@sebastianbergmann
Copy link
Owner

I also do not see any changes in php-token-stream which is the component that yields the value of $_token which https://github.com/sebastianbergmann/php-code-coverage/blob/8.0.0/src/CodeCoverage.php#L704 and https://github.com/sebastianbergmann/php-code-coverage/blob/8.0.0/src/CodeCoverage.php#L705 look at.

@kukulich
Copy link
Contributor Author

With PHPUnit 8.5.2

coverage

@sebastianbergmann
Copy link
Owner

I believe you :-) I am able to reproduce the issue. And I may have just found the root cause.

@sebastianbergmann sebastianbergmann self-assigned this Feb 10, 2020
@sebastianbergmann sebastianbergmann transferred this issue from sebastianbergmann/php-code-coverage Feb 10, 2020
@sebastianbergmann
Copy link
Owner

This is a bug in PHPUnit itself after all: due to a mistake I made while working on #3914, the processing of annotations such as @codeCoverageIgnoreStart is ignored by default in PHPUnit 9.0.0.

@sebastianbergmann sebastianbergmann added the type/bug Something is broken label Feb 10, 2020
@sebastianbergmann sebastianbergmann changed the title @codeCoverageIgnoreStart annotation does not work in PHPUnit 9.0.0 Annotations for ignoring code from code coverage are unintentionally ignored by default Feb 10, 2020
@curry684
Copy link

Funny how I just ran into this to find it fixed 3 hours ago :)

However - 'ignored by default' implies I should be able to fix it by adding disableCodeCoverageIgnore="false" to the phpunit.xml, but that doesn't change a thing. Don't you mean they are always ignored, not just by default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants