Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Exclusions Passed to lint_package() Not Ignored #304

Closed
stufield opened this issue Mar 20, 2018 · 1 comment
Closed

File Exclusions Passed to lint_package() Not Ignored #304

stufield opened this issue Mar 20, 2018 · 1 comment

Comments

@stufield
Copy link
Collaborator

@stufield stufield commented Mar 20, 2018

Hello Jim,

I've been running into an issue trying to lint a package while passing file exclusions via the .... From my understanding, the ... should be passed from lint_package() -> lint() -> exclude(), which is where I want my exclusions list() to end up. It's a little difficult to provide a reprex but here is an example.

library(lintr)
lint_package(".", exclusions = list("inst/examples/bad_lint.R"))

The problem is that the list of excluded files are not being ignored. I have traced the issue to lintr:::exclude(), and it stems from the fact that the filenames in the df object (e.g. df$filename[1]) are written as full absolute paths, whereas the filenames being passed via the ... are provided as relative path(s). So during the vapply() step, the filenames (paths) do not match, and it doesn't know to exclude these "matching" files (i.e. file %in% namex(excl) evaluates to FALSE).

To work around this I have been able to:

  1. use absolute paths in the original call, which is a bit tedious and doesn't appear to be what you had in mind considering the relative_path = argument defaults to TRUE.
  2. I saw in the package README.md where you suggest configuring with a .lintr file with the exclusions supplied there in Debian Control Format. This DOES work! The paths do not get misaligned, so it's a slightly different behavior with passing via the ...

Questions:

  1. Am I using lint_package with exclusions as you intended?
  2. I have some inconveniently long paths, so specifying relative paths (which from your examples you intended to be the case) would be ideal. Besides the package level config with .lintr, do you have any suggestions?

I realize there is a lot more going on under the hood, so I am sorry if this is not a simple work-around. I'd appreciate any advice. BTW, I absolutely love lintr, thank you so much for putting it together. I have been trying unify our group around common code style and practices for years ... I am hoping pre-commit hooks with lintr will get us there! ;)

Thank you so much,
Stu

@stufield
Copy link
Collaborator Author

@stufield stufield commented Mar 20, 2018

Issue has been resolved in the v1.0.2.9000 development version of lintr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant