pjcj / Devel--Cover

Code coverage metrics for Perl
http://www.pjcj.net/perl.html
93 stars 87 forks source link

cover -add_uncoverable_point: Use of uninitialized value $_ in split #328

Open martinvonwittich opened 10 months ago

martinvonwittich commented 10 months ago

So far I've been using the invasive specification to mark code as uncoverable, but that causes me to lose my coverage data each time I change something; therefore I wanted to try out the non-invasive way with cover -add_uncoverable_point. My first attempt led to this error message (I probably haven't gotten the specification right yet, the docs are unfortunately lacking):

martin.mein-iserv.de ~/git/user-backend/sbin (63013-chkmanagedusers) # cover -add_uncoverable_point 'chkmanagedusers condition 345 1 left foo bar'
Reading database from /root/git/user-backend/sbin/cover_db
Use of uninitialized value $_ in split at /usr/lib/x86_64-linux-gnu/perl5/5.32/Devel/Cover/DB.pm line 618.
Use of uninitialized value $file in open at /usr/lib/x86_64-linux-gnu/perl5/5.32/Devel/Cover/DB.pm line 622.
Use of uninitialized value $file in concatenation (.) or string at /usr/lib/x86_64-linux-gnu/perl5/5.32/Devel/Cover/DB.pm line 623.
Devel::Cover: Can't open : No such file or directory at /usr/lib/x86_64-linux-gnu/perl5/5.32/Devel/Cover/DB.pm line 623.

As far as I can tell, this is an obvious bug in lib/Devel/Cover/DB.pm:

https://github.com/pjcj/Devel--Cover/blob/82526a3d8b9886ec579896311e66f4556a3b41cd/lib/Devel/Cover/DB.pm#L620-L622

The for loop names the variable $add, but the split attempts to parse $_ instead of $add.

martinvonwittich commented 10 months ago

OK, I didn't get very far even after fixing this - cover apparently doesn't read the .uncoverable file: #218

pjcj commented 4 months ago

Thanks for looking at this. You're right about the docs. I was working on the whole uncoverable feature and deliberately didn't document it because it was all quite fluid. Then I sort of ran out of time and people were finding it useful anyway so I tidied it up a bit and released it, but never quite got around to finishing it up. The $add vs $_ bug is an obvious symptom of this.