Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 90fca7e

Browse files
committed
Merge pull request #2081 from rspec/rebased-bennacer860-rubocop
Rebased bennacer860 rubocop upgrade
2 parents 7477810 + 0eab115 commit 90fca7e

File tree

9 files changed

+70
-21
lines changed

9 files changed

+70
-21
lines changed

.rubocop.yml

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ AllCops:
66
- lib/rspec/core/backport_random.rb
77

88
# This should go down over time.
9-
ClassLength:
9+
Metrics/ClassLength:
1010
Max: 330
1111

1212
Encoding:
@@ -15,9 +15,24 @@ Encoding:
1515
- lib/rspec/core/formatters/exception_presenter.rb
1616

1717
# This should go down over time.
18-
LineLength:
18+
Metrics/AbcSize:
19+
Max: 40
20+
21+
# This should go down over time.
22+
Metrics/LineLength:
1923
Max: 130
2024

25+
# This should go down over time.
26+
Metrics/MethodLength:
27+
Max: 40
28+
29+
# This should go down over time.
30+
Metrics/CyclomaticComplexity:
31+
Max: 12
32+
33+
Metrics/PerceivedComplexity:
34+
Max: 15
35+
2136
Lint/HandleExceptions:
2237
Exclude:
2338
- lib/rspec/core/example.rb
@@ -28,9 +43,37 @@ Lint/HandleExceptions:
2843
Lint/LiteralInInterpolation:
2944
Enabled: false
3045

31-
# This should go down over time.
32-
MethodLength:
33-
Max: 40
46+
Lint/NonLocalExitFromIterator:
47+
Enabled: false
48+
49+
# We don't care about single vs double qoutes.
50+
Style/StringLiteralsInInterpolation:
51+
Enabled: false
52+
53+
Style/SymbolProc:
54+
Enabled: false
55+
56+
Style/SpaceAroundOperators:
57+
MultiSpaceAllowedForOperators:
58+
- '='
59+
- '||='
60+
- '==='
61+
- '=>'
62+
- '<<'
63+
- '||'
64+
65+
Style/AccessModifierIndentation:
66+
Enabled: false
67+
68+
Style/RegexpLiteral:
69+
Enabled: false
70+
71+
# This could change depending of the style used
72+
Style/MultilineOperationIndentation:
73+
Enabled: false
74+
75+
Style/BarePercentLiterals:
76+
Enabled: false
3477

3578
# Exclude the default spec_helper to make it easier to uncomment out
3679
# default settings (for both users and the Cucumber suite).
@@ -46,10 +89,6 @@ Style/ClassAndModuleChildren:
4689
- lib/rspec/core/option_parser.rb
4790
- lib/rspec/core/reporter.rb
4891

49-
# This should go down over time.
50-
Style/CyclomaticComplexity:
51-
Max: 12
52-
5392
Style/RaiseArgs:
5493
Exclude:
5594
- lib/rspec/core/configuration.rb

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ cache:
88
- ../bundle
99
before_install:
1010
- "script/clone_all_rspec_repos"
11-
# Downgrade bundler to work around https://github.com/bundler/bundler/issues/3004
1211
# Note this doesn't work on JRUBY 2.0.0 mode so we don't do it
13-
- if [ -z "$JRUBY_OPTS" ]; then gem install bundler -v=1.5.3 && alias bundle="bundle _1.5.3_"; fi
12+
- if [ "jruby" != "$TRAVIS_RUBY_VERSION" ]; then gem install bundler; fi
1413
bundler_args: "--binstubs --standalone --without documentation --path ../bundle"
1514
script: "script/run_build"
1615
rvm:

Gemfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ platforms :jruby do
2929
end
3030

3131
gem 'simplecov', '~> 0.8'
32-
gem 'rubocop', "~> 0.23.0", :platform => [:ruby_19, :ruby_20, :ruby_21]
32+
33+
# There is no platform :ruby_193 and Rubocop only supports >= 1.9.3
34+
unless RUBY_VERSION == "1.9.2"
35+
gem "rubocop",
36+
"~> 0.32.1",
37+
:platform => [:ruby_19, :ruby_20, :ruby_21, :ruby_22]
38+
end
39+
3340
gem 'test-unit', '~> 3.0' if RUBY_VERSION.to_f >= 2.2
3441

3542
eval File.read('Gemfile-custom') if File.exist?('Gemfile-custom')

lib/rspec/core/configuration.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
module RSpec
66
module Core
7-
# rubocop:disable Style/ClassLength
7+
# rubocop:disable Metrics/ClassLength
88

99
# Stores runtime configuration information.
1010
#
@@ -580,7 +580,7 @@ def mock_with(framework)
580580
end
581581

582582
new_name, old_name = [framework_module, @mock_framework].map do |mod|
583-
mod.respond_to?(:framework_name) ? mod.framework_name : :unnamed
583+
mod.respond_to?(:framework_name) ? mod.framework_name : :unnamed
584584
end
585585

586586
unless new_name == old_name
@@ -1731,7 +1731,8 @@ def extract_location(path)
17311731

17321732
if match
17331733
captures = match.captures
1734-
path, lines = captures[0], captures[1][1..-1].split(":").map { |n| n.to_i }
1734+
path = captures[0]
1735+
lines = captures[1][1..-1].split(":").map(&:to_i)
17351736
filter_manager.add_location path, lines
17361737
else
17371738
path, scoped_ids = Example.parse_id(path)
@@ -1811,6 +1812,6 @@ def clear_values_derived_from_example_status_persistence_file_path
18111812
@spec_files_with_failures = nil
18121813
end
18131814
end
1814-
# rubocop:enable Style/ClassLength
1815+
# rubocop:enable Metrics/ClassLength
18151816
end
18161817
end

lib/rspec/core/configuration_options.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def force?(key)
6464
end
6565

6666
def order(keys)
67-
OPTIONS_ORDER.reverse.each do |key|
67+
OPTIONS_ORDER.reverse_each do |key|
6868
keys.unshift(key) if keys.delete(key)
6969
end
7070
keys

lib/rspec/core/formatters/html_printer.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ def print_example_passed(description, run_time)
3333
"<span class='duration'>#{formatted_run_time}s</span></dd>"
3434
end
3535

36-
# rubocop:disable Style/ParameterLists
36+
# rubocop:disable Metrics/ParameterLists
3737
def print_example_failed(pending_fixed, description, run_time, failure_id,
3838
exception, extra_content)
39-
# rubocop:enable Style/ParameterLists
39+
# rubocop:enable Metrics/ParameterLists
4040
formatted_run_time = "%.5f" % run_time
4141

4242
@output.puts " <dd class=\"example #{pending_fixed ? 'pending_fixed' : 'failed'}\">"
@@ -139,7 +139,6 @@ def indentation_style(number_of_parents)
139139
EOF
140140
# rubocop:enable LineLength
141141

142-
# rubocop:disable LineLength
143142
GLOBAL_SCRIPTS = <<-EOF
144143
145144
function addClass(element_id, classname) {

lib/rspec/core/notifications.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module Notifications
1010
# @private
1111
module NullColorizer
1212
module_function
13+
1314
def wrap(line, _code_or_symbol)
1415
line
1516
end

lib/rspec/core/option_parser.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def parse(source=nil)
3434
private
3535

3636
# rubocop:disable MethodLength
37+
# rubocop:disable Metrics/AbcSize
3738
# rubocop:disable CyclomaticComplexity
3839
def parser(options)
3940
OptionParser.new do |parser|
@@ -251,9 +252,9 @@ def parser(options)
251252
raise OptionParser::InvalidOption.new
252253
end
253254
end
254-
255255
end
256256
end
257+
# rubocop:enable Metrics/AbcSize
257258
# rubocop:enable MethodLength
258259
# rubocop:enable CyclomaticComplexity
259260

lib/rspec/core/shared_example_group.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def shared_examples(name, *args, &block)
9696
# Shared examples top level DSL.
9797
module TopLevelDSL
9898
# @private
99+
# rubocop:disable Lint/NestedMethodDefinition
99100
def self.definitions
100101
proc do
101102
def shared_examples(name, *args, &block)
@@ -105,6 +106,7 @@ def shared_examples(name, *args, &block)
105106
alias shared_examples_for shared_examples
106107
end
107108
end
109+
# rubocop:enable Lint/NestedMethodDefinition
108110

109111
# @private
110112
def self.exposed_globally?

0 commit comments

Comments
 (0)