Re: [Rd] CRAN policies

From: William Dunlap <wdunlap_at_tibco.com>
Date: Thu, 29 Mar 2012 20:21:38 +0000

> > codetools should be able to do special checks for known functions that
> > do not following the standard evaluation rules . E.g., do not check any
> > arguments of `~`, do not check the 'expr' argument of with, do not check
> > the subset or weights arguments of lm.
> >
> > If a package writer introduces a new function with nonstandard evaluation,
> > perhaps the package could include some information about the matter
> > in a file that codetools could could source before running its checks.
>
>
> This gets my vote -- but I don't have the bandwidth nor authority
> to effect the change ;-) Spencer

Most of that stuff is already in codetools, at least when it is checking functions with checkUsage(). E.g., arguments of ~ are not checked. The expr argument to with() will not be checked if you add skipWith=FALSE to the call to checkUsage.

  > library(codetools)

  > checkUsage(function(dataFrame) with(dataFrame, {Num/Den ; Resp ~ Pred}))   <anonymous>: no visible binding for global variable 'Num' (:1)   <anonymous>: no visible binding for global variable 'Den' (:1)

  > checkUsage(function(dataFrame) with(dataFrame, {Num/Den ; Resp ~ Pred}), skipWith=TRUE)

  > checkUsage(function(dataFrame) with(DataFrame, {Num/Den ; Resp ~ Pred}), skipWith=TRUE)   <anonymous>: no visible binding for global variable 'DataFrame'

The only part that I don't see is the mechanism to add code-walker functions to the environment in codetools that has the standard list of them for functions with nonstandard evaluation:
  > objects(codetools:::collectUsageHandlers, all=TRUE)

   [1] "$"             "$<-"           ".Internal"    
   [4] "::"            ":::"           "@"            
   [7] "@<-"           "{"             "~"            
  [10] "<-"            "<<-"           "="            
  [13] "assign"        "binomial"      "bquote"       
  [16] "data"          "detach"        "expression"   
  [19] "for"           "function"      "Gamma"        
  [22] "gaussian"      "if"            "library"      
  [25] "local"         "poisson"       "quasi"        
  [28] "quasibinomial" "quasipoisson"  "quote"        
  [31] "Quote"         "require"       "substitute"   
  [34] "with"         

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

> -----Original Message-----
> From: Spencer Graves [mailto:spencer.graves_at_prodsyse.com]
> Sent: Thursday, March 29, 2012 12:22 PM
> To: William Dunlap
> Cc: Matthew Dowle; r-devel_at_stat.math.ethz.ch
> Subject: Re: [Rd] CRAN policies
>
> On 3/29/2012 11:29 AM, William Dunlap wrote:
> >
> > Bill Dunlap
> > Spotfire, TIBCO Software
> > wdunlap tibco.com
> >
> >
> >> -----Original Message-----
> >> From: r-devel-bounces_at_r-project.org [mailto:r-devel-bounces_at_r-project.org] On
> Behalf
> >> Of Matthew Dowle
> >> Sent: Thursday, March 29, 2012 10:41 AM
> >> To: r-devel_at_stat.math.ethz.ch
> >> Subject: Re: [Rd] CRAN policies
> >>
> >> William Dunlap<wdunlap<at> tibco.com> writes:
> >>
> >>>> -----Original Message-----
> >>>> The survival package has a similar special case: the routines for
> >>>> expected population survival are set up to accept multiple types of date
> >>>> format so have lines like
> >>>> if (class(x) == 'chron') { y<- as.numeric(x - chron("01/01/1960")}
> >>>> This leaves me with two extraneous "no visible binding" messages.
> >>> Suppose we defined a function like
> >>> NO_VISIBLE_BINDING(expr) expr
> >>> and added an entry to the stuff in codetools so that it
> >>> would not check for misspelled object names in call to
> >>> NO_VISIBLE_BINDING. Then Terry could write that line as
> >>> if (class(x) == "chron") { y<- as.numeric(x - NO_VISIBLE_BINDING(chron)
> >> ("01/01/1960")}
> >>> and the Notes would disappear.
> >>>
> >> That's ok for package code, but what about test suites? Say there was a test
> >> on the result of "with(DF,a+b)", you wouldn't want to change the test to "with
> >> (DF,NO_VISIBLE_BINDING(a)+NO_VISIBLE_BINDING(b))" not just because that's long
> >> and onerous, but because that's *changing* the test i.e. introducing a
> >> difference between what's tested and what user code will do.
> > I don't know if test suites need to be checked for no visible bindings -
> > if there is a real problem the test ought to fail.
> >
> > codetools should be able to do special checks for known functions that
> > do not following the standard evaluation rules . E.g., do not check any
> > arguments of `~`, do not check the 'expr' argument of with, do not check
> > the subset or weights arguments of lm.
> >
> > If a package writer introduces a new function with nonstandard evaluation,
> > perhaps the package could include some information about the matter
> > in a file that codetools could could source before running its checks.
>
>
> This gets my vote -- but I don't have the bandwidth nor authority
> to effect the change ;-) Spencer
> >
> > Bill Dunlap
> > Spotfire, TIBCO Software
> > wdunlap tibco.com
> >> As others suggested, how about a new category: MEMO. The "no visible binding"
> >> NOTE would be downgraded to MEMO. CRAN maintainers could then ignore MEMOs
> >> more
> >> easily.
> >>
> >> What I really like about NOTES is that when new checks are added to R then as a
> >> package maintainer you know you don't have to fix them straight away. If a new
> >> WARNING shows up on r-devel daily checks, however, then you've got some warning
> >> about the WARNING that you need to fix more urgently and may even accelerate a
> >> release. So it's not just about checks when submitting a package, but what
> >> happens afterwards as R itself (and packages in Depends) move on. In other
> >> words, you know you need to fix new NOTES but not as urgently as new WARNINGS.
> >>
> >> Matthew
> >>
> >> ______________________________________________
> >> R-devel_at_r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-devel
> > ______________________________________________
> > R-devel_at_r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 29 Mar 2012 - 20:24:29 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 29 Mar 2012 - 21:10:37 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive