-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Performance cops #1677
Comments
and some more https://github.com/DamirSvrtan/fasterer :) |
Why use many tools to check your code when you can do this with just one? :-) All performance checks are pretty easy to implement, so we'll definitely add them to RuboCop at some point. Or at least the sensible ones - e.g. it is silly to compare |
I agree, rubocop could easily have performance checks. I think it's worth when it's pretty clear that it's a performance gain in any implementation of ruby. |
Maybe we should extract reasonable idioms from these tools and create issue for each of them? |
@palkan Yeah, it makes sense to have separate issues. I created this meta-issue just as a quick reminder. |
Why use many tools? Different tools have different purposes; the differences between SRP applies to tools, not just methods or classes. Cluttering up tools with laundry lists of tenuously-related features just introduces bloat and makes the tool easier to break and slower to run. Unix won the war that systems with one-executable-does-everything started precisely because of its use-the-smallest-right-tool-for-the-job mentality; this filtered through into numerous later systems. Having RuboCop be a tool that evaluates code against the Ruby Style Guide, with configurable overrides, is insanely useful. Adding auto-correct seemed to make sense, but how hard was/is it to get right, and how many users still run without it, preferring to manually update code? Adding more cruft will do just that; add more cruft to what started out as remarkably cruft-free code. If somebody really wants a single, fire-and-forget tool that calls out your style violations, chops vegetables and washes the dog, then consider a new "meta-tool" that runs what is now RuboCop, the new performance tools, and whatever other chrome tail-fins you care to throw into the box… but make each fully usable as a standalone tool for those who don't share the same preferences (or available runtime resources). And then explain how your new meta-tool has advantages over Rake and Thor and a long list of other tools in the Ruby omniverse that allow you to hook things up, too. (Maybe your meta-tool is a Thor script.) Don't fix what isn't broken. |
I understand your concerns, but on the other hand RuboCop currently represents pretty much the ultimate framework for implementing static code analysis in Ruby. Adding more checks adds little performance overhead and next to zero complexity to the codebase overall. I'm not saying we should start checking for uses of There will always be room for alternative tools, but when some task is a good fit for RuboCop I don't see why we shouldn't implement it. P.S. Some of the P.P.S. RuboCop stopped being the tool which simply enforced the style guide the moment we added the first configuration option. No amount of extra cops would ever offset the complexity which configuration brought to the table. But on the other hand the rich config options turned RuboCop into the de facto standard Ruby lint tool. |
Fine; I see where you're going with "the ultimate framework [for] implementing static code analysis in Ruby". I think I'd still (moderately) argue for a "meta", or driver, tool driving a set of "feature" executables (existing RuboCop, performance, etc). The counter to that, of course, is KISS. Not sure where you get the PPS from. Configuration merely affects how it does its job(s); not (at a conceptual level) what tasks it performs. But, as I said, fine; I'll just sit back down and enjoy the view. It has been a fantastic ride. 😄 |
This has actually been in my backburner for at least a year - there's rubocop-rspec and I've planned to extract rubocop-rails. Unfortunately, lately I've been extremely busy with other stuff and I'm not sure when/if this modularization will happen.
I'm probably more fond of KISS (and the SRP) than you are. But my personal preferences often do not agree with other people's preferences (
|
I think that RuboCop checking for performance improvements is a great idea. If we really wanted to get nit picky about SRP, then one could argue that RuboCop, as a single gem, currently does too much by checking metrics, lint, sytle, and rails. I have interest in this, and I would like to start working on a cop or two. |
@rrosenblum Go for it! |
Some more ideas: https://github.com/tcopeland/pippi And 👍 for modularizing RuboCop! |
Very happy to see these features being added to RuboCop. Thanks to @JuanitoFatas for taking the time to add these benchmarks to GitHub. |
Some which might still be added:
|
Totally - there's plenty of work to be done here. |
Btw, there's something else to consider here - some people dislike operators and favour
I believe there's already a cop for this. P.S. Another classic is |
I have a cop written for What is the replacement or more performant form of Another one to consider would be I have intentions of expanding the functionality of In a = b.to_a
a.count we would know that |
|
I think |
I may have discovered the problem with the |
That sounds very familiar. I think that is the issue that I ran into. I assume that the same issue exists for |
Yeah, I've actually given up on |
Guess we can close this. |
Here's a few ideas worth considering https://github.com/JuanitoFatas/fast-ruby
The text was updated successfully, but these errors were encountered: