[Rd] R CMD check may not detect a code/documentation mismatch

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Mon Dec 14 10:24:36 CET 2009


Kurt Hornik wrote:
>>>>>> Peter Dalgaard writes:
> 
>> Petr Savicky wrote:
>>> For the package at
>>> http://www.cs.cas.cz/~savicky/R-devel/something_0.0.0.tar.gz
>>> which is a minor part of some other package only to demonstrate the
>>> problem, i get (under R version 2.11.0 Under development 2009-12-12 r50714
>>> and also under R-2.9.2, openSUSE 11.1 (x86_64) and CentOS release 5.2)
>>>
>>> R CMD check something_0.0.0.tar.gz
>>>
>>> ...
>>> * checking Rd files ... OK
>>> * checking Rd metadata ... OK
>>> * checking Rd cross-references ... OK
>>> * checking for missing documentation entries ... OK
>>> * checking for code/documentation mismatches ... OK
>>> * checking Rd \usage sections ... OK
>>> * checking examples ... NONE
>>> * checking PDF version of manual ... OK
>>>
>>> although the package code contains
>>>
>>> testCoreNA <- function()
>>>
>>> and the documentation contains
>>>
>>> \usage{
>>> testCoreClass(verbose=0)
>>> testCoreAttrEval(verbose=0)
>>> testCoreReg(verbose=0)
>>> testCoreNA(verbose=0)
>>> }
>>>
>>> There is a mismatch between code and documentation of testCoreNA(). Is the 
>>> problem caused by having four entries in \usage{} section?
> 
>> Hmm, looks more like a thinko in this code inside codoc():
> 
>>      functions_in_code <- Filter(function(f) {
>>          f <- get(f, envir = code_env)
>>          is.function(f) && (length(formals(f)) > 0L)
>>      }, objects_in_code)
> 
>> which, further down the line, causes functions with no formal arguments 
>> to be skipped when compared to the usage section.
> 
>> Browse[2]>
>> debug: ind <- (!functions %in% functions_to_be_ignored & functions %in%
>>      functions_in_code)
>> Browse[2]> functions
>> [1] "testCoreClass"    "testCoreAttrEval" "testCoreReg" 
>> "testCoreNA"
>> Browse[2]>
>> debug: bad_functions <- mapply(functions[ind], exprs[ind], FUN = 
>> function(x,
>>      y) check_codoc(x, as.pairlist(as.alist.call(y[-1L]))), SIMPLIFY = 
>> FALSE)
>> Browse[2]> ind
>> [1]  TRUE  TRUE  TRUE FALSE
> 
>> I.e. testCoreNA is never tested by check_codoc. There may of course be
>> a rationale for this, but it escapes me...
> 
> Well, I am sure I had good reasons when I wrote the code many years ago,
> but of course I no longer recall what they were.
> 
> Did you try the effect of removing the length(formals(f)) test?

Not yet. Priorities....

-p

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-devel mailing list