Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extractions still being linted in unnecessary_lambda_linter() with explicit return #2258

Closed
MichaelChirico opened this issue Nov 8, 2023 · 2 comments · Fixed by #2278
Closed
Labels
false-positive code that shouldn't lint, but does regression code that used to work, but now doesn't
Milestone

Comments

@MichaelChirico
Copy link
Collaborator

lint("
  sapply(
    x,
    function(xi) {
      return(foo(xi)$bar)
    }
  )
", unnecessary_lambda_linter())
# <text>:4:5: warning: [unnecessary_lambda_linter] Pass foo 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)).
#     function(xi) {
#     ^~~~~~~~~~~~~~```
@MichaelChirico MichaelChirico added false-positive code that shouldn't lint, but does regression code that used to work, but now doesn't labels Nov 8, 2023
@MichaelChirico MichaelChirico added this to the 3.1.2 milestone Nov 8, 2023
@MichaelChirico
Copy link
Collaborator Author

Another test case:

apply(X, 1, function(x) {
  return(sum(x) == 0)
})

@MichaelChirico
Copy link
Collaborator Author

And another:

sapply(
  colnames(data.wide),
  function(nm) {
    return(data[match(nm, data[, by.var]), color.var])
  }
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false-positive code that shouldn't lint, but does regression code that used to work, but now doesn't
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant