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

Inaccurate lineToCover in report generated by \atoum\atoum\reports\sonar\clover #55

Open
amottier opened this issue Aug 10, 2023 · 0 comments

Comments

@amottier
Copy link

I'm running a test on the following basic class:

<?php
namespace ow2\demo;

class Calculator
{
    public $var = 'a default value';

    public function add(int $a, int $b)
    {
        return $a + $b;
    }

    public function sub(int $a, int $b)
    {
        return $a - $b;
    }
}

The test only calls add function so I expect the report to be something like:

<?xml version="1.0" encoding="UTF-8"?>
<coverage version="1">
  <file path="src/ow2/demo/Calculator.php">
    <lineToCover lineNumber="10" covered="true"/> <!--  return $a + $b; -->
    <lineToCover lineNumber="15" covered="false"/> <!-- return $a - $b; -->
  </file>
</coverage>

but instead the report include lineToCover entries for function closing braces:

<?xml version="1.0" encoding="UTF-8"?>
<coverage version="1">
  <file path="src/ow2/demo/Calculator.php">
    <lineToCover lineNumber="10" covered="true"/>
    <lineToCover lineNumber="11" covered="false"/>
    <lineToCover lineNumber="15" covered="false"/>
    <lineToCover lineNumber="16" covered="false"/>
  </file>
</coverage>

This report lead to a coverage of 25% in Sonar whereas it should be 50%.

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

1 participant