Skip to content

unnecessary_lambda_linter() misses '!' when suggesting removing a lambda #2742

@MichaelChirico

Description

@MichaelChirico
lint(text = "sapply(x, function(xi) !all.equal(xi, y))", linters = unnecessary_lambda_linter())
# <text>:1:11: warning: [unnecessary_lambda_linter] Pass all.equal directly as a symbol to sapply() instead of wrapping it in an unnecessary anonymous function. For example, prefer lapply(DF, sum) to lapply(DF, function(x) sum(x)).
# sapply(x, function(xi) !all.equal(xi, y))
#           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We could do sapply(x, Negate(all.equal), y), I think, but that's hardly a strict improvement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    false-positivecode that shouldn't lint, but does

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions