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

Some linters get garbled metadata with "unexpected" comments #2826

Open
MichaelChirico opened this issue Mar 10, 2025 · 0 comments
Open

Some linters get garbled metadata with "unexpected" comments #2826

MichaelChirico opened this issue Mar 10, 2025 · 0 comments
Labels
bug an unexpected problem or unintended behavior lint-metadata

Comments

@MichaelChirico
Copy link
Collaborator

As fixed in #2822, here are some failures on main:

expect_lint(
  trim_some("
    !(x #
    > y)
  "),
  rex::rex("Use x <= y, not !(x > y)"),
  comparison_negation_linter()
)
# check #1: message "Use x NA y, not !(x x#>y y)." did not match "Use x <= y, not !\\(x > y\\)"

expect_lint(
  trim_some("
    ifelse(2 + p + 104 + 1 #comment
    > ncols, ncols, 2 + p + 104 + 1)
  "),
  rex::rex("pmin(x, y) is preferable to ifelse(x > y, y, x)"),
  ifelse_censor_linter()
)
# check #1: message "pmin(x, y) is preferable to ifelse(x #comment y, y, x)." did not match "pmin\\(x, y\\) is preferable to ifelse\\(x > y, y, x\\)"

expect_lint(
  trim_some("
    all(nchar(x) #comment
    == 0L)
  "),
  rex::rex("Use !nzchar(x) instead of nchar(x) == 0"),
  nzchar_linter()
)
# check #1: message "NAWhenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default." did not match "Use !nzchar\\(x\\) instead of nchar\\(x\\) == 0"

expect_no_lint(
  trim_some("
    if (TRUE) {
      x | y
    }
  "),
  vector_logic_linter()
)
# check #1: message "Use `#` in subsetting expressions." did not match "Use `&` in subsetting expressions"
@MichaelChirico MichaelChirico added bug an unexpected problem or unintended behavior lint-metadata labels Mar 10, 2025
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 lint-metadata
Projects
None yet
Development

No branches or pull requests

1 participant