lucassabreu/comment-coverage-clover

Don't show empty files

sertxudev opened this issue · 4 comments

Hi, thanks to this GitHub Action I'm able to review the coverage of my projects.

I was wondering if there's a way to hide the empty files from the report comment.

For example, those four files have no content inside.

image

image

On the other hand, this file has some code but no line is being tested.

image

image

As you can see both examples are shown in the table report.
I'm currently hiding files with more than 95% tested, and I wanted to hide the four files without code.


MergesPdfs.php

<file name="/var/www/html/app/Actions/Utilities/MergesPdfs.php">
  <class name="App\Actions\Utilities\MergesPdfs" namespace="global">
    <metrics complexity="2" methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="10" coveredstatements="0" elements="11" coveredelements="0"/>
  </class>
  <line num="16" type="method" name="mergePdfs" visibility="protected" complexity="2" crap="6" count="0"/>
  <line num="17" type="stmt" count="0"/>
  <line num="19" type="stmt" count="0"/>
  <line num="21" type="stmt" count="0"/>
  <line num="22" type="stmt" count="0"/>
  <line num="25" type="stmt" count="0"/>
  <line num="26" type="stmt" count="0"/>
  <line num="27" type="stmt" count="0"/>
  <line num="28" type="stmt" count="0"/>
  <line num="30" type="stmt" count="0"/>
  <line num="34" type="stmt" count="0"/>
  <metrics loc="37" ncloc="31" classes="1" methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="10" coveredstatements="0" elements="11" coveredelements="0"/>
</file>

RepositoryNotFoundException.php

<file name="/var/www/html/app/Exceptions/RepositoryNotFoundException.php">
  <class name="App\Exceptions\RepositoryNotFoundException" namespace="global">
    <metrics complexity="0" methods="0" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="0" coveredstatements="0" elements="0" coveredelements="0"/>
  </class>
  <metrics loc="11" ncloc="10" classes="0" methods="0" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="0" coveredstatements="0" elements="0" coveredelements="0"/>
</file>

Maybe the action could check if the values classes, methods, conditionals, statements and/or elements are 0, to know if the file is indeed empty.

hi @sertxudev, just to be sure i understood it, you wanna a option to hide files that have "0 lines" like the RepositoryNotFoundException right?

to hide the MergesPdfs you can use the only-with-cover input.

Yeah, that's right.

@sertxudev i created a new input "only-with-coverable-lines", please take a look if it solves this problem

Nice work @lucassabreu.

I've checked the only-with-coverable-lines input in one of my projects and now the table it's showing 41 files, instead of the 66 shown previously, that's 25 non-coverable files removed from the table.

I'm adding the new input to another four projects.

Thanks! 😄