Questions tagged [lintr]

Static code analysis for R mostly based on Hadley Wickham's R Style Guide.

Github repo

32 questions
15
votes
2 answers

anyone know why lintr is marking the first string of my jupyter r kernels in red?

i just set up R to work with Jupyter notebooks in vscode but it is marking the first string of my kernels in red. The message I get is: Failed to run diagnostics: ! error in callr subprocess Caused by error: ! Full file exclusions must be…
Matt Park
  • 151
  • 5
6
votes
1 answer

Why are sapply() and options() "undesirable"?

Jim Hester's "lintr" package contains many different linters for R. The README for the package describes one of the linters in this way: undesirable_function_linter: report the use of undesirable functions, e.g. options or sapply and suggest an…
user697473
  • 2,165
  • 1
  • 20
  • 47
6
votes
1 answer

testthat with lintr::expect_lint_free() fails with devtools::check() but works with devtools::test()

This test in my package works fine with devtools::test(). Also the online Travis build is going well. test_that("Package style", { lintr::expect_lint_free() }) However, with devtools::check() it fails. The error message is invalid 'path'…
Willy
  • 497
  • 3
  • 10
3
votes
0 answers

Customize R linters in VSCode

I'm trying to customize the linter settings in VSCode for R but I'm a little confused. I've checked just about every source available, from SO questions to the lintr package vingette, but I'm stumbling on an issue. It could be that since I'm not a…
hmhensen
  • 2,974
  • 3
  • 22
  • 43
3
votes
0 answers

devtools::check() noting .lintr as a hidden file and directory

When I run devtools::check(), my build is noting my .lintr (located in the root directory) as being a hidden file most likely included in error. Is there anyway to prevent this from being noted on a check? It was not included in error, I need it to…
Dylan Russell
  • 936
  • 1
  • 10
  • 29
3
votes
0 answers

Where can the .lintr config file be located?

The R package lintr checks files for "lint" (errors or style violations). It can be configured with a .lintr file. Where can that file be located? I was hoping to put it at the top of my git repo, but that doesn't seem to be working when I run in…
dfrankow
  • 20,191
  • 41
  • 152
  • 214
3
votes
0 answers

.Renviron getting overwritten by globalVariables

Let's say I have a function in my package my_fn <- function() { mtcars_dt <- data.table::data.table(mtcars) mtcars_dt[, mpg_div_hp := mpg / hp] mtcars_dt } In my .Renviron I have the setting…
nathaneastwood
  • 3,664
  • 24
  • 41
3
votes
2 answers

Why does lintr say "warning: no visible binding for global variable ‘Cloaked’"?

I'm sure that this is a misunderstanding of mine, since I'm not really an R programmer... I have my code here: https://gist.github.com/bnsh/3839c4eb2c6b31e32c39ec312014b2b8 #! /usr/bin/env Rscript library(R6) Cloaked <- R6::R6Class("Cloaked", …
bnsh
  • 800
  • 2
  • 6
  • 20
3
votes
2 answers

Lintr - is there a way to suppress capitalised data frame column name warnings?

I've been writing an R package and using lintr to tidy it up stylistically. One problem I am seeing a lot is that my data.frame columns are named from the CSV and are capitalised, e.g. MyVariableName. This is outside my control and outputted data…
Andrew Hill
  • 307
  • 2
  • 12
3
votes
0 answers

Generate SQALE Rating from Lintr (for the R Language)

Is it possible to generate SQALE rating (or Maintainability Rating in sonarqube speak) out of the lintr result or is there any other tool to do this for the R language?
David Tam
  • 485
  • 5
  • 13
2
votes
1 answer

No visible global function definition/no visible binding for global variable in a project?

I'm working with R in VS Code, using the R Extension. I do almost all of my project work using targets, which means that my package imports and functions are usually in separate files. A simple example would be working in a folder which looks…
Taren Sanders
  • 421
  • 2
  • 12
2
votes
1 answer

How to make azure devops build fail when R linting issues occur

I am using lintr library in R to find linting issues in the code. I put them into an xml format like this:
Wanderer
  • 21
  • 3
2
votes
0 answers

how to add non failing lintr checks in tic.R

I would like to add non failing lintr checks to my (TravisCI-based) CI via tic. (Initially I implemented the testthat approach but it is too bothersome for development.) The lintr documentation provides an example for .travis.yml after_success: -…
espinielli
  • 666
  • 1
  • 6
  • 19
2
votes
1 answer

Import from `.` `data.table` so that lintr recognizes it

When running lintr on an R function that uses data.table I get the following warning: warning: no visible global function definition for '.', Did you mean '-'? I thought an easy fix would be adding importFrom data.table .. I also tried quoting…
Bob Jansen
  • 1,215
  • 2
  • 12
  • 31
2
votes
1 answer

How does one enable lintr with Visual Studio Code

As the title says... I've installed the R extension for VSC. Every time I save an .R file in VSC, I get a popup that says lintr is not installed (it most certainly is; I've been using it). If click the install button the terminal confirms that lintr…
Adam Hoelscher
  • 1,804
  • 2
  • 17
  • 33
1
2 3