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

Error in aggregate.data.frame #57

Closed
piccolbo opened this issue Feb 16, 2015 · 4 comments
Closed

Error in aggregate.data.frame #57

piccolbo opened this issue Feb 16, 2015 · 4 comments

Comments

@piccolbo
Copy link

This might very well be operator error, but ...

ff = function(x) identity(x)
function_coverage("ff", ff(1))

Results in

Error in aggregate.data.frame(mf[1L], mf[-1L], FUN = FUN, ...) : 
  no rows to aggregate

What am I missing? Thanks

@jimhester
Copy link
Member

Not at the computer so I can't verify, but I believe function coverage takes the function definition, not the function name. Remove the quotes in your example and it should work.

@piccolbo
Copy link
Author

Tried that

> function_coverage(ff, ff(1))
Error in get(name, envir = env) : invalid first argument

@jimhester
Copy link
Member

This is a bug related to #24. Because the function has no filename as.data.frame.coverage works incorrectly.

You can fix the example by pre-pending a filename to the names attribute of the returned coverage.

ff = function(x) identity(x)
cov <- function_coverage("ff", ff(1))
names(cov) <- paste0("<file>", names(cov))
cov

# Package Coverage: 100.00%
# <file>: 100.00%

as.data.frame(cov)
#   filename first_line first_byte last_line last_byte first_column last_column first_parsed last_parsed value
# 1   <file>          1          6         1        28            6          28            1           1     1

That being said this is a bug. Additionally reporting "Package Coverage" from the print method when printing function coverage also makes no sense, we should probably change that to "Overall Coverage" to be more general.

@jimhester
Copy link
Member

Should be fixed with the new srcref based counting.

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

2 participants