Skip to content

expect_comparison_linter() gets bad metadata for faulty expect_true() usage #2083

Closed

Description

@MichaelChirico

Came across this:

expect_true(is.count(n_draws), n_draws > 1)

This throws expect_comparison_linter(), but gives a bad message:

lint(
  text = "expect_true(is.count(n_draws), n_draws > 1)",
  linters = expect_comparison_linter()
)
<text>:1:1: warning: [expect_comparison_linter] NA(x, y) is better than expect_true(x ( y).
expect_true(is.count(n_draws), n_draws > 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Maybe we shouldn't invest in doing anything here since expect_true()'s been used incorrectly, but certainly it's not a helpful lint message.

Activity

  1. AshesITR commented on Aug 13, 2023

    @AshesITR
    Collaborator

    Can the bug be triggered by a valid usage like

    expect_true(info = "my info first", a > b)

    ?

    If so, I think putting a more robust XPath in place to find the comparator is a good idea.

  2. added this to the 3.1.2 milestone on Oct 12, 2023
  3. MichaelChirico commented on Dec 9, 2023

    @MichaelChirico
    CollaboratorAuthor
    expect_true(info = "my info first", a > b)

    this doesn't lint, it's unusual enough that I would wait for a request first before supporting that.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions