From c85146074bd4b8b90c2dd043824a3c99cc1c5683 Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Mon, 12 Oct 2015 21:48:34 +0200 Subject: [PATCH] Rubocop: use Hash.key? instead of Hash.has_key? (deprecated) --- .rubocop_todo.yml | 14 -------------- app/models/problem.rb | 4 +++- lib/airbrake_api/v3/notice_parser.rb | 2 +- lib/hoptoad/v2.rb | 12 ++++++------ spec/lib/airbrake_api/v3/notice_parser_spec.rb | 4 ++-- 5 files changed, 12 insertions(+), 24 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index eddf533..8439143 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -121,12 +121,6 @@ Style/ClassCheck: Exclude: - 'app/helpers/navigation_helper.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Style/ClosingParenthesisIndentation: - Exclude: - - 'app/models/problem.rb' - # Offense count: 23 Style/ConstantName: Exclude: @@ -141,14 +135,6 @@ Style/ConstantName: - 'app/models/notification_services/slack_service.rb' - 'app/models/notification_services/webhook_service.rb' -# Offense count: 11 -# Cop supports --auto-correct. -Style/DeprecatedHashMethods: - Exclude: - - 'lib/airbrake_api/v3/notice_parser.rb' - - 'lib/hoptoad/v2.rb' - - 'spec/lib/airbrake_api/v3/notice_parser_spec.rb' - # Offense count: 70 # Configuration parameters: Exclude. Style/Documentation: diff --git a/app/models/problem.rb b/app/models/problem.rb index d85b7bc..ca4d49a 100644 --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -162,7 +162,9 @@ class Problem end def url - Rails.application.routes.url_helpers.app_problem_url(app, self, + Rails.application.routes.url_helpers.app_problem_url( + app, + self, :host => Errbit::Config.host, :port => Errbit::Config.port ) diff --git a/lib/airbrake_api/v3/notice_parser.rb b/lib/airbrake_api/v3/notice_parser.rb index 4c385ba..bb6edc2 100644 --- a/lib/airbrake_api/v3/notice_parser.rb +++ b/lib/airbrake_api/v3/notice_parser.rb @@ -27,7 +27,7 @@ module AirbrakeApi private def error - raise AirbrakeApi::ParamsError unless params.has_key?('errors') && params['errors'].any? + raise AirbrakeApi::ParamsError unless params.key?('errors') && params['errors'].any? @error ||= params['errors'].first end diff --git a/lib/hoptoad/v2.rb b/lib/hoptoad/v2.rb index 73099f3..ad71e10 100644 --- a/lib/hoptoad/v2.rb +++ b/lib/hoptoad/v2.rb @@ -11,21 +11,21 @@ module Hoptoad def self.rekey(node) case node when Hash - if node.has_key?('var') && node.has_key?('key') + if node.key?('var') && node.key?('key') {normalize_key(node['key']) => rekey(node['var'])} - elsif node.has_key?('var') + elsif node.key?('var') rekey(node['var']) - elsif node.has_key?('__content__') && node.has_key?('key') + elsif node.key?('__content__') && node.key?('key') {normalize_key(node['key']) => rekey(node['__content__'])} - elsif node.has_key?('__content__') + elsif node.key?('__content__') rekey(node['__content__']) - elsif node.has_key?('key') + elsif node.key?('key') {normalize_key(node['key']) => nil} else node.inject({}) {|rekeyed, (key, val)| rekeyed.merge(normalize_key(key) => rekey(val))} end when Array - if node.first.has_key?('key') + if node.first.key?('key') node.inject({}) {|rekeyed, keypair| rekeyed.merge(rekey(keypair))} else node.map {|n| rekey(n)} diff --git a/spec/lib/airbrake_api/v3/notice_parser_spec.rb b/spec/lib/airbrake_api/v3/notice_parser_spec.rb index 2d7aa5e..48b4205 100644 --- a/spec/lib/airbrake_api/v3/notice_parser_spec.rb +++ b/spec/lib/airbrake_api/v3/notice_parser_spec.rb @@ -53,8 +53,8 @@ describe AirbrakeApi::V3::NoticeParser do json = Rails.root.join('spec', 'fixtures', 'api_v3_request.json').read data = JSON.parse(json) - data['key'] = options[:key] if options.has_key?(:key) - data['project_id'] = options[:project_id] if options.has_key?(:project_id) + data['key'] = options[:key] if options.key?(:key) + data['project_id'] = options[:project_id] if options.key?(:project_id) data end -- libgit2 0.21.2