Skip to content

New unnecessary_lambda_linter - #1541

Merged
AshesITR merged 22 commits into
mainfrom
anon
Sep 30, 2022
Merged

AshesITR merged 22 commits into
mainfrom
anon

Conversation

@MichaelChirico

@MichaelChirico MichaelChirico commented Sep 20, 2022 •

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Collaborator Author

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

open to ideas

@IndrajeetPatil

Copy link
Copy Markdown
Contributor

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

How about unnecessary_lambda_linter()?

@MichaelChirico

Copy link
Copy Markdown
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
Copy Markdown
Contributor

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

@AshesITR AshesITR left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread R/unnecessary_lambda_linter.R Resolved
Comment thread R/unnecessary_lambda_linter.R Resolved
@MichaelChirico

Copy link
Copy Markdown
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
Copy Markdown
Collaborator

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

Otherwise looks good so far

@MichaelChirico

Copy link
Copy Markdown
Collaborator Author

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

@AshesITR

Copy link
Copy Markdown
Collaborator

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

@MichaelChirico

Copy link
Copy Markdown
Collaborator Author

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

@MichaelChirico

Copy link
Copy Markdown
Collaborator Author

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

@AshesITR
AshesITR merged commit a69d935 into main Sep 30, 2022
@AshesITR
AshesITR deleted the anon branch September 30, 2022 04:39
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