Commit c85146074bd4b8b90c2dd043824a3c99cc1c5683

Authored by Laust Rud Jacobsen
1 parent 312b43fe
Exists in master and in 1 other branch production

Rubocop: use Hash.key? instead of Hash.has_key? (deprecated)

.rubocop_todo.yml
@@ -121,12 +121,6 @@ Style/ClassCheck: @@ -121,12 +121,6 @@ Style/ClassCheck:
121 Exclude: 121 Exclude:
122 - 'app/helpers/navigation_helper.rb' 122 - 'app/helpers/navigation_helper.rb'
123 123
124 -# Offense count: 1  
125 -# Cop supports --auto-correct.  
126 -Style/ClosingParenthesisIndentation:  
127 - Exclude:  
128 - - 'app/models/problem.rb'  
129 -  
130 # Offense count: 23 124 # Offense count: 23
131 Style/ConstantName: 125 Style/ConstantName:
132 Exclude: 126 Exclude:
@@ -141,14 +135,6 @@ Style/ConstantName: @@ -141,14 +135,6 @@ Style/ConstantName:
141 - 'app/models/notification_services/slack_service.rb' 135 - 'app/models/notification_services/slack_service.rb'
142 - 'app/models/notification_services/webhook_service.rb' 136 - 'app/models/notification_services/webhook_service.rb'
143 137
144 -# Offense count: 11  
145 -# Cop supports --auto-correct.  
146 -Style/DeprecatedHashMethods:  
147 - Exclude:  
148 - - 'lib/airbrake_api/v3/notice_parser.rb'  
149 - - 'lib/hoptoad/v2.rb'  
150 - - 'spec/lib/airbrake_api/v3/notice_parser_spec.rb'  
151 -  
152 # Offense count: 70 138 # Offense count: 70
153 # Configuration parameters: Exclude. 139 # Configuration parameters: Exclude.
154 Style/Documentation: 140 Style/Documentation:
app/models/problem.rb
@@ -162,7 +162,9 @@ class Problem @@ -162,7 +162,9 @@ class Problem
162 end 162 end
163 163
164 def url 164 def url
165 - Rails.application.routes.url_helpers.app_problem_url(app, self, 165 + Rails.application.routes.url_helpers.app_problem_url(
  166 + app,
  167 + self,
166 :host => Errbit::Config.host, 168 :host => Errbit::Config.host,
167 :port => Errbit::Config.port 169 :port => Errbit::Config.port
168 ) 170 )
lib/airbrake_api/v3/notice_parser.rb
@@ -27,7 +27,7 @@ module AirbrakeApi @@ -27,7 +27,7 @@ module AirbrakeApi
27 private 27 private
28 28
29 def error 29 def error
30 - raise AirbrakeApi::ParamsError unless params.has_key?('errors') && params['errors'].any? 30 + raise AirbrakeApi::ParamsError unless params.key?('errors') && params['errors'].any?
31 @error ||= params['errors'].first 31 @error ||= params['errors'].first
32 end 32 end
33 33
lib/hoptoad/v2.rb
@@ -11,21 +11,21 @@ module Hoptoad @@ -11,21 +11,21 @@ module Hoptoad
11 def self.rekey(node) 11 def self.rekey(node)
12 case node 12 case node
13 when Hash 13 when Hash
14 - if node.has_key?('var') && node.has_key?('key') 14 + if node.key?('var') && node.key?('key')
15 {normalize_key(node['key']) => rekey(node['var'])} 15 {normalize_key(node['key']) => rekey(node['var'])}
16 - elsif node.has_key?('var') 16 + elsif node.key?('var')
17 rekey(node['var']) 17 rekey(node['var'])
18 - elsif node.has_key?('__content__') && node.has_key?('key') 18 + elsif node.key?('__content__') && node.key?('key')
19 {normalize_key(node['key']) => rekey(node['__content__'])} 19 {normalize_key(node['key']) => rekey(node['__content__'])}
20 - elsif node.has_key?('__content__') 20 + elsif node.key?('__content__')
21 rekey(node['__content__']) 21 rekey(node['__content__'])
22 - elsif node.has_key?('key') 22 + elsif node.key?('key')
23 {normalize_key(node['key']) => nil} 23 {normalize_key(node['key']) => nil}
24 else 24 else
25 node.inject({}) {|rekeyed, (key, val)| rekeyed.merge(normalize_key(key) => rekey(val))} 25 node.inject({}) {|rekeyed, (key, val)| rekeyed.merge(normalize_key(key) => rekey(val))}
26 end 26 end
27 when Array 27 when Array
28 - if node.first.has_key?('key') 28 + if node.first.key?('key')
29 node.inject({}) {|rekeyed, keypair| rekeyed.merge(rekey(keypair))} 29 node.inject({}) {|rekeyed, keypair| rekeyed.merge(rekey(keypair))}
30 else 30 else
31 node.map {|n| rekey(n)} 31 node.map {|n| rekey(n)}
spec/lib/airbrake_api/v3/notice_parser_spec.rb
@@ -53,8 +53,8 @@ describe AirbrakeApi::V3::NoticeParser do @@ -53,8 +53,8 @@ describe AirbrakeApi::V3::NoticeParser do
53 json = Rails.root.join('spec', 'fixtures', 'api_v3_request.json').read 53 json = Rails.root.join('spec', 'fixtures', 'api_v3_request.json').read
54 data = JSON.parse(json) 54 data = JSON.parse(json)
55 55
56 - data['key'] = options[:key] if options.has_key?(:key)  
57 - data['project_id'] = options[:project_id] if options.has_key?(:project_id) 56 + data['key'] = options[:key] if options.key?(:key)
  57 + data['project_id'] = options[:project_id] if options.key?(:project_id)
58 58
59 data 59 data
60 end 60 end