3

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 RStudio.

Note: the RStudio project is below the top level of the git repo. Perhaps that means lintr in RStudio won't look in parent directories? What's the right thing to do then? Soft-link it into the project directory?

EDIT: To reproduce:

  • create a project in RStudio from a directory called proj1
  • make a file foo.R with a lint violation: a=1
  • run lintr::lint('foo.R') in the RStudio console to see the lint errors
  • make a .lintr in proj1 that turns off the lintr: exclusions: ('foo.R')
  • run lintr::lint('foo.R') in the RStudio console to see the error goes away
  • move .lintr one directory up (outside of the project, but in a parent directory)
  • run lintr::lint('foo.R') in the RStudio console to see the lint problems returned

EDIT 2: I ended up soft-linking the top-level .lintr in every directory where I need it.

FYI my lintr version is 1.0.3 and R version is 3.5.2.

dfrankow
  • 20,191
  • 41
  • 152
  • 214
  • 2
    The [code to find the config](https://github.com/jimhester/lintr/blob/1a7114b87c4d672772c74ffc30c932dcdb3ce017/R/settings.R#L59) seems to walk up parent directories till it finds a match. Are you sure it's not working when it's in the main repo directory? Can you provide some sort of reproducible example? – MrFlick Feb 24 '20 at 20:28
  • 1
    "Works for me" on Linux. (We had another issue with ESS which for a while ignored a `~/.lintr` file.) – Dirk Eddelbuettel Feb 24 '20 at 20:46
  • @MrFlick Thanks for trying to reproduce. I added more explicit instructions to reproduce the problem. It must be run inside RStudio. – dfrankow Feb 24 '20 at 22:31

0 Answers0