Skip to content

Commit

Permalink
Silence some ruby warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ojab committed Jul 24, 2021
1 parent dbd2cc8 commit 0adc8d0
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 16 deletions.
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) }

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

0 comments on commit 0adc8d0

Please sign in to comment.