Skip to content

New unnecessary_lambda_linter #1541

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

Merged
merged 22 commits into from
Sep 30, 2022
Merged

New unnecessary_lambda_linter #1541

merged 22 commits into from
Sep 30, 2022

Conversation

MichaelChirico
Copy link
Collaborator

@MichaelChirico MichaelChirico commented Sep 20, 2022

Part of #884. Closes #1531.

cc @Bisaloo for viz.

WIP: I will have to add extra logic for customizing the lint message. Filing now for early feedback.

@MichaelChirico
Copy link
Collaborator Author

Looks like we'll need a new name -- 37 characters is too long 🫣

open to ideas

@IndrajeetPatil
Copy link
Collaborator

Looks like we'll need a new name -- 37 characters is too long

How about unnecessary_lambda_linter()?

@MichaelChirico
Copy link
Collaborator Author

How about unnecessary_lambda_linter()?

makes sense to me, but i wonder if less-experienced users will be confused by this name

@IndrajeetPatil
Copy link
Collaborator

makes sense to me, but i wonder if less-experienced users will be confused by this name

IMO, given the kind of users that use linter or know what lints are, I think we can safely assume that they either know what this means or have the wherewithal to figure it out on their own. Plus, the doc should help as well.

@MichaelChirico MichaelChirico changed the title New unnecessary_anonymous_function_linter New unnecessary_lambda_linter Sep 24, 2022
Copy link
Collaborator

@AshesITR AshesITR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should test multi-line functions and braces more thoroughly, especially the false negative case.

e.g.
lapply(1:10, function(x) { print(x) }), which should lint

and

lapply(1:10, function(x) { print(x); x^2 }), which should not lint.

@MichaelChirico
Copy link
Collaborator Author

I think we should test multi-line functions and braces more thoroughly

Great idea! Indeed caught some false negatives. Let's leave them for follow-up (#1567) -- false negatives are more tolerable than false positives.

@AshesITR
Copy link
Collaborator

Am I missing the positive braced test?
e.g. function(x) { is.data.frame(x) }.

Otherwise looks good so far

@MichaelChirico
Copy link
Collaborator Author

that's marked for follow-up (#1567), is that a blocker to merge?

@AshesITR
Copy link
Collaborator

Ah sorry I missed that issue. Is it referenced somewhere in the code or tests?

@MichaelChirico
Copy link
Collaborator Author

There wasn't! Just added, it slipped through the cracks.

@MichaelChirico
Copy link
Collaborator Author

@AshesITR need your approval now since the Changes requested is still pending

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

Successfully merging this pull request may close these issues.

New linter: discourage the use of anonymous functions for trivial cases
3 participants