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

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

Open
martinvonwittich opened this issue Aug 30, 2023 · 2 comments

Comments

@martinvonwittich
Copy link

martinvonwittich commented Aug 30, 2023

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:

for my $add (@$adds) {
my ($file, $crit, $line, $count, $type, $class, $note) =
split " ", $_, 7;

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

@martinvonwittich
Copy link
Author

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

@pjcj
Copy link
Owner

pjcj commented Mar 12, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants