From chalabi at phys.ethz.ch  Tue Jul 29 15:31:17 2008
From: chalabi at phys.ethz.ch (Yohan Chalabi)
Date: Tue, 29 Jul 2008 15:31:17 +0200
Subject: [Rd] 'R CMD check' and S4 methods
Message-ID: <20080729153117.48900157@mimi>

Dear all,

I was looking for a function to analyze the code of a package and I
went throught the function 'checkUsagePackage' of package:codetools
which is used in 'R CMD check' script.

As far as I understand it, 'checkUsagePackage' does not check the code
usage of  S4 methods because it loads all function names from a given
environment where only the name of the generic function is given for S4
methods.

for example

library(codetools)
setClass("foo", representation(x= "character"))
foo <- new("foo", x = "dummy")
setMethod("show", "foo", function(object) noVisibleGlobalFunction())
print.foo <- function(x, ...) noVisibleGlobalFunction()
## checkUsageEnv detects the problem in print.foo but not with the
## defined method
checkUsageEnv(.GlobalEnv)
## or
checkUsage(show)


One can repeat this exmaple with 'checkUsagePackage'.

Is it right that code usage of S4 methods is not checked with
'R CMD check'?

thanks in advance for your response,
Yohan



[Rd] 'R CMD check' and S4 methods
Yohan Chalabi