Skip to content

Commit 4480718

Browse files
committed
Enable all new cops and autocorrect
1 parent 1d8f692 commit 4480718

30 files changed

+82
-72
lines changed

.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ AllCops:
1111
- "vendor/bundle/**/*"
1212
- "vendor/bundle/**/.*"
1313
TargetRubyVersion: 2.5
14+
NewCops: enable
1415
# we might wanna adopt rspec and rake but it's a bit annoying for now
1516
SuggestExtensions: false
1617

features/step_definitions/web_steps.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ def with_scope(locator)
4646

4747
Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
4848
with_scope(selector) do
49-
expect(page).to have_no_content(text)
49+
expect(page).not_to have_content(text)
5050
end
5151
end
5252

5353
Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
5454
regexp = Regexp.new(regexp)
5555
with_scope(selector) do
56-
expect(page).to have_no_xpath("//*", text: regexp)
56+
expect(page).not_to have_xpath("//*", text: regexp)
5757
end
5858
end
5959

@@ -65,7 +65,7 @@ def with_scope(locator)
6565
end
6666

6767
Then "{string} should not be visible" do |text|
68-
expect(page).to have_no_content(:visible, text)
68+
expect(page).not_to have_content(:visible, text)
6969
end
7070

7171
Then /^show me the page$/ do

lib/simplecov.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
# @see https://github.com/simplecov-ruby/simplecov/issues/86
1212
# @see https://jira.codehaus.org/browse/JRUBY-6106
1313

14-
warn 'Coverage may be inaccurate; set the "--debug" command line option,' \
15-
' or do JRUBY_OPTS="--debug"' \
16-
' or set the "debug.fullTrace=true" option in your .jrubyrc'
14+
warn 'Coverage may be inaccurate; set the "--debug" command line option, ' \
15+
'or do JRUBY_OPTS="--debug" ' \
16+
'or set the "debug.fullTrace=true" option in your .jrubyrc'
1717
end
1818

1919
#
@@ -48,8 +48,8 @@ class << self
4848
def start(profile = nil, &block)
4949
require "coverage"
5050
initial_setup(profile, &block)
51-
require_relative "./simplecov/process" if SimpleCov.enabled_for_subprocesses? &&
52-
::Process.respond_to?(:fork)
51+
require_relative "simplecov/process" if SimpleCov.enabled_for_subprocesses? &&
52+
::Process.respond_to?(:fork)
5353

5454
make_parallel_tests_available
5555

@@ -301,7 +301,7 @@ def round_coverage(coverage)
301301

302302
def initial_setup(profile, &block)
303303
load_profile(profile) if profile
304-
configure(&block) if block_given?
304+
configure(&block) if block
305305
self.running = true
306306
end
307307

@@ -347,9 +347,9 @@ def start_coverage_measurement
347347
end
348348

349349
def start_coverage_with_criteria
350-
start_arguments = coverage_criteria.map do |criterion|
350+
start_arguments = coverage_criteria.to_h do |criterion|
351351
[lookup_corresponding_ruby_coverage_name(criterion), true]
352-
end.to_h
352+
end
353353

354354
start_arguments[:eval] = true if coverage_for_eval_enabled?
355355

@@ -432,7 +432,7 @@ def make_parallel_tests_available
432432
end
433433

434434
def probably_running_parallel_tests?
435-
ENV["TEST_ENV_NUMBER"] && ENV["PARALLEL_TEST_GROUPS"]
435+
ENV.fetch("TEST_ENV_NUMBER", nil) && ENV.fetch("PARALLEL_TEST_GROUPS", nil)
436436
end
437437
end
438438
end

lib/simplecov/command_guesser.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ def from_env
2323
# If being run from inside parallel_tests set the command name according to the process number
2424
return unless ENV["PARALLEL_TEST_GROUPS"] && ENV["TEST_ENV_NUMBER"]
2525

26-
number = ENV["TEST_ENV_NUMBER"]
26+
number = ENV.fetch("TEST_ENV_NUMBER", nil)
2727
number = "1" if number.empty?
28-
"(#{number}/#{ENV['PARALLEL_TEST_GROUPS']})"
28+
"(#{number}/#{ENV.fetch('PARALLEL_TEST_GROUPS', nil)})"
2929
end
3030

3131
def from_command_line_options

lib/simplecov/configuration.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def coverage_dir(dir = nil)
3535
return @coverage_dir if defined?(@coverage_dir) && dir.nil?
3636

3737
@coverage_path = nil # invalidate cache
38-
@coverage_dir = (dir || "coverage")
38+
@coverage_dir = dir || "coverage"
3939
end
4040

4141
#
@@ -140,7 +140,7 @@ def print_error_status
140140
def nocov_token(nocov_token = nil)
141141
return @nocov_token if defined?(@nocov_token) && nocov_token.nil?
142142

143-
@nocov_token = (nocov_token || "nocov")
143+
@nocov_token = nocov_token || "nocov"
144144
end
145145
alias skip_token nocov_token
146146

@@ -191,9 +191,9 @@ def configure(&block)
191191
# end
192192
#
193193
def at_exit(&block)
194-
return Proc.new unless running || block_given?
194+
return Proc.new unless running || block
195195

196-
@at_exit = block if block_given?
196+
@at_exit = block if block
197197
@at_exit ||= proc { SimpleCov.result.format! }
198198
end
199199

@@ -231,7 +231,7 @@ def enabled_for_subprocesses?
231231
# end
232232
#
233233
def at_fork(&block)
234-
@at_fork = block if block_given?
234+
@at_fork = block if block
235235
@at_fork ||= lambda { |pid|
236236
# This needs a unique name so it won't be ovewritten
237237
SimpleCov.command_name "#{SimpleCov.command_name} (subprocess: #{pid})"
@@ -344,7 +344,7 @@ def minimum_coverage_by_file(coverage = nil)
344344
def refuse_coverage_drop(*criteria)
345345
criteria = coverage_criteria if criteria.empty?
346346

347-
maximum_coverage_drop(criteria.map { |c| [c, 0] }.to_h)
347+
maximum_coverage_drop(criteria.to_h { |c| [c, 0] })
348348
end
349349

350350
#

lib/simplecov/defaults.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
load filename
4545
rescue LoadError, StandardError
4646
warn "Warning: Error occurred while trying to load #{filename}. " \
47-
"Error message: #{$!.message}"
47+
"Error message: #{$!.message}"
4848
end
4949
break
5050
end

lib/simplecov/formatter/simple_formatter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def format(result)
1111
output = +""
1212
result.groups.each do |name, files|
1313
output << "Group: #{name}\n"
14-
output << "=" * 40
14+
output << ("=" * 40)
1515
output << "\n"
1616
files.each do |file|
1717
output << "#{file.filename} (coverage: #{file.covered_percent.round(2)}%)\n"

lib/simplecov/load_global_config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
require "etc"
4-
home_dir = (ENV["HOME"] && File.expand_path("~")) || Etc.getpwuid.dir || (ENV["USER"] && File.expand_path("~#{ENV['USER']}"))
4+
home_dir = (Dir.home && File.expand_path("~")) || Etc.getpwuid.dir || (ENV.fetch("USER", nil) && File.expand_path("~#{ENV.fetch('USER', nil)}"))
55
if home_dir
66
global_config_path = File.join(home_dir, ".simplecov")
77
load global_config_path if File.exist?(global_config_path)

lib/simplecov/process.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def fork_with_simplecov(&block)
66
if defined?(SimpleCov) && SimpleCov.running
77
fork_without_simplecov do
88
SimpleCov.at_fork.call(Process.pid)
9-
block.call if block_given?
9+
yield if block
1010
end
1111
else
1212
fork_without_simplecov(&block)

lib/simplecov/result.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def self.from_hash(hash)
8383

8484
def coverage
8585
keys = original_result.keys & filenames
86-
Hash[keys.zip(original_result.values_at(*keys))]
86+
keys.zip(original_result.values_at(*keys)).to_h
8787
end
8888

8989
# Applies all configured SimpleCov filters on this result's source files

0 commit comments

Comments
 (0)