Skip to content

Commit

Permalink
Fix Minitest/AssertEmpty Rubocop exclusions
Browse files Browse the repository at this point in the history
  • Loading branch information
esquith committed Sep 12, 2022
1 parent 51fc036 commit a696764
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 28 deletions.
13 changes: 0 additions & 13 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@ Layout/EmptyLinesAroundBlockBody:
- 'test/multiverse/suites/active_record/db/schema.rb'
- 'test/multiverse/suites/active_record_pg/db/schema.rb'

# Offense count: 15
# This cop supports safe autocorrection (--autocorrect).
Minitest/AssertEmpty:
Exclude:
- 'test/agent_helper.rb'
- 'test/multiverse/suites/rails/error_tracing_test.rb'
- 'test/new_relic/agent/configuration/default_source_test.rb'
- 'test/new_relic/agent/configuration/yaml_source_test.rb'
- 'test/new_relic/agent/external_test.rb'
- 'test/new_relic/agent/threading/backtrace_service_test.rb'
- 'test/new_relic/agent/threading/thread_profile_test.rb'
- 'test/new_relic/agent/transaction/slowest_sample_buffer_test.rb'

# Offense count: 52
# This cop supports safe autocorrection (--autocorrect).
Minitest/AssertEmptyLiteral:
Expand Down
4 changes: 2 additions & 2 deletions test/agent_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def assert_not_includes(collection, member, msg = nil)

unless defined? assert_empty
def assert_empty(collection, msg = nil)
assert collection.empty?, msg
assert_empty collection, msg
end
end

Expand Down Expand Up @@ -902,7 +902,7 @@ def assert_event_attributes(event, test_name, expected_attributes, non_expected_
event_attrs.each do |name, actual_value|
msg << " #{name}: #{actual_value.inspect}\n"
end
assert(incorrect_attributes.empty?, msg)
assert_empty(incorrect_attributes, msg)

non_expected_attributes.each do |name|
refute event_attrs[name], "Found value '#{event_attrs[name]}' for attribute '#{name}', but expected nothing in #{test_name}"
Expand Down
10 changes: 5 additions & 5 deletions test/multiverse/suites/rails/error_tracing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ def test_should_apply_parameter_filtering_for_non_standard_errors

def test_should_not_notice_errors_from_ignored_action
get('/error/ignored_action')
assert(errors.empty?,
assert_empty(errors,
'Noticed an error that should have been ignored')
end

def test_should_not_notice_ignored_error_classes
get('/error/ignored_error')
assert(errors.empty?,
assert_empty(errors,
'Noticed an error that should have been ignored')
end

Expand All @@ -232,15 +232,15 @@ def test_should_not_notice_filtered_errors
get('/error/controller_error')
end

assert(errors.empty?,
assert_empty(errors,
'Noticed an error that should have been ignored')
end

def test_should_not_notice_ignored_status_codes
with_config(:'error_collector.ignore_status_codes' => '500') do
get('/error/ignored_status_code')

assert(errors.empty?, 'Noticed an error that should have been ignored')
assert_empty(errors, 'Noticed an error that should have been ignored')
end
end

Expand Down Expand Up @@ -352,7 +352,7 @@ def test_should_notice_server_ignored_error_if_no_server_side_config
def test_should_ignore_server_ignored_errors
get('/error/server_ignored_error')

assert(errors.empty?,
assert_empty(errors,
'Noticed an error that should have been ignored' + errors.join(', '))
end
end
4 changes: 2 additions & 2 deletions test/new_relic/agent/configuration/default_source_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ def test_all_settings_specify_whether_they_are_allowed_from_server
end
end

assert unspecified_keys.empty?, "The following keys did not specify a value for :allowed_from_server: #{unspecified_keys.join(', ')}"
assert bad_value_keys.empty?, "The following keys had incorrect :allowed_from_server values (only true or false are allowed): #{bad_value_keys.join(', ')}"
assert_empty unspecified_keys, "The following keys did not specify a value for :allowed_from_server: #{unspecified_keys.join(', ')}"
assert_empty bad_value_keys, "The following keys had incorrect :allowed_from_server values (only true or false are allowed): #{bad_value_keys.join(', ')}"
end

def test_host_correct_when_license_key_matches_identifier
Expand Down
2 changes: 1 addition & 1 deletion test/new_relic/agent/configuration/yaml_source_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_failure_should_include_message
def test_transaction_threshold_one_liner
config = {'transaction_tracer.transaction_threshold' => 'apdex_f'}
@source.send(:substitute_transaction_threshold, config)
assert config.empty?
assert_empty config
end

[1, 'no', 'off', 0, 'false', [], {}, 1.0, Time.now].each do |value|
Expand Down
4 changes: 2 additions & 2 deletions test/new_relic/agent/external_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_process_request_metadata_not_in_transaction
}))

l = with_array_logger { NewRelic::Agent::External.process_request_metadata(rmd) }
assert l.array.empty?, "process_request_metadata should not log errors without a current transaction"
assert_empty l.array, "process_request_metadata should not log errors without a current transaction"

refute Tracer.current_transaction
end
Expand Down Expand Up @@ -123,7 +123,7 @@ def test_process_request_metadata_cross_app_disabled

in_transaction do |txn|
l = with_array_logger { NewRelic::Agent::External.process_request_metadata(rmd) }
assert l.array.empty?, "process_request_metadata should not log errors when cross app tracing is disabled"
assert_empty l.array, "process_request_metadata should not log errors when cross app tracing is disabled"

refute txn.distributed_tracer.cross_app_payload
end
Expand Down
2 changes: 1 addition & 1 deletion test/new_relic/agent/threading/backtrace_service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def test_on_transaction_finished_always_clears_buffer_for_current_thread
@service.poll

fake_transaction_finished('bar', 0, 1, thread)
assert @service.buffer.empty?
assert_empty @service.buffer
end

def test_on_transaction_finished_aggregates_backtraces_to_subscribed_profile
Expand Down
2 changes: 1 addition & 1 deletion test/new_relic/agent/threading/thread_profile_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def test_sample_count_for_thread_profiling

def test_empty
profile = ThreadProfile.new
assert profile.empty?
assert_empty profile
end

def test_not_empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_harvest_samples_resets

@buffer.harvest_samples

assert(@buffer.samples.empty?)
assert_empty(@buffer.samples)
end
end
end

0 comments on commit a696764

Please sign in to comment.