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

Silence some ruby warnings #1504

Merged
merged 1 commit into from
Jul 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sentry-ruby/lib/sentry/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def valid?
def sample_allowed?
return true if sample_rate == 1.0

if Random::DEFAULT.rand >= sample_rate
if Random.rand >= sample_rate
@errors << "Excluded by random sample"
false
else
Expand Down
1 change: 1 addition & 0 deletions sentry-ruby/lib/sentry/core_ext/object/deep_dup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def deep_dup
end

class Array
undef_method :deep_dup if method_defined?(:deep_dup)
# Returns a deep copy of array.
#
# array = [1, [2, 3]]
Expand Down
1 change: 1 addition & 0 deletions sentry-ruby/lib/sentry/core_ext/object/duplicable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def duplicable?
end

class Method
undef_method :duplicable? if method_defined?(:duplicable?)
# Methods are not duplicable:
#
# method(:puts).duplicable? # => false
Expand Down
3 changes: 2 additions & 1 deletion sentry-ruby/lib/sentry/transport/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module Sentry
class Transport
class Configuration
attr_accessor :timeout, :open_timeout, :proxy, :ssl, :ssl_ca_file, :ssl_verification, :http_adapter, :faraday_builder,
:transport_class, :encoding
:encoding
attr_reader :transport_class

def initialize
@ssl_verification = true
Expand Down
4 changes: 2 additions & 2 deletions sentry-ruby/spec/sentry/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@
end

it 'captured_allowed false when sampled' do
allow(Random::DEFAULT).to receive(:rand).and_return(0.76)
allow(Random).to receive(:rand).and_return(0.76)
expect(subject.sending_allowed?).to eq(false)
expect(subject.errors).to eq(["Excluded by random sample"])
end

it 'captured_allowed true when not sampled' do
allow(Random::DEFAULT).to receive(:rand).and_return(0.74)
allow(Random).to receive(:rand).and_return(0.74)
expect(subject.sending_allowed?).to eq(true)
end
end
Expand Down
4 changes: 2 additions & 2 deletions sentry-ruby/spec/sentry/interfaces/request_interface_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
it 'does not call #to_s for unnecessary env variables' do
expect(mock).not_to receive(:to_s)

interface = described_class.build(env: env)
described_class.build(env: env)
end
end
end
Expand Down Expand Up @@ -133,7 +133,7 @@ def to_s

new_env = env.merge("HTTP_FOO" => "BAR", "rails_object" => obj)

expect { interface = described_class.build(env: new_env) }.to_not raise_error
expect { described_class.build(env: new_env) }.to_not raise_error
end
end

Expand Down
10 changes: 1 addition & 9 deletions sentry-ruby/spec/sentry/net/http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@
::Logger.new(string_io)
end

original_buffered_io = Net::BufferedIO

before(:all) do
Net.send(:const_set, :BufferedIO, Net::WebMockNetBufferedIO)
end

after(:all) do
Net.send(:const_set, :BufferedIO, original_buffered_io)
end
before { stub_const('Net::BufferedIO', Net::WebMockNetBufferedIO) }
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍


class FakeSocket < StringIO
def setsockopt(*args); end
Expand Down
2 changes: 1 addition & 1 deletion sentry-ruby/spec/sentry/transport_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
before do
configuration.logger = Logger.new(string_io)
configuration.sample_rate = 0.5
allow(Random::DEFAULT).to receive(:rand).and_return(0.6)
allow(Random).to receive(:rand).and_return(0.6)
end

it "logs correct message" do
Expand Down