pkgnet icon indicating copy to clipboard operation
pkgnet copied to clipboard

FunctionReporter: Test coverage does not work with class methods

Open jayqi opened this issue 6 years ago • 0 comments

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.

Screen Shot 2019-03-12 at 10 09 01 PM

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:

  1. Convince the maintainers of covr to include some method for identifying the class to which a method belongs
  2. Parse the source files and assign the method to a class based on the line numbers. (This sounds like a lot of work.)

jayqi avatar Mar 13 '19 03:03 jayqi