From fb7258e65385bffc34abf10f755ad69dfcd27b81 Mon Sep 17 00:00:00 2001 From: esquith Date: Mon, 12 Sep 2022 14:37:38 -0400 Subject: [PATCH] Adjust code for RefuteEmpty rubocop rule --- .rubocop_todo.yml | 11 ----------- .../agent_integrations/datastore_segment_test.rb | 2 +- .../agent_integrations/segment_test.rb | 2 +- .../suites/sidekiq/sidekiq_instrumentation_test.rb | 4 ++-- test/new_relic/agent/external_test.rb | 4 ++-- test/new_relic/agent/new_relic_service_test.rb | 6 +++--- .../transaction/external_request_segment_test.rb | 4 ++-- 7 files changed, 11 insertions(+), 22 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index faa66a961d..41406e75f6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -179,17 +179,6 @@ Minitest/LiteralAsActualArgument: Minitest/MultipleAssertions: Max: 28 -# Offense count: 11 -# This cop supports safe autocorrection (--autocorrect). -Minitest/RefuteEmpty: - Exclude: - - 'infinite_tracing/test/infinite_tracing/agent_integrations/datastore_segment_test.rb' - - 'infinite_tracing/test/infinite_tracing/agent_integrations/segment_test.rb' - - 'test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb' - - 'test/new_relic/agent/external_test.rb' - - 'test/new_relic/agent/new_relic_service_test.rb' - - 'test/new_relic/agent/transaction/external_request_segment_test.rb' - # Offense count: 9 # This cop supports safe autocorrection (--autocorrect). Minitest/RefuteEqual: diff --git a/infinite_tracing/test/infinite_tracing/agent_integrations/datastore_segment_test.rb b/infinite_tracing/test/infinite_tracing/agent_integrations/datastore_segment_test.rb index b92dee9179..07c40c3320 100644 --- a/infinite_tracing/test/infinite_tracing/agent_integrations/datastore_segment_test.rb +++ b/infinite_tracing/test/infinite_tracing/agent_integrations/datastore_segment_test.rb @@ -57,7 +57,7 @@ def test_sampled_segment_records_span_event assert_equal 'Span', intrinsics['type'].string_value assert_equal trace_id, intrinsics['traceId'].string_value - refute intrinsics['guid'].string_value.empty? + refute_empty intrinsics['guid'].string_value assert_equal root_guid, intrinsics['parentId'].string_value assert_equal txn_guid, intrinsics['transactionId'].string_value assert_equal sampled, intrinsics['sampled'].bool_value diff --git a/infinite_tracing/test/infinite_tracing/agent_integrations/segment_test.rb b/infinite_tracing/test/infinite_tracing/agent_integrations/segment_test.rb index 68dbf9a4d4..6d680160e4 100644 --- a/infinite_tracing/test/infinite_tracing/agent_integrations/segment_test.rb +++ b/infinite_tracing/test/infinite_tracing/agent_integrations/segment_test.rb @@ -45,7 +45,7 @@ def test_sampled_segment_records_span_event assert_equal 'Span', custom_span_event['intrinsics']['type'].string_value assert_equal trace_id, custom_span_event['intrinsics']['traceId'].string_value - refute custom_span_event['intrinsics']['guid'].string_value.empty? + refute_empty custom_span_event['intrinsics']['guid'].string_value assert_equal root_guid, custom_span_event['intrinsics']['parentId'].string_value assert_equal txn_guid, custom_span_event['intrinsics']['transactionId'].string_value assert_equal sampled, custom_span_event['intrinsics']['sampled'].bool_value diff --git a/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb b/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb index 25c743bbed..ecd3da7b3a 100644 --- a/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +++ b/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb @@ -192,7 +192,7 @@ def assert_metric_and_call_count(name, expected_call_count) def assert_attributes_on_transaction_trace transaction_samples = $collector.calls_for('transaction_sample_data') - refute transaction_samples.empty?, "Expected a transaction trace" + refute_empty transaction_samples, "Expected a transaction trace" transaction_samples.each do |post| post.samples.each do |sample| @@ -207,7 +207,7 @@ def assert_attributes_on_transaction_trace def refute_attributes_on_transaction_trace transaction_samples = $collector.calls_for('transaction_sample_data') - refute transaction_samples.empty?, "Didn't find any transaction samples!" + refute_empty transaction_samples, "Didn't find any transaction samples!" transaction_samples.each do |post| post.samples.each do |sample| diff --git a/test/new_relic/agent/external_test.rb b/test/new_relic/agent/external_test.rb index 2779bfdfee..5c441ed02a 100644 --- a/test/new_relic/agent/external_test.rb +++ b/test/new_relic/agent/external_test.rb @@ -88,7 +88,7 @@ def test_process_request_metadata_with_invalid_id in_transaction do |txn| l = with_array_logger { NewRelic::Agent::External.process_request_metadata(rmd) } - refute l.array.empty?, "process_request_metadata should log error on invalid ID" + refute_empty l.array, "process_request_metadata should log error on invalid ID" assert l.array.first =~ %r{invalid/non-trusted ID} refute txn.distributed_tracer.cross_app_payload @@ -106,7 +106,7 @@ def test_process_request_metadata_with_non_trusted_id in_transaction do |txn| l = with_array_logger { NewRelic::Agent::External.process_request_metadata(rmd) } - refute l.array.empty?, "process_request_metadata should log error on invalid ID" + refute_empty l.array, "process_request_metadata should log error on invalid ID" assert l.array.first =~ %r{invalid/non-trusted ID} refute txn.distributed_tracer.cross_app_payload diff --git a/test/new_relic/agent/new_relic_service_test.rb b/test/new_relic/agent/new_relic_service_test.rb index e3d1fb76be..63591fa229 100644 --- a/test/new_relic/agent/new_relic_service_test.rb +++ b/test/new_relic/agent/new_relic_service_test.rb @@ -286,7 +286,7 @@ def test_preconnect_with_token_and_lasp with_config(:security_policies_token => 'please-use-lasp') do response = @service.preconnect assert_equal 'localhost', response['redirect_host'] - refute response['security_policies'].empty? + refute_empty response['security_policies'] end end @@ -359,7 +359,7 @@ def test_preliminary_security_policies_sent_on_connect with_config(:security_policies_token => 'please-use-lasp') do @service.connect payload = @http_handle.last_request_payload.first - refute payload['security_policies'].empty? + refute_empty payload['security_policies'] assert_equal policies.keys, payload['security_policies'].keys end end @@ -371,7 +371,7 @@ def test_security_policies_merged_into_connect_response with_config(:security_policies_token => 'please-use-lasp') do response = @service.connect - refute response['security_policies'].empty? + refute_empty response['security_policies'] assert_equal policies.keys, response['security_policies'].keys end end diff --git a/test/new_relic/agent/transaction/external_request_segment_test.rb b/test/new_relic/agent/transaction/external_request_segment_test.rb index a776cc0f4d..1960f16d54 100644 --- a/test/new_relic/agent/transaction/external_request_segment_test.rb +++ b/test/new_relic/agent/transaction/external_request_segment_test.rb @@ -695,7 +695,7 @@ def test_process_response_metadata_with_invalid_cross_app_id l = with_array_logger do segment = external_request_segment { |s| s.process_response_metadata(rmd); s } end - refute l.array.empty?, "process_response_metadata should log error on invalid ID" + refute_empty l.array, "process_response_metadata should log error on invalid ID" assert l.array.first =~ %r{invalid/non-trusted ID} assert_equal 'External/example.com/foo/get', segment.name @@ -721,7 +721,7 @@ def test_process_response_metadata_with_untrusted_cross_app_id l = with_array_logger do segment = external_request_segment { |s| s.process_response_metadata(rmd); s } end - refute l.array.empty?, "process_response_metadata should log error on invalid ID" + refute_empty l.array, "process_response_metadata should log error on invalid ID" assert l.array.first =~ %r{invalid/non-trusted ID} assert_equal 'External/example.com/foo/get', segment.name