Skip to content

Consistency fuzz testing? #2191

Open
Open
@MichaelChirico

Description

@MichaelChirico

One concern I have about the consistency cleanups in this release (#2039, #2046, #2190) is there's no mechanism to ensure future improvements/new linters continue to keep "up to code" & enforce the same consistency.

One approach that seems doable is to have a GHA that fuzzes our test suite. For example, for #2190, that means:

  • Go through the suite and identify all expect_lint() calls using "function(...)" or \(...) in the content= argument (text matching should be enough, but we could also use getParseData() here...).
  • Randomly (or exhaustively?) switch all such usages to their opposite: s/function/\/g and s/\/function/g
  • Run the test suite
  • Any test failure means a linter is inconsistently handling function(...) and \(...)

Similar fuzzes could apply in the other cases:

  • Randomly swap %>% and |>
  • Randomly swap $ and @

Some exceptions will need to be carved out, e.g. for cases where intentionally only one alternative is meant to be linted, and we might need some work to make the fuzzing robust to changes in an expected lint message. But overall this approach seems pretty doable to me.

If run with randomness, I'd also run it periodically, not on push/merge, since a failure might not be caught up-front & surfacing that failure on "someone else's" PR would be bad form.

Metadata

Metadata

Assignees

No one assigned

    Labels

    automation 🤖internalsIssues related to inner workings of lintr, i.e., not user-visibletesting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions