From Kurt.Hornik at wu.ac.at  Mon Dec 14 09:24:12 2009
From: Kurt.Hornik at wu.ac.at (Kurt Hornik)
Date: Mon, 14 Dec 2009 09:24:12 +0100
Subject: [Rd] R CMD check may not detect a code/documentation mismatch
In-Reply-To: <4B24E54B.7080005@biostat.ku.dk>
References: <20091213104402.GA20719@cs.cas.cz> <4B24E54B.7080005@biostat.ku.dk>
Message-ID: <19237.63020.855201.147223@fangorn.hornik.net>

>>>>> 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?

-k


> -- 
>     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



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