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

Consolidate suboptimal usages of which() under one linter #1544

Closed
IndrajeetPatil opened this issue Sep 20, 2022 · 4 comments
Closed

Consolidate suboptimal usages of which() under one linter #1544

IndrajeetPatil opened this issue Sep 20, 2022 · 4 comments
Assignees
Labels
feature a feature request or enhancement new-linter

Comments

@IndrajeetPatil
Copy link
Collaborator

To lint for instances of which(x == min(x)) or which(x == max(x)), which should be avoided in favour of more efficient which.min() or which.max(), respectively.

Ref: https://csgillespie.github.io/efficientR/performance.html

Screenshot 2022-09-20 at 15 39 43

@IndrajeetPatil IndrajeetPatil added the feature a feature request or enhancement label Sep 20, 2022
@MichaelChirico
Copy link
Collaborator

Great observation!

I would rather name it which_optimum_linter(), or combine it with the pending which_grepl_linter() from #884 and just call it which_linter() more generally

@IndrajeetPatil
Copy link
Collaborator Author

Sounds like a plan! Thanks.

I guess I will wait for WhichGreplLinter to be ported over to {lintr} and then build on top of it to consolidate all of it into which_linter().

@IndrajeetPatil IndrajeetPatil changed the title Introduce unnecessary_which_linter() Consolidate suboptimal usages of which() under one linter Nov 5, 2024
@IndrajeetPatil IndrajeetPatil self-assigned this Nov 5, 2024
@MichaelChirico
Copy link
Collaborator

One issue I have here is which(grepl(.)) could either go under a which_linter() umbrella or a regex_linter() umbrella.

It's not clear to me how to prefer one or the other.

@IndrajeetPatil
Copy link
Collaborator Author

As astutely noted by @AshesITR, the two versions of the code in the original post aren't equivalent and therefore don't make a good candidate for a new linter. Pity.

#2684 (comment)

@IndrajeetPatil IndrajeetPatil closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement new-linter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants