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
Extract Performance Cops into a separate gem #5977
Comments
Agreed. Language level optimizations also suffer from being subject to the current VM implementation. So a big task for whoever wants to take this would be to benchmark on every Ruby version and see that the improvements still hold. |
Although they just extract it as-is in the beginning and improve things later. Probably performance cops should have explicit versions on which they make sense as part of their config. |
Extracting as it is into a gem seems simple enough. I could handle this one if nobody is on it yet. I also like the idea of showing instructions on how to add the gem if they have performance cops in their configs, the same way you suggested on #5976. |
@gizotti Happy to hear this! I've created a placeholder repo for the extraction https://github.com/rubocop-hq/rubocop-performance |
@bbatsov can you just add a README on the repo please? I can't fork an empty repo :) |
Done. |
Oh darn, I didn't see that you wanted to take this on @gizotti. I opened rubocop/rubocop-performance#1 but maybe we can work together on it. If you are already further along than I was, I can also just close the PR. I should have checked the issue again before doing anything. |
No worries @composerinteralia, I got to where you were last night so not reason to push my stuff if you already did. |
I'm investigating the same git history problem as the current RuboCop Rails repository. The current situation is below. |
@bbatsov @composerinteralia I extracted The following branch including previous work done in RuboCop Performance repo, and it is synchronized with the latest performance cops of RuboCop Core. If it's OK, force-push this branch to master of RuboCop Performance repo. After that, we can restart work based on this git history for this issue. 📝 @amatsuda told me the experiecce that how to divided Kaminari repo at Asakusa.rb. So I was able to obtain great knowledge. Thank you! |
Yeah, it's OK. Make this happen! P.S. Great work, probably should document the process somewhere for future reference. |
Thanks! I force-pushed it. |
@bbatsov Thank you for waiting. We can release the rubocop-performance gem. We need to decide on the rubocop-performance version to be released. The version number should be a number greater than 0.61. Also, I'm ready to remove performance cops from rubocop-hq/rubocop repo, but before that we need to notify the users in some way. Anyway, it is good to release the rubocop-performance gem. |
Fantastic work! Let's go with version 1.0 for |
Let's just add some message that say on |
Thank you for the advice! |
👍 |
Follow up of rubocop/rubocop#5977 (comment). This PR prepares for release 1.0.0.
rubocop-performance 1.0.0 has been released 🚀 |
Fantastic! I'll make an announcement once we've made the necessary changes to RuboCop itself. |
Fixes #5977. This PR removes Performance cops from RuboCop core. These cops were transferred to rubocop-hq/rubocop-performance repository. https://github.com/rubocop-hq/rubocop-performance
Performance cops will be extracted from RuboCop to RuboCop Performance when next RuboCop 0.68 will be released. rubocop/rubocop#5977 RuboCop 0.67 is its transition period. Since rails/rails repository uses Performance cops, This PR added rubocop-performance gem to Gemfile. And this PR fixes some offenses using the following auto-correct. ```console % bundle exec rubocop -a Offenses: activerecord/test/cases/connection_adapters/connection_handlers_multi_db_test.rb:212:26: C: [Corrected] Layout/SpaceAroundOperators: Operator = > should be surrounded by a single space. "primary" => { adapter: "sqlite3", database: "db/primary.sqlite3" } ^^ activerecord/test/cases/connection_adapters/connection_handlers_multi_db_test.rb:239:26: C: [Corrected] Layout/SpaceAroundOperators: Operator => should be surrounded by a single space. "primary" => { adapter: "sqlite3", database: "db/primary.sqlite3" } ^^ actionview/test/template/resolver_shared_tests.rb:1:1: C: [Corrected] Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true. module ResolverSharedTests ^ actionview/test/template/resolver_shared_tests.rb:10:33: C: [Corrected] Layout/SpaceAroundEqualsInParameterDefault: Surrounding space missing in default value assignment. def with_file(filename, source="File at #{filename}") ^ actionview/test/template/resolver_shared_tests.rb:106:5: C: [Corrected] Rails/RefuteMethods: Prefer assert_not_same over refute_same. refute_same a, b ^^^^^^^^^^^ 2760 files inspected, 5 offenses detected, 5 offenses corrected ```
Performance cops were moved out in to their own gem in Rubocop 0.68[1], which means that referring to them logs a warning like: `Warning: unrecognized cop Performance/Casecmp found in …` Remove the reference to the performance cop to resolve this. Note that it may negatively impact users who do not upgrade to 0.68, as this previously disabled Performace cop will now be enabled until they upgrade to 0.68. [1]: rubocop/rubocop#5977
Performance cops were extracted in rubocop/rubocop#5977 and @koic updated to 0.67.2 and added the rubocop-performance gem in rails#35989. This bumps rubocop to 0.68.1 to be on the latest version. Two changes were made in regards to the bump of the version: * The first was that Layout/FirstParameterIndentation was renamed to Layout/IndentFirstArgument. These changes can be seen in rubocop/rubocop#6982 and rubocop/rubocop#6987 * The second was that a new instance of the Style/HashSyntax cop was found. I updated that instance to follow the new Ruby >= 1.9 syntax.
These cops are no longer available in core rubocop. rubocop/rubocop#5977
These cops are no longer available in core rubocop. rubocop/rubocop#5977
This should have the same result. The extra gem is because this rubocop-performance functionality was extracted from the main gem and needed to be added back in. More info is in rubocop/rubocop#5977
This should have the same result. The extra gem is because this rubocop-performance functionality was extracted from the main gem and needed to be added back in. More info is in rubocop/rubocop#5977
This should have the same result. The extra gem is because this rubocop-performance functionality was extracted from the main gem and needed to be added back in. More info is in rubocop/rubocop#5977
I've just realised that you used cherry-pick to keep the history in the extracted extension. |
👍 That's what I used to extract |
@pirj Looks pretty cool! Thanks for sharing it! |
@pirj 👍 I can't remember what was wrong, I remember giving up on |
Follow up of rubocop/rubocop#5977 (comment). This PR prepares for release 1.0.0.
Follow up of rubocop/rubocop#5977 (comment). This PR prepares for release 1.0.0.
Follow up of rubocop/rubocop#5977 (comment). This PR prepares for release 1.0.0.
Follow up of rubocop/rubocop#5977 (comment). This PR prepares for release 1.0.0.
Performance cops have to extracted into a standalone gem (named something like rubocop-performance or whatever).
The reason for this decision is simple. I want RuboCop to be focused just on Ruby and have no framework/library/runtime dependant pieces for the sake of being easier to focus on evolving it. Creating more extensions should also help us come up with a good official API for them. Performance cops are all MRI focused and are highly dependent of the version of MRI you're using, so they don't belong in the core RuboCop.
Any volunteers to do this? I was always ambivalent towards the performance checks (as they often come at the expense of readability), so I'm not particularly interested in working on this.
The text was updated successfully, but these errors were encountered: