Skip to content

Commit 46aadb5

Browse files
committed
Rubocop: hashes: format neatly with symbols for keys and aligned values
1 parent fe3f623 commit 46aadb5

File tree

141 files changed

+947
-958
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+947
-958
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ Style/DotPosition:
3636
Style/IndentHash:
3737
EnforcedStyle: consistent
3838

39+
Style/AlignHash:
40+
EnforcedColonStyle: table
41+
3942
Style/SpaceAroundOperators:
4043
MultiSpaceAllowedForOperators:
4144
- '='

.rubocop_todo.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,6 @@ Rails/Validation:
5353
- 'app/models/problem.rb'
5454
- 'app/models/user.rb'
5555

56-
# Offense count: 8
57-
# Cop supports --auto-correct.
58-
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
59-
Style/AlignHash:
60-
Exclude:
61-
- 'app/models/app.rb'
62-
- 'spec/controllers/apps_controller_spec.rb'
63-
- 'spec/controllers/comments_controller_spec.rb'
64-
- 'spec/controllers/problems_controller_spec.rb'
65-
- 'spec/models/problem_spec.rb'
66-
6756
# Offense count: 105
6857
# Cop supports --auto-correct.
6958
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
@@ -141,12 +130,6 @@ Style/FormatString:
141130
Style/GuardClause:
142131
Enabled: false
143132

144-
# Offense count: 1168
145-
# Cop supports --auto-correct.
146-
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
147-
Style/HashSyntax:
148-
Enabled: false
149-
150133
# Offense count: 6
151134
# Cop supports --auto-correct.
152135
# Configuration parameters: MaxLineLength.

Gemfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ gem 'htmlentities'
2929
gem 'kaminari', '>= 0.14.1'
3030
gem 'mongoid', '5.0.0'
3131
gem 'mongoid_rails_migrations'
32-
gem 'rack-ssl', :require => 'rack/ssl' # force SSL
33-
gem 'rack-ssl-enforcer', :require => false
32+
gem 'rack-ssl', require: 'rack/ssl' # force SSL
33+
gem 'rack-ssl-enforcer', require: false
3434
gem 'rails_autolink'
3535
gem 'useragent'
3636

@@ -44,7 +44,7 @@ gem 'campy'
4444
# Hipchat
4545
gem 'hipchat'
4646
# Google Talk
47-
gem 'xmpp4r', :require => ["xmpp4r", "xmpp4r/muc"]
47+
gem 'xmpp4r', require: ["xmpp4r", "xmpp4r/muc"]
4848
# Hoiio (SMS)
4949
gem 'hoi'
5050
# Pushover (iOS Push notifications)
@@ -64,7 +64,7 @@ gem 'yajl-ruby', platform: 'ruby'
6464
gem 'json', platform: 'jruby'
6565

6666
group :development, :test do
67-
gem 'airbrake', :require => false
67+
gem 'airbrake', require: false
6868
gem 'pry-rails'
6969
gem 'pry-byebug', platforms: [:mri]
7070
gem 'quiet_assets'
@@ -103,7 +103,7 @@ group :heroku, :production do
103103
gem 'unicorn', require: false, platform: 'ruby'
104104
end
105105

106-
gem 'therubyracer', :platform => :ruby # C Ruby (MRI) or Rubinius, but NOT Windows
106+
gem 'therubyracer', platform: :ruby # C Ruby (MRI) or Rubinius, but NOT Windows
107107
gem 'sass-rails'
108108
gem 'uglifier'
109109
# We can't upgrade because not compatible to jquery >= 1.9.

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Rails.application.load_tasks
88
begin
99
require 'rspec/core/rake_task'
1010
RSpec::Core::RakeTask.new(:spec)
11-
task :default => :spec
11+
task default: :spec
1212
rescue LoadError
1313
warn "Notice: no rspec tasks available in this environment"
1414
end

app/controllers/api/v1/notices_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ def index
88
if params.key?(:start_date) && params.key?(:end_date)
99
start_date = Time.zone.parse(params[:start_date]).utc
1010
end_date = Time.zone.parse(params[:end_date]).utc
11-
query = { :created_at => { "$lte" => end_date, "$gte" => start_date } }
11+
query = { created_at: { "$lte" => end_date, "$gte" => start_date } }
1212
end
1313

1414
results = benchmark("[api/v1/notices_controller] query time") do
15-
Notice.where(query).with(:consistency => :strong).only(fields).to_a
15+
Notice.where(query).with(consistency: :strong).only(fields).to_a
1616
end
1717

1818
respond_to do |format|
19-
format.any(:html, :json) { render :json => JSON.dump(results) } # render JSON if no extension specified on path
20-
format.xml { render :xml => results }
19+
format.any(:html, :json) { render json: JSON.dump(results) } # render JSON if no extension specified on path
20+
format.xml { render xml: results }
2121
end
2222
end
2323
end

app/controllers/api/v1/problems_controller.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def show
1313
end
1414

1515
respond_to do |format|
16-
format.any(:html, :json) { render :json => result } # render JSON if no extension specified on path
17-
format.xml { render :xml => result }
16+
format.any(:html, :json) { render json: result } # render JSON if no extension specified on path
17+
format.xml { render xml: result }
1818
end
1919
end
2020

@@ -24,16 +24,16 @@ def index
2424
if params.key?(:start_date) && params.key?(:end_date)
2525
start_date = Time.parse(params[:start_date]).utc
2626
end_date = Time.parse(params[:end_date]).utc
27-
query = { :first_notice_at => { "$lte" => end_date }, "$or" => [{ :resolved_at => nil }, { :resolved_at => { "$gte" => start_date } }] }
27+
query = { :first_notice_at => { "$lte" => end_date }, "$or" => [{ resolved_at: nil }, { resolved_at: { "$gte" => start_date } }] }
2828
end
2929

3030
results = benchmark("[api/v1/problems_controller/index] query time") do
31-
Problem.where(query).with(:consistency => :strong).only(FIELDS).to_a
31+
Problem.where(query).with(consistency: :strong).only(FIELDS).to_a
3232
end
3333

3434
respond_to do |format|
35-
format.any(:html, :json) { render :json => JSON.dump(results) } # render JSON if no extension specified on path
36-
format.xml { render :xml => results }
35+
format.any(:html, :json) { render json: JSON.dump(results) } # render JSON if no extension specified on path
36+
format.xml { render xml: results }
3737
end
3838
end
3939
end

app/controllers/api/v1/stats_controller.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ def app
1111
end
1212

1313
stats = {
14-
:name => @app.name,
15-
:id => @app.id,
16-
:last_error_time => @last_error_time,
17-
:unresolved_errors => @app.unresolved_count
14+
name: @app.name,
15+
id: @app.id,
16+
last_error_time: @last_error_time,
17+
unresolved_errors: @app.unresolved_count
1818
}
1919

2020
respond_to do |format|
21-
format.any(:html, :json) { render :json => JSON.dump(stats) } # render JSON if no extension specified on path
22-
format.xml { render :xml => stats }
21+
format.any(:html, :json) { render json: JSON.dump(stats) } # render JSON if no extension specified on path
22+
format.xml { render xml: stats }
2323
end
2424
end
2525

2626
protected def require_api_key_or_authenticate_user!
2727
if params[:api_key].present?
28-
if (@app = App.where(:api_key => params[:api_key]).first)
28+
if (@app = App.where(api_key: params[:api_key]).first)
2929
return true
3030
end
3131
end

app/controllers/api/v3/notices_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def create
1515
if report.should_keep?
1616
report.generate_notice!
1717
render json: {
18-
id: report.notice.id,
18+
id: report.notice.id,
1919
url: app_problem_url(
2020
report.app,
2121
report.error.problem_id)

app/controllers/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base
55
before_action :authenticate_user!
66
before_action :set_time_zone
77

8-
rescue_from ActionController::RedirectBackError, :with => :redirect_to_root
8+
rescue_from ActionController::RedirectBackError, with: :redirect_to_root
99

1010
class StrongParametersWithEagerAttributesStrategy < DecentExposure::StrongParametersStrategy
1111
def assign_attributes?

app/controllers/apps_controller.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
class AppsController < ApplicationController
22
include ProblemsSearcher
33

4-
before_action :require_admin!, :except => [:index, :show]
5-
before_action :parse_email_at_notices_or_set_default, :only => [:create, :update]
6-
before_action :parse_notice_at_notices_or_set_default, :only => [:create, :update]
4+
before_action :require_admin!, except: [:index, :show]
5+
before_action :parse_email_at_notices_or_set_default, only: [:create, :update]
6+
before_action :parse_notice_at_notices_or_set_default, only: [:create, :update]
77
respond_to :html
88

99
expose(:app_scope) { App }
@@ -55,7 +55,7 @@ def new
5555
def create
5656
initialize_subclassed_notification_service
5757
if app.save
58-
redirect_to app_url(app), :flash => { :success => I18n.t('controllers.apps.flash.create.success') }
58+
redirect_to app_url(app), flash: { success: I18n.t('controllers.apps.flash.create.success') }
5959
else
6060
flash[:error] = I18n.t('controllers.apps.flash.create.error')
6161
render :new
@@ -65,7 +65,7 @@ def create
6565
def update
6666
initialize_subclassed_notification_service
6767
if app.save
68-
redirect_to app_url(app), :flash => { :success => I18n.t('controllers.apps.flash.update.success') }
68+
redirect_to app_url(app), flash: { success: I18n.t('controllers.apps.flash.update.success') }
6969
else
7070
flash[:error] = I18n.t('controllers.apps.flash.update.error')
7171
render :edit
@@ -78,7 +78,7 @@ def edit
7878

7979
def destroy
8080
if app.destroy
81-
redirect_to apps_url, :flash => { :success => I18n.t('controllers.apps.flash.destroy.success') }
81+
redirect_to apps_url, flash: { success: I18n.t('controllers.apps.flash.destroy.success') }
8282
else
8383
flash[:error] = I18n.t('controllers.apps.flash.destroy.error')
8484
render :show

0 commit comments

Comments
 (0)