Thanks to visit codestin.com
Credit goes to github.com

Skip to content

object_usage_linter not working for S4 code? #24

@fabian-s

Description

@fabian-s

Thanks for the great package, it's a nice help with grading programming assignments in addition to its general usefulness.

However, if I try to run the default linters on S4 code (here I just use some examples from the methods-package to make this reproducible) I get:

tmpfile <- tempfile(fileext = ".R")
writeLines(example(setClass, give.lines=TRUE), con=tmpfile)
lintr::lint(tmpfile)
## Error in typeof(fun) : object 'fun' not found
## Error in body(fun) : object 'fun' not found
writeLines(example(Methods, give.lines=TRUE), con=tmpfile)
lintr::lint(tmpfile)
## Error in typeof(fun) : object 'fun' not found
## Error in body(fun) : object 'fun' not found
traceback()
## 12: body(fun)
## 11: findLocalsList(c(list(body), dropMissings(formals)))
## 10: codetools::findFuncLocals(formals(fun), body(fun))
## 9: FUN(19L[[1L]], ...)
## 8: lapply(ids_with_token(source_file, rex(start, "FUNCTION"), fun = re_matches), 
##       function(loc) {
##           id <- source_file$parsed_content$id[loc]
##         [...]
## 7: linters[[linter]](expr)
## [...]
lintr::lint(tmpfile, 
     linters=default_linters[names(default_linters) != "object_usage_linter"])
## works as expected

sessionInfo():

R version 3.1.2 (2014-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] lintr_0.2.0

loaded via a namespace (and not attached):
 [1] codetools_0.2-8  crayon_1.1.0     digest_0.6.4     htmltools_0.2.6  igraph_0.7.1    
 [6] lazyeval_0.1.9   magrittr_1.5     packrat_0.4.1-1  parallel_3.1.2   rex_0.2.0       
[11] rmarkdown_0.3.3  stringdist_0.8.1 tools_3.1.2      yaml_2.1.13     

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions