Skip to content

Account for vectors of length 0 when cleaning coverage#632

Open
maksymiuks wants to merge 9 commits into
r-lib:mainfrom
dgkf:main
Open

Account for vectors of length 0 when cleaning coverage#632
maksymiuks wants to merge 9 commits into
r-lib:mainfrom
dgkf:main

Conversation

@maksymiuks
Copy link
Copy Markdown
Contributor

Hi @jimhester, I'm sorry for bothering again. Apparently, my previous PR didn't cover an edge case of an edge case, or rather, by solving one, I created another. I'm sorry for that.

covr/R/covr.R

Line 669 in f1866d2

val <- obj[[i]]$value

val variable, in particular scenarios, can have integer(0) value and because of this R behaviour:

> FALSE || logical(0)
[1] NA

we end up with an NA in the conditional. That's why I've rewritten the condition to use length(val) == 0 instead of is.null(val). It is more robust and covers more of the cases that are problematic for that function, because both NULL and integer(0) are of length 0. There should be no more problems with that function anymore.

Closes #631

@jimhester
Copy link
Copy Markdown
Member

Could you add a test case to verify we don't break this in the future, thanks!

@maksymiuks
Copy link
Copy Markdown
Contributor Author

@jimhester Added the test. I figured it's better to prepare a dummy problematic object rather than an example package, so the test case is more robust and we are sure the function handles the problem well regardless of the source.

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

Successfully merging this pull request may close these issues.

Rare edge cases in count_test and clean_coverage_tests

2 participants