Skip to content

Commit 65f1687

Browse files
committed
Enable Layout/LineLength and break long lines at logical seams
1 parent e68a018 commit 65f1687

29 files changed

Lines changed: 160 additions & 61 deletions

.rubocop.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ Layout/AccessModifierIndentation:
2525
EnforcedStyle: outdent
2626

2727
Layout/LineLength:
28-
Description: Checks the length of lines in the source code.
2928
AllowURI: true
30-
Enabled: false
3129

3230
Layout/SpaceInsideHashLiteralBraces:
3331
Description: Use spaces inside hash literal braces - or don't.

features/step_definitions/html_steps.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
coverage_data
5757
end
5858

59-
expect(files.sort_by { |coverage_data| coverage_data["name"] }).to eq(expected_files.sort_by { |coverage_data| coverage_data["name"] })
59+
by_name = ->(coverage_data) { coverage_data["name"] }
60+
expect(files.sort_by(&by_name)).to eq(expected_files.sort_by(&by_name))
6061
end
6162

6263
Then /^there should be (\d+) skipped lines in the source files$/ do |expected_count|
@@ -91,7 +92,12 @@
9192

9293
if for_file
9394
# File detail view: check the summary in the dialog (new) or source_table (old)
94-
selector = page.has_css?("#source-dialog[open]", wait: 0) ? "#source-dialog .t-#{coverage_type}-summary" : ".source_table .t-#{coverage_type}-summary"
95+
selector =
96+
if page.has_css?("#source-dialog[open]", wait: 0)
97+
"#source-dialog .t-#{coverage_type}-summary"
98+
else
99+
".source_table .t-#{coverage_type}-summary"
100+
end
95101
summary_text = find(selector, visible: false).text
96102
else
97103
# Try new format: sum data attributes from file rows

lib/simplecov.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ def previous_error?(error_exit_status)
235235
#
236236
# Thinking: Move this behavior earlier so if there was an error we do nothing?
237237
def exit_and_report_previous_error(exit_status)
238-
warn("Stopped processing SimpleCov as a previous error not related to SimpleCov has been detected") if print_error_status
238+
if print_error_status
239+
warn("Stopped processing SimpleCov as a previous error not related to SimpleCov has been detected")
240+
end
239241
Kernel.exit(exit_status)
240242
end
241243

@@ -266,7 +268,13 @@ def process_result(result)
266268
end
267269

268270
# @api private
269-
CoverageLimits = Struct.new(:minimum_coverage, :minimum_coverage_by_file, :minimum_coverage_by_group, :maximum_coverage_drop, keyword_init: true)
271+
CoverageLimits = Struct.new(
272+
:minimum_coverage,
273+
:minimum_coverage_by_file,
274+
:minimum_coverage_by_group,
275+
:maximum_coverage_drop,
276+
keyword_init: true
277+
)
270278
def result_exit_status(result)
271279
coverage_limits = CoverageLimits.new(
272280
minimum_coverage: minimum_coverage, minimum_coverage_by_file: minimum_coverage_by_file,
@@ -468,7 +476,10 @@ def make_parallel_tests_available
468476

469477
require "parallel_tests"
470478
rescue LoadError
471-
warn("SimpleCov guessed you were running inside parallel tests but couldn't load it. Please file a bug report with us!")
479+
warn(
480+
"SimpleCov guessed you were running inside parallel tests but couldn't load it. " \
481+
"Please file a bug report with us!"
482+
)
472483
end
473484

474485
def probably_running_parallel_tests?

lib/simplecov/combine/branches_combiner.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ module BranchesCombiner
1515
# Branches inside files are always same if they exist, the difference only in coverage count.
1616
# Branch coverage report for any conditional case is built from hash, it's key is a condition and
1717
# it's body is a hash << keys from condition and value is coverage rate >>.
18-
# ex: branches =>{ [:if, 3, 8, 6, 8, 36] => {[:then, 4, 8, 6, 8, 12] => 1, [:else, 5, 8, 6, 8, 36]=>2}, other conditions...}
18+
# ex: branches => { [:if, 3, 8, 6, 8, 36] =>
19+
# {[:then, 4, 8, 6, 8, 12] => 1, [:else, 5, 8, 6, 8, 36] => 2}, ... }
1920
# We create copy of result and update it values depending on the combined branches coverage values.
2021
#
2122
# @return [Hash]

lib/simplecov/combine/files_combiner.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ module FilesCombiner
1616
#
1717
def combine(coverage_a, coverage_b)
1818
combination = {"lines" => Combine.combine(LinesCombiner, coverage_a["lines"], coverage_b["lines"])}
19-
combination["branches"] = Combine.combine(BranchesCombiner, coverage_a["branches"], coverage_b["branches"]) || {} if SimpleCov.branch_coverage?
20-
combination["methods"] = Combine.combine(MethodsCombiner, coverage_a["methods"], coverage_b["methods"]) if SimpleCov.method_coverage?
19+
if SimpleCov.branch_coverage?
20+
combined_branches = Combine.combine(BranchesCombiner, coverage_a["branches"], coverage_b["branches"])
21+
combination["branches"] = combined_branches || {}
22+
end
23+
if SimpleCov.method_coverage?
24+
combination["methods"] = Combine.combine(MethodsCombiner, coverage_a["methods"], coverage_b["methods"])
25+
end
2126
combination
2227
end
2328
end

lib/simplecov/command_guesser.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ def from_defined_constants
5656
DEFINED_CONSTANT_FRAMEWORKS.each { |name, defined_check| return name if defined_check.call }
5757

5858
# TODO: Provide link to docs/wiki article
59-
warn "SimpleCov failed to recognize the test framework and/or suite used. Please specify manually using SimpleCov.command_name 'Unit Tests'."
59+
warn(
60+
"SimpleCov failed to recognize the test framework and/or suite used. " \
61+
"Please specify manually using SimpleCov.command_name 'Unit Tests'."
62+
)
6063
"Unknown Test Framework"
6164
end
6265
end

lib/simplecov/configuration.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ def formatter(formatter = nil)
9898
return @formatter if defined?(@formatter) && formatter.nil?
9999

100100
@formatter = formatter
101-
raise "No formatter configured. Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter" unless @formatter
101+
unless @formatter
102+
raise "No formatter configured. " \
103+
"Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter"
104+
end
102105

103106
@formatter
104107
end
@@ -243,7 +246,7 @@ def enabled_for_subprocesses?
243246
# SimpleCov.start do
244247
# # This needs a unique name so it won't be ovewritten
245248
# SimpleCov.command_name "#{SimpleCov.command_name} (subprocess: #{pid})"
246-
# # be quiet, the parent process will be in charge of using the regular formatter and checking coverage totals
249+
# # be quietthe parent process is in charge of using the regular formatter and checking coverage totals
247250
# SimpleCov.print_error_status = false
248251
# SimpleCov.formatter SimpleCov::Formatter::SimpleFormatter
249252
# SimpleCov.minimum_coverage 0
@@ -520,7 +523,8 @@ def raise_if_criterion_disabled(criterion)
520523
raise_if_criterion_unsupported(criterion)
521524
return if coverage_criterion_enabled?(criterion)
522525

523-
raise "Coverage criterion #{criterion}, is disabled! Please enable it first through enable_coverage #{criterion} (if supported)"
526+
raise "Coverage criterion #{criterion}, is disabled! " \
527+
"Please enable it first through enable_coverage #{criterion} (if supported)"
524528
end
525529

526530
def raise_if_criterion_unsupported(criterion)

lib/simplecov/coverage_statistics.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ class CoverageStatistics
1616

1717
def self.from(coverage_statistics)
1818
sum_covered, sum_missed, sum_omitted, sum_total_strength =
19-
coverage_statistics.reduce([0, 0, 0, 0.0]) do |(covered, missed, omitted, total_strength), file_coverage_statistics|
19+
coverage_statistics.reduce([0, 0, 0, 0.0]) do |(covered, missed, omitted, total_strength), stats|
2020
[
21-
covered + file_coverage_statistics.covered,
22-
missed + file_coverage_statistics.missed,
23-
omitted + file_coverage_statistics.omitted,
21+
covered + stats.covered,
22+
missed + stats.missed,
23+
omitted + stats.omitted,
2424
# gotta remultiply with loc because files have different strength and loc
2525
# giving them a different "weight" in total
26-
total_strength + (file_coverage_statistics.strength * file_coverage_statistics.total)
26+
total_strength + (stats.strength * stats.total)
2727
]
2828
end
2929

lib/simplecov/coverage_violations.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ def group_minimum_violations(group_name, group, minimums)
6767

6868
def lookup_group(result, group_name)
6969
group = result.groups[group_name]
70-
warn "minimum_coverage_by_group: no group named '#{group_name}' exists. Available groups: #{result.groups.keys.join(', ')}" unless group
70+
unless group
71+
warn "minimum_coverage_by_group: no group named '#{group_name}' exists. " \
72+
"Available groups: #{result.groups.keys.join(', ')}"
73+
end
7174
group
7275
end
7376

lib/simplecov/exit_codes/maximum_coverage_drop_check.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def failing?
1717
def report
1818
violations.each do |violation|
1919
$stderr.printf(
20-
"%<criterion>s coverage has dropped by %<drop_percent>.2f%% since the last time (maximum allowed: %<max_drop>.2f%%).\n",
20+
"%<criterion>s coverage has dropped by %<drop_percent>.2f%% since the last time " \
21+
"(maximum allowed: %<max_drop>.2f%%).\n",
2122
criterion: violation.fetch(:criterion).capitalize,
2223
drop_percent: violation.fetch(:actual),
2324
max_drop: violation.fetch(:maximum)

0 commit comments

Comments
 (0)