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

Rebased bennacer860 rubocop upgrade #2081

Merged
merged 10 commits into from
Oct 12, 2015
Merged
57 changes: 48 additions & 9 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AllCops:
- lib/rspec/core/backport_random.rb

# This should go down over time.
ClassLength:
Metrics/ClassLength:
Max: 330

Encoding:
Expand All @@ -15,9 +15,24 @@ Encoding:
- lib/rspec/core/formatters/exception_presenter.rb

# This should go down over time.
LineLength:
Metrics/AbcSize:
Max: 40

# This should go down over time.
Metrics/LineLength:
Max: 130

# This should go down over time.
Metrics/MethodLength:
Max: 40

# This should go down over time.
Metrics/CyclomaticComplexity:
Max: 12

Metrics/PerceivedComplexity:
Max: 15

Lint/HandleExceptions:
Exclude:
- lib/rspec/core/example.rb
Expand All @@ -28,9 +43,37 @@ Lint/HandleExceptions:
Lint/LiteralInInterpolation:
Enabled: false

# This should go down over time.
MethodLength:
Max: 40
Lint/NonLocalExitFromIterator:
Enabled: false

# We don't care about single vs double qoutes.
Style/StringLiteralsInInterpolation:
Enabled: false

Style/SymbolProc:
Enabled: false

Style/SpaceAroundOperators:
MultiSpaceAllowedForOperators:
- '='
- '||='
- '==='
- '=>'
- '<<'
- '||'

Style/AccessModifierIndentation:
Enabled: false

Style/RegexpLiteral:
Enabled: false

# This could change depending of the style used
Style/MultilineOperationIndentation:
Enabled: false

Style/BarePercentLiterals:
Enabled: false

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

# This should go down over time.
Style/CyclomaticComplexity:
Max: 12

Style/RaiseArgs:
Exclude:
- lib/rspec/core/configuration.rb
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ cache:
- ../bundle
before_install:
- "script/clone_all_rspec_repos"
# Downgrade bundler to work around https://github.com/bundler/bundler/issues/3004
# 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
bundler_args: "--binstubs --standalone --without documentation --path ../bundle"
script: "script/run_build"
rvm:
Expand Down
9 changes: 8 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ platforms :jruby do
end

gem 'simplecov', '~> 0.8'
gem 'rubocop', "~> 0.23.0", :platform => [:ruby_19, :ruby_20, :ruby_21]

# There is no platform :ruby_193 and Rubocop only supports >= 1.9.3
unless RUBY_VERSION == "1.9.2"
gem "rubocop",
"~> 0.32.1",
:platform => [:ruby_19, :ruby_20, :ruby_21, :ruby_22]
end

gem 'test-unit', '~> 3.0' if RUBY_VERSION.to_f >= 2.2

eval File.read('Gemfile-custom') if File.exist?('Gemfile-custom')
9 changes: 5 additions & 4 deletions lib/rspec/core/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module RSpec
module Core
# rubocop:disable Style/ClassLength
# rubocop:disable Metrics/ClassLength

# Stores runtime configuration information.
#
Expand Down Expand Up @@ -580,7 +580,7 @@ def mock_with(framework)
end

new_name, old_name = [framework_module, @mock_framework].map do |mod|
mod.respond_to?(:framework_name) ? mod.framework_name : :unnamed
mod.respond_to?(:framework_name) ? mod.framework_name : :unnamed
end

unless new_name == old_name
Expand Down Expand Up @@ -1731,7 +1731,8 @@ def extract_location(path)

if match
captures = match.captures
path, lines = captures[0], captures[1][1..-1].split(":").map { |n| n.to_i }
path = captures[0]
lines = captures[1][1..-1].split(":").map(&:to_i)
filter_manager.add_location path, lines
else
path, scoped_ids = Example.parse_id(path)
Expand Down Expand Up @@ -1811,6 +1812,6 @@ def clear_values_derived_from_example_status_persistence_file_path
@spec_files_with_failures = nil
end
end
# rubocop:enable Style/ClassLength
# rubocop:enable Metrics/ClassLength
end
end
2 changes: 1 addition & 1 deletion lib/rspec/core/configuration_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def force?(key)
end

def order(keys)
OPTIONS_ORDER.reverse.each do |key|
OPTIONS_ORDER.reverse_each do |key|
keys.unshift(key) if keys.delete(key)
end
keys
Expand Down
5 changes: 2 additions & 3 deletions lib/rspec/core/formatters/html_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def print_example_passed(description, run_time)
"<span class='duration'>#{formatted_run_time}s</span></dd>"
end

# rubocop:disable Style/ParameterLists
# rubocop:disable Metrics/ParameterLists
def print_example_failed(pending_fixed, description, run_time, failure_id,
exception, extra_content)
# rubocop:enable Style/ParameterLists
# rubocop:enable Metrics/ParameterLists
formatted_run_time = "%.5f" % run_time

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

# rubocop:disable LineLength
GLOBAL_SCRIPTS = <<-EOF

function addClass(element_id, classname) {
Expand Down
1 change: 1 addition & 0 deletions lib/rspec/core/notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Notifications
# @private
module NullColorizer
module_function

def wrap(line, _code_or_symbol)
line
end
Expand Down
3 changes: 2 additions & 1 deletion lib/rspec/core/option_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def parse(source=nil)
private

# rubocop:disable MethodLength
# rubocop:disable Metrics/AbcSize
# rubocop:disable CyclomaticComplexity
def parser(options)
OptionParser.new do |parser|
Expand Down Expand Up @@ -251,9 +252,9 @@ def parser(options)
raise OptionParser::InvalidOption.new
end
end

end
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable MethodLength
# rubocop:enable CyclomaticComplexity

Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/core/shared_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def shared_examples(name, *args, &block)
# Shared examples top level DSL.
module TopLevelDSL
# @private
# rubocop:disable Lint/NestedMethodDefinition
def self.definitions
proc do
def shared_examples(name, *args, &block)
Expand All @@ -105,6 +106,7 @@ def shared_examples(name, *args, &block)
alias shared_examples_for shared_examples
end
end
# rubocop:enable Lint/NestedMethodDefinition

# @private
def self.exposed_globally?
Expand Down