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

From: Peter Dalgaard <P.Dalgaard_at_biostat.ku.dk>
Date: Mon, 14 Dec 2009 10:24:36 +0100

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

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Mon 14 Dec 2009 - 09:28:22 GMT

This archive was generated by hypermail 2.2.0 : Mon 14 Dec 2009 - 12:41:05 GMT