Questions tagged [lintr]

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

Github repo

32 questions
1
vote
0 answers

How to set tab size equivalent of 4 spaces in .lintr configuration file?

I use ESS in Emacs for R development. No matter for what programming language (R, Rust, Python, etc.) I always set 4 spaces as a tab via a general setting in my Emacs init file : (setq-default indent-tabs-mode nil) (setq-default tab-width…
user17911
  • 1,073
  • 1
  • 8
  • 18
1
vote
1 answer

lines should not be more than 80 characters. lint_length_linter; Use <-, not =, for assignment.assignment_linter

I use R in vscode, it throw many notes with blue wavy underlines, such as 'lines should not be more than 80 characters. lint_length_linte', 'Use <-, not =, for assignment.assignment_linter'. Creating a '.lintr ' file in the project work for this…
1
vote
1 answer

lintr package - check without roxygen documentation

I'm using lintr package to check for inconsistency with tidyverse coding standards in my package. However, the problem I'm dealing with, is that lintr package raises issues with exceeding 80 character per line even in roxygen documentation which I…
John
  • 1,849
  • 2
  • 13
  • 23
1
vote
1 answer

Exclude source file line range from a single lintr (NOT all lintr)

To check the code quality of my package I am using the package lintr using the command lintr::lint_package() and get one result that I want to ignore: functions should have cyclomatic complexity of less than 15 How can I ignore this single "false…
R Yoda
  • 8,358
  • 2
  • 50
  • 87
1
vote
1 answer

Setting up lintr with CI

I've been unsucessfully trying to setup lintr package with GitHub actions (circleCi would be good too, since it's a private repo) to check PR and pushes. My project is a book so i don't need package build checks, but only enforcing style since…
Alberson Miranda
  • 1,248
  • 7
  • 25
1
vote
0 answers

object_usage_linter marks wrong line with no visible binding message

Consider the following code snippet (comments at the end indicate line numbers and are not part of the problem): set.seed(1) # 1 my_dat1 <- data.frame(x = runif(100, 1, 10), # 2 w = runif(100,…
thothal
  • 16,690
  • 3
  • 36
  • 71
1
vote
2 answers

How to get non-zero exit status with lintr::lint() in order to fail a build

I am trying to help our group of developers obtain similar code styles by using the lintr package when writing R code. To automate this step, I want our builds to fail if there are any mistakes (bad styles) in the code. We are using Jenkins for our…
Thomas
  • 214
  • 1
  • 11
1
vote
2 answers

How to export lintr output to a file?

I am writing some scripts in R and our standard is use lintr for standardization of the code. Please advice how can I export the output of the lint function to a txt file for example. Thanks in advance!
Steves
  • 39
  • 1
  • 8
1
vote
1 answer

lintr no visible binding for global variable ‘.SD’

lintr throws error while using data.table functions like .SD, .SDcols, e.g: /path/readData.R:130:29: warning: no visible binding for global variable ‘.SD’, Did you mean 'SSD'? DT[, "row.sum" := rowSums(.SD), .SDcols = names(DT)] …
Taz
  • 5,755
  • 6
  • 26
  • 63
1
vote
1 answer

Specify linters in lintr::lint

I cannot figure out how to turn off specific linters using lintr. The documentation offers an example (for vim/syntastic, which is what I'm using), which is not very clear: let g:syntastic_r_lintr_linters =…
Jesse Anderson
  • 4,507
  • 26
  • 36
0
votes
0 answers

Is there a way to stop object_*_linter from applying to string literals?

object_name_linter and object_length_linter are both applying to any string literal and not just object names. I didn't expect it to apply to all strings (including file names, labels, or messages printed out). Am I missing something, or should I…
0
votes
1 answer

Removing wavy warnings about long lines in R-VSCode

I am running R in Visual Studio Code. I would like to get rid off the Lines should not be more than 80 characters.line_length_linter warnings marked as wavy underlines. I would like to get a global effect so that the warnings are removed from all R…
Imsa
  • 69
  • 4
0
votes
1 answer

lintr fails to load in RStudio

I am unable to get lintr to work in RStudio. Any suggestion appreciated. I believe I have updated everything. (For context, I am a newbie. I could certainly be doing something dumb.) Here's what happens to me: > library(lintr) Error: package or…
Startz
  • 11
  • 1
0
votes
1 answer

lintr test passes with devtools::check() and fails with devtools::test()

I am writing an R package with the following lint test: context("Require no code style errors") library(lintr) test_that("Package has no lintr errors", { lintr::expect_lint_free() }) The tests pass with `devtools::check(): $ Rscript -e…
miguelmorin
  • 5,025
  • 4
  • 29
  • 64
0
votes
1 answer

lintr keyboard shortcut rstudio

I am having a problem with the R package lintr I installed it install.packages("lintr") and everything works fine, the markers pane appears in RStudio and I can 'lint' R files e.g. like this lintr::lint("model_Forecast.R") Now typing this is…
Steffen Moritz
  • 7,277
  • 11
  • 36
  • 55