Skip to content

Commit 17a2cbd

Browse files
committed
chore: Avoid method redefinition warnings.
These are harmless but I'm trying to get my application warning free because warnings tend to point nasty bugs. ``` lib/twilio-ruby/util/configuration.rb:8: warning: method redefined; discarding old account_sid= lib/twilio-ruby/util/configuration.rb:12: warning: method redefined; discarding old auth_token= lib/twilio-ruby/util/configuration.rb:16: warning: method redefined; discarding old http_client= lib/twilio-ruby/util/configuration.rb:20: warning: method redefined; discarding old region= lib/twilio-ruby/util/configuration.rb:24: warning: method redefined; discarding old edge= lib/twilio-ruby/util/configuration.rb:28: warning: method redefined; discarding old logger= ``` There are a number of warnings left but I can't fix them because they are in generated code. Almost all of them have to do witht the `context` method: ``` lib/twilio-ruby/rest/studio/v1/flow/engagement.rb:321: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/engagement.rb:282: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v1/flow/engagement/engagement_context.rb:162: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/engagement/engagement_context.rb:143: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v1/flow/engagement/step.rb:293: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/engagement/step.rb:249: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v1/flow/engagement/step/step_context.rb:170: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/engagement/step/step_context.rb:150: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v1/flow/execution.rb:367: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/execution.rb:328: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v1/flow/execution/execution_context.rb:163: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/execution/execution_context.rb:144: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step.rb:299: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step.rb:255: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step/execution_step_context.rb:173: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step/execution_step_context.rb:153: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v2/flow/execution.rb:360: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v2/flow/execution.rb:327: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v2/flow/execution/execution_context.rb:163: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v2/flow/execution/execution_context.rb:144: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step.rb:299: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step.rb:255: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step/execution_step_context.rb:173: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step/execution_step_context.rb:153: warning: previous definition of context was here lib/twilio-ruby/twiml/voice_response.rb:794: warning: method redefined; discarding old initialize lib/twilio-ruby/twiml/messaging_response.rb:50: warning: previous definition of initialize was here ```
1 parent 4192192 commit 17a2cbd

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

lib/twilio-ruby/util/configuration.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module Twilio
44
module Util
55
class Configuration
6-
attr_accessor :account_sid, :auth_token, :http_client, :region, :edge, :logger
6+
attr_reader :account_sid, :auth_token, :http_client, :region, :edge, :logger
77

88
def account_sid=(value)
99
@account_sid = value

spec/rack/twilio_webhook_authentication_spec.rb

+12-12
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
expect(Twilio::Security::RequestValidator).to receive(:new).with(auth_token).and_return(request_validator)
3939
expect(request_validator).to receive(:validate).and_return(true)
4040
request = Rack::MockRequest.env_for('/voice')
41-
status, headers, body = @middleware.call(request)
41+
status, _headers, _body = @middleware.call(request)
4242
expect(status).to be(200)
4343
end
4444
end
@@ -51,7 +51,7 @@
5151
it 'should not intercept when the path doesn\'t match' do
5252
expect(Twilio::Security::RequestValidator).to_not receive(:validate)
5353
request = Rack::MockRequest.env_for('/sms')
54-
status, headers, body = @middleware.call(request)
54+
status, _headers, _body = @middleware.call(request)
5555
expect(status).to be(200)
5656
end
5757

@@ -60,7 +60,7 @@
6060
receive(:validate).and_return(true)
6161
)
6262
request = Rack::MockRequest.env_for('/voice')
63-
status, headers, body = @middleware.call(request)
63+
status, _headers, _body = @middleware.call(request)
6464
expect(status).to be(200)
6565
end
6666

@@ -69,7 +69,7 @@
6969
receive(:validate).and_return(false)
7070
)
7171
request = Rack::MockRequest.env_for('/voice')
72-
status, headers, body = @middleware.call(request)
72+
status, _headers, _body = @middleware.call(request)
7373
expect(status).to be(403)
7474
end
7575
end
@@ -82,7 +82,7 @@
8282
it 'should not intercept when the path doesn\'t match' do
8383
expect(Twilio::Security::RequestValidator).to_not receive(:validate)
8484
request = Rack::MockRequest.env_for('icesms')
85-
status, headers, body = @middleware.call(request)
85+
status, _headers, _body = @middleware.call(request)
8686
expect(status).to be(200)
8787
end
8888

@@ -91,7 +91,7 @@
9191
receive(:validate).and_return(true)
9292
)
9393
request = Rack::MockRequest.env_for('/sms')
94-
status, headers, body = @middleware.call(request)
94+
status, _headers, _body = @middleware.call(request)
9595
expect(status).to be(200)
9696
end
9797

@@ -100,7 +100,7 @@
100100
receive(:validate).and_return(false)
101101
)
102102
request = Rack::MockRequest.env_for('/sms')
103-
status, headers, body = @middleware.call(request)
103+
status, _headers, _body = @middleware.call(request)
104104
expect(status).to be(403)
105105
end
106106
end
@@ -118,7 +118,7 @@
118118
request['HTTP_X_TWILIO_SIGNATURE'] = '+LYlbGr/VmN84YPJQCuWs+9UA7E='
119119
request['CONTENT_TYPE'] = 'application/json'
120120

121-
status, headers, body = middleware.call(request)
121+
status, _headers, _body = middleware.call(request)
122122

123123
expect(status).not_to be(200)
124124
end
@@ -135,7 +135,7 @@
135135
request['HTTP_X_TWILIO_SIGNATURE'] = 'zR5Oq4f6cijN5oz5bisiVuxYnTU='
136136
request['CONTENT_TYPE'] = 'application/json'
137137

138-
status, headers, body = middleware.call(request)
138+
status, _headers, _body = middleware.call(request)
139139

140140
expect(status).to be(200)
141141
end
@@ -153,7 +153,7 @@
153153
request['CONTENT_TYPE'] = 'application/json'
154154
request['rack.input'].read
155155

156-
status, headers, body = middleware.call(request)
156+
status, _headers, _body = middleware.call(request)
157157

158158
expect(status).to be(200)
159159
end
@@ -171,7 +171,7 @@
171171
request['HTTP_X_TWILIO_SIGNATURE'] = 'foobarbaz'
172172
expect(request['CONTENT_TYPE']).to eq('application/x-www-form-urlencoded')
173173

174-
status, headers, body = middleware.call(request)
174+
status, _headers, _body = middleware.call(request)
175175

176176
expect(status).not_to be(200)
177177
end
@@ -187,7 +187,7 @@
187187
request['HTTP_X_TWILIO_SIGNATURE'] = 'TR9Skm9jiF4WVRJznU5glK5I83k='
188188
expect(request['CONTENT_TYPE']).to eq('application/x-www-form-urlencoded')
189189

190-
status, headers, body = middleware.call(request)
190+
status, _headers, _body = middleware.call(request)
191191

192192
expect(status).to be(200)
193193
end

spec/spec_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
$VERBOSE = true
2+
13
if RUBY_VERSION.start_with?('3.0')
24
require 'simplecov'
35
require 'simplecov_json_formatter'

0 commit comments

Comments
 (0)