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

Upgraded RuboCop to 0.80.1, targeting Ruby 2.3+. #246

Merged
merged 1 commit into from
Mar 28, 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
16 changes: 14 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.2.0
TargetRubyVersion: 2.3
Exclude:
- vendor/**/*
- examples/**/vendor/**/*
Expand All @@ -8,10 +8,22 @@ AllCops:
Metrics:
Enabled: false

Metrics/LineLength:
Layout/LineLength:
Max: 512

Style/Documentation:
Enabled: false

Style/HashEachMethods:
Enabled: true

Style/HashTransformKeys:
Enabled: true

Style/HashTransformValues:
Enabled: true

Style/ModuleFunction:
Enabled: false

inherit_from: .rubocop_todo.yml
49 changes: 13 additions & 36 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,29 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-03-25 10:27:43 -0400 using RuboCop version 0.58.2.
# on 2020-03-28 18:37:09 -0400 using RuboCop version 0.80.1.
# 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
# versions of RuboCop, may require this file to be generated again.

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
Layout/IndentHeredoc:
Exclude:
- 'lib/slack-ruby-bot/commands/help.rb'
- 'spec/slack-ruby-bot/commands/help_spec.rb'

# Offense count: 1
Lint/DuplicateMethods:
Exclude:
- 'lib/slack-ruby-bot/hooks/set.rb'

# Offense count: 2
Lint/HandleExceptions:
# Configuration parameters: AllowComments.
Lint/SuppressedException:
Exclude:
- 'lib/initializers/giphy.rb'
- 'lib/initializers/giphy_client.rb'

# Offense count: 1
# Cop supports --auto-correct.
Lint/UnneededCopEnableDirective:
# 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:
- 'Gemfile'
- 'lib/slack-ruby-bot.rb'

# Offense count: 2
# Configuration parameters: EnforcedStyle.
Expand All @@ -51,27 +44,11 @@ Style/DoubleNegation:
Exclude:
- 'lib/slack-ruby-bot/commands/base.rb'

# Offense count: 5
# Cop supports --auto-correct.
Style/ExpandPathArguments:
Exclude:
- 'lib/config/application.rb'
- 'lib/config/environment.rb'
- 'lib/slack-ruby-bot.rb'
- 'slack-ruby-bot.gemspec'

# Offense count: 2
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Exclude:
- 'lib/slack-ruby-bot/commands/support/match.rb'
- 'lib/slack-ruby-bot/mvc/controller/base.rb'

# Offense count: 2
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: module_function, extend_self
Style/ModuleFunction:
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Exclude:
- 'lib/initializers/giphy_client.rb'
- 'lib/slack-ruby-bot/config.rb'
- 'spec/**/*'
- 'examples/market/marketbot.rb'
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ cache: bundler

matrix:
include:
- rvm: 2.3.0
- rvm: 2.6.5
script:
- bundle exec danger
- rvm: 2.3.0
env: CONCURRENCY=celluloid-io
- rvm: 2.3.0
env: CONCURRENCY=faye-websocket
- rvm: 2.3.0
env: CONCURRENCY=async-websocket
- rvm: 2.6.5
env: CONCURRENCY=celluloid-io WITH_GIPHY=true
- rvm: 2.3.0
- rvm: 2.6.5
env: CONCURRENCY=faye-websocket WITH_GIPHY=true
- rvm: 2.3.0
- rvm: 2.6.5
env: CONCURRENCY=celluloid-io WITH_GIPHY_CLIENT=true
- rvm: 2.3.0
- rvm: 2.6.5
env: CONCURRENCY=faye-websocket WITH_GIPHY_CLIENT=true
- rvm: 2.5
- rvm: 2.6.5
env: CONCURRENCY=async-websocket WITH_GIPHY_CLIENT=true
- rvm: ruby-head
- rvm: jruby-head
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
### 0.12.1 (Next)
### 0.13.0 (Next)

* [#244](https://github.com/slack-ruby/slack-ruby-bot/pull/244): Change log message when the bot is reconnected - [@wasabigeek](https://github.com/wasabigeek).
* [#209](https://github.com/slack-ruby/slack-ruby-bot/pull/209): Allow `respond_to_slack_message` and `respond_to_slack_messages` without arguments - [@dblock](https://github.com/dblock).
* [#216](https://github.com/slack-ruby/slack-ruby-bot/pull/216): Added `start_typing` RSpec matcher - [@dblock](https://github.com/dblock).
* [#214](https://github.com/slack-ruby/slack-ruby-bot/pull/214): Add passenger deployment documentation - [@cybercrediators](https://github.com/cybercrediators).
* [#220](https://github.com/slack-ruby/slack-ruby-bot/pull/220): Updated examples/market to pull from IEX instead of defunct yahoo service - [@corprew](https://github.com/corprew).
* [#246](https://github.com/slack-ruby/slack-ruby-bot/pull/246): Drop support for Ruby 2.2 - [@dblock](https://github.com/dblock).
* Your contribution here.


Expand Down
2 changes: 2 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# frozen_string_literal: true

danger.import_dangerfile(gem: 'slack-ruby-danger')
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'http://rubygems.org'

gemspec
Expand All @@ -11,8 +13,6 @@ if ENV.key?('CONCURRENCY')
end
end

# rubocop:enable Bundler/OrderedGems

gem 'giphy', require: false if ENV.key?('WITH_GIPHY')
gem 'GiphyClient', require: false if ENV.key?('WITH_GIPHY_CLIENT')

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2015-2016 Daniel Doubrovkine, Artsy and Contributors
Copyright (c) 2015-2020 Daniel Doubrovkine, Artsy and Contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,6 @@ See [CHANGELOG](CHANGELOG.md) for a history of changes and [UPGRADING](UPGRADING

## Copyright and License

Copyright (c) 2015-2016, [Daniel Doubrovkine](https://twitter.com/dblockdotorg), [Artsy](https://www.artsy.net) and [Contributors](CHANGELOG.md).
Copyright (c) 2015-2020, [Daniel Doubrovkine](https://twitter.com/dblockdotorg), [Artsy](https://www.artsy.net) and [Contributors](CHANGELOG.md).

This project is licensed under the [MIT License](LICENSE.md).
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rubygems'
require 'bundler'
require 'bundler/gem_tasks'
Expand Down
8 changes: 8 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Upgrading SlackRubyBot
======================

### Upgrading to >= 0.13.0

#### Minimum Ruby Version

Ruby 2.3 or later is now required.

See [#246](https://github.com/slack-ruby/slack-ruby-bot/pull/246) for more information.

### Upgrading to >= 0.12.0

#### Remove any references to `SlackRubyBot::Server#restart!`
Expand Down
2 changes: 2 additions & 0 deletions examples/inventory/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'http://rubygems.org'

gem 'celluloid-io'
Expand Down
6 changes: 5 additions & 1 deletion examples/inventory/inventorybot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'slack-ruby-bot'
require 'sqlite3'

Expand Down Expand Up @@ -56,6 +58,7 @@ def delete
def notify_admin
row = _row.first
return if row[:quantity].to_i.zero?

view.email_admin("Inventory item #{row[:name]} needs to be refilled.")
view.say(channel: data.channel, text: "Administrator notified via email to refill #{row[:name]}.")
end
Expand Down Expand Up @@ -93,6 +96,7 @@ def initialize
count = 0
count += 1 while results.next
return if count < 4

add_item "'Audi',3,52642"
add_item "'Mercedes',1,57127"
add_item "'Skoda',5,9000"
Expand Down Expand Up @@ -241,7 +245,7 @@ class InventoryBot < SlackRubyBot::Bot
view = InventoryView.new
@controller = InventoryController.new(model, view)
@controller.class.command_class.routes.each do |route|
STDERR.puts route.inspect
warn route.inspect
end
end

Expand Down
2 changes: 2 additions & 0 deletions examples/market/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'http://rubygems.org'
gem 'faye-websocket'
gem 'iex-ruby-client'
Expand Down
2 changes: 2 additions & 0 deletions examples/market/marketbot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'iex-ruby-client'
require 'slack-ruby-bot'

Expand Down
2 changes: 2 additions & 0 deletions examples/minimal/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'http://rubygems.org'

gem 'celluloid-io'
Expand Down
2 changes: 2 additions & 0 deletions examples/minimal/pongbot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'slack-ruby-bot'

class Bot < SlackRubyBot::Bot
Expand Down
2 changes: 2 additions & 0 deletions examples/weather/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'http://rubygems.org'

gem 'celluloid-io'
Expand Down
2 changes: 2 additions & 0 deletions examples/weather/weatherbot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'slack-ruby-bot'

SlackRubyBot::Client.logger.level = Logger::WARN
Expand Down
6 changes: 4 additions & 2 deletions lib/config/application.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# frozen_string_literal: true

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
$LOAD_PATH.unshift(File.dirname(__FILE__))

require 'boot'

Dir[File.expand_path('../../initializers', __FILE__) + '/**/*.rb'].each do |file|
Dir[File.expand_path('../initializers', __dir__) + '/**/*.rb'].sort.each do |file|
require file
end

require File.expand_path('../application', __FILE__)
require File.expand_path('application', __dir__)

require 'slack_ruby_bot'
2 changes: 2 additions & 0 deletions lib/config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rubygems'
require 'logger'
require 'active_support'
Expand Down
4 changes: 3 additions & 1 deletion lib/config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

ENV['RACK_ENV'] ||= 'development'

require File.expand_path('../application', __FILE__)
require File.expand_path('application', __dir__)
2 changes: 2 additions & 0 deletions lib/initializers/giphy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

begin
require 'giphy'
rescue LoadError
Expand Down
2 changes: 2 additions & 0 deletions lib/initializers/giphy_client.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

begin
require 'GiphyClient'

Expand Down
4 changes: 3 additions & 1 deletion lib/slack-ruby-bot.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require File.expand_path('../config/environment', __FILE__)
# frozen_string_literal: true

require File.expand_path('config/environment', __dir__)

require 'slack-ruby-bot/version'
require 'slack-ruby-bot/support/loggable'
Expand Down
4 changes: 3 additions & 1 deletion lib/slack-ruby-bot/about.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

module SlackRubyBot
ABOUT = <<-ABOUT.freeze
ABOUT = <<-ABOUT
#{SlackRubyBot::VERSION}
https://github.com/slack-ruby/slack-ruby-bot
https://twitter.com/dblockdotorg
Expand Down
2 changes: 2 additions & 0 deletions lib/slack-ruby-bot/app.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SlackRubyBot
class App < Server
def initialize(options = {})
Expand Down
2 changes: 2 additions & 0 deletions lib/slack-ruby-bot/bot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SlackRubyBot
class Bot < SlackRubyBot::Commands::Base
delegate :client, to: :instance
Expand Down
11 changes: 7 additions & 4 deletions lib/slack-ruby-bot/client.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SlackRubyBot
class Client < Slack::RealTime::Client
include Loggable
Expand Down Expand Up @@ -31,11 +33,12 @@ def name?(name)

def send_gifs?
return false unless defined?(Giphy)

send_gifs.nil? ? SlackRubyBot::Config.send_gifs? : send_gifs
end

def name
SlackRubyBot.config.user || (self.self && self.self.name)
SlackRubyBot.config.user || self.self&.name
end

def url
Expand All @@ -51,9 +54,9 @@ def say(options = {})
if keywords && send_gifs?
gif = begin
Giphy.random(keywords)
rescue StandardError => e
logger.warn "Giphy.random: #{e.message}"
nil
rescue StandardError => e
logger.warn "Giphy.random: #{e.message}"
nil
end
end
text = [text, gif && gif.image_url.to_s].compact.join("\n")
Expand Down
2 changes: 2 additions & 0 deletions lib/slack-ruby-bot/commands.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'slack-ruby-bot/commands/base'
require 'slack-ruby-bot/commands/about'
require 'slack-ruby-bot/commands/help'
Expand Down
2 changes: 2 additions & 0 deletions lib/slack-ruby-bot/commands/about.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SlackRubyBot
module Commands
class Default < Base
Expand Down
Loading