Skip to content

Commit

Permalink
Resolve warnings
Browse files Browse the repository at this point in the history
This commit resolves the following warnings:

* instance variable @variable_name not initialized
* ambiguous first argument; put parentheses or a space even after `/' operator
* Using `expect { }.not_to raise_error(SpecificErrorClass, message)` risks false positives
  • Loading branch information
abicky committed May 15, 2022
1 parent 7625ec6 commit d6ef116
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
6 changes: 4 additions & 2 deletions lib/datadog/statsd/forwarder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ def initialize(
)
@transport_type = connection_cfg.transport_type

if telemetry_flush_interval
@telemetry = Telemetry.new(telemetry_flush_interval,
@telemetry = if telemetry_flush_interval
Telemetry.new(telemetry_flush_interval,
global_tags: global_tags,
transport_type: @transport_type
)
else
nil
end

@connection = connection_cfg.make_connection(logger: logger, telemetry: telemetry)
Expand Down
6 changes: 4 additions & 2 deletions lib/datadog/statsd/sender.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ def initialize(message_buffer, telemetry: nil, queue_size: UDP_DEFAULT_BUFFER_SI
@mx = Mutex.new
@queue_class = queue_class
@thread_class = thread_class
if flush_interval
@flush_timer = Datadog::Statsd::Timer.new(flush_interval) { flush(sync: true) }
@flush_timer = if flush_interval
Datadog::Statsd::Timer.new(flush_interval) { flush(sync: true) }
else
nil
end
end

Expand Down
1 change: 1 addition & 0 deletions lib/datadog/statsd/timer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def initialize(interval, &callback)
@interval = interval
@callback = callback
@stop = true
@thread = nil
end

def start
Expand Down
2 changes: 1 addition & 1 deletion spec/statsd/version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Datadog::Statsd do
describe 'VERSION' do
it 'has a version' do
expect(Datadog::Statsd::VERSION).to match /\d+\.\d+\.\d+/
expect(Datadog::Statsd::VERSION).to match(/\d+\.\d+\.\d+/)
end
end
end
2 changes: 1 addition & 1 deletion spec/statsd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@
it 'does not raise error' do
expect do
subject.event(title, text, options)
end.not_to raise_error(RuntimeError, /payload is too big/)
end.not_to raise_error
end
end
end
Expand Down

0 comments on commit d6ef116

Please sign in to comment.