Skip to content

object_name_linter: Attempt to apply non-function #471

Closed

Description

@pat-s
lintr::lint(paste0(readLines("https://raw.githubusercontent.com/mlr3learners/mlr3learners.fnn/2c7e9aee40bcc37f50d3d181af73c7a289c15faf/R/LearnerRegrFNN.R"), collapse = "\n"),
  linters = list(lintr::with_defaults(object_name_linter = NULL)))
#> Error in linters[[linter]](expr): attempt to apply non-function

Created on 2020-03-20 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                                      
#>  version  R version 3.6.3 Patched (2020-02-29 r77919)
#>  os       macOS Catalina 10.15.3                     
#>  system   x86_64, darwin15.6.0                       
#>  ui       X11                                        
#>  language (EN)                                       
#>  collate  en_US.UTF-8                                
#>  ctype    en_US.UTF-8                                
#>  tz       Europe/Berlin                              
#>  date     2020-03-20                                 
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version    date       lib source                          
#>  assertthat     0.2.1      2019-03-21 [1] CRAN (R 3.6.2)                  
#>  backports      1.1.5      2019-10-02 [1] CRAN (R 3.6.2)                  
#>  callr          3.4.2      2020-02-12 [1] CRAN (R 3.6.2)                  
#>  cli            2.0.2      2020-02-28 [1] CRAN (R 3.6.3)                  
#>  crayon         1.3.4      2020-03-15 [1] Github (r-lib/crayon@f4bc7b8)   
#>  cyclocomp      1.1.0      2016-09-10 [1] CRAN (R 3.6.2)                  
#>  desc           1.2.0      2018-05-01 [1] CRAN (R 3.6.2)                  
#>  devtools       2.2.2      2020-02-17 [1] CRAN (R 3.6.2)                  
#>  digest         0.6.25     2020-02-23 [1] CRAN (R 3.6.2)                  
#>  ellipsis       0.3.0      2019-09-20 [1] CRAN (R 3.6.2)                  
#>  evaluate       0.14       2019-05-28 [1] CRAN (R 3.6.2)                  
#>  fansi          0.4.1      2020-01-08 [1] CRAN (R 3.6.2)                  
#>  fs             1.3.2      2020-03-05 [1] CRAN (R 3.6.3)                  
#>  glue           1.3.2      2020-03-12 [1] CRAN (R 3.6.3)                  
#>  highr          0.8        2019-03-20 [1] CRAN (R 3.6.2)                  
#>  htmltools      0.4.0      2019-10-04 [1] CRAN (R 3.6.2)                  
#>  knitr          1.28       2020-02-06 [1] CRAN (R 3.6.2)                  
#>  lazyeval       0.2.2      2019-03-15 [1] CRAN (R 3.6.2)                  
#>  lintr          2.0.1      2020-03-20 [1] Github (jimhester/lintr@edb3b12)
#>  magrittr       1.5        2014-11-22 [1] CRAN (R 3.6.2)                  
#>  memoise        1.1.0      2017-04-21 [1] CRAN (R 3.6.2)                  
#>  pkgbuild       1.0.6      2019-10-09 [1] CRAN (R 3.6.2)                  
#>  pkgload        1.0.2      2018-10-29 [1] CRAN (R 3.6.2)                  
#>  prettyunits    1.1.1      2020-01-24 [1] CRAN (R 3.6.2)                  
#>  processx       3.4.2      2020-02-09 [1] CRAN (R 3.6.2)                  
#>  ps             1.3.2      2020-02-13 [1] CRAN (R 3.6.2)                  
#>  R6             2.4.1      2019-11-12 [1] CRAN (R 3.6.2)                  
#>  Rcpp           1.0.4.3    2020-03-20 [1] Github (RcppCore/Rcpp@ce5538b)  
#>  remotes        2.1.1      2020-02-15 [1] CRAN (R 3.6.2)                  
#>  rex            1.1.2      2017-10-19 [1] CRAN (R 3.6.2)                  
#>  rlang          0.4.5      2020-03-01 [1] CRAN (R 3.6.3)                  
#>  rmarkdown      2.1        2020-01-20 [1] CRAN (R 3.6.2)                  
#>  rprojroot      1.3-2      2018-01-03 [1] CRAN (R 3.6.2)                  
#>  sessioninfo    1.1.1      2018-11-05 [1] CRAN (R 3.6.2)                  
#>  stringi        1.4.6      2020-02-17 [1] CRAN (R 3.6.2)                  
#>  stringr        1.4.0      2019-02-10 [1] CRAN (R 3.6.2)                  
#>  testthat       2.3.2      2020-03-02 [1] CRAN (R 3.6.3)                  
#>  usethis        1.5.1.9000 2020-03-20 [1] Github (r-lib/usethis@4cfa070)  
#>  withr          2.1.2      2018-03-15 [1] CRAN (R 3.6.2)                  
#>  xfun           0.12       2020-01-13 [1] CRAN (R 3.6.2)                  
#>  xml2           1.2.5      2020-03-11 [1] CRAN (R 3.6.3)                  
#>  xmlparsedata   1.0.3      2019-09-27 [1] CRAN (R 3.6.2)                  
#>  yaml           2.2.1      2020-02-01 [1] CRAN (R 3.6.2)                  
#> 
#> [1] /Users/pjs/Library/R/3.6/library
#> [2] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

Using default linters works fine

 lintr::lint(paste0(readLines("https://raw.githubusercontent.com/mlr3learners/mlr3learners.fnn/2c7e9aee40bcc37f50d3d181af73c7a289c15faf/R/LearnerRegrFNN.R"), collapse = "\n"))
#> <text>:9:1: style: Variable and function name style should be snake_case.
#> LearnerRegrFNN = R6Class("LearnerRegrFNN",
#> ^~~~~~~~~~~~~~
#> <text>:9:16: style: Use <-, not =, for assignment.
#> LearnerRegrFNN = R6Class("LearnerRegrFNN",
#>                ^
#> <text>:17:10: style: Use <-, not =, for assignment.
#>       ps = ParamSet$new(
#>          ^
#> <text>:47:13: style: Use <-, not =, for assignment.
#>       model = self$model
#>             ^
#> <text>:48:13: style: Use <-, not =, for assignment.
#>       train = model$data[, task$feature_names, with = FALSE]
#>             ^
#> <text>:49:14: style: Use <-, not =, for assignment.
#>       target = model$data[, task$target_names, with = FALSE][[1]]
#>              ^
#> <text>:50:15: style: Use <-, not =, for assignment.
#>       newdata = task$data(cols = task$feature_names)
#>               ^
#> <text>:52:9: style: Use <-, not =, for assignment.
#>       p = invoke(FNN::knn.reg,
#>         ^

Created on 2020-03-20 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                                      
#>  version  R version 3.6.3 Patched (2020-02-29 r77919)
#>  os       macOS Catalina 10.15.3                     
#>  system   x86_64, darwin15.6.0                       
#>  ui       X11                                        
#>  language (EN)                                       
#>  collate  en_US.UTF-8                                
#>  ctype    en_US.UTF-8                                
#>  tz       Europe/Berlin                              
#>  date     2020-03-20                                 
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version    date       lib source                          
#>  assertthat     0.2.1      2019-03-21 [1] CRAN (R 3.6.2)                  
#>  backports      1.1.5      2019-10-02 [1] CRAN (R 3.6.2)                  
#>  callr          3.4.2      2020-02-12 [1] CRAN (R 3.6.2)                  
#>  cli            2.0.2      2020-02-28 [1] CRAN (R 3.6.3)                  
#>  crayon         1.3.4      2020-03-15 [1] Github (r-lib/crayon@f4bc7b8)   
#>  cyclocomp      1.1.0      2016-09-10 [1] CRAN (R 3.6.2)                  
#>  desc           1.2.0      2018-05-01 [1] CRAN (R 3.6.2)                  
#>  devtools       2.2.2      2020-02-17 [1] CRAN (R 3.6.2)                  
#>  digest         0.6.25     2020-02-23 [1] CRAN (R 3.6.2)                  
#>  ellipsis       0.3.0      2019-09-20 [1] CRAN (R 3.6.2)                  
#>  evaluate       0.14       2019-05-28 [1] CRAN (R 3.6.2)                  
#>  fansi          0.4.1      2020-01-08 [1] CRAN (R 3.6.2)                  
#>  fs             1.3.2      2020-03-05 [1] CRAN (R 3.6.3)                  
#>  glue           1.3.2      2020-03-12 [1] CRAN (R 3.6.3)                  
#>  highr          0.8        2019-03-20 [1] CRAN (R 3.6.2)                  
#>  htmltools      0.4.0      2019-10-04 [1] CRAN (R 3.6.2)                  
#>  knitr          1.28       2020-02-06 [1] CRAN (R 3.6.2)                  
#>  lazyeval       0.2.2      2019-03-15 [1] CRAN (R 3.6.2)                  
#>  lintr          2.0.1      2020-03-20 [1] Github (jimhester/lintr@edb3b12)
#>  magrittr       1.5        2014-11-22 [1] CRAN (R 3.6.2)                  
#>  memoise        1.1.0      2017-04-21 [1] CRAN (R 3.6.2)                  
#>  pkgbuild       1.0.6      2019-10-09 [1] CRAN (R 3.6.2)                  
#>  pkgload        1.0.2      2018-10-29 [1] CRAN (R 3.6.2)                  
#>  prettyunits    1.1.1      2020-01-24 [1] CRAN (R 3.6.2)                  
#>  processx       3.4.2      2020-02-09 [1] CRAN (R 3.6.2)                  
#>  ps             1.3.2      2020-02-13 [1] CRAN (R 3.6.2)                  
#>  R6             2.4.1      2019-11-12 [1] CRAN (R 3.6.2)                  
#>  Rcpp           1.0.4.3    2020-03-20 [1] Github (RcppCore/Rcpp@ce5538b)  
#>  remotes        2.1.1      2020-02-15 [1] CRAN (R 3.6.2)                  
#>  rex            1.1.2      2017-10-19 [1] CRAN (R 3.6.2)                  
#>  rlang          0.4.5      2020-03-01 [1] CRAN (R 3.6.3)                  
#>  rmarkdown      2.1        2020-01-20 [1] CRAN (R 3.6.2)                  
#>  rprojroot      1.3-2      2018-01-03 [1] CRAN (R 3.6.2)                  
#>  rstudioapi     0.11       2020-02-07 [1] CRAN (R 3.6.2)                  
#>  sessioninfo    1.1.1      2018-11-05 [1] CRAN (R 3.6.2)                  
#>  stringi        1.4.6      2020-02-17 [1] CRAN (R 3.6.2)                  
#>  stringr        1.4.0      2019-02-10 [1] CRAN (R 3.6.2)                  
#>  testthat       2.3.2      2020-03-02 [1] CRAN (R 3.6.3)                  
#>  usethis        1.5.1.9000 2020-03-20 [1] Github (r-lib/usethis@4cfa070)  
#>  withr          2.1.2      2018-03-15 [1] CRAN (R 3.6.2)                  
#>  xfun           0.12       2020-01-13 [1] CRAN (R 3.6.2)                  
#>  xml2           1.2.5      2020-03-11 [1] CRAN (R 3.6.3)                  
#>  xmlparsedata   1.0.3      2019-09-27 [1] CRAN (R 3.6.2)                  
#>  yaml           2.2.1      2020-02-01 [1] CRAN (R 3.6.2)                  
#> 
#> [1] /Users/pjs/Library/R/3.6/library
#> [2] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

Activity

  1. russHyde commented on Mar 20, 2020

    @russHyde
    Collaborator

    Could you check with :

    lintr::lint(
      paste0(readLines(
      
      "https://raw.githubusercontent.com/mlr3learners/mlr3learners.fnn/2c7e9aee40bcc37f50d3d181af73c7a289c15faf/R/LearnerRegrFNN.R"
        ),
        collapse = "\n"
      ),
      linters = lintr::with_defaults(object_name_linter = NULL))
    

    with_defaults returns a list of linters for use by lint.

  2. pat-s commented on Mar 20, 2020

    @pat-s
    Author

    Thanks!. While this works, I still get the error locally when callling lintr::lint_package() with the following .lintr file

    linters: with_defaults(object_name_linter = "CamelCase")
    
     lintr::lint(
      paste0(readLines(
      
      "https://raw.githubusercontent.com/mlr3learners/mlr3learners.fnn/2c7e9aee40bcc37f50d3d181af73c7a289c15faf/R/LearnerRegrFNN.R"
        ),
        collapse = "\n"
      ),
      linters = lintr::with_defaults(object_name_linter = "CamelCase"))
    #> Error in linters[[linter]](expr): attempt to apply non-function

    Created on 2020-03-20 by the reprex package (v0.3.0)

  3. russHyde commented on Mar 20, 2020

    @russHyde
    Collaborator

    The correct syntax for your needs is :

    lintr::lint(
      some_file,
      linters = lintr::with_defaults(object_name_linter = object_name_linter("CamelCase"))
    )
    

    and similarly in your .lintr:

    linters: with_defaults(object_name_linter = object_name_linter("CamelCase"))
    
  4. pat-s commented on Mar 20, 2020

    @pat-s
    Author

    Ugh, indeed! My bad. Thanks for helping out so quickly - this was driving me nuts 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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