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

Commit 37c6435

Browse files
committed
fix most of the offences that will not change the current style
1 parent a30c5a2 commit 37c6435

13 files changed

+39
-25
lines changed

.rubocop.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ ClassLength:
1313
LineLength:
1414
Max: 130
1515

16+
# This should go down over time
17+
Metrics/AbcSize:
18+
Max: 40
19+
20+
Metrics/PerceivedComplexity:
21+
Max: 15
22+
1623
Lint/HandleExceptions:
1724
Exclude:
1825
- lib/rspec/core/example.rb
@@ -27,6 +34,13 @@ Lint/LiteralInInterpolation:
2734
MethodLength:
2835
Max: 40
2936

37+
Style/AccessModifierIndentation:
38+
Enabled: false
39+
40+
# This could change depending of the style used
41+
Style/MultilineOperationIndentation:
42+
Enabled: false
43+
3044
# Exclude the default spec_helper to make it easier to uncomment out
3145
# default settings (for both users and the Cucumber suite).
3246
Style/BlockComments:

lib/rspec/core/bisect/runner.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def command_for(locations)
2525
parts << RUBY << load_path
2626
parts << open3_safe_escape(RSpec::Core.path_to_executable)
2727

28-
parts << "--format" << "bisect"
28+
parts << "--format" << "bisect"
2929
parts << "--drb-port" << @server.drb_port
3030
parts.concat reusable_cli_options
3131
parts.concat locations.map { |l| open3_safe_escape(l) }
@@ -131,8 +131,7 @@ def load_path
131131
# https://github.com/ruby/rake/commit/968682759b3b65e42748cd2befb2ff3e982272d9
132132
RUBY = File.join(
133133
RbConfig::CONFIG['bindir'],
134-
RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']).
135-
sub(/.*\s.*/m, '"\&"')
134+
RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']).sub(/.*\s.*/m, '"\&"')
136135
end
137136
end
138137
end

lib/rspec/core/configuration.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -1686,7 +1686,7 @@ def get_matching_files(path, pattern)
16861686

16871687
def file_glob_from(path, pattern)
16881688
stripped = "{#{pattern.gsub(/\s*,\s*/, ',')}}"
1689-
return stripped if pattern =~ /^(\.\/)?#{Regexp.escape path}/ || absolute_pattern?(pattern)
1689+
return stripped if pattern =~ %r{^(\.\/)?#{Regexp.escape path}} || absolute_pattern?(pattern)
16901690
File.join(path, stripped)
16911691
end
16921692

@@ -1712,7 +1712,8 @@ def extract_location(path)
17121712

17131713
if match
17141714
captures = match.captures
1715-
path, lines = captures[0], captures[1][1..-1].split(":").map { |n| n.to_i }
1715+
path = captures[0]
1716+
lines = captures[1][1..-1].split(":").map(&:id)
17161717
filter_manager.add_location path, lines
17171718
else
17181719
path, scoped_ids = Example.parse_id(path)

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/filter_manager.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def file_scoped_include?(ex_metadata, ids, locations)
107107
return yield if no_location_filters && no_id_filters
108108

109109
MetadataFilter.filter_applies?(:ids, ids, ex_metadata) ||
110-
MetadataFilter.filter_applies?(:locations, locations, ex_metadata)
110+
MetadataFilter.filter_applies?(:locations, locations, ex_metadata)
111111
end
112112
end
113113

lib/rspec/core/formatters.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ def add(formatter_to_use, *paths)
168168

169169
def find_formatter(formatter_to_use)
170170
built_in_formatter(formatter_to_use) ||
171-
custom_formatter(formatter_to_use) ||
172-
(raise ArgumentError, "Formatter '#{formatter_to_use}' unknown - " \
173-
"maybe you meant 'documentation' or 'progress'?.")
171+
custom_formatter(formatter_to_use) ||
172+
(raise ArgumentError, "Formatter '#{formatter_to_use}' unknown - " \
173+
"maybe you meant 'documentation' or 'progress'?.")
174174
end
175175

176176
def register(formatter, notifications)

lib/rspec/core/formatters/deprecation_formatter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def output_formatted(str)
8585
end
8686

8787
def deprecation_type_for(data)
88-
data.message.gsub(/(\w+\/)+\w+\.rb:\d+/, '')
88+
data.message.gsub(%r{(\w+\/)+\w+\.rb:\d+}, '')
8989
end
9090
end
9191

lib/rspec/core/formatters/profile_formatter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def dump_profile_slowest_examples(profile)
3737
profile.slowest_examples.each do |example|
3838
@output.puts " #{example.full_description}"
3939
@output.puts " #{bold(Helpers.format_seconds(example.execution_result.run_time))} " \
40-
"#{bold("seconds")} #{format_caller(example.location)}"
40+
"#{bold('seconds')} #{format_caller(example.location)}"
4141
end
4242
end
4343

@@ -46,7 +46,7 @@ def dump_profile_slowest_example_groups(profile)
4646

4747
@output.puts "\nTop #{profile.slowest_groups.size} slowest example groups:"
4848
profile.slowest_groups.each do |loc, hash|
49-
average = "#{bold(Helpers.format_seconds(hash[:average]))} #{bold("seconds")} average"
49+
average = "#{bold(Helpers.format_seconds(hash[:average]))} #{bold('seconds')} average"
5050
total = "#{Helpers.format_seconds(hash[:total_time])} seconds"
5151
count = Helpers.pluralize(hash[:count], "example")
5252
@output.puts " #{hash[:description]}"

lib/rspec/core/formatters/snippet_extractor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class SnippetExtractor
99
# @private
1010
module NullConverter
1111
def self.convert(code)
12-
%Q(#{code}\n<span class="comment"># Install the coderay gem to get syntax highlighting</span>)
12+
%(#{code}\n<span class="comment"># Install the coderay gem to get syntax highlighting</span>)
1313
end
1414
end
1515

lib/rspec/core/hooks.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,8 @@ def extract_scope_from(args)
585585
normalized_scope_for(args.shift)
586586
elsif args.any? { |a| a.is_a?(Symbol) }
587587
error_message = "You must explicitly give a scope " \
588-
"(#{SCOPES.join(", ")}) or scope alias " \
589-
"(#{SCOPE_ALIASES.keys.join(", ")}) when using symbols as " \
588+
"(#{SCOPES.join(', ')}) or scope alias " \
589+
"(#{SCOPE_ALIASES.keys.join(', ')}) when using symbols as " \
590590
"metadata for a hook."
591591
raise ArgumentError.new error_message
592592
else

lib/rspec/core/metadata.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def populate_location_attributes
151151
metadata[:line_number] = line_number.to_i
152152
metadata[:location] = "#{relative_file_path}:#{line_number}"
153153
metadata[:absolute_file_path] = File.expand_path(relative_file_path)
154-
metadata[:rerun_file_path] ||= relative_file_path
154+
metadata[:rerun_file_path] ||= relative_file_path
155155
metadata[:scoped_id] = build_scoped_id_for(relative_file_path)
156156
end
157157

@@ -185,7 +185,7 @@ def ensure_valid_user_keys
185185
RESERVED_KEYS.each do |key|
186186
next unless user_metadata.key?(key)
187187
raise <<-EOM.gsub(/^\s+\|/, '')
188-
|#{"*" * 50}
188+
|#{'*' * 51}
189189
|:#{key} is not allowed
190190
|
191191
|RSpec reserves some hash keys for its own internal use,
@@ -196,7 +196,7 @@ def ensure_valid_user_keys
196196
|Here are all of RSpec's reserved hash keys:
197197
|
198198
| #{RESERVED_KEYS.join("\n ")}
199-
|#{"*" * 50}
199+
|#{'*' * 50}
200200
EOM
201201
end
202202
end

lib/rspec/core/notifications.rb

Lines changed: 5 additions & 4 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
@@ -338,10 +339,10 @@ def colorized_totals_line(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
338339
# @return [String] A colorized summary line.
339340
def colorized_rerun_commands(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
340341
"\nFailed examples:\n\n" +
341-
failed_examples.map do |example|
342-
colorizer.wrap("rspec #{rerun_argument_for(example)}", RSpec.configuration.failure_color) + " " +
343-
colorizer.wrap("# #{example.full_description}", RSpec.configuration.detail_color)
344-
end.join("\n")
342+
failed_examples.map do |example|
343+
colorizer.wrap("rspec #{rerun_argument_for(example)}", RSpec.configuration.failure_color) + " " +
344+
colorizer.wrap("# #{example.full_description}", RSpec.configuration.detail_color)
345+
end.join("\n")
345346
end
346347

347348
# @return [String] a formatted version of the time it took to run the

lib/rspec/core/option_parser.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ def parser(options)
251251
raise OptionParser::InvalidOption.new
252252
end
253253
end
254-
255254
end
256255
end
257256
# rubocop:enable MethodLength

0 commit comments

Comments
 (0)