Skip to content

Commit

Permalink
Fix Layout/SpaceInsideHashLiteralBraces
Browse files Browse the repository at this point in the history
  • Loading branch information
dks17 committed Mar 25, 2018
1 parent c3df98a commit ba24f73
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 39 deletions.
19 changes: 0 additions & 19 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,25 +222,6 @@ Layout/SpaceInsideBlockBraces:
- 'lib/devise_token_auth/rails/routes.rb'
- 'test/lib/generators/devise_token_auth/install_generator_test.rb'

# Offense count: 25
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
# SupportedStyles: space, no_space, compact
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceInsideHashLiteralBraces:
Exclude:
- 'app/controllers/devise_token_auth/confirmations_controller.rb'
- 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb'
- 'app/controllers/devise_token_auth/passwords_controller.rb'
- 'app/controllers/devise_token_auth/unlocks_controller.rb'
- 'app/models/devise_token_auth/concerns/user.rb'
- 'lib/devise_token_auth/engine.rb'
- 'lib/devise_token_auth/rails/routes.rb'
- 'test/dummy/app/controllers/custom/passwords_controller.rb'
- 'test/dummy/app/controllers/custom/registrations_controller.rb'
- 'test/dummy/app/controllers/custom/sessions_controller.rb'
- 'test/dummy/app/controllers/custom/token_validations_controller.rb'
- 'test/lib/devise_token_auth/url_test.rb'

# Offense count: 5
# Cop supports --auto-correct.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def show

yield @resource if block_given?

redirect_header_options = {account_confirmation_success: true}
redirect_header_options = { account_confirmation_success: true }
redirect_headers = build_redirect_headers(token,
client_id,
redirect_header_options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def omniauth_success

def omniauth_failure
@error = params[:message]
render_data_or_redirect('authFailure', {error: @error})
render_data_or_redirect('authFailure', { error: @error })
end

protected
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/devise_token_auth/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def edit

yield @resource if block_given?

redirect_header_options = {reset_password: true}
redirect_header_options = { reset_password: true }
redirect_headers = build_redirect_headers(token,
client_id,
redirect_header_options)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/devise_token_auth/unlocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def show
@resource.save!
yield @resource if block_given?

redirect_header_options = {unlock: true}
redirect_header_options = { unlock: true }
redirect_headers = build_redirect_headers(token,
client_id,
redirect_header_options)
Expand Down
2 changes: 1 addition & 1 deletion app/models/devise_token_auth/concerns/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def remove_tokens_after_password_reset

if tokens.present? && tokens.many?
client_id, token_data = tokens.max_by { |cid, v| v[:expiry] || v['expiry'] }
self.tokens = {client_id => token_data}
self.tokens = { client_id => token_data }
end
end

Expand Down
10 changes: 5 additions & 5 deletions lib/devise_token_auth/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class Engine < ::Rails::Engine
self.enable_standard_devise_support = false
self.remove_tokens_after_password_reset = false
self.default_callbacks = true
self.headers_names = {'access-token': 'access-token',
'client': 'client',
'expiry': 'expiry',
'uid': 'uid',
'token-type': 'token-type' }
self.headers_names = { 'access-token': 'access-token',
'client': 'client',
'expiry': 'expiry',
'uid': 'uid',
'token-type': 'token-type' }
self.bypass_sign_in = true

def self.setup(&block)
Expand Down
8 changes: 4 additions & 4 deletions lib/devise_token_auth/rails/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def mount_devise_token_auth_for(resource, opts)
unlocks_ctrl = opts[:controllers][:unlocks] || 'devise_token_auth/unlocks'

# define devise controller mappings
controllers = {sessions: sessions_ctrl,
registrations: registrations_ctrl,
passwords: passwords_ctrl,
confirmations: confirmations_ctrl}
controllers = { sessions: sessions_ctrl,
registrations: registrations_ctrl,
passwords: passwords_ctrl,
confirmations: confirmations_ctrl }

controllers[:unlocks] = unlocks_ctrl if unlocks_ctrl

Expand Down
2 changes: 1 addition & 1 deletion test/dummy/app/controllers/custom/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def update_block_called?
protected

def render_update_success
render json: {custom: 'foo'}
render json: { custom: 'foo' }
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def destroy_block_called?
protected

def render_create_success
render json: {custom: 'foo'}
render json: { custom: 'foo' }
end

end
2 changes: 1 addition & 1 deletion test/dummy/app/controllers/custom/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def destroy_block_called?
protected

def render_create_success
render json: {custom: 'foo'}
render json: { custom: 'foo' }
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def validate_token_block_called?
protected

def render_validate_token_success
render json: {custom: 'foo'}
render json: { custom: 'foo' }
end

end
4 changes: 2 additions & 2 deletions test/lib/devise_token_auth/url_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class DeviseTokenAuth::UrlTest < ActiveSupport::TestCase
describe 'DeviseTokenAuth::Url#generate' do
test 'URI fragment should appear at the end of URL' do
params = {client_id: 123}
params = { client_id: 123 }
url = 'http://example.com#fragment'
assert_equal DeviseTokenAuth::Url.send(:generate, url, params), 'http://example.com?client_id=123#fragment'
end
Expand All @@ -15,7 +15,7 @@ class DeviseTokenAuth::UrlTest < ActiveSupport::TestCase
end

test 'should marge existing query params with new ones' do
params = {client_id: 123}
params = { client_id: 123 }
url = 'http://example.com?a=1'
assert_equal DeviseTokenAuth::Url.send(:generate, url, params), 'http://example.com?a=1&client_id=123'
end
Expand Down

0 comments on commit ba24f73

Please sign in to comment.