Skip to content

Commit 0adc8d0

Browse files
committed
Silence some ruby warnings
1 parent dbd2cc8 commit 0adc8d0

File tree

8 files changed

+11
-16
lines changed

8 files changed

+11
-16
lines changed

sentry-ruby/lib/sentry/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ def valid?
405405
def sample_allowed?
406406
return true if sample_rate == 1.0
407407

408-
if Random::DEFAULT.rand >= sample_rate
408+
if Random.rand >= sample_rate
409409
@errors << "Excluded by random sample"
410410
false
411411
else

sentry-ruby/lib/sentry/core_ext/object/deep_dup.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def deep_dup
2020
end
2121

2222
class Array
23+
undef_method :deep_dup if method_defined?(:deep_dup)
2324
# Returns a deep copy of array.
2425
#
2526
# array = [1, [2, 3]]

sentry-ruby/lib/sentry/core_ext/object/duplicable.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def duplicable?
115115
end
116116

117117
class Method
118+
undef_method :duplicable? if method_defined?(:duplicable?)
118119
# Methods are not duplicable:
119120
#
120121
# method(:puts).duplicable? # => false

sentry-ruby/lib/sentry/transport/configuration.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ module Sentry
22
class Transport
33
class Configuration
44
attr_accessor :timeout, :open_timeout, :proxy, :ssl, :ssl_ca_file, :ssl_verification, :http_adapter, :faraday_builder,
5-
:transport_class, :encoding
5+
:encoding
6+
attr_reader :transport_class
67

78
def initialize
89
@ssl_verification = true

sentry-ruby/spec/sentry/configuration_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,13 @@
195195
end
196196

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

203203
it 'captured_allowed true when not sampled' do
204-
allow(Random::DEFAULT).to receive(:rand).and_return(0.74)
204+
allow(Random).to receive(:rand).and_return(0.74)
205205
expect(subject.sending_allowed?).to eq(true)
206206
end
207207
end

sentry-ruby/spec/sentry/interfaces/request_interface_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
it 'does not call #to_s for unnecessary env variables' do
6767
expect(mock).not_to receive(:to_s)
6868

69-
interface = described_class.build(env: env)
69+
described_class.build(env: env)
7070
end
7171
end
7272
end
@@ -133,7 +133,7 @@ def to_s
133133

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

136-
expect { interface = described_class.build(env: new_env) }.to_not raise_error
136+
expect { described_class.build(env: new_env) }.to_not raise_error
137137
end
138138
end
139139

sentry-ruby/spec/sentry/net/http_spec.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,7 @@
1010
::Logger.new(string_io)
1111
end
1212

13-
original_buffered_io = Net::BufferedIO
14-
15-
before(:all) do
16-
Net.send(:const_set, :BufferedIO, Net::WebMockNetBufferedIO)
17-
end
18-
19-
after(:all) do
20-
Net.send(:const_set, :BufferedIO, original_buffered_io)
21-
end
13+
before { stub_const('Net::BufferedIO', Net::WebMockNetBufferedIO) }
2214

2315
class FakeSocket < StringIO
2416
def setsockopt(*args); end

sentry-ruby/spec/sentry/transport_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
before do
8888
configuration.logger = Logger.new(string_io)
8989
configuration.sample_rate = 0.5
90-
allow(Random::DEFAULT).to receive(:rand).and_return(0.6)
90+
allow(Random).to receive(:rand).and_return(0.6)
9191
end
9292

9393
it "logs correct message" do

0 commit comments

Comments
 (0)