Skip to content

Commit

Permalink
Upgraded to RuboCop 0.51.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Nov 25, 2017
1 parent 9e6ea96 commit 43fd6ea
Show file tree
Hide file tree
Showing 42 changed files with 200 additions and 177 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ AllCops:
- vendor/**/*
- lib/slack/web/api/slack-api-ref/**/*

Naming/MethodName:
Enabled: false

inherit_from: .rubocop_todo.yml
64 changes: 30 additions & 34 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 2017-09-19 15:04:24 -0400 using RuboCop version 0.35.0.
# on 2017-11-25 11:28:32 -0500 using RuboCop version 0.51.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 All @@ -14,34 +14,38 @@ Lint/HandleExceptions:
- 'spec/slack/real_time/concurrency/eventmachine_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IgnoreEmptyBlocks.
Lint/UnusedBlockArgument:
Lint/RescueWithoutErrorClass:
Exclude:
- 'lib/slack/messages/formatting.rb'
- 'lib/slack/real_time/concurrency/celluloid.rb'

# Offense count: 18
Metrics/AbcSize:
Max: 44

# Offense count: 81
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 421

# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 165
Max: 166

# Offense count: 4
Metrics/CyclomaticComplexity:
Max: 9

# Offense count: 734
# Configuration parameters: AllowURI, URISchemes.
# Offense count: 741
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 266

# Offense count: 9
# Offense count: 10
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 32
Max: 42

# Offense count: 1
# Configuration parameters: CountComments.
Expand All @@ -52,28 +56,32 @@ Metrics/ModuleLength:
Metrics/PerceivedComplexity:
Max: 11

# Offense count: 64
# Configuration parameters: Exclude.
Style/Documentation:
Enabled: false

# Offense count: 1
# Configuration parameters: Exclude.
Style/FileName:
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'lib/slack-ruby-client.rb'

# Offense count: 136
# Offense count: 63
Style/Documentation:
Enabled: false

# Offense count: 137
# Configuration parameters: AllowedVariables.
Style/GlobalVars:
Enabled: false

# Offense count: 24
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/MethodName:
Enabled: false
# Offense count: 2
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'lib/slack/real_time/stores/store.rb'
- 'lib/slack/web/faraday/response/raise_error.rb'

# Offense count: 3
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: module_function, extend_self
Style/ModuleFunction:
Exclude:
- 'lib/slack/config.rb'
Expand All @@ -84,15 +92,3 @@ Style/ModuleFunction:
Style/MultilineTernaryOperator:
Exclude:
- 'spec/support/real_time/connected_client.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/RescueModifier:
Exclude:
- 'lib/slack/real_time/concurrency/celluloid.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/SpecialGlobalVars:
Exclude:
- 'lib/slack/messages/formatting.rb'
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ cache: bundler
rvm:
- 2.2
- 2.1
- 2.0
- 2.3.4
- ruby-head
- jruby-head
Expand Down
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
### 0.10.1 (next)

* Your contribution here.
* [#173](https://github.com/slack-ruby/slack-ruby-client/issues/173): Added dialog support - [@alexagranov](https://github.com/alexagranov).
* [#176](https://github.com/slack-ruby/slack-ruby-client/issues/176): Drop dependency on `json` gem - [@seuros](https://github.com/seuros).
* [#177](https://github.com/slack-ruby/slack-ruby-client/pull/177): Fix api ref repo - [@manuelmeurer](https://github.com/manuelmeurer).
* [#176](https://github.com/slack-ruby/slack-ruby-client/issues/176): Drop dependency on json gem - [@seuros](https://github.com/seuros).
* [#173](https://github.com/slack-ruby/slack-ruby-client/issues/173): Updated to latest slack-api-ref => we have Dialogs!; Added dialog.1.open-json-support patch to apply the JSON fix to :dialog param - [@alexagranov](https://github.com/alexagranov).
* [#180](https://github.com/slack-ruby/slack-ruby-client/pull/180): Upgraded RuboCop 0.51.0 - [@dblock](https://github.com/dblock).
* Your contribution here.

### 0.10.0 (9/19/2017)

Expand Down
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ source 'http://rubygems.org'
gemspec

gem ENV['CONCURRENCY'], require: false if ENV.key?('CONCURRENCY')
gem 'picky' unless RUBY_PLATFORM == 'java'
# rubocop:enable Bundler/OrderedGems

gem 'activesupport', '~> 4.0'
gem 'picky' unless RUBY_PLATFORM == 'java'

group :test do
gem 'slack-ruby-danger', '~> 0.1.0', require: false
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ end
require 'rubocop/rake_task'
RuboCop::RakeTask.new

task default: [:rubocop, :spec]
task default: %i[rubocop spec]

load 'tasks/git.rake'
load 'tasks/web.rake'
Expand Down
2 changes: 1 addition & 1 deletion bin/slack
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ program_desc 'Slack client.'

default_command :help

switch [:d, :debug], desc: 'Enable debug-level logging.', default_value: false
switch %i[d debug], desc: 'Enable debug-level logging.', default_value: false
flag [:t, 'slack-api-token'], desc: 'Slack API token.', default_value: ENV['SLACK_API_TOKEN']
flag ['vcr-cassette-name'], desc: 'Offline VCR cassette.'

Expand Down
2 changes: 1 addition & 1 deletion examples/hi_real_time/hi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
config.token = ENV['SLACK_API_TOKEN']
config.logger = Logger.new(STDOUT)
config.logger.level = Logger::INFO
fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
end

client = Slack::RealTime::Client.new
Expand Down
2 changes: 1 addition & 1 deletion examples/hi_real_time_and_web/hi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Slack.configure do |config|
config.token = ENV['SLACK_API_TOKEN']
fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
end

client = Slack::RealTime::Client.new
Expand Down
2 changes: 1 addition & 1 deletion examples/hi_real_time_async_celluloid/hi.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'slack-ruby-client'

fail 'Missing ENV[SLACK_API_TOKENS]!' unless ENV.key?('SLACK_API_TOKENS')
raise 'Missing ENV[SLACK_API_TOKENS]!' unless ENV.key?('SLACK_API_TOKENS')

$stdout.sync = true
logger = Logger.new($stdout)
Expand Down
2 changes: 1 addition & 1 deletion examples/hi_real_time_async_eventmachine/hi.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'slack-ruby-client'

fail 'Missing ENV[SLACK_API_TOKENS]!' unless ENV.key?('SLACK_API_TOKENS')
raise 'Missing ENV[SLACK_API_TOKENS]!' unless ENV.key?('SLACK_API_TOKENS')

$stdout.sync = true
logger = Logger.new($stdout)
Expand Down
2 changes: 1 addition & 1 deletion examples/hi_web/hi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Slack.configure do |config|
config.token = ENV['SLACK_API_TOKEN']
fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
end

client = Slack::Web::Client.new
Expand Down
2 changes: 1 addition & 1 deletion examples/new_ticket/new_ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Slack.configure do |config|
config.token = ENV['SLACK_API_TOKEN']
fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
end

client = Slack::Web::Client.new
Expand Down
8 changes: 4 additions & 4 deletions lib/slack/messages/formatting.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8

module Slack
module Messages
module Formatting
Expand All @@ -10,9 +10,9 @@ class << self
def unescape(message)
CGI.unescapeHTML(message.gsub(/[“”]/, '"')
.gsub(/[‘’]/, "'")
.gsub(/<(?<sign>[?@#!]?)(?<dt>.*?)>/) do |match|
sign = $~[:sign]
dt = $~[:dt]
.gsub(/<(?<sign>[?@#!]?)(?<dt>.*?)>/) do
sign = Regexp.last_match[:sign]
dt = Regexp.last_match[:dt]
rhs = dt.split('|', 2).last
case sign
when '@', '!'
Expand Down
3 changes: 1 addition & 2 deletions lib/slack/messages/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ def to_s
private

# see https://github.com/intridea/hashie/issues/394
def log_built_in_message(*)
end
def log_built_in_message(*); end
end
end
end
19 changes: 10 additions & 9 deletions lib/slack/real_time/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def initialize(options = {})
@web_client = Slack::Web::Client.new(token: token, logger: logger)
end

[:users, :self, :channels, :team, :teams, :groups, :ims, :bots].each do |store_method|
%i[users self channels team teams groups ims bots].each do |store_method|
define_method store_method do
store.send(store_method) if store
end
Expand All @@ -60,7 +60,7 @@ def start_async(&block)
end

def stop!
fail ClientNotStartedError unless started?
raise ClientNotStartedError unless started?
@socket.disconnect! if @socket
end

Expand Down Expand Up @@ -106,7 +106,7 @@ def run_loop

# @return [Slack::RealTime::Socket]
def build_socket
fail ClientAlreadyStartedError if started?
raise ClientAlreadyStartedError if started?
start = web_client.send(rtm_start_method, start_options)
data = Slack::Messages::Message.new(start)
@url = data.url
Expand Down Expand Up @@ -138,13 +138,12 @@ def socket_class
end

def send_json(data)
fail ClientNotStartedError unless started?
raise ClientNotStartedError unless started?
logger.debug("#{self.class}##{__method__}") { data }
@socket.send_data(data.to_json)
end

def open(_event)
end
def open(_event); end

def close(_event)
socket = @socket
Expand Down Expand Up @@ -183,9 +182,11 @@ def dispatch(event)

def run_handlers(type, data)
handlers = store.class.events[type.to_s]
handlers.each do |handler|
store.instance_exec(data, &handler)
end if handlers
if handlers
handlers.each do |handler|
store.instance_exec(data, &handler)
end
end
rescue StandardError => e
logger.error e
false
Expand Down
6 changes: 5 additions & 1 deletion lib/slack/real_time/concurrency/celluloid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ def run_loop
logger.debug("#{self.class}##{__method__}") { e }
driver.emit(:close, WebSocket::Driver::CloseEvent.new(1001, 'server closed connection')) unless @closing
ensure
current_actor.terminate if current_actor.alive? rescue nil
begin
current_actor.terminate if current_actor.alive?
rescue
nil
end
end

def close
Expand Down
22 changes: 11 additions & 11 deletions lib/slack/real_time/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ class NoConcurrencyError < StandardError; end

extend self

ATTRIBUTES = [
:token,
:websocket_ping,
:websocket_proxy,
:concurrency,
:start_method,
:start_options,
:store_class,
:logger
ATTRIBUTES = %i[
token
websocket_ping
websocket_proxy
concurrency
start_method
start_options
store_class
logger
].freeze

attr_accessor(*Config::ATTRIBUTES)
Expand All @@ -36,15 +36,15 @@ def concurrency
private

def detect_concurrency
[:Eventmachine, :Celluloid].each do |concurrency|
%i[Eventmachine Celluloid].each do |concurrency|
begin
return Slack::RealTime::Concurrency.const_get(concurrency)
rescue LoadError, NameError
false # could not be loaded, missing dependencies
end
end

fail NoConcurrencyError, 'Missing concurrency. Add faye-websocket or celluloid-io to your Gemfile.'
raise NoConcurrencyError, 'Missing concurrency. Add faye-websocket or celluloid-io to your Gemfile.'
end
end

Expand Down
3 changes: 1 addition & 2 deletions lib/slack/real_time/models/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ def presence
end

# see https://github.com/intridea/hashie/issues/394
def log_built_in_message(*)
end
def log_built_in_message(*); end
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/slack/real_time/socket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def start_sync(client)

# @return [#join]
def start_async(_client)
fail NotImplementedError, "Expected #{self.class} to implement #{__method__}."
raise NotImplementedError, "Expected #{self.class} to implement #{__method__}."
end

def close
Expand Down Expand Up @@ -79,7 +79,7 @@ def port
end

def connect
fail NotImplementedError, "Expected #{self.class} to implement #{__method__}."
raise NotImplementedError, "Expected #{self.class} to implement #{__method__}."
end
end
end
Expand Down
Loading

0 comments on commit 43fd6ea

Please sign in to comment.