Skip to content

Use partial matching for linter names in exclusion directives #1138

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

Merged
merged 9 commits into from
May 16, 2022

Conversation

AshesITR
Copy link
Collaborator

fixes #872

  • transitioned our internal # nolints to the short-hand notation
  • we raise a warning if no linter could be matched by an exclusion
  • documented the short-hand notation
  • added an example in the using_lintr vignette
  • added tests
  • extended NEWS bullet for Allow turning off specific linters per line #660

test_that("partial matching works for exclusions but warns if no linter found", {
read_settings(NULL)

expect_warning(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really the way to do multiple warning tests in testthat? oh boy 😂

the withCallingHandlers approach is not particularly nicer... maybe we need a helper. i've definitely written expect_warnings() before.

otoh, it seems like an intentional design decision that testthat has limited matching exactly one warning at a time:

https://testthat.r-lib.org/reference/expect_error.html

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, pretty bulky. I think they should allow to somehow vectorize on regexp so that multiple warnings each matching some regex are expected.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed r-lib/testthat#1625 as a suggestion

@MichaelChirico
Copy link
Collaborator

LGTM after small fix to reduce redundancy

@MichaelChirico MichaelChirico merged commit fceac40 into master May 16, 2022
@MichaelChirico MichaelChirico deleted the feature/872-nolint-pmatch branch May 16, 2022 20:38
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

Successfully merging this pull request may close these issues.

Remove redundant _linter suffix from auto names?
2 participants