Skip to content

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

Open
@MichaelChirico

Description

@MichaelChirico

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorlint-metadata

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions