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

Fix rubocop offenses #444

Merged
merged 3 commits into from Jan 24, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .rubocop.yml
@@ -0,0 +1,5 @@
inherit_from: .rubocop_todo.yml
Copy link
Collaborator

Choose a reason for hiding this comment

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

wdyt about adding the TargetRubyVersion here? and maybe DisplayCopNames as well?

AllCops:
  TargetRubyVersion: 2.0
  DisplayCopNames: true

will probably need to add rubocop as a dev dependency too, i think version 0.50.0 is the last one to support ruby 2.0


AllCops:
TargetRubyVersion: 2.0
DisplayCopNames: true
180 changes: 180 additions & 0 deletions .rubocop_todo.yml
@@ -0,0 +1,180 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-12-18 20:02:43 -0300 using RuboCop version 0.59.2.
# 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: 1
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'exception_notification.gemspec'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Layout/EndAlignment:
Exclude:
- 'lib/exception_notifier/campfire_notifier.rb'
- 'lib/exception_notifier/hipchat_notifier.rb'

# Offense count: 2
# Cop supports --auto-correct.
Layout/RescueEnsureAlignment:
Exclude:
- 'lib/exception_notifier/modules/error_grouping.rb'
- 'test/exception_notifier/webhook_notifier_test.rb'

# Offense count: 2
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
Exclude:
- 'lib/exception_notifier/modules/error_grouping.rb'

# Offense count: 12
Lint/RescueException:
Exclude:
- 'examples/sinatra/sinatra_app.rb'
- 'lib/exception_notification/rack.rb'
- 'lib/exception_notification/sidekiq.rb'
- 'lib/exception_notifier.rb'
- 'test/exception_notifier/campfire_notifier_test.rb'
- 'test/exception_notifier/hipchat_notifier_test.rb'
- 'test/exception_notifier/irc_notifier_test.rb'
- 'test/exception_notifier/slack_notifier_test.rb'
- 'test/exception_notifier/sns_notifier_test.rb'
- 'test/exception_notifier/webhook_notifier_test.rb'

# Offense count: 2
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier:
Exclude:
- 'lib/exception_notifier/datadog_notifier.rb'
- 'test/exception_notifier/datadog_notifier_test.rb'

# Offense count: 1
Lint/UselessAssignment:
Exclude:
- 'lib/exception_notifier/sns_notifier.rb'

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

# Offense count: 3
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 88

# Offense count: 10
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 186

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

# Offense count: 28
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 90

# Offense count: 7
Metrics/PerceivedComplexity:
Max: 24

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'test/dummy/test/test_helper.rb'

# Offense count: 6
Style/ClassVars:
Exclude:
- 'lib/exception_notifier.rb'
- 'test/exception_notifier/modules/error_grouping_test.rb'

# Offense count: 28
Style/Documentation:
Enabled: false

# Offense count: 1
Style/DoubleNegation:
Exclude:
- 'lib/exception_notifier/irc_notifier.rb'

# Offense count: 1
Style/EvalWithLocation:
Exclude:
- 'test/exception_notifier_test.rb'

# Offense count: 6
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'lib/exception_notifier/campfire_notifier.rb'
- 'lib/exception_notifier/email_notifier.rb'
- 'lib/exception_notifier/google_chat_notifier.rb'
- 'lib/exception_notifier/irc_notifier.rb'
- 'lib/exception_notifier/slack_notifier.rb'
- 'lib/exception_notifier/sns_notifier.rb'

# Offense count: 7
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Exclude:
- 'lib/exception_notification/rack.rb'
- 'lib/exception_notifier/datadog_notifier.rb'
- 'lib/exception_notifier/google_chat_notifier.rb'
- 'lib/exception_notifier/webhook_notifier.rb'
- 'test/dummy/test/functional/posts_controller_test.rb'
- 'test/exception_notifier/email_notifier_test.rb'

# Offense count: 3
Style/MethodMissingSuper:
Exclude:
- 'lib/exception_notifier/email_notifier.rb'
- 'lib/exception_notifier/mattermost_notifier.rb'
- 'lib/exception_notifier/teams_notifier.rb'

# Offense count: 3
Style/MissingRespondToMissing:
Exclude:
- 'lib/exception_notifier/email_notifier.rb'
- 'lib/exception_notifier/mattermost_notifier.rb'
- 'lib/exception_notifier/teams_notifier.rb'

# Offense count: 1
Style/MultilineBlockChain:
Exclude:
- 'lib/exception_notifier/email_notifier.rb'

# Offense count: 2
Style/NestedTernaryOperator:
Exclude:
- 'lib/exception_notifier/slack_notifier.rb'
- 'lib/exception_notifier/sns_notifier.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Exclude:
- 'spec/**/*'
- 'test/exception_notifier/modules/error_grouping_test.rb'

# Offense count: 253
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 226
2 changes: 1 addition & 1 deletion Appraisals
@@ -1,7 +1,7 @@
rails_versions = ['~> 4.0.5', '~> 4.1.1', '~> 4.2.0', '~> 5.0.0', '~> 5.1.0', '~> 5.2.0']

rails_versions.each do |rails_version|
appraise "rails#{rails_version.slice(/\d+\.\d+/).gsub('.', '_')}" do
appraise "rails#{rails_version.slice(/\d+\.\d+/).tr('.', '_')}" do
gem 'rails', rails_version
end
end
2 changes: 1 addition & 1 deletion Gemfile
@@ -1,3 +1,3 @@
source "https://rubygems.org"
source 'https://rubygems.org'

gemspec
12 changes: 6 additions & 6 deletions examples/sinatra/Gemfile
@@ -1,8 +1,8 @@
source "https://rubygems.org"
source 'https://rubygems.org'

gem "exception_notification", path: "../../"
gem 'exception_notification', path: '../../'

gem "thin", "~> 1.5.1"
gem "sinatra", "~> 1.3.5"
gem "foreman"
gem "mailcatcher"
gem 'foreman'
gem 'mailcatcher'
gem 'sinatra', '~> 1.3.5'
gem 'thin', '~> 1.5.1'
2 changes: 1 addition & 1 deletion examples/sinatra/config.ru
@@ -1,3 +1,3 @@
require ::File.expand_path('../sinatra_app', __FILE__)
require ::File.expand_path('../sinatra_app', __FILE__)

run SinatraApp
19 changes: 10 additions & 9 deletions examples/sinatra/sinatra_app.rb
Expand Up @@ -9,24 +9,25 @@ class SinatraApp < Sinatra::Base
end

use ExceptionNotification::Rack,
email: {
email_prefix: '[Example] ',
sender_address: %{"notifier" <notifier@example.com>},
exception_recipients: %w{exceptions@example.com},
smtp_settings: {
address: 'localhost',
port: 1025
email: {
email_prefix: '[Example] ',
sender_address: %("notifier" <notifier@example.com>),
exception_recipients: %w[exceptions@example.com],
smtp_settings: {
address: 'localhost',
port: 1025
}
}
}

get '/' do
raise StandardError, "ERROR: #{params[:error]}" unless params[:error].blank?

'Everything is fine! Now, lets break things clicking <a href="/?error=ops"> here </a>. Dont forget to see the emails at <a href="http://localhost:1080">mailcatcher</a> !'
end

get '/background_notification' do
begin
1/0
1 / 0
rescue Exception => e
ExceptionNotifier.notify_exception(e, data: { msg: 'Cannot divide by zero!' })
end
Expand Down
49 changes: 25 additions & 24 deletions exception_notification.gemspec
@@ -1,12 +1,12 @@
Gem::Specification.new do |s|
s.name = 'exception_notification'
s.version = '4.3.0'
s.authors = ["Jamis Buck", "Josh Peek"]
s.date = %q{2018-11-22}
s.summary = "Exception notification for Rails apps"
s.homepage = "https://smartinez87.github.io/exception_notification/"
s.email = "smartinez87@gmail.com"
s.license = "MIT"
s.authors = ['Jamis Buck', 'Josh Peek']
s.date = '2018-11-22'
s.summary = 'Exception notification for Rails apps'
s.homepage = 'https://smartinez87.github.io/exception_notification/'
s.email = 'smartinez87@gmail.com'
s.license = 'MIT'

s.required_ruby_version = '>= 2.0'
s.required_rubygems_version = '>= 1.8.11'
Expand All @@ -16,24 +16,25 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -- test`.split("\n")
s.require_path = 'lib'

s.add_dependency("actionmailer", ">= 4.0", "< 6")
s.add_dependency("activesupport", ">= 4.0", "< 6")
s.add_dependency('actionmailer', '>= 4.0', '< 6')
s.add_dependency('activesupport', '>= 4.0', '< 6')

s.add_development_dependency "rails", ">= 4.0", "< 6"
s.add_development_dependency "resque", "~> 1.8.0"
s.add_development_dependency 'appraisal', '~> 2.2.0'
s.add_development_dependency 'aws-sdk-sns', '~> 1'
s.add_development_dependency 'carrier-pigeon', '>= 0.7.0'
s.add_development_dependency 'coveralls', '~> 0.8.2'
s.add_development_dependency 'dogapi', '>= 1.23.0'
s.add_development_dependency 'hipchat', '>= 1.0.0'
s.add_development_dependency 'httparty', '~> 0.10.2'
s.add_development_dependency 'mock_redis', '~> 0.18.0'
s.add_development_dependency 'mocha', '>= 0.13.0'
s.add_development_dependency 'rails', '>= 4.0', '< 6'
s.add_development_dependency 'resque', '~> 1.8.0'
s.add_development_dependency 'rubocop', '0.50.0'
# Sidekiq 3.2.2 does not support Ruby 1.9.
s.add_development_dependency "sidekiq", "~> 3.0.0", "< 3.2.2"
s.add_development_dependency "tinder", "~> 1.8"
s.add_development_dependency "httparty", "~> 0.10.2"
s.add_development_dependency "mocha", ">= 0.13.0"
s.add_development_dependency "sqlite3", ">= 1.3.4"
s.add_development_dependency "coveralls", "~> 0.8.2"
s.add_development_dependency "appraisal", "~> 2.2.0"
s.add_development_dependency "hipchat", ">= 1.0.0"
s.add_development_dependency "carrier-pigeon", ">= 0.7.0"
s.add_development_dependency "slack-notifier", ">= 1.0.0"
s.add_development_dependency "aws-sdk-sns", "~> 1"
s.add_development_dependency "dogapi", ">= 1.23.0"
s.add_development_dependency "timecop", "~>0.9.0"
s.add_development_dependency "mock_redis", "~> 0.18.0"
s.add_development_dependency 'sidekiq', '~> 3.0.0', '< 3.2.2'
Copy link
Collaborator

Choose a reason for hiding this comment

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

wdyt about moving the sidekick comment above this line?

s.add_development_dependency 'slack-notifier', '>= 1.0.0'
s.add_development_dependency 'sqlite3', '>= 1.3.4'
s.add_development_dependency 'timecop', '~>0.9.0'
s.add_development_dependency 'tinder', '~> 1.8'
end
6 changes: 3 additions & 3 deletions gemfiles/rails4_0.gemfile
@@ -1,7 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"
source 'https://rubygems.org'

gem "rails", "~> 4.0.5"
gem 'rails', '~> 4.0.5'

gemspec path: "../"
gemspec path: '../'
6 changes: 3 additions & 3 deletions gemfiles/rails4_1.gemfile
@@ -1,7 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"
source 'https://rubygems.org'

gem "rails", "~> 4.1.1"
gem 'rails', '~> 4.1.1'

gemspec path: "../"
gemspec path: '../'
6 changes: 3 additions & 3 deletions gemfiles/rails4_2.gemfile
@@ -1,7 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"
source 'https://rubygems.org'

gem "rails", "~> 4.2.0"
gem 'rails', '~> 4.2.0'

gemspec path: "../"
gemspec path: '../'
6 changes: 3 additions & 3 deletions gemfiles/rails5_0.gemfile
@@ -1,7 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"
source 'https://rubygems.org'

gem "rails", "~> 5.0.0"
gem 'rails', '~> 5.0.0'

gemspec path: "../"
gemspec path: '../'
6 changes: 3 additions & 3 deletions gemfiles/rails5_1.gemfile
@@ -1,7 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"
source 'https://rubygems.org'

gem "rails", "~> 5.1.0"
gem 'rails', '~> 5.1.0'

gemspec path: "../"
gemspec path: '../'
6 changes: 3 additions & 3 deletions gemfiles/rails5_2.gemfile
@@ -1,7 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"
source 'https://rubygems.org'

gem "rails", "~> 5.2.0"
gem 'rails', '~> 5.2.0'

gemspec path: "../"
gemspec path: '../'