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

Log when methods are deprecated #329

Merged
merged 8 commits into from
Jun 22, 2020
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
8 changes: 4 additions & 4 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-05-09 11:15:45 -0400 using RuboCop version 0.82.0.
# on 2020-06-22 23:35:07 +0800 using RuboCop version 0.82.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -77,7 +77,7 @@ RSpec/ContextWording:
RSpec/EmptyLineAfterExample:
Enabled: false

# Offense count: 65
# Offense count: 66
# Configuration parameters: Max.
RSpec/ExampleLength:
Enabled: false
Expand All @@ -95,13 +95,13 @@ RSpec/InstanceVariable:
- 'spec/slack/real_time/client_spec.rb'
- 'spec/slack/slack_spec.rb'

# Offense count: 75
# Offense count: 77
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
EnforcedStyle: receive

# Offense count: 94
# Offense count: 95
RSpec/MultipleExpectations:
Max: 5
Comment on lines +98 to 106
Copy link
Contributor Author

@wasabigeek wasabigeek Jun 22, 2020

Choose a reason for hiding this comment

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

EDITED

Ok I managed to get by this offence by doing this:

        logger = instance_double(Logger)
        allow(client).to receive(:logger).and_return(logger)
        allow(client).to receive(:post)

        expect(logger).to receive(:warn).with(/
          ^channels\.archive:\ This\ method\ is\ deprecated
          .+
          Alternative\ methods:\ conversations\.archive\.
        /x)
        client.channels_archive(channel: 'test')

Do you think I should do so? If not, could we ignore these style cops completely :D

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think ignoring expectations is fine. I usually just -a everything and selectively fix if I feel like it.


Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [#324](https://github.com/slack-ruby/slack-ruby-client/pull/324): Require Faraday >= 1.0 - [@dblock](https://github.com/dblock).
* [#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).
* [#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).
* [#329](https://github.com/slack-ruby/slack-ruby-client/pull/329): Log when methods are deprecated - [@wasabigeek](https://github.com/wasabigeek).
* Your contribution here.

### 0.14.6 (2020/3/28)
Expand Down
15 changes: 15 additions & 0 deletions lib/slack/web/api/endpoints/channels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Channels
def channels_archive(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
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.')
post('channels.archive', options)
end

Expand All @@ -30,6 +31,7 @@ def channels_archive(options = {})
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.create.json
def channels_create(options = {})
throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
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.')
post('channels.create', options)
end

Expand Down Expand Up @@ -64,6 +66,7 @@ def channels_delete(options = {})
def channels_history(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
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.')
post('channels.history', options)
end

Expand All @@ -79,6 +82,7 @@ def channels_history(options = {})
def channels_info(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
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.')
post('channels.info', options)
end

Expand All @@ -96,6 +100,7 @@ def channels_invite(options = {})
throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
options = options.merge(user: users_id(options)['user']['id']) if options[:user]
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.')
post('channels.invite', options)
end

Expand All @@ -110,6 +115,7 @@ def channels_invite(options = {})
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.join.json
def channels_join(options = {})
throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
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.')
post('channels.join', options)
end

Expand All @@ -127,6 +133,7 @@ def channels_kick(options = {})
throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
options = options.merge(user: users_id(options)['user']['id']) if options[:user]
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.')
post('channels.kick', options)
end

Expand All @@ -140,6 +147,7 @@ def channels_kick(options = {})
def channels_leave(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
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.')
post('channels.leave', options)
end

Expand All @@ -157,6 +165,7 @@ def channels_leave(options = {})
# @see https://api.slack.com/methods/channels.list
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.list.json
def channels_list(options = {})
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.')
if block_given?
Pagination::Cursor.new(self, :channels_list, options).each do |page|
yield page
Expand All @@ -179,6 +188,7 @@ def channels_mark(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
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: .')
post('channels.mark', options)
end

Expand All @@ -197,6 +207,7 @@ def channels_rename(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
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.')
post('channels.rename', options)
end

Expand All @@ -213,6 +224,7 @@ def channels_replies(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :thread_ts missing') if options[:thread_ts].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
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.')
post('channels.replies', options)
end

Expand All @@ -231,6 +243,7 @@ def channels_setPurpose(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :purpose missing') if options[:purpose].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
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.')
post('channels.setPurpose', options)
end

Expand All @@ -247,6 +260,7 @@ def channels_setTopic(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :topic missing') if options[:topic].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
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.')
post('channels.setTopic', options)
end

Expand All @@ -260,6 +274,7 @@ def channels_setTopic(options = {})
def channels_unarchive(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
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.')
post('channels.unarchive', options)
end
end
Expand Down
Loading