Commit 294d63adbe29eb3639b75a0afec932756af838e7
Exists in
master
and in
1 other branch
Merge pull request #964 from rud/chore/fix-low-hanging-rubocop-issues
Fix some low hanging rubocop issues
Showing
42 changed files
with
124 additions
and
277 deletions
Show diff stats
.rubocop.yml
.rubocop_todo.yml
1 | # This configuration was generated by | 1 | # This configuration was generated by |
2 | # `rubocop --auto-gen-config` | 2 | # `rubocop --auto-gen-config` |
3 | -# on 2015-10-12 09:35:47 +0200 using RuboCop version 0.34.2. | 3 | +# on 2015-10-12 21:53:36 +0200 using RuboCop version 0.34.2. |
4 | # The point is for the user to remove these configuration records | 4 | # The point is for the user to remove these configuration records |
5 | # one by one as the offenses are removed from the code base. | 5 | # one by one as the offenses are removed from the code base. |
6 | # Note that changes in the inspected code, or installation of new | 6 | # Note that changes in the inspected code, or installation of new |
@@ -13,7 +13,7 @@ Metrics/AbcSize: | @@ -13,7 +13,7 @@ Metrics/AbcSize: | ||
13 | # Offense count: 5 | 13 | # Offense count: 5 |
14 | # Configuration parameters: CountComments. | 14 | # Configuration parameters: CountComments. |
15 | Metrics/ClassLength: | 15 | Metrics/ClassLength: |
16 | - Max: 203 | 16 | + Max: 206 |
17 | 17 | ||
18 | # Offense count: 5 | 18 | # Offense count: 5 |
19 | Metrics/CyclomaticComplexity: | 19 | Metrics/CyclomaticComplexity: |
@@ -33,36 +33,6 @@ Metrics/MethodLength: | @@ -33,36 +33,6 @@ Metrics/MethodLength: | ||
33 | Metrics/PerceivedComplexity: | 33 | Metrics/PerceivedComplexity: |
34 | Max: 12 | 34 | Max: 12 |
35 | 35 | ||
36 | -# Offense count: 2 | ||
37 | -# Cop supports --auto-correct. | ||
38 | -Performance/Sample: | ||
39 | - Exclude: | ||
40 | - - 'lib/tasks/errbit/demo.rake' | ||
41 | - - 'spec/fabricators/backtrace_fabricator.rb' | ||
42 | - | ||
43 | -# Offense count: 2 | ||
44 | -# Cop supports --auto-correct. | ||
45 | -Performance/StringReplacement: | ||
46 | - Exclude: | ||
47 | - - 'app/models/notification_services/gtalk_service.rb' | ||
48 | - - 'lib/hoptoad/v2.rb' | ||
49 | - | ||
50 | -# Offense count: 1 | ||
51 | -# Cop supports --auto-correct. | ||
52 | -# Configuration parameters: EnforcedStyle, SupportedStyles, Include. | ||
53 | -Rails/ActionFilter: | ||
54 | - Exclude: | ||
55 | - - 'app/controllers/notices_controller.rb' | ||
56 | - | ||
57 | -# Offense count: 4 | ||
58 | -# Cop supports --auto-correct. | ||
59 | -# Configuration parameters: Include. | ||
60 | -Rails/FindBy: | ||
61 | - Exclude: | ||
62 | - - 'app/models/app.rb' | ||
63 | - - 'app/models/error_report.rb' | ||
64 | - - 'app/models/user.rb' | ||
65 | - | ||
66 | # Offense count: 16 | 36 | # Offense count: 16 |
67 | # Configuration parameters: Include. | 37 | # Configuration parameters: Include. |
68 | Rails/Output: | 38 | Rails/Output: |
@@ -71,19 +41,6 @@ Rails/Output: | @@ -71,19 +41,6 @@ Rails/Output: | ||
71 | - 'app/interactors/problem_recacher.rb' | 41 | - 'app/interactors/problem_recacher.rb' |
72 | - 'db/seeds.rb' | 42 | - 'db/seeds.rb' |
73 | 43 | ||
74 | -# Offense count: 14 | ||
75 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
76 | -Rails/TimeZone: | ||
77 | - Exclude: | ||
78 | - - 'app/models/problem.rb' | ||
79 | - - 'lib/tasks/errbit/demo.rake' | ||
80 | - - 'spec/controllers/api/v1/notices_controller_spec.rb' | ||
81 | - - 'spec/controllers/problems_controller_spec.rb' | ||
82 | - - 'spec/models/error_report_spec.rb' | ||
83 | - - 'spec/models/problem_spec.rb' | ||
84 | - - 'spec/views/apps/index.html.haml_spec.rb' | ||
85 | - - 'spec/views/users/show.html.haml_spec.rb' | ||
86 | - | ||
87 | # Offense count: 12 | 44 | # Offense count: 12 |
88 | # Configuration parameters: Include. | 45 | # Configuration parameters: Include. |
89 | Rails/Validation: | 46 | Rails/Validation: |
@@ -96,19 +53,6 @@ Rails/Validation: | @@ -96,19 +53,6 @@ Rails/Validation: | ||
96 | - 'app/models/problem.rb' | 53 | - 'app/models/problem.rb' |
97 | - 'app/models/user.rb' | 54 | - 'app/models/user.rb' |
98 | 55 | ||
99 | -# Offense count: 2 | ||
100 | -# Cop supports --auto-correct. | ||
101 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
102 | -Style/AccessModifierIndentation: | ||
103 | - Enabled: false | ||
104 | - | ||
105 | -# Offense count: 3 | ||
106 | -# Cop supports --auto-correct. | ||
107 | -Style/Alias: | ||
108 | - Exclude: | ||
109 | - - 'app/decorators/issue_tracker_field_decorator.rb' | ||
110 | - - 'app/models/app.rb' | ||
111 | - | ||
112 | # Offense count: 8 | 56 | # Offense count: 8 |
113 | # Cop supports --auto-correct. | 57 | # Cop supports --auto-correct. |
114 | # Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. | 58 | # Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. |
@@ -120,7 +64,7 @@ Style/AlignHash: | @@ -120,7 +64,7 @@ Style/AlignHash: | ||
120 | - 'spec/controllers/problems_controller_spec.rb' | 64 | - 'spec/controllers/problems_controller_spec.rb' |
121 | - 'spec/models/problem_spec.rb' | 65 | - 'spec/models/problem_spec.rb' |
122 | 66 | ||
123 | -# Offense count: 7 | 67 | +# Offense count: 6 |
124 | # Cop supports --auto-correct. | 68 | # Cop supports --auto-correct. |
125 | # Configuration parameters: EnforcedStyle, SupportedStyles. | 69 | # Configuration parameters: EnforcedStyle, SupportedStyles. |
126 | Style/AlignParameters: | 70 | Style/AlignParameters: |
@@ -128,17 +72,8 @@ Style/AlignParameters: | @@ -128,17 +72,8 @@ Style/AlignParameters: | ||
128 | - 'app/helpers/apps_helper.rb' | 72 | - 'app/helpers/apps_helper.rb' |
129 | - 'app/models/app.rb' | 73 | - 'app/models/app.rb' |
130 | - 'app/models/notification_services/gtalk_service.rb' | 74 | - 'app/models/notification_services/gtalk_service.rb' |
131 | - - 'app/models/problem.rb' | ||
132 | - 'config/initializers/devise.rb' | 75 | - 'config/initializers/devise.rb' |
133 | 76 | ||
134 | -# Offense count: 2 | ||
135 | -# Cop supports --auto-correct. | ||
136 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
137 | -Style/AndOr: | ||
138 | - Exclude: | ||
139 | - - 'app/controllers/users_controller.rb' | ||
140 | - - 'app/models/error_report.rb' | ||
141 | - | ||
142 | # Offense count: 105 | 77 | # Offense count: 105 |
143 | # Cop supports --auto-correct. | 78 | # Cop supports --auto-correct. |
144 | # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. | 79 | # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. |
@@ -178,19 +113,6 @@ Style/ClassAndModuleChildren: | @@ -178,19 +113,6 @@ Style/ClassAndModuleChildren: | ||
178 | - 'app/models/notification_services/webhook_service.rb' | 113 | - 'app/models/notification_services/webhook_service.rb' |
179 | - 'config/initializers/overrides.rb' | 114 | - 'config/initializers/overrides.rb' |
180 | 115 | ||
181 | -# Offense count: 1 | ||
182 | -# Cop supports --auto-correct. | ||
183 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
184 | -Style/ClassCheck: | ||
185 | - Exclude: | ||
186 | - - 'app/helpers/navigation_helper.rb' | ||
187 | - | ||
188 | -# Offense count: 1 | ||
189 | -# Cop supports --auto-correct. | ||
190 | -Style/ClosingParenthesisIndentation: | ||
191 | - Exclude: | ||
192 | - - 'app/models/problem.rb' | ||
193 | - | ||
194 | # Offense count: 23 | 116 | # Offense count: 23 |
195 | Style/ConstantName: | 117 | Style/ConstantName: |
196 | Exclude: | 118 | Exclude: |
@@ -205,33 +127,17 @@ Style/ConstantName: | @@ -205,33 +127,17 @@ Style/ConstantName: | ||
205 | - 'app/models/notification_services/slack_service.rb' | 127 | - 'app/models/notification_services/slack_service.rb' |
206 | - 'app/models/notification_services/webhook_service.rb' | 128 | - 'app/models/notification_services/webhook_service.rb' |
207 | 129 | ||
208 | -# Offense count: 11 | ||
209 | -# Cop supports --auto-correct. | ||
210 | -Style/DeprecatedHashMethods: | ||
211 | - Exclude: | ||
212 | - - 'lib/airbrake_api/v3/notice_parser.rb' | ||
213 | - - 'lib/hoptoad/v2.rb' | ||
214 | - - 'spec/lib/airbrake_api/v3/notice_parser_spec.rb' | ||
215 | - | ||
216 | # Offense count: 70 | 130 | # Offense count: 70 |
217 | # Configuration parameters: Exclude. | 131 | # Configuration parameters: Exclude. |
218 | Style/Documentation: | 132 | Style/Documentation: |
219 | Enabled: false | 133 | Enabled: false |
220 | 134 | ||
221 | -# Offense count: 7 | 135 | +# Offense count: 9 |
222 | # Cop supports --auto-correct. | 136 | # Cop supports --auto-correct. |
223 | # Configuration parameters: EnforcedStyle, SupportedStyles. | 137 | # Configuration parameters: EnforcedStyle, SupportedStyles. |
224 | Style/DotPosition: | 138 | Style/DotPosition: |
225 | Enabled: false | 139 | Enabled: false |
226 | 140 | ||
227 | -# Offense count: 6 | ||
228 | -Style/DoubleNegation: | ||
229 | - Exclude: | ||
230 | - - 'Gemfile' | ||
231 | - - 'app/controllers/apps_controller.rb' | ||
232 | - - 'app/helpers/apps_helper.rb' | ||
233 | - - 'app/models/app.rb' | ||
234 | - | ||
235 | # Offense count: 5 | 141 | # Offense count: 5 |
236 | Style/EachWithObject: | 142 | Style/EachWithObject: |
237 | Exclude: | 143 | Exclude: |
@@ -253,12 +159,11 @@ Style/EmptyLineBetweenDefs: | @@ -253,12 +159,11 @@ Style/EmptyLineBetweenDefs: | ||
253 | - 'spec/decorators/issue_tracker_type_decorator_spec.rb' | 159 | - 'spec/decorators/issue_tracker_type_decorator_spec.rb' |
254 | - 'spec/views/problems/show.html.haml_spec.rb' | 160 | - 'spec/views/problems/show.html.haml_spec.rb' |
255 | 161 | ||
256 | -# Offense count: 13 | 162 | +# Offense count: 12 |
257 | # Cop supports --auto-correct. | 163 | # Cop supports --auto-correct. |
258 | Style/EmptyLines: | 164 | Style/EmptyLines: |
259 | Exclude: | 165 | Exclude: |
260 | - 'app/controllers/api/v1/stats_controller.rb' | 166 | - 'app/controllers/api/v1/stats_controller.rb' |
261 | - - 'app/controllers/application_controller.rb' | ||
262 | - 'app/decorators/issue_tracker_field_decorator.rb' | 167 | - 'app/decorators/issue_tracker_field_decorator.rb' |
263 | - 'app/models/app.rb' | 168 | - 'app/models/app.rb' |
264 | - 'app/models/problem.rb' | 169 | - 'app/models/problem.rb' |
@@ -267,20 +172,6 @@ Style/EmptyLines: | @@ -267,20 +172,6 @@ Style/EmptyLines: | ||
267 | - 'script/rspec-queue-mongoid.rb' | 172 | - 'script/rspec-queue-mongoid.rb' |
268 | - 'spec/acceptance/app_regenerate_api_key_spec.rb' | 173 | - 'spec/acceptance/app_regenerate_api_key_spec.rb' |
269 | 174 | ||
270 | -# Offense count: 9 | ||
271 | -# Cop supports --auto-correct. | ||
272 | -Style/EmptyLinesAroundAccessModifier: | ||
273 | - Exclude: | ||
274 | - - 'app/controllers/apps_controller.rb' | ||
275 | - - 'app/controllers/comments_controller.rb' | ||
276 | - - 'app/decorators/backtrace_line_decorator.rb' | ||
277 | - - 'app/helpers/application_helper.rb' | ||
278 | - - 'app/models/backtrace.rb' | ||
279 | - - 'app/models/comment.rb' | ||
280 | - - 'lib/hoptoad.rb' | ||
281 | - - 'lib/hoptoad/v2.rb' | ||
282 | - - 'lib/overrides/hoptoad_notifier/hoptoad_notifier.rb' | ||
283 | - | ||
284 | # Offense count: 28 | 175 | # Offense count: 28 |
285 | # Cop supports --auto-correct. | 176 | # Cop supports --auto-correct. |
286 | # Configuration parameters: EnforcedStyle, SupportedStyles. | 177 | # Configuration parameters: EnforcedStyle, SupportedStyles. |
@@ -398,13 +289,6 @@ Style/IndentationConsistency: | @@ -398,13 +289,6 @@ Style/IndentationConsistency: | ||
398 | - 'app/models/watcher.rb' | 289 | - 'app/models/watcher.rb' |
399 | - 'lib/hoptoad.rb' | 290 | - 'lib/hoptoad.rb' |
400 | 291 | ||
401 | -# Offense count: 1 | ||
402 | -# Cop supports --auto-correct. | ||
403 | -# Configuration parameters: Width. | ||
404 | -Style/IndentationWidth: | ||
405 | - Exclude: | ||
406 | - - 'app/controllers/notices_controller.rb' | ||
407 | - | ||
408 | # Offense count: 6 | 292 | # Offense count: 6 |
409 | # Cop supports --auto-correct. | 293 | # Cop supports --auto-correct. |
410 | Style/Lambda: | 294 | Style/Lambda: |
@@ -427,19 +311,6 @@ Style/LeadingCommentSpace: | @@ -427,19 +311,6 @@ Style/LeadingCommentSpace: | ||
427 | - 'spec/models/notification_service/hoiio_service_spec.rb' | 311 | - 'spec/models/notification_service/hoiio_service_spec.rb' |
428 | - 'spec/models/notification_service/pushover_service_spec.rb' | 312 | - 'spec/models/notification_service/pushover_service_spec.rb' |
429 | 313 | ||
430 | -# Offense count: 6 | ||
431 | -# Cop supports --auto-correct. | ||
432 | -Style/MethodCallParentheses: | ||
433 | - Exclude: | ||
434 | - - 'spec/controllers/api/v1/notices_controller_spec.rb' | ||
435 | - - 'spec/controllers/api/v1/problems_controller_spec.rb' | ||
436 | - | ||
437 | -# Offense count: 3 | ||
438 | -# Cop supports --auto-correct. | ||
439 | -# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
440 | -Style/MethodDefParentheses: | ||
441 | - Enabled: false | ||
442 | - | ||
443 | # Offense count: 7 | 314 | # Offense count: 7 |
444 | # Cop supports --auto-correct. | 315 | # Cop supports --auto-correct. |
445 | Style/MultilineBlockLayout: | 316 | Style/MultilineBlockLayout: |
@@ -457,19 +328,6 @@ Style/MultilineBlockLayout: | @@ -457,19 +328,6 @@ Style/MultilineBlockLayout: | ||
457 | Style/MultilineOperationIndentation: | 328 | Style/MultilineOperationIndentation: |
458 | Enabled: false | 329 | Enabled: false |
459 | 330 | ||
460 | -# Offense count: 1 | ||
461 | -# Cop supports --auto-correct. | ||
462 | -Style/NegatedIf: | ||
463 | - Exclude: | ||
464 | - - 'app/controllers/apps_controller.rb' | ||
465 | - | ||
466 | -# Offense count: 2 | ||
467 | -# Cop supports --auto-correct. | ||
468 | -Style/ParallelAssignment: | ||
469 | - Exclude: | ||
470 | - - 'app/models/problem.rb' | ||
471 | - - 'spec/models/app_spec.rb' | ||
472 | - | ||
473 | # Offense count: 5 | 331 | # Offense count: 5 |
474 | # Cop supports --auto-correct. | 332 | # Cop supports --auto-correct. |
475 | # Configuration parameters: PreferredDelimiters. | 333 | # Configuration parameters: PreferredDelimiters. |
@@ -494,19 +352,9 @@ Style/Proc: | @@ -494,19 +352,9 @@ Style/Proc: | ||
494 | - 'app/models/problem.rb' | 352 | - 'app/models/problem.rb' |
495 | 353 | ||
496 | # Offense count: 2 | 354 | # Offense count: 2 |
497 | -# Configuration parameters: SupportedStyles. | 355 | +# Configuration parameters: EnforcedStyle, SupportedStyles. |
498 | Style/RaiseArgs: | 356 | Style/RaiseArgs: |
499 | - EnforcedStyle: compact | ||
500 | - | ||
501 | -# Offense count: 13 | ||
502 | -# Cop supports --auto-correct. | ||
503 | -Style/RedundantSelf: | ||
504 | - Exclude: | ||
505 | - - 'app/models/app.rb' | ||
506 | - - 'app/models/issue_tracker.rb' | ||
507 | - - 'app/models/notification_service.rb' | ||
508 | - - 'app/models/problem.rb' | ||
509 | - - 'lib/configurator.rb' | 357 | + Enabled: false |
510 | 358 | ||
511 | # Offense count: 3 | 359 | # Offense count: 3 |
512 | # Cop supports --auto-correct. | 360 | # Cop supports --auto-correct. |
@@ -715,22 +563,3 @@ Style/TrailingWhitespace: | @@ -715,22 +563,3 @@ Style/TrailingWhitespace: | ||
715 | Style/UnlessElse: | 563 | Style/UnlessElse: |
716 | Exclude: | 564 | Exclude: |
717 | - 'app/controllers/problems_searcher.rb' | 565 | - 'app/controllers/problems_searcher.rb' |
718 | - | ||
719 | -# Offense count: 1 | ||
720 | -# Cop supports --auto-correct. | ||
721 | -Style/UnneededPercentQ: | ||
722 | - Exclude: | ||
723 | - - 'spec/models/notice_spec.rb' | ||
724 | - | ||
725 | -# Offense count: 6 | ||
726 | -# Cop supports --auto-correct. | ||
727 | -Style/WhenThen: | ||
728 | - Exclude: | ||
729 | - - 'app/models/problem.rb' | ||
730 | - - 'lib/hoptoad.rb' | ||
731 | - | ||
732 | -# Offense count: 10 | ||
733 | -# Cop supports --auto-correct. | ||
734 | -# Configuration parameters: WordRegex. | ||
735 | -Style/WordArray: | ||
736 | - MinSize: 11 |
Gemfile
@@ -8,8 +8,8 @@ detected_ruby_version = Gem::Version.new(RUBY_VERSION.dup) | @@ -8,8 +8,8 @@ detected_ruby_version = Gem::Version.new(RUBY_VERSION.dup) | ||
8 | required_ruby_version = Gem::Version.new('2.1.0') # minimum supported version | 8 | required_ruby_version = Gem::Version.new('2.1.0') # minimum supported version |
9 | 9 | ||
10 | if detected_ruby_version < required_ruby_version | 10 | if detected_ruby_version < required_ruby_version |
11 | - fail RuntimeError, "RUBY_VERSION must be at least #{required_ruby_version}" \ | ||
12 | - ", detected RUBY_VERSION #{RUBY_VERSION}" | 11 | + fail "RUBY_VERSION must be at least #{required_ruby_version}, " \ |
12 | + "detected RUBY_VERSION #{RUBY_VERSION}" | ||
13 | end | 13 | end |
14 | 14 | ||
15 | gem 'actionmailer', RAILS_VERSION | 15 | gem 'actionmailer', RAILS_VERSION |
@@ -100,7 +100,7 @@ group :test do | @@ -100,7 +100,7 @@ group :test do | ||
100 | end | 100 | end |
101 | 101 | ||
102 | group :heroku, :production do | 102 | group :heroku, :production do |
103 | - gem 'rails_12factor', require: !!ENV["HEROKU"] | 103 | + gem 'rails_12factor', require: ENV.key?("HEROKU") |
104 | gem 'unicorn', require: false, platform: 'ruby' | 104 | gem 'unicorn', require: false, platform: 'ruby' |
105 | end | 105 | end |
106 | 106 |
app/controllers/application_controller.rb
@@ -17,8 +17,7 @@ class ApplicationController < ActionController::Base | @@ -17,8 +17,7 @@ class ApplicationController < ActionController::Base | ||
17 | strategy StrongParametersWithEagerAttributesStrategy | 17 | strategy StrongParametersWithEagerAttributesStrategy |
18 | end | 18 | end |
19 | 19 | ||
20 | -protected | ||
21 | - | 20 | + protected |
22 | 21 | ||
23 | ## | 22 | ## |
24 | # Check if the current_user is admin or not and redirect to root url if not | 23 | # Check if the current_user is admin or not and redirect to root url if not |
app/controllers/apps_controller.rb
@@ -20,7 +20,7 @@ class AppsController < ApplicationController | @@ -20,7 +20,7 @@ class AppsController < ApplicationController | ||
20 | end | 20 | end |
21 | 21 | ||
22 | expose(:all_errs) { | 22 | expose(:all_errs) { |
23 | - !!params[:all_errs] | 23 | + params[:all_errs].present? |
24 | } | 24 | } |
25 | 25 | ||
26 | expose(:problems) { | 26 | expose(:problems) { |
@@ -97,13 +97,13 @@ class AppsController < ApplicationController | @@ -97,13 +97,13 @@ class AppsController < ApplicationController | ||
97 | if params[:app][:notification_service_attributes] && (notification_type = params[:app][:notification_service_attributes][:type]) | 97 | if params[:app][:notification_service_attributes] && (notification_type = params[:app][:notification_service_attributes][:type]) |
98 | available_notification_classes = [NotificationService] + NotificationService.subclasses | 98 | available_notification_classes = [NotificationService] + NotificationService.subclasses |
99 | notification_class = available_notification_classes.detect{|c| c.name == notification_type} | 99 | notification_class = available_notification_classes.detect{|c| c.name == notification_type} |
100 | - if !notification_class.nil? | 100 | + if notification_class.present? |
101 | app.notification_service = notification_class.new(params[:app][:notification_service_attributes]) | 101 | app.notification_service = notification_class.new(params[:app][:notification_service_attributes]) |
102 | end | 102 | end |
103 | end | 103 | end |
104 | end | 104 | end |
105 | 105 | ||
106 | - def plug_params app | 106 | + def plug_params(app) |
107 | app.watchers.build if app.watchers.none? | 107 | app.watchers.build if app.watchers.none? |
108 | app.issue_tracker ||= IssueTracker.new | 108 | app.issue_tracker ||= IssueTracker.new |
109 | app.notification_service = NotificationService.new unless app.notification_service_configured? | 109 | app.notification_service = NotificationService.new unless app.notification_service_configured? |
@@ -142,6 +142,7 @@ class AppsController < ApplicationController | @@ -142,6 +142,7 @@ class AppsController < ApplicationController | ||
142 | end | 142 | end |
143 | 143 | ||
144 | private | 144 | private |
145 | + | ||
145 | def app_params | 146 | def app_params |
146 | params.require(:app).permit! | 147 | params.require(:app).permit! |
147 | end | 148 | end |
app/controllers/comments_controller.rb
@@ -25,6 +25,7 @@ class CommentsController < ApplicationController | @@ -25,6 +25,7 @@ class CommentsController < ApplicationController | ||
25 | end | 25 | end |
26 | 26 | ||
27 | protected | 27 | protected |
28 | + | ||
28 | def find_app | 29 | def find_app |
29 | @app = App.find(params[:app_id]) | 30 | @app = App.find(params[:app_id]) |
30 | end | 31 | end |
app/controllers/notices_controller.rb
@@ -3,7 +3,7 @@ class NoticesController < ApplicationController | @@ -3,7 +3,7 @@ class NoticesController < ApplicationController | ||
3 | class ParamsError < StandardError; end | 3 | class ParamsError < StandardError; end |
4 | 4 | ||
5 | skip_before_action :authenticate_user!, only: :create | 5 | skip_before_action :authenticate_user!, only: :create |
6 | - skip_before_filter :verify_authenticity_token, only: :create | 6 | + skip_before_action :verify_authenticity_token, only: :create |
7 | 7 | ||
8 | rescue_from ParamsError, :with => :bad_params | 8 | rescue_from ParamsError, :with => :bad_params |
9 | 9 | ||
@@ -15,7 +15,7 @@ class NoticesController < ApplicationController | @@ -15,7 +15,7 @@ class NoticesController < ApplicationController | ||
15 | if report.should_keep? | 15 | if report.should_keep? |
16 | report.generate_notice! | 16 | report.generate_notice! |
17 | api_xml = report.notice.to_xml(:only => false, :methods => [:id]) do |xml| | 17 | api_xml = report.notice.to_xml(:only => false, :methods => [:id]) do |xml| |
18 | - xml.url locate_url(report.notice.id, :host => Errbit::Config.host) | 18 | + xml.url locate_url(report.notice.id, :host => Errbit::Config.host) |
19 | end | 19 | end |
20 | render :xml => api_xml | 20 | render :xml => api_xml |
21 | else | 21 | else |
app/controllers/users_controller.rb
@@ -55,7 +55,7 @@ class UsersController < ApplicationController | @@ -55,7 +55,7 @@ class UsersController < ApplicationController | ||
55 | 55 | ||
56 | def require_user_edit_priviledges | 56 | def require_user_edit_priviledges |
57 | can_edit = current_user == user || current_user.admin? | 57 | can_edit = current_user == user || current_user.admin? |
58 | - redirect_to(root_path) and return(false) unless can_edit | 58 | + redirect_to(root_path) unless can_edit |
59 | end | 59 | end |
60 | 60 | ||
61 | def user_params | 61 | def user_params |
app/decorators/backtrace_line_decorator.rb
@@ -50,6 +50,7 @@ class BacktraceLineDecorator < Draper::Decorator | @@ -50,6 +50,7 @@ class BacktraceLineDecorator < Draper::Decorator | ||
50 | end | 50 | end |
51 | 51 | ||
52 | private | 52 | private |
53 | + | ||
53 | def link_to_in_app_source_file(app, text) | 54 | def link_to_in_app_source_file(app, text) |
54 | return unless in_app? | 55 | return unless in_app? |
55 | if file_name =~ /\.js$/ | 56 | if file_name =~ /\.js$/ |
app/decorators/issue_tracker_field_decorator.rb
@@ -6,7 +6,7 @@ class IssueTrackerFieldDecorator < Draper::Decorator | @@ -6,7 +6,7 @@ class IssueTrackerFieldDecorator < Draper::Decorator | ||
6 | end | 6 | end |
7 | attr_reader :object, :field_info | 7 | attr_reader :object, :field_info |
8 | 8 | ||
9 | - alias :key :object | 9 | + alias_method :key, :object |
10 | 10 | ||
11 | def label | 11 | def label |
12 | field_info[:label] || object.to_s.titleize | 12 | field_info[:label] || object.to_s.titleize |
app/helpers/application_helper.rb
@@ -76,6 +76,7 @@ module ApplicationHelper | @@ -76,6 +76,7 @@ module ApplicationHelper | ||
76 | end | 76 | end |
77 | 77 | ||
78 | private | 78 | private |
79 | + | ||
79 | def total_from_tallies(tallies) | 80 | def total_from_tallies(tallies) |
80 | tallies.values.inject(0) {|sum, n| sum + n} | 81 | tallies.values.inject(0) {|sum, n| sum + n} |
81 | end | 82 | end |
app/helpers/apps_helper.rb
@@ -45,7 +45,7 @@ module AppsHelper | @@ -45,7 +45,7 @@ module AppsHelper | ||
45 | @any_github_repos ||= app.github_repo? | 45 | @any_github_repos ||= app.github_repo? |
46 | @any_bitbucket_repos ||= app.bitbucket_repo? | 46 | @any_bitbucket_repos ||= app.bitbucket_repo? |
47 | @any_issue_trackers ||= app.issue_tracker_configured? | 47 | @any_issue_trackers ||= app.issue_tracker_configured? |
48 | - @any_deploys ||= !!app.last_deploy_at | 48 | + @any_deploys ||= app.last_deploy_at.present? |
49 | @any_notification_services ||= app.notification_service_configured? | 49 | @any_notification_services ||= app.notification_service_configured? |
50 | end | 50 | end |
51 | end | 51 | end |
app/helpers/navigation_helper.rb
@@ -28,7 +28,7 @@ module NavigationHelper | @@ -28,7 +28,7 @@ module NavigationHelper | ||
28 | 28 | ||
29 | active = nil | 29 | active = nil |
30 | sections.each do |controller, actions| | 30 | sections.each do |controller, actions| |
31 | - actions = ([] << actions) unless actions.kind_of?(Array) | 31 | + actions = Array(actions) |
32 | active = ' active' if current_controller == controller && (actions.include?(:all) || actions.include?(current_action)) | 32 | active = ' active' if current_controller == controller && (actions.include?(:all) || actions.include?(current_action)) |
33 | end | 33 | end |
34 | active | 34 | active |
app/models/app.rb
@@ -94,7 +94,7 @@ class App | @@ -94,7 +94,7 @@ class App | ||
94 | def notify_on_errs | 94 | def notify_on_errs |
95 | !(super == false) | 95 | !(super == false) |
96 | end | 96 | end |
97 | - alias :notify_on_errs? :notify_on_errs | 97 | + alias_method :notify_on_errs?, :notify_on_errs |
98 | 98 | ||
99 | def emailable? | 99 | def emailable? |
100 | notify_on_errs? && notification_recipients.any? | 100 | notify_on_errs? && notification_recipients.any? |
@@ -103,14 +103,14 @@ class App | @@ -103,14 +103,14 @@ class App | ||
103 | def notify_on_deploys | 103 | def notify_on_deploys |
104 | !(super == false) | 104 | !(super == false) |
105 | end | 105 | end |
106 | - alias :notify_on_deploys? :notify_on_deploys | 106 | + alias_method :notify_on_deploys?, :notify_on_deploys |
107 | 107 | ||
108 | def repo_branch | 108 | def repo_branch |
109 | - self.repository_branch.present? ? self.repository_branch : 'master' | 109 | + repository_branch.present? ? repository_branch : 'master' |
110 | end | 110 | end |
111 | 111 | ||
112 | def github_repo? | 112 | def github_repo? |
113 | - self.github_repo.present? | 113 | + github_repo.present? |
114 | end | 114 | end |
115 | 115 | ||
116 | def github_url | 116 | def github_url |
@@ -122,7 +122,7 @@ class App | @@ -122,7 +122,7 @@ class App | ||
122 | end | 122 | end |
123 | 123 | ||
124 | def bitbucket_repo? | 124 | def bitbucket_repo? |
125 | - self.bitbucket_repo.present? | 125 | + bitbucket_repo.present? |
126 | end | 126 | end |
127 | 127 | ||
128 | def bitbucket_url | 128 | def bitbucket_url |
@@ -135,11 +135,12 @@ class App | @@ -135,11 +135,12 @@ class App | ||
135 | 135 | ||
136 | 136 | ||
137 | def issue_tracker_configured? | 137 | def issue_tracker_configured? |
138 | - !!issue_tracker && !!(issue_tracker.configured?) | 138 | + issue_tracker.present? && issue_tracker.configured? |
139 | end | 139 | end |
140 | 140 | ||
141 | def notification_service_configured? | 141 | def notification_service_configured? |
142 | - !!(notification_service.class < NotificationService && notification_service.configured?) | 142 | + (notification_service.class < NotificationService) && |
143 | + notification_service.configured? | ||
143 | end | 144 | end |
144 | 145 | ||
145 | 146 | ||
@@ -156,12 +157,12 @@ class App | @@ -156,12 +157,12 @@ class App | ||
156 | if (copy_app = App.where(:_id => app_id).first) | 157 | if (copy_app = App.where(:_id => app_id).first) |
157 | # Copy fields | 158 | # Copy fields |
158 | (copy_app.fields.keys - %w(_id name created_at updated_at)).each do |k| | 159 | (copy_app.fields.keys - %w(_id name created_at updated_at)).each do |k| |
159 | - self.send("#{k}=", copy_app.send(k)) | 160 | + send("#{k}=", copy_app.send(k)) |
160 | end | 161 | end |
161 | # Clone the embedded objects that can be changed via apps/edit (ignore errs & deploys, etc.) | 162 | # Clone the embedded objects that can be changed via apps/edit (ignore errs & deploys, etc.) |
162 | %w(watchers issue_tracker notification_service).each do |relation| | 163 | %w(watchers issue_tracker notification_service).each do |relation| |
163 | if (obj = copy_app.send(relation)) | 164 | if (obj = copy_app.send(relation)) |
164 | - self.send("#{relation}=", obj.is_a?(Array) ? obj.map(&:clone) : obj.clone) | 165 | + send("#{relation}=", obj.is_a?(Array) ? obj.map(&:clone) : obj.clone) |
165 | end | 166 | end |
166 | end | 167 | end |
167 | end | 168 | end |
app/models/backtrace.rb
@@ -23,6 +23,7 @@ class Backtrace | @@ -23,6 +23,7 @@ class Backtrace | ||
23 | end | 23 | end |
24 | 24 | ||
25 | private | 25 | private |
26 | + | ||
26 | def generate_fingerprint | 27 | def generate_fingerprint |
27 | self.fingerprint = self.class.generate_fingerprint(lines) | 28 | self.fingerprint = self.class.generate_fingerprint(lines) |
28 | end | 29 | end |
app/models/comment.rb
app/models/error_report.rb
@@ -94,7 +94,7 @@ class ErrorReport | @@ -94,7 +94,7 @@ class ErrorReport | ||
94 | 94 | ||
95 | # Launch all notification define on the app associate to this notice | 95 | # Launch all notification define on the app associate to this notice |
96 | def services_notification | 96 | def services_notification |
97 | - return true unless app.notification_service_configured? and should_notify? | 97 | + return true unless app.notification_service_configured? && should_notify? |
98 | app.notification_service.create_notification(problem) | 98 | app.notification_service.create_notification(problem) |
99 | rescue => e | 99 | rescue => e |
100 | HoptoadNotifier.notify(e) | 100 | HoptoadNotifier.notify(e) |
app/models/issue_tracker.rb
@@ -12,7 +12,7 @@ class IssueTracker | @@ -12,7 +12,7 @@ class IssueTracker | ||
12 | def tracker | 12 | def tracker |
13 | @tracker ||= | 13 | @tracker ||= |
14 | begin | 14 | begin |
15 | - klass = ErrbitPlugin::Registry.issue_trackers[self.type_tracker] || ErrbitPlugin::NoneIssueTracker | 15 | + klass = ErrbitPlugin::Registry.issue_trackers[type_tracker] || ErrbitPlugin::NoneIssueTracker |
16 | # TODO: we need to find out a better way to pass those config to the issue tracker | 16 | # TODO: we need to find out a better way to pass those config to the issue tracker |
17 | klass.new(options.merge( | 17 | klass.new(options.merge( |
18 | github_repo: app.try(:github_repo), | 18 | github_repo: app.try(:github_repo), |
@@ -22,7 +22,7 @@ class IssueTracker | @@ -22,7 +22,7 @@ class IssueTracker | ||
22 | end | 22 | end |
23 | 23 | ||
24 | def type_tracker | 24 | def type_tracker |
25 | - self.attributes['type_tracker'] ? self.attributes['type_tracker'] : 'none' | 25 | + attributes['type_tracker'] ? attributes['type_tracker'] : 'none' |
26 | end | 26 | end |
27 | 27 | ||
28 | # Allow the tracker to validate its own params | 28 | # Allow the tracker to validate its own params |
app/models/notification_service.rb
@@ -39,7 +39,7 @@ class NotificationService | @@ -39,7 +39,7 @@ class NotificationService | ||
39 | end | 39 | end |
40 | 40 | ||
41 | # Allows us to set the issue tracker class from a single form. | 41 | # Allows us to set the issue tracker class from a single form. |
42 | - def type; self._type; end | 42 | + def type; _type; end |
43 | def type=(t); self._type=t; end | 43 | def type=(t); self._type=t; end |
44 | 44 | ||
45 | def url; nil; end | 45 | def url; nil; end |
app/models/notification_services/gtalk_service.rb
@@ -59,13 +59,13 @@ class NotificationServices::GtalkService < NotificationService | @@ -59,13 +59,13 @@ class NotificationServices::GtalkService < NotificationService | ||
59 | 59 | ||
60 | private | 60 | private |
61 | 61 | ||
62 | - def send_to_users client, message | ||
63 | - user_id.gsub(/ /i, ",").gsub(/;/i, ",").split(",").map(&:strip).reject(&:empty?).each do |user| | 62 | + def send_to_users(client, message) |
63 | + user_id.tr(' ', ",").tr(';', ",").split(",").map(&:strip).reject(&:empty?).each do |user| | ||
64 | client.send(Jabber::Message.new(user, message)) | 64 | client.send(Jabber::Message.new(user, message)) |
65 | end | 65 | end |
66 | end | 66 | end |
67 | 67 | ||
68 | - def send_to_muc client, message | 68 | + def send_to_muc(client, message) |
69 | #TODO: set this so that it can send to multiple rooms like users, nb multiple room joins in one send fail randomly so leave as one room for the moment | 69 | #TODO: set this so that it can send to multiple rooms like users, nb multiple room joins in one send fail randomly so leave as one room for the moment |
70 | muc = Jabber::MUC::SimpleMUCClient.new(client) | 70 | muc = Jabber::MUC::SimpleMUCClient.new(client) |
71 | muc.join(room_id + "/errbit") | 71 | muc.join(room_id + "/errbit") |
app/models/notification_services/hipchat_service.rb
@@ -20,7 +20,7 @@ if defined? HipChat | @@ -20,7 +20,7 @@ if defined? HipChat | ||
20 | }], | 20 | }], |
21 | ] | 21 | ] |
22 | Mandatory_fields = [:service, :api_token, :room_id] | 22 | Mandatory_fields = [:service, :api_token, :room_id] |
23 | - API_versions = ['v1', 'v2'] | 23 | + API_versions = %w(v1 v2) |
24 | 24 | ||
25 | def check_params | 25 | def check_params |
26 | Fields.each do |field, hash| | 26 | Fields.each do |field, hash| |
app/models/problem.rb
@@ -13,8 +13,8 @@ class Problem | @@ -13,8 +13,8 @@ class Problem | ||
13 | }.freeze | 13 | }.freeze |
14 | 14 | ||
15 | 15 | ||
16 | - field :last_notice_at, :type => ActiveSupport::TimeWithZone, :default => Proc.new { Time.now } | ||
17 | - field :first_notice_at, :type => ActiveSupport::TimeWithZone, :default => Proc.new { Time.now } | 16 | + field :last_notice_at, :type => ActiveSupport::TimeWithZone, :default => Proc.new { Time.zone.now } |
17 | + field :first_notice_at, :type => ActiveSupport::TimeWithZone, :default => Proc.new { Time.zone.now } | ||
18 | field :last_deploy_at, :type => Time | 18 | field :last_deploy_at, :type => Time |
19 | field :resolved, :type => Boolean, :default => false | 19 | field :resolved, :type => Boolean, :default => false |
20 | field :resolved_at, :type => Time | 20 | field :resolved_at, :type => Time |
@@ -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 | ) |
@@ -173,7 +175,7 @@ class Problem | @@ -173,7 +175,7 @@ class Problem | ||
173 | end | 175 | end |
174 | 176 | ||
175 | def resolve! | 177 | def resolve! |
176 | - self.update_attributes!(:resolved => true, :resolved_at => Time.now) | 178 | + self.update_attributes!(:resolved => true, :resolved_at => Time.zone.now) |
177 | end | 179 | end |
178 | 180 | ||
179 | def unresolve! | 181 | def unresolve! |
@@ -214,11 +216,11 @@ class Problem | @@ -214,11 +216,11 @@ class Problem | ||
214 | 216 | ||
215 | def self.ordered_by(sort, order) | 217 | def self.ordered_by(sort, order) |
216 | case sort | 218 | case sort |
217 | - when "app"; order_by(["app_name", order]) | ||
218 | - when "message"; order_by(["message", order]) | ||
219 | - when "last_notice_at"; order_by(["last_notice_at", order]) | ||
220 | - when "last_deploy_at"; order_by(["last_deploy_at", order]) | ||
221 | - when "count"; order_by(["notices_count", order]) | 219 | + when "app" then order_by(["app_name", order]) |
220 | + when "message" then order_by(["message", order]) | ||
221 | + when "last_notice_at" then order_by(["last_notice_at", order]) | ||
222 | + when "last_deploy_at" then order_by(["last_deploy_at", order]) | ||
223 | + when "count" then order_by(["notices_count", order]) | ||
222 | else raise("\"#{sort}\" is not a recognized sort") | 224 | else raise("\"#{sort}\" is not a recognized sort") |
223 | end | 225 | end |
224 | end | 226 | end |
@@ -231,7 +233,7 @@ class Problem | @@ -231,7 +233,7 @@ class Problem | ||
231 | end | 233 | end |
232 | 234 | ||
233 | def truncate_message | 235 | def truncate_message |
234 | - self.message = self.message[0, 1000] if self.message | 236 | + self.message = message[0, 1000] if message |
235 | end | 237 | end |
236 | 238 | ||
237 | def issue_type | 239 | def issue_type |
@@ -247,7 +249,8 @@ class Problem | @@ -247,7 +249,8 @@ class Problem | ||
247 | private | 249 | private |
248 | 250 | ||
249 | def attribute_count_descrease(name, value) | 251 | def attribute_count_descrease(name, value) |
250 | - counter, index = send(name), attribute_index(value) | 252 | + counter = send(name) |
253 | + index = attribute_index(value) | ||
251 | if counter[index] && counter[index]['count'] > 1 | 254 | if counter[index] && counter[index]['count'] > 1 |
252 | counter[index]['count'] -= 1 | 255 | counter[index]['count'] -= 1 |
253 | else | 256 | else |
config/load.rb
@@ -26,7 +26,7 @@ Errbit::Config = Configurator.run({ | @@ -26,7 +26,7 @@ Errbit::Config = Configurator.run({ | ||
26 | 26 | ||
27 | serve_static_assets: ['SERVE_STATIC_ASSETS'], | 27 | serve_static_assets: ['SERVE_STATIC_ASSETS'], |
28 | secret_key_base: ['SECRET_KEY_BASE'], | 28 | secret_key_base: ['SECRET_KEY_BASE'], |
29 | - mongo_url: ['MONGOLAB_URI', 'MONGOHQ_URL', 'MONGODB_URL', 'MONGO_URL'], | 29 | + mongo_url: %w(MONGOLAB_URI MONGOHQ_URL MONGODB_URL MONGO_URL), |
30 | 30 | ||
31 | # github | 31 | # github |
32 | github_url: ['GITHUB_URL', ->(values) { | 32 | github_url: ['GITHUB_URL', ->(values) { |
@@ -48,8 +48,8 @@ Errbit::Config = Configurator.run({ | @@ -48,8 +48,8 @@ Errbit::Config = Configurator.run({ | ||
48 | smtp_address: ['SMTP_SERVER'], | 48 | smtp_address: ['SMTP_SERVER'], |
49 | smtp_port: ['SMTP_PORT'], | 49 | smtp_port: ['SMTP_PORT'], |
50 | smtp_authentication: ['SMTP_AUTHENTICATION'], | 50 | smtp_authentication: ['SMTP_AUTHENTICATION'], |
51 | - smtp_user_name: ['SMTP_USERNAME', 'SENDGRID_USERNAME'], | ||
52 | - smtp_password: ['SMTP_PASSWORD', 'SENDGRID_PASSWORD'], | 51 | + smtp_user_name: %w(SMTP_USERNAME SENDGRID_USERNAME), |
52 | + smtp_password: %w(SMTP_PASSWORD SENDGRID_PASSWORD), | ||
53 | smtp_domain: ['SMTP_DOMAIN', 'SENDGRID_DOMAIN', ->(values) { | 53 | smtp_domain: ['SMTP_DOMAIN', 'SENDGRID_DOMAIN', ->(values) { |
54 | values[:smtp_domain] || | 54 | values[:smtp_domain] || |
55 | (values[:email_from] && values[:email_from].split('@').last)|| | 55 | (values[:email_from] && values[:email_from].split('@').last)|| |
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/configurator.rb
@@ -39,7 +39,7 @@ class Configurator | @@ -39,7 +39,7 @@ class Configurator | ||
39 | # a list of environment variables to scan for configuration | 39 | # a list of environment variables to scan for configuration |
40 | # @return OpenStruct configuration object | 40 | # @return OpenStruct configuration object |
41 | def self.run(mapping) | 41 | def self.run(mapping) |
42 | - reader = self.new(mapping) | 42 | + reader = new(mapping) |
43 | reader.read | 43 | reader.read |
44 | end | 44 | end |
45 | 45 |
lib/hoptoad.rb
@@ -14,9 +14,10 @@ module Hoptoad | @@ -14,9 +14,10 @@ module Hoptoad | ||
14 | end | 14 | end |
15 | 15 | ||
16 | private | 16 | private |
17 | + | ||
17 | def self.get_version_processor(version) | 18 | def self.get_version_processor(version) |
18 | case version | 19 | case version |
19 | - when /2\.[01234]/; Hoptoad::V2 | 20 | + when /2\.[01234]/ then Hoptoad::V2 |
20 | else; raise ApiVersionError | 21 | else; raise ApiVersionError |
21 | end | 22 | end |
22 | end | 23 | end |
lib/hoptoad/v2.rb
@@ -6,25 +6,26 @@ module Hoptoad | @@ -6,25 +6,26 @@ module Hoptoad | ||
6 | rekey(parsed))) | 6 | rekey(parsed))) |
7 | end | 7 | end |
8 | 8 | ||
9 | - private | 9 | + private |
10 | + | ||
10 | def self.rekey(node) | 11 | def self.rekey(node) |
11 | case node | 12 | case node |
12 | when Hash | 13 | when Hash |
13 | - if node.has_key?('var') && node.has_key?('key') | 14 | + if node.key?('var') && node.key?('key') |
14 | {normalize_key(node['key']) => rekey(node['var'])} | 15 | {normalize_key(node['key']) => rekey(node['var'])} |
15 | - elsif node.has_key?('var') | 16 | + elsif node.key?('var') |
16 | rekey(node['var']) | 17 | rekey(node['var']) |
17 | - elsif node.has_key?('__content__') && node.has_key?('key') | 18 | + elsif node.key?('__content__') && node.key?('key') |
18 | {normalize_key(node['key']) => rekey(node['__content__'])} | 19 | {normalize_key(node['key']) => rekey(node['__content__'])} |
19 | - elsif node.has_key?('__content__') | 20 | + elsif node.key?('__content__') |
20 | rekey(node['__content__']) | 21 | rekey(node['__content__']) |
21 | - elsif node.has_key?('key') | 22 | + elsif node.key?('key') |
22 | {normalize_key(node['key']) => nil} | 23 | {normalize_key(node['key']) => nil} |
23 | else | 24 | else |
24 | 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))} |
25 | end | 26 | end |
26 | when Array | 27 | when Array |
27 | - if node.first.has_key?('key') | 28 | + if node.first.key?('key') |
28 | node.inject({}) {|rekeyed, keypair| rekeyed.merge(rekey(keypair))} | 29 | node.inject({}) {|rekeyed, keypair| rekeyed.merge(rekey(keypair))} |
29 | else | 30 | else |
30 | node.map {|n| rekey(n)} | 31 | node.map {|n| rekey(n)} |
@@ -35,7 +36,7 @@ module Hoptoad | @@ -35,7 +36,7 @@ module Hoptoad | ||
35 | end | 36 | end |
36 | 37 | ||
37 | def self.normalize_key(key) | 38 | def self.normalize_key(key) |
38 | - key.gsub('.', '_') | 39 | + key.tr('.', '_') |
39 | end | 40 | end |
40 | 41 | ||
41 | def self.normalize(notice) | 42 | def self.normalize(notice) |
lib/overrides/hoptoad_notifier/hoptoad_notifier.rb
@@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
5 | HoptoadNotifier.module_eval do | 5 | HoptoadNotifier.module_eval do |
6 | class << self | 6 | class << self |
7 | private | 7 | private |
8 | + | ||
8 | def send_notice(notice) | 9 | def send_notice(notice) |
9 | # Log the error internally if we are not in a development environment. | 10 | # Log the error internally if we are not in a development environment. |
10 | if configuration.public? | 11 | if configuration.public? |
lib/tasks/errbit/demo.rake
@@ -3,7 +3,7 @@ namespace :errbit do | @@ -3,7 +3,7 @@ namespace :errbit do | ||
3 | task :demo => :environment do | 3 | task :demo => :environment do |
4 | require 'fabrication' | 4 | require 'fabrication' |
5 | 5 | ||
6 | - app = Fabricate(:app, :name => "Demo App #{Time.now.strftime("%N")}") | 6 | + app = Fabricate(:app, :name => "Demo App #{Time.zone.now.strftime("%N")}") |
7 | 7 | ||
8 | # Report a number of errors for the application | 8 | # Report a number of errors for the application |
9 | app.problems.delete_all | 9 | app.problems.delete_all |
@@ -35,7 +35,7 @@ namespace :errbit do | @@ -35,7 +35,7 @@ namespace :errbit do | ||
35 | 99.times {|t| backtrace << { | 35 | 99.times {|t| backtrace << { |
36 | 'number' => t.hash % 1000, | 36 | 'number' => t.hash % 1000, |
37 | 'file' => "/path/to/file.rb", | 37 | 'file' => "/path/to/file.rb", |
38 | - 'method' => RANDOM_METHODS.shuffle.first.to_s | 38 | + 'method' => RANDOM_METHODS.sample.to_s |
39 | }} | 39 | }} |
40 | backtrace | 40 | backtrace |
41 | end | 41 | end |
spec/controllers/api/v1/notices_controller_spec.rb
@@ -6,15 +6,15 @@ describe Api::V1::NoticesController, type: 'controller' do | @@ -6,15 +6,15 @@ describe Api::V1::NoticesController, type: 'controller' do | ||
6 | 6 | ||
7 | describe "GET /api/v1/notices" do | 7 | describe "GET /api/v1/notices" do |
8 | before do | 8 | before do |
9 | - Fabricate(:notice, :created_at => Time.new(2012, 8, 01)) | ||
10 | - Fabricate(:notice, :created_at => Time.new(2012, 8, 01)) | ||
11 | - Fabricate(:notice, :created_at => Time.new(2012, 8, 21)) | ||
12 | - Fabricate(:notice, :created_at => Time.new(2012, 8, 30)) | 9 | + Fabricate(:notice, :created_at => Time.zone.parse('2012-08-01')) |
10 | + Fabricate(:notice, :created_at => Time.zone.parse('2012-08-01')) | ||
11 | + Fabricate(:notice, :created_at => Time.zone.parse('2012-08-21')) | ||
12 | + Fabricate(:notice, :created_at => Time.zone.parse('2012-08-30')) | ||
13 | end | 13 | end |
14 | 14 | ||
15 | it "should return JSON if JSON is requested" do | 15 | it "should return JSON if JSON is requested" do |
16 | get :index, :auth_token => @user.authentication_token, :format => "json" | 16 | get :index, :auth_token => @user.authentication_token, :format => "json" |
17 | - expect { JSON.load(response.body) }.not_to raise_error() #JSON::ParserError) | 17 | + expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) |
18 | end | 18 | end |
19 | 19 | ||
20 | it "should return XML if XML is requested" do | 20 | it "should return XML if XML is requested" do |
@@ -24,7 +24,7 @@ describe Api::V1::NoticesController, type: 'controller' do | @@ -24,7 +24,7 @@ describe Api::V1::NoticesController, type: 'controller' do | ||
24 | 24 | ||
25 | it "should return JSON by default" do | 25 | it "should return JSON by default" do |
26 | get :index, :auth_token => @user.authentication_token | 26 | get :index, :auth_token => @user.authentication_token |
27 | - expect { JSON.load(response.body) }.not_to raise_error() #JSON::ParserError) | 27 | + expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError) |
28 | end | 28 | end |
29 | 29 | ||
30 | describe "given a date range" do | 30 | describe "given a date range" do |
spec/controllers/api/v1/problems_controller_spec.rb
@@ -13,7 +13,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -13,7 +13,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | ||
13 | 13 | ||
14 | it "should return JSON if JSON is requested" do | 14 | it "should return JSON if JSON is requested" do |
15 | get :show, :auth_token => @user.authentication_token, :format => "json", :id => Problem.first.id | 15 | get :show, :auth_token => @user.authentication_token, :format => "json", :id => Problem.first.id |
16 | - expect { JSON.load(response.body) }.not_to raise_error() #JSON::ParserError | 16 | + expect { JSON.load(response.body) }.not_to raise_error #JSON::ParserError |
17 | end | 17 | end |
18 | 18 | ||
19 | it "should return XML if XML is requested" do | 19 | it "should return XML if XML is requested" do |
@@ -23,7 +23,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -23,7 +23,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | ||
23 | 23 | ||
24 | it "should return JSON by default" do | 24 | it "should return JSON by default" do |
25 | get :show, :auth_token => @user.authentication_token, :id => @problem.id | 25 | get :show, :auth_token => @user.authentication_token, :id => @problem.id |
26 | - expect { JSON.load(response.body) }.not_to raise_error()#JSON::ParserError) | 26 | + expect { JSON.load(response.body) }.not_to raise_error#JSON::ParserError) |
27 | end | 27 | end |
28 | 28 | ||
29 | it "should return the correct problem" do | 29 | it "should return the correct problem" do |
@@ -37,19 +37,18 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -37,19 +37,18 @@ describe Api::V1::ProblemsController, type: 'controller' do | ||
37 | get :show, :auth_token => @user.authentication_token, :format => "json", :id => @problem.id | 37 | get :show, :auth_token => @user.authentication_token, :format => "json", :id => @problem.id |
38 | returned_problem = JSON.parse(response.body) | 38 | returned_problem = JSON.parse(response.body) |
39 | 39 | ||
40 | - expect( returned_problem.keys ).to match_array([ | ||
41 | - "app_name", | ||
42 | - "first_notice_at", | ||
43 | - "message", | ||
44 | - "app_id", | ||
45 | - "last_notice_at", | ||
46 | - "_id", | ||
47 | - "resolved", | ||
48 | - "resolved_at", | ||
49 | - "where", | ||
50 | - "notices_count", | ||
51 | - "environment" | ||
52 | - ]) | 40 | + expect( returned_problem.keys ).to match_array(%w( |
41 | + app_name | ||
42 | + first_notice_at | ||
43 | + message | ||
44 | + app_id | ||
45 | + last_notice_at | ||
46 | + _id | ||
47 | + resolved | ||
48 | + resolved_at | ||
49 | + where | ||
50 | + notices_count | ||
51 | + environment)) | ||
53 | end | 52 | end |
54 | 53 | ||
55 | it "returns a 404 if the problem cannot be found" do | 54 | it "returns a 404 if the problem cannot be found" do |
@@ -68,7 +67,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -68,7 +67,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | ||
68 | 67 | ||
69 | it "should return JSON if JSON is requested" do | 68 | it "should return JSON if JSON is requested" do |
70 | get :index, :auth_token => @user.authentication_token, :format => "json" | 69 | get :index, :auth_token => @user.authentication_token, :format => "json" |
71 | - expect { JSON.load(response.body) }.not_to raise_error()#JSON::ParserError) | 70 | + expect { JSON.load(response.body) }.not_to raise_error#JSON::ParserError) |
72 | end | 71 | end |
73 | 72 | ||
74 | it "should return XML if XML is requested" do | 73 | it "should return XML if XML is requested" do |
@@ -78,7 +77,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | @@ -78,7 +77,7 @@ describe Api::V1::ProblemsController, type: 'controller' do | ||
78 | 77 | ||
79 | it "should return JSON by default" do | 78 | it "should return JSON by default" do |
80 | get :index, :auth_token => @user.authentication_token | 79 | get :index, :auth_token => @user.authentication_token |
81 | - expect { JSON.load(response.body) }.not_to raise_error()#JSON::ParserError) | 80 | + expect { JSON.load(response.body) }.not_to raise_error#JSON::ParserError) |
82 | end | 81 | end |
83 | 82 | ||
84 | describe "given a date range" do | 83 | describe "given a date range" do |
spec/controllers/apps_controller_spec.rb
@@ -118,7 +118,7 @@ describe AppsController, type: 'controller' do | @@ -118,7 +118,7 @@ describe AppsController, type: 'controller' do | ||
118 | 118 | ||
119 | context 'with environment filters' do | 119 | context 'with environment filters' do |
120 | before(:each) do | 120 | before(:each) do |
121 | - environments = ['production', 'test', 'development', 'staging'] | 121 | + environments = %w(production test development staging) |
122 | 20.times do |i| | 122 | 20.times do |i| |
123 | Fabricate(:problem, :app => app, :environment => environments[i % environments.length]) | 123 | Fabricate(:problem, :app => app, :environment => environments[i % environments.length]) |
124 | end | 124 | end |
spec/controllers/problems_controller_spec.rb
@@ -34,7 +34,7 @@ describe ProblemsController, type: 'controller' do | @@ -34,7 +34,7 @@ describe ProblemsController, type: 'controller' do | ||
34 | 34 | ||
35 | context 'with environment filters' do | 35 | context 'with environment filters' do |
36 | before(:each) do | 36 | before(:each) do |
37 | - environments = ['production', 'test', 'development', 'staging'] | 37 | + environments = %w(production test development staging) |
38 | 20.times do |i| | 38 | 20.times do |i| |
39 | Fabricate(:problem, :environment => environments[i % environments.length]) | 39 | Fabricate(:problem, :environment => environments[i % environments.length]) |
40 | end | 40 | end |
@@ -139,7 +139,7 @@ describe ProblemsController, type: 'controller' do | @@ -139,7 +139,7 @@ describe ProblemsController, type: 'controller' do | ||
139 | context 'pagination' do | 139 | context 'pagination' do |
140 | let!(:notices) do | 140 | let!(:notices) do |
141 | 3.times.reduce([]) do |coll, i| | 141 | 3.times.reduce([]) do |coll, i| |
142 | - coll << Fabricate(:notice, :err => err, :created_at => (Time.now + i)) | 142 | + coll << Fabricate(:notice, :err => err, :created_at => (i.seconds.from_now)) |
143 | end | 143 | end |
144 | end | 144 | end |
145 | 145 |
spec/fabricators/backtrace_fabricator.rb
@@ -3,7 +3,7 @@ Fabricator :backtrace do | @@ -3,7 +3,7 @@ Fabricator :backtrace do | ||
3 | { | 3 | { |
4 | number: rand(999), | 4 | number: rand(999), |
5 | file: "/path/to/file/#{SecureRandom.hex(4)}.rb", | 5 | file: "/path/to/file/#{SecureRandom.hex(4)}.rb", |
6 | - method: ActiveSupport.methods.shuffle.first | 6 | + method: ActiveSupport.methods.sample |
7 | } | 7 | } |
8 | end | 8 | end |
9 | end | 9 | end |
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 |
spec/lib/configurator_spec.rb
@@ -6,12 +6,12 @@ describe Configurator do | @@ -6,12 +6,12 @@ describe Configurator do | ||
6 | end | 6 | end |
7 | 7 | ||
8 | it 'takes the first existing env, second item' do | 8 | it 'takes the first existing env, second item' do |
9 | - result = Configurator.run({ two: ['VARTWO', 'VARTHREE'] }) | 9 | + result = Configurator.run({ two: %w(VARTWO VARTHREE) }) |
10 | expect(result.two).to eq('zipp') | 10 | expect(result.two).to eq('zipp') |
11 | end | 11 | end |
12 | 12 | ||
13 | it 'takes the first existing env, first item' do | 13 | it 'takes the first existing env, first item' do |
14 | - result = Configurator.run({ three: ['VARTHREE', 'VARONE'] }) | 14 | + result = Configurator.run({ three: %w(VARTHREE VARONE) }) |
15 | expect(result.three).to eq('zipp') | 15 | expect(result.three).to eq('zipp') |
16 | end | 16 | end |
17 | 17 | ||
@@ -44,7 +44,7 @@ describe Configurator do | @@ -44,7 +44,7 @@ describe Configurator do | ||
44 | it 'extracts array values' do | 44 | it 'extracts array values' do |
45 | allow(ENV).to receive(:[]).with('MYARRAY').and_return('[one,two,three]') | 45 | allow(ENV).to receive(:[]).with('MYARRAY').and_return('[one,two,three]') |
46 | result = Configurator.run({ myarray: ['MYARRAY'] }) | 46 | result = Configurator.run({ myarray: ['MYARRAY'] }) |
47 | - expect(result.myarray).to eq(['one', 'two', 'three']) | 47 | + expect(result.myarray).to eq(%w(one two three)) |
48 | end | 48 | end |
49 | 49 | ||
50 | it 'extracts booleans' do | 50 | it 'extracts booleans' do |
spec/models/app_spec.rb
@@ -152,8 +152,8 @@ describe App, type: 'model' do | @@ -152,8 +152,8 @@ describe App, type: 'model' do | ||
152 | 152 | ||
153 | context "copying attributes from existing app" do | 153 | context "copying attributes from existing app" do |
154 | it "should only copy the necessary fields" do | 154 | it "should only copy the necessary fields" do |
155 | - @app, @copy_app = Fabricate(:app, :name => "app", :github_repo => "url"), | ||
156 | - Fabricate(:app, :name => "copy_app", :github_repo => "copy url") | 155 | + @app = Fabricate(:app, :name => "app", :github_repo => "url") |
156 | + @copy_app = Fabricate(:app, :name => "copy_app", :github_repo => "copy url") | ||
157 | @copy_watcher = Fabricate(:watcher, :email => "copywatcher@example.com", :app => @copy_app) | 157 | @copy_watcher = Fabricate(:watcher, :email => "copywatcher@example.com", :app => @copy_app) |
158 | @app.copy_attributes_from(@copy_app.id) | 158 | @app.copy_attributes_from(@copy_app.id) |
159 | expect(@app.name).to eq "app" | 159 | expect(@app.name).to eq "app" |
spec/models/error_report_spec.rb
@@ -156,7 +156,7 @@ describe ErrorReport do | @@ -156,7 +156,7 @@ describe ErrorReport do | ||
156 | error_report.generate_notice! | 156 | error_report.generate_notice! |
157 | problem = error_report.problem | 157 | problem = error_report.problem |
158 | problem.update( | 158 | problem.update( |
159 | - resolved_at: Time.now, | 159 | + resolved_at: Time.zone.now, |
160 | resolved: true | 160 | resolved: true |
161 | ) | 161 | ) |
162 | 162 |
spec/models/notice_spec.rb
@@ -41,7 +41,7 @@ describe Notice, type: 'model' do | @@ -41,7 +41,7 @@ describe Notice, type: 'model' do | ||
41 | 41 | ||
42 | it 'has a curl representation' do | 42 | it 'has a curl representation' do |
43 | cmd = notice.to_curl | 43 | cmd = notice.to_curl |
44 | - expect(cmd).to eq(%q[curl -X GET -H 'User-Agent: Mozilla/5.0' http://example.com/resource/12]) | 44 | + expect(cmd).to eq("curl -X GET -H 'User-Agent: Mozilla/5.0' http://example.com/resource/12") |
45 | end | 45 | end |
46 | end | 46 | end |
47 | 47 |
spec/models/problem_spec.rb
@@ -236,7 +236,7 @@ describe Problem, type: 'model' do | @@ -236,7 +236,7 @@ describe Problem, type: 'model' do | ||
236 | context "#last_deploy_at" do | 236 | context "#last_deploy_at" do |
237 | before do | 237 | before do |
238 | @app = Fabricate(:app) | 238 | @app = Fabricate(:app) |
239 | - @last_deploy = Time.at(10.days.ago.localtime.to_i) | 239 | + @last_deploy = 10.days.ago |
240 | Fabricate(:deploy, :app => @app, :created_at => @last_deploy, :environment => "production") | 240 | Fabricate(:deploy, :app => @app, :created_at => @last_deploy, :environment => "production") |
241 | end | 241 | end |
242 | 242 | ||
@@ -247,11 +247,13 @@ describe Problem, type: 'model' do | @@ -247,11 +247,13 @@ describe Problem, type: 'model' do | ||
247 | 247 | ||
248 | it "is updated when a deploy is created" do | 248 | it "is updated when a deploy is created" do |
249 | problem = Fabricate(:problem, :app => @app, :environment => "production") | 249 | problem = Fabricate(:problem, :app => @app, :environment => "production") |
250 | - next_deploy = Time.at(5.minutes.ago.localtime.to_i) | 250 | + next_deploy = 5.minutes.ago |
251 | expect { | 251 | expect { |
252 | @deploy = Fabricate(:deploy, :app => @app, :created_at => next_deploy) | 252 | @deploy = Fabricate(:deploy, :app => @app, :created_at => next_deploy) |
253 | problem.reload | 253 | problem.reload |
254 | - }.to change(problem, :last_deploy_at).from(@last_deploy).to(next_deploy) | 254 | + }.to change { problem.last_deploy_at.iso8601 }. |
255 | + from(@last_deploy.iso8601). | ||
256 | + to(next_deploy.iso8601) | ||
255 | end | 257 | end |
256 | end | 258 | end |
257 | 259 |
spec/views/apps/index.html.haml_spec.rb
1 | describe "apps/index.html.haml", type: 'view' do | 1 | describe "apps/index.html.haml", type: 'view' do |
2 | before do | 2 | before do |
3 | - app = stub_model(App, :deploys => [stub_model(Deploy, :created_at => Time.now, :revision => "123456789abcdef")]) | 3 | + app = stub_model(App, :deploys => [stub_model(Deploy, :created_at => Time.zone.now, :revision => "123456789abcdef")]) |
4 | allow(view).to receive(:apps).and_return([app]) | 4 | allow(view).to receive(:apps).and_return([app]) |
5 | allow(controller).to receive(:current_user).and_return(stub_model(User)) | 5 | allow(controller).to receive(:current_user).and_return(stub_model(User)) |
6 | end | 6 | end |
spec/views/users/show.html.haml_spec.rb
1 | describe 'users/show.html.haml', type: 'view' do | 1 | describe 'users/show.html.haml', type: 'view' do |
2 | let(:user) do | 2 | let(:user) do |
3 | - stub_model(User, :created_at => Time.now, :email => "test@example.com") | 3 | + stub_model(User, :created_at => Time.zone.now, :email => "test@example.com") |
4 | end | 4 | end |
5 | 5 | ||
6 | before do | 6 | before do |