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-specific linter exclusions error #1442

Closed
russHyde opened this issue Jul 5, 2022 · 4 comments · Fixed by #1447
Closed

file-specific linter exclusions error #1442

russHyde opened this issue Jul 5, 2022 · 4 comments · Fixed by #1447
Labels
bug an unexpected problem or unintended behavior

Comments

@russHyde
Copy link
Collaborator

russHyde commented Jul 5, 2022

I have a package with ./tests/testthat/test-style.R and R/style.R and am trying to use the file/linter-specific exclusion setup described here: https://lintr.r-lib.org/articles/lintr.html#excluding-files-completely

If I have a .lintr config at package-root with the contents:

linters: linters_with_defaults()                                                                                             
exclusions: list(                                                                                                                    
    "tests/testthat/test-style.R" = list(semicolon_linter = Inf)                                                                                           
  )

The following error arises:

Error in file_exclusion[[names2(file_exclusion) == ""]] : 
  attempt to select less than one element in integerOneIndex

This results from the following call (from lintr::lint_dir):

path <- "/home/me/blah"
files <- file.path(path, c("R/style.R", "tests/testthat.R", "tests/testthat/test-style.R"))
exclusions <- list(list(semicolon_linter = Inf))
names(exclusions) <- file.path(path, "tests/testthat/test-style.R")

lintr:::drop_excluded(files, exclusions)
#> Error in file_exclusion[[names2(file_exclusion) == ""]] : 
#>   attempt to select less than one element in integerOneIndex

Apologies if I've misunderstood this new exclusions syntax.

@russHyde russHyde added the bug an unexpected problem or unintended behavior label Jul 5, 2022
@russHyde
Copy link
Collaborator Author

russHyde commented Jul 5, 2022

I note that someone has raised a related issue in #1413

@russHyde
Copy link
Collaborator Author

russHyde commented Jul 5, 2022

Using current lintr-master (1a170f5) on the same R package

lintr::lint_package()
Error in file_exclusion[[which(names2(file_exclusion) == "")]] : 
  attempt to select less than one element in get1index

@AshesITR
Copy link
Collaborator

Thanks for reporting. Can you test #1447 on your package just to be sure the bug is squashed for good?

@russHyde
Copy link
Collaborator Author

Thanks. This works great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants