Skip to content

file-specific linter exclusions error #1442

Closed

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.

Activity

  1. added
    bugan unexpected problem or unintended behavior
    on Jul 5, 2022
  2. russHyde commented on Jul 5, 2022

    @russHyde
    CollaboratorAuthor

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

  3. russHyde commented on Jul 5, 2022

    @russHyde
    CollaboratorAuthor

    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
    
  4. AshesITR commented on Jul 11, 2022

    @AshesITR
    Collaborator

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

  5. russHyde commented on Jul 12, 2022

    @russHyde
    CollaboratorAuthor

    Thanks. This works great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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