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

Documentation issue in exclusions #1413

Closed
jabenninghoff opened this issue Jun 18, 2022 · 2 comments · Fixed by #1417
Closed

Documentation issue in exclusions #1413

jabenninghoff opened this issue Jun 18, 2022 · 2 comments · Fixed by #1417
Labels
bug an unexpected problem or unintended behavior

Comments

@jabenninghoff
Copy link

Even after the documentation fix for #1401, when using the 3.0.0 CRAN release of lintr, implementing the example in https://lintr.r-lib.org/articles/lintr.html#excluding-lines-via-the-config-file results in an unexpected error:

linters: linters_with_defaults(
    line_length_linter(100) 
  )
exclusions: list(
    "bad.R" = list(
      1, # global exclusions are unnamed
      line_length_linter = 4:6
    )
  )

Error message when running lint_dir():

$ Rscript -e 'lintr::lint_dir(".")'
Error in file_exclusion[[names2(file_exclusion) == ""]] : 
  attempt to select less than one element in integerOneIndex
Calls: <Anonymous> ... drop_excluded -> vapply -> FUN -> is_excluded_file -> %in%
Execution halted

To reproduce: run Rscript -e 'lintr::lint_dir(".")' from a directory containing the .lintr file above, and the following bad.R:

tmp = "value"

# regular comment
# really long comment ............................................................................................................
# really long comment ............................................................................................................
# really long comment ............................................................................................................
# regular comment
@jabenninghoff
Copy link
Author

This appears to be a bug specific to lint_dir(). The following command works with no issues:

$ Rscript -e 'lintr::lint("bad.R")'

@AshesITR AshesITR added the bug an unexpected problem or unintended behavior label Jun 19, 2022
@AshesITR
Copy link
Collaborator

Thanks for your testing. The bug you found is triggered whenever exclusions: in the .lintr config contains more than one instruction for a single file.
The only workaround I see is to put some of the exclusion directives directly into the file using nolint comments.

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