Skip to content

file-specific linter exclusions error #1442

@russHyde

Description

@russHyde

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions