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

Coverage on not implemented interface #919

Open
andrewprofile opened this issue Jun 9, 2022 · 6 comments
Open

Coverage on not implemented interface #919

andrewprofile opened this issue Jun 9, 2022 · 6 comments

Comments

@andrewprofile
Copy link

andrewprofile commented Jun 9, 2022

Q A
php-code-coverage version 9.2.15
PHP version 8.0.9
Driver Xdebug
Xdebug version 3.1.5
Installation Method Composer
Usage Method PHPUnit
PHPUnit version 9.5.20

When I use code coverage in the report I get false-positive information that I partially have un-covered methods from the interface, which is a contract and has no implementation at all in this repository in my case.

image

@andrewprofile
Copy link
Author

andrewprofile commented Jun 9, 2022

The problem is caused by this workaround

// Workaround for https://bugs.xdebug.org/view.php?id=1798
which starts ignoring the line and then because this is the infterface in the next condition

it already returns $node without defining the end of the ignore.

I modified the code and in my case it solved the problem

if ($node instanceof Interface_) {
    $this->ignoredLines = array_merge(
        $this->ignoredLines,
        range($node->getStartLine(), $node->getEndLine())
    );
    return;
}

image

But I don't know if this global change broke something, that's why I didn't create a Pull Request

@sebastianbergmann what do you think?

andrewprofile added a commit to andrewprofile/php-code-coverage that referenced this issue Jun 10, 2022
@andrewprofile
Copy link
Author

@sebastianbergmann Could you take a look at it because I don't know whether to give a pull request?

@danielgelling
Copy link

danielgelling commented Dec 22, 2022

We're experiencing the same issue with the following (newer) versions:

Q A
php-code-coverage version 9.2.21 and 9.2.22
PHP version 8.1.13
Driver both PCOV and Xdebug
PCOV version 1.0.11
Xdebug version 3.1.6
Installation Method Composer
Usage Method PHPUnit
PHPUnit version 9.5.25

But with version 9.2.20 everything works as expected.

@vstelmakh
Copy link

Same issue for me, some lines from interfaces reported as uncovered, starting from 9.2.21. With 9.2.20 and before it was fine. I guess issue introduced here #964.

Q A
php-code-coverage version 9.2.21
PHP version 8.1.13
Driver Xdebug
Xdebug version 3.2.0
Installation Method Composer
Usage Method PHPUnit
PHPUnit version 9.5.27

For reproducible example see https://github.com/vstelmakh/url-highlight

  1. Clone the repository
  2. Install dependencies: composer install
  3. Run tests with code coverage: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-clover var/coverage.xml
  4. See var/coverage.xml for results.

Additionally, attaching a coverage.xml part here. It shrieked (to 13 lines) just to display an issue. The same issue is with HTML coverage.

@vstelmakh
Copy link

Seems like got fixed. Not reproducible in 9.2.23 for me.

@niconoe-
Copy link

Hi. I'm sorry to dig up this issue, but I'm encountering something similar an I didn't want to create a duplicate of it.

The coverage reports a false positive on interfaces when signature of methods are described on multiple lines.

image

You can see the version of CodeCoverage/PHP/PHPUnit I'm using to report this coverage. I'm using XDebug 3.2.0.

Thanks a lot

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

No branches or pull requests

4 participants