Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve warnings #258

Merged
merged 1 commit into from
May 19, 2022
Merged

Resolve warnings #258

merged 1 commit into from
May 19, 2022

Conversation

abicky
Copy link
Contributor

@abicky abicky commented May 15, 2022

This PR 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

Before

% ruby --version
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20]
% bundle exec rake >/dev/null 2>&1 | grep -i warning: | sed -E 's/^[.*]+//g' | sort -u
/Users/arabiki/ghq/src/github.com/DataDog/dogstatsd-ruby/lib/datadog/statsd/forwarder.rb:67: warning: instance variable @telemetry not initialized
/Users/arabiki/ghq/src/github.com/DataDog/dogstatsd-ruby/lib/datadog/statsd/sender.rb:105: warning: instance variable @flush_timer not initialized
/Users/arabiki/ghq/src/github.com/DataDog/dogstatsd-ruby/lib/datadog/statsd/sender.rb:97: warning: instance variable @flush_timer not initialized
/Users/arabiki/ghq/src/github.com/DataDog/dogstatsd-ruby/lib/datadog/statsd/timer.rb:44: warning: instance variable @thread not initialized
/Users/arabiki/ghq/src/github.com/DataDog/dogstatsd-ruby/spec/statsd/version_spec.rb:6: warning: ambiguous first argument; put parentheses or a space even after `/' operator
WARNING: Using `expect { }.not_to raise_error(SpecificErrorClass, message)` risks false positives, since literally any other error would cause the expectation to pass, including those raised by Ruby (e.g. `NoMethodError`, `NameError` and `ArgumentError`), meaning the code you are intending to test may not even get reached. Instead consider using `expect { }.not_to raise_error` or `expect { }.to raise_error(DifferentSpecificErrorClass)`. This message can be suppressed by setting: `RSpec::Expectations.configuration.on_potential_false_positives = :nothing`. Called from /Users/arabiki/ghq/src/github.com/DataDog/dogstatsd-ruby/spec/statsd_spec.rb:1015:in `block (5 levels) in <top (required)>'.
%
% ruby --version
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin20]
% bundle exec rake >/dev/null 2>&1 | grep -i warning: | sed -E 's/^[.*]+//g' | sort -u
/Users/arabiki/ghq/src/github.com/DataDog/dogstatsd-ruby/spec/statsd/version_spec.rb:6: warning: ambiguity between regexp and two divisions: wrap regexp in parentheses or add a space after `/' operator
WARNING: Using `expect { }.not_to raise_error(SpecificErrorClass, message)` risks false positives, since literally any other error would cause the expectation to pass, including those raised by Ruby (e.g. `NoMethodError`, `NameError` and `ArgumentError`), meaning the code you are intending to test may not even get reached. Instead consider using `expect { }.not_to raise_error` or `expect { }.to raise_error(DifferentSpecificErrorClass)`. This message can be suppressed by setting: `RSpec::Expectations.configuration.on_potential_false_positives = :nothing`. Called from /Users/arabiki/ghq/src/github.com/DataDog/dogstatsd-ruby/spec/statsd_spec.rb:1015:in `block (5 levels) in <top (required)>'.
%

After

% ruby --version
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20]
% bundle exec rake >/dev/null 2>&1 | grep -i warning: | sed -E 's/^[.*]+//g' | sort -u
%
% ruby --version
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin20]
% bundle exec rake >/dev/null 2>&1 | grep -i warning: | sed -E 's/^[.*]+//g' | sort -u
%

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
Copy link
Contributor

@djmitche djmitche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look great -- thanks!

@djmitche djmitche merged commit 14cf326 into DataDog:master May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants