Skip to content

Commit

Permalink
Adjust code for RefuteEmpty rubocop rule
Browse files Browse the repository at this point in the history
  • Loading branch information
esquith committed Sep 12, 2022
1 parent 51fc036 commit fb7258e
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 22 deletions.
11 changes: 0 additions & 11 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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|
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 @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/new_relic/agent/new_relic_service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit fb7258e

Please sign in to comment.