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
Update rubocop to latest with Ruby 2.2 support #233
Conversation
😦 way too many builds. A bit tired so was thrashing trying to get the travis config working. Now that things are green, I'm grabbing a few hours of sleep and will get this cleaned up in the AM. Also, I'm temporarily dumping the parallel-vs-sequential assignment and symbol-to-proc-vs-block benchmarks to stdout in the I skimmed the benchmarks and it looks like the general trends are:
There were a lot of numbers to skim over tonight, but I think the benchmarks show that sequential vs parallel assignment really doesn't matter much for us. So we can disable that cop and use what seems best for the situation. As for the block vs symbol-to-proc, we just need to decide if / when we are going to start following the optimizations for the newer Rubies. Thoughts? /cc @rspec/rspec |
This also updates the travis setup to use the latest bundler. Travis currently defaults to Bundler version 1.7.4, however, this bundler version does not support the `platform: :ruby_22` configuration setting. So we need to tell travis to install a more recent bundler. Also, `platform: :ruby_19` applies to **both** 1.9.2 and 1.9.3. But Rubocop stopped supporting 1.9.2. Thus we need to check the `RUBY_VERSION` in our `Gemfile` and not attempt to install Rubocop specifically for 1.9.2. Unfortunately, this bundler does not work with JRuby (2.0 mode), but does work with JRuby 1.8 mode. So we need to update the config to ignore JRuby 2.0. However, the current config incorrectly assumes we can do that by checking the `JRUBY_OPTS` environment variable. Travis actually sets this be default on _all_ systems: http://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables However, we can check the Ruby version we pass into the travis matrix by using the `TRAVIS_RUBY_VERSION` and seeing if it equals "jruby".
lib/rspec/support/ruby_features.rb:9:7: C: Outdent access modifiers like module_function. module_function ^^^^^^^^^^^^^^^ lib/rspec/support/ruby_features.rb:24:7: C: Outdent access modifiers like module_function. module_function ^^^^^^^^^^^^^^^ lib/rspec/support/ruby_features.rb:48:7: C: Outdent access modifiers like module_function. module_function ^^^^^^^^^^^^^^^
lib/rspec/support/spec/string_matcher.rb:7:1: C: Extra empty line detected at block body beginning.
02daf44
to
6761718
Compare
The check name is a little misleading. The check really is more: "`returned` called from inside a block". Given RSpec's DSL syntax and our heavy block usage, from which calling `return` is valid, this is being turned off.
lib/rspec/support/caller_filter.rb:72:23: C: Operator *= should be surrounded with a single space. increment *= 2 # The choice of two here is arbitrary. ^^ lib/rspec/support/method_signature_verifier.rb:98:48: C: Operator + should be surrounded with a single space. @max_non_kw_args = @min_non_kw_args + optional_non_kw_args ^
This raises the code metric thresholds for perceived complexity and assignment branch conditionals. These are only meant to be temporary settings to ignore the existing offenses. We fully intend to reduce these over time.
We have not decided how we are going to handle the symbol to proc vs block implementations. This is because the block is faster on Ruby 1.8.7, REE, and JRuby but slower on Ruby 1.9.2 through 2.2.2.
lib/rspec/support/version_checker.rb:8:9: C: Do not use parallel assignment. @library_name, @library_version = library_name, library_version ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6761718
to
d26a58b
Compare
This is good to go. |
# Note this doesn't work on JRUBY 2.0.0 mode so we don't do it | ||
- if [ -z "$JRUBY_OPTS" ]; then gem install bundler -v=1.5.3 && alias bundle="bundle _1.5.3_"; fi | ||
- if [ "jruby" != "$TRAVIS_RUBY_VERSION" ]; then gem install bundler; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't do the same thing, can we now safely use the later version of bundler on JRuby?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment above states that the older version of bundler is necessary due to an issue which is fixed. Though now I see that the default bundler on Travis, 1.7.4, doesn't contain the fix. So I can adjust this to support both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I'm not sure there is anything to change. The comment was stating that we weren't running the custom lower bundler version on JRuby, so it was supposed to be using the Travis default of 1.7.4. Am I missing something here?
Good work on the benchmarks, but shouldn't we be doing the config via rspec-dev as its centralised? Also I disagree with one of the style changes but I'm willing to go with the majority obviously :) |
Bumping rubocop will cause all the builds to fail. We've opened up PRs on all repos that have these fixes as a stop-gap so the new cops can be configured and fixes made. I am going to have a PR open for rspec-mocks tonight, and a PR for rspec-dev with the "master" changes; which I plan to push out after the PRs get merged in so that the build stays happy. |
Yeah but we can open the PRs from rspec-dev with the bump and then fix them in those PRS |
bac55b1
to
d26a58b
Compare
@JonRowe do you think fix conflicts in a new PR (from this one) could be a good idea? I can work on it. It seems lot's of things have change since. Maybe it can be close? |
@benoittgt feel free to take a shot at rebasing this |
Closing for now. In favor of #350 |
…pec/rspec-support#350) Updated rubocop rules see: rspec/rspec-support#350 --- This commit was imported from rspec/rspec-support@0953e54.
This updates Rubocop from 0.23.0 to 0.32.1 (most recent).
Unfortunately, in order to support this new version, which includes several bug fixes and support for Ruby 2.2, we need to drop support on Ruby 1.9.2. In fact Rubocop dropped 1.9.2 support as of version 0.25.0.
Some additional new cops are now available:
There are three additional new cops but they have been disabled (these settings should be ported to rspec-dev as part of the project defaults):
Lint/NonLocalExitFromIterator
This has been disabled due it's inability to distinguish between when / where
return
is sent from within a block. For example, a DSL block which has an explicit return in a method definition triggers this cop:Style/ParallelAssignment
Rubocop suggested this because it believed that parallel assignment was slower than sequential assignment. Unfortunately the benchmark they reference is flawed due to how Ruby handles implicit returns. It turns out that parallel assignment is faster.
Style/StringLiteralsInInterpolation
We previously disabled the related cop Style/StringLiterals. We simply don't care about single vs double qoutes.
See also: rspec/rspec-dev#134