Skip to content

Commit 318796f

Browse files
authored
Log when methods are deprecated (#329)
1 parent c04a831 commit 318796f

File tree

9 files changed

+67
-5
lines changed

9 files changed

+67
-5
lines changed

.rubocop_todo.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2020-05-09 11:15:45 -0400 using RuboCop version 0.82.0.
3+
# on 2020-06-22 23:35:07 +0800 using RuboCop version 0.82.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -77,7 +77,7 @@ RSpec/ContextWording:
7777
RSpec/EmptyLineAfterExample:
7878
Enabled: false
7979

80-
# Offense count: 65
80+
# Offense count: 66
8181
# Configuration parameters: Max.
8282
RSpec/ExampleLength:
8383
Enabled: false
@@ -95,13 +95,13 @@ RSpec/InstanceVariable:
9595
- 'spec/slack/real_time/client_spec.rb'
9696
- 'spec/slack/slack_spec.rb'
9797

98-
# Offense count: 75
98+
# Offense count: 77
9999
# Configuration parameters: .
100100
# SupportedStyles: have_received, receive
101101
RSpec/MessageSpies:
102102
EnforcedStyle: receive
103103

104-
# Offense count: 94
104+
# Offense count: 95
105105
RSpec/MultipleExpectations:
106106
Max: 5
107107

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* [#324](https://github.com/slack-ruby/slack-ruby-client/pull/324): Require Faraday >= 1.0 - [@dblock](https://github.com/dblock).
55
* [#324](https://github.com/slack-ruby/slack-ruby-client/pull/324): Upgrade slack-ruby-danger, rubocop, rubocop-rspec and rubocop-performance - [@dblock](https://github.com/dblock).
66
* [#327](https://github.com/slack-ruby/slack-ruby-client/pull/327), [#326](https://github.com/slack-ruby/slack-ruby-client/pull/326): Added `admin_conversations_whitelist`, `admin_usergroups`, `calls` and `calls_participants` endpoints - [@wasabigeek](https://github.com/wasabigeek).
7+
* [#329](https://github.com/slack-ruby/slack-ruby-client/pull/329): Log when methods are deprecated - [@wasabigeek](https://github.com/wasabigeek).
78
* Your contribution here.
89

910
### 0.14.6 (2020/3/28)

lib/slack/web/api/endpoints/channels.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module Channels
1616
def channels_archive(options = {})
1717
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
1818
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
19+
logger.warn('channels.archive: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.archive.')
1920
post('channels.archive', options)
2021
end
2122

@@ -30,6 +31,7 @@ def channels_archive(options = {})
3031
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.create.json
3132
def channels_create(options = {})
3233
throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
34+
logger.warn('channels.create: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.create.')
3335
post('channels.create', options)
3436
end
3537

@@ -64,6 +66,7 @@ def channels_delete(options = {})
6466
def channels_history(options = {})
6567
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
6668
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
69+
logger.warn('channels.history: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.history.')
6770
post('channels.history', options)
6871
end
6972

@@ -79,6 +82,7 @@ def channels_history(options = {})
7982
def channels_info(options = {})
8083
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
8184
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
85+
logger.warn('channels.info: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.info.')
8286
post('channels.info', options)
8387
end
8488

@@ -96,6 +100,7 @@ def channels_invite(options = {})
96100
throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
97101
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
98102
options = options.merge(user: users_id(options)['user']['id']) if options[:user]
103+
logger.warn('channels.invite: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.invite.')
99104
post('channels.invite', options)
100105
end
101106

@@ -110,6 +115,7 @@ def channels_invite(options = {})
110115
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.join.json
111116
def channels_join(options = {})
112117
throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
118+
logger.warn('channels.join: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.join.')
113119
post('channels.join', options)
114120
end
115121

@@ -127,6 +133,7 @@ def channels_kick(options = {})
127133
throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
128134
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
129135
options = options.merge(user: users_id(options)['user']['id']) if options[:user]
136+
logger.warn('channels.kick: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.kick.')
130137
post('channels.kick', options)
131138
end
132139

@@ -140,6 +147,7 @@ def channels_kick(options = {})
140147
def channels_leave(options = {})
141148
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
142149
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
150+
logger.warn('channels.leave: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.leave.')
143151
post('channels.leave', options)
144152
end
145153

@@ -157,6 +165,7 @@ def channels_leave(options = {})
157165
# @see https://api.slack.com/methods/channels.list
158166
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.list.json
159167
def channels_list(options = {})
168+
logger.warn('channels.list: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.list, users.conversations.')
160169
if block_given?
161170
Pagination::Cursor.new(self, :channels_list, options).each do |page|
162171
yield page
@@ -179,6 +188,7 @@ def channels_mark(options = {})
179188
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
180189
throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
181190
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
191+
logger.warn('channels.mark: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: .')
182192
post('channels.mark', options)
183193
end
184194

@@ -197,6 +207,7 @@ def channels_rename(options = {})
197207
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
198208
throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
199209
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
210+
logger.warn('channels.rename: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.rename.')
200211
post('channels.rename', options)
201212
end
202213

@@ -213,6 +224,7 @@ def channels_replies(options = {})
213224
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
214225
throw ArgumentError.new('Required arguments :thread_ts missing') if options[:thread_ts].nil?
215226
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
227+
logger.warn('channels.replies: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.replies.')
216228
post('channels.replies', options)
217229
end
218230

@@ -231,6 +243,7 @@ def channels_setPurpose(options = {})
231243
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
232244
throw ArgumentError.new('Required arguments :purpose missing') if options[:purpose].nil?
233245
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
246+
logger.warn('channels.setPurpose: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.setPurpose.')
234247
post('channels.setPurpose', options)
235248
end
236249

@@ -247,6 +260,7 @@ def channels_setTopic(options = {})
247260
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
248261
throw ArgumentError.new('Required arguments :topic missing') if options[:topic].nil?
249262
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
263+
logger.warn('channels.setTopic: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.setTopic.')
250264
post('channels.setTopic', options)
251265
end
252266

@@ -260,6 +274,7 @@ def channels_setTopic(options = {})
260274
def channels_unarchive(options = {})
261275
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
262276
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
277+
logger.warn('channels.unarchive: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.unarchive.')
263278
post('channels.unarchive', options)
264279
end
265280
end

0 commit comments

Comments
 (0)