Skip to content

Regular expression captures break expect_lint() #196

@fangly

Description

@fangly
> expect_lint("cat('hello')", "double-quotes", lintr::single_quotes_linter)
As expected

> expect_lint("cat('hello')", "double-quotes (with parentheses)", lintr::single_quotes_linter)
Error: Don't know how to convert 'data.frame' to expectation.

The first expect_lint() call behaves as expected. The second does not; it errors instead of reporting that the "message" does not match.

The problem in the second case is the presence of parentheses in the regular expression, which are interpreted as captures. Captures have no reasons to be used in this context and they cause trouble at expect_lint.R line 60 because re_matches then returns a data.frame instead of a logical. Potential solutions would be to somehow escape captures in "value" just before the call to re_matches, or to force re_matches to return a single logical.

Best,

Florent

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions