pkgnet
pkgnet copied to clipboard
FunctionReporter: Test coverage does not work with class methods
Right now, test coverage in FunctionReporter does not work with R6 methods. Presumably if Reference Class methods were supported (#197), they would not work either. All of those turn up as NA.
The reason is because covr simply assigns the name of the method as the name of the function. There is no simple, bulletproof way to recover which class that method belongs to from the coverage output. (Imagine you have two classes in the same file with methods of the same name.)
> pkgCovDT[filename == 'R/AbstractGraphReporter.R']
filename functions first_line first_byte
1: R/AbstractGraphReporter.R calculate_default_measures 38 13
2: R/AbstractGraphReporter.R calculate_default_measures 41 13
3: R/AbstractGraphReporter.R calculate_default_measures 44 13
4: R/AbstractGraphReporter.R get_summary_view 50 13
5: R/AbstractGraphReporter.R get_summary_view 61 13
Two ideas for solutions:
- Convince the maintainers of
covrto include some method for identifying the class to which a method belongs - Parse the source files and assign the method to a class based on the line numbers. (This sounds like a lot of work.)