Skip to content

Commit

Permalink
Merge branch 'Style/HashSyntax' into add_rubocop CHANGELOG.md Gemfile…
Browse files Browse the repository at this point in the history
… Gemfile.lock Guardfile LICENSE README.md Rakefile app bin config coverage devise_token_auth.gemspec lib tags test Style/HashSyntax: Update hash syntax to ruby 1.9 style in test-dummy rails app. Update hash syntax from hash-rockets to ruby 1.9 style. Move `Style/HashSyntax` from todos to main config.
  • Loading branch information
Evan-M committed Mar 26, 2018
2 parents 751b35c + 0ead803 commit c609d57
Show file tree
Hide file tree
Showing 22 changed files with 104 additions and 98 deletions.
15 changes: 14 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,17 @@ Style/FrozenStringLiteralComment:
# Description from Rubocop Manual:
# https://rubocop.readthedocs.io/en/latest/cops_style/#styleclassandmodulechildren
Style/ClassAndModuleChildren:
Enabled: false
Enabled: false

# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues,
# PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
#
# Description from Rubocop Manual:
# This cop checks hash literal syntax
#
# https://rubocop.readthedocs.io/en/latest/cops_style/#stylehashsyntax
Style/HashSyntax:
Enabled: true
EnforcedStyle: ruby19
7 changes: 0 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -550,13 +550,6 @@ Style/GuardClause:
- 'test/dummy/app/models/user.rb'
- 'test/test_helper.rb'

# Offense count: 127
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
Style/HashSyntax:
Enabled: false

# Offense count: 23
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def render_data(message, data)
@data = data.merge({
message: message
})
render :layout => nil, :template => 'devise_token_auth/omniauth_external_window'
render layout: nil, template: 'devise_token_auth/omniauth_external_window'
end

def render_data_or_redirect(message, data, user_data = {})
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/devise_token_auth/passwords_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module DeviseTokenAuth
class PasswordsController < DeviseTokenAuth::ApplicationController
before_action :set_user_by_token, :only => [:update]
skip_after_action :update_auth_header, :only => [:create, :edit]
before_action :set_user_by_token, only: [:update]
skip_after_action :update_auth_header, only: [:create, :edit]

# this action is responsible for generating password reset tokens and
# sending emails
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/devise_token_auth/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# see http://www.emilsoman.com/blog/2013/05/18/building-a-tested/
module DeviseTokenAuth
class SessionsController < DeviseTokenAuth::ApplicationController
before_action :set_user_by_token, :only => [:destroy]
after_action :reset_session, :only => [:destroy]
before_action :set_user_by_token, only: [:destroy]
after_action :reset_session, only: [:destroy]

def new
render_new_error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module DeviseTokenAuth
class TokenValidationsController < DeviseTokenAuth::ApplicationController
skip_before_action :assert_is_devise_resource!, :only => [:validate_token]
before_action :set_user_by_token, :only => [:validate_token]
skip_before_action :assert_is_devise_resource!, only: [:validate_token]
before_action :set_user_by_token, only: [:validate_token]

def validate_token
# @resource will have been set by set_user_by_token concern
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
@@ -1,6 +1,6 @@
module DeviseTokenAuth
class UnlocksController < DeviseTokenAuth::ApplicationController
skip_after_action :update_auth_header, :only => [:create, :show]
skip_after_action :update_auth_header, only: [:create, :show]

# this action is responsible for generating unlock tokens and
# sending emails
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
18 changes: 9 additions & 9 deletions lib/devise_token_auth/rails/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ 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

# remove any unwanted devise modules
opts[:skip].each{|item| controllers.delete(item)}

devise_for resource.pluralize.underscore.gsub('/', '_').to_sym,
:class_name => resource,
:module => :devise,
:path => "#{opts[:at]}",
:controllers => controllers,
:skip => opts[:skip] + [:omniauth_callbacks]
class_name: resource,
module: :devise,
path: "#{opts[:at]}",
controllers: controllers,
skip: opts[:skip] + [:omniauth_callbacks]

unnest_namespace do
# get full url path as if it were namespaced
Expand Down
6 changes: 3 additions & 3 deletions test/dummy/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use Rack::Cors do
allow do
origins '*'
resource '*',
:headers => :any,
:expose => ['access-token', 'expiry', 'token-type', 'uid', 'client'],
:methods => [:get, :post, :options, :delete, :put]
headers: :any,
expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'],
methods: [:get, :post, :options, :delete, :put]
end
end
4 changes: 2 additions & 2 deletions test/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
config.action_mailer.raise_delivery_errors = true

# use mailcatcher for development
config.action_mailer.default_url_options = { :host => 'devise-token-auth.dev' }
config.action_mailer.default_url_options = { host: 'devise-token-auth.dev' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :address => 'localhost', :port => 1025 }
config.action_mailer.smtp_settings = { address: 'localhost', port: 1025 }

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
config.action_mailer.default_url_options = { :host => 'localhost' }
config.action_mailer.default_url_options = { host: 'localhost' }

# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
Expand Down
4 changes: 2 additions & 2 deletions test/dummy/config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET']
provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET']
provider :developer,
:fields => [:first_name, :last_name],
:uid_field => :last_name
fields: [:first_name, :last_name],
uid_field: :last_name
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ def change
create_table(:users) do |t|
## Database authenticatable
t.string :email
t.string :encrypted_password, :null => false, :default => ''
t.string :encrypted_password, null: false, default: ''

## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
t.string :reset_password_redirect_url
t.boolean :allow_password_change, :default => false
t.boolean :allow_password_change, default: false

## Rememberable
t.datetime :remember_created_at

## Trackable
t.integer :sign_in_count, :default => 0, :null => false
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
Expand All @@ -41,7 +41,7 @@ def change

## unique oauth id
t.string :provider
t.string :uid, :null => false, :default => ''
t.string :uid, null: false, default: ''

## Tokens
if json_supported_database?
Expand All @@ -54,10 +54,10 @@ def change
end

add_index :users, :email
add_index :users, [:uid, :provider], :unique => true
add_index :users, :reset_password_token, :unique => true
add_index :users, :confirmation_token, :unique => true
add_index :users, :nickname, :unique => true
add_index :users, [:uid, :provider], unique: true
add_index :users, :reset_password_token, unique: true
add_index :users, :confirmation_token, unique: true
add_index :users, :nickname, unique: true
# add_index :users, :unlock_token, :unique => true
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ def change
create_table(:mangs) do |t|
## Database authenticatable
t.string :email
t.string :encrypted_password, :null => false, :default => ''
t.string :encrypted_password, null: false, default: ''

## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
t.string :reset_password_redirect_url
t.boolean :allow_password_change, :default => false
t.boolean :allow_password_change, default: false

## Rememberable
t.datetime :remember_created_at

## Trackable
t.integer :sign_in_count, :default => 0, :null => false
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
Expand All @@ -41,7 +41,7 @@ def change

## unique oauth id
t.string :provider
t.string :uid, :null => false, :default => ''
t.string :uid, null: false, default: ''

## Tokens
if json_supported_database?
Expand All @@ -54,9 +54,9 @@ def change
end

add_index :mangs, :email
add_index :mangs, [:uid, :provider], :unique => true
add_index :mangs, :reset_password_token, :unique => true
add_index :mangs, :confirmation_token, :unique => true
add_index :mangs, [:uid, :provider], unique: true
add_index :mangs, :reset_password_token, unique: true
add_index :mangs, :confirmation_token, unique: true
# add_index :mangs, :unlock_token, :unique => true
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ def change
create_table(:evil_users) do |t|
## Database authenticatable
t.string :email
t.string :encrypted_password, :null => false, :default => ''
t.string :encrypted_password, null: false, default: ''

## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
t.boolean :allow_password_change, :default => false
t.boolean :allow_password_change, default: false

## Rememberable
t.datetime :remember_created_at

## Trackable
t.integer :sign_in_count, :default => 0, :null => false
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
Expand All @@ -40,7 +40,7 @@ def change

## unique oauth id
t.string :provider
t.string :uid, :null => false, :default => ''
t.string :uid, null: false, default: ''

## Tokens
if json_supported_database?
Expand All @@ -56,9 +56,9 @@ def change
end

add_index :evil_users, :email
add_index :evil_users, [:uid, :provider], :unique => true
add_index :evil_users, :reset_password_token, :unique => true
add_index :evil_users, :confirmation_token, :unique => true
add_index :evil_users, [:uid, :provider], unique: true
add_index :evil_users, :reset_password_token, unique: true
add_index :evil_users, :confirmation_token, unique: true
# add_index :evil_users, :unlock_token, :unique => true
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ class DeviseTokenAuthCreateOnlyEmailUsers < ActiveRecord::Migration[4.2]
def change
create_table(:only_email_users) do |t|
## Required
t.string :provider, :null => false
t.string :uid, :null => false, :default => ''
t.string :provider, null: false
t.string :uid, null: false, default: ''

## Database authenticatable
t.string :encrypted_password, :null => false, :default => ''
t.string :encrypted_password, null: false, default: ''

## Recoverable
#t.string :reset_password_token
Expand Down Expand Up @@ -52,7 +52,7 @@ def change
end

add_index :only_email_users, :email
add_index :only_email_users, [:uid, :provider], :unique => true
add_index :only_email_users, [:uid, :provider], unique: true
#add_index :only_email_users, :reset_password_token, :unique => true
# add_index :only_email_users, :confirmation_token, :unique => true
# add_index :only_email_users, :unlock_token, :unique => true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ class DeviseTokenAuthCreateUnregisterableUsers < ActiveRecord::Migration[4.2]
def change
create_table(:unregisterable_users) do |t|
## Required
t.string :provider, :null => false
t.string :uid, :null => false, :default => ''
t.string :provider, null: false
t.string :uid, null: false, default: ''

## Database authenticatable
t.string :encrypted_password, :null => false, :default => ''
t.string :encrypted_password, null: false, default: ''

## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
t.boolean :allow_password_change, :default => false
t.boolean :allow_password_change, default: false

## Rememberable
t.datetime :remember_created_at

## Trackable
t.integer :sign_in_count, :default => 0, :null => false
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
Expand Down Expand Up @@ -53,8 +53,8 @@ def change
end

add_index :unregisterable_users, :email
add_index :unregisterable_users, [:uid, :provider], :unique => true
add_index :unregisterable_users, :reset_password_token, :unique => true
add_index :unregisterable_users, [:uid, :provider], unique: true
add_index :unregisterable_users, :reset_password_token, unique: true
# add_index :unregisterable_users, :confirmation_token, :unique => true
# add_index :unregisterable_users, :unlock_token, :unique => true
end
Expand Down
Loading

0 comments on commit c609d57

Please sign in to comment.