Merge pull request #1746 from consul/rubocop/rails_fixes
Rubocop fixes 🤖: Rails edition 💎🛤
This commit is contained in:
@@ -365,35 +365,6 @@ Performance/RedundantMatch:
|
||||
- 'app/controllers/valuation/spending_proposals_controller.rb'
|
||||
- 'app/helpers/embed_videos_helper.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent.
|
||||
Rails/Blank:
|
||||
Exclude:
|
||||
- 'app/controllers/management/base_controller.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Rails/Delegate:
|
||||
Exclude:
|
||||
- 'app/models/poll/question.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: Whitelist.
|
||||
# Whitelist: find_by_sql
|
||||
Rails/DynamicFindBy:
|
||||
Exclude:
|
||||
- 'app/controllers/users/confirmations_controller.rb'
|
||||
- 'app/controllers/users/registrations_controller.rb'
|
||||
- 'spec/features/management/users_spec.rb'
|
||||
|
||||
# Offense count: 2
|
||||
Rails/FilePath:
|
||||
Exclude:
|
||||
- 'app/controllers/sandbox_controller.rb'
|
||||
- 'spec/spec_helper.rb'
|
||||
|
||||
# Offense count: 16
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: Include.
|
||||
@@ -449,13 +420,6 @@ Rails/OutputSafety:
|
||||
- 'app/helpers/users_helper.rb'
|
||||
- 'app/helpers/valuation_helper.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank.
|
||||
Rails/Present:
|
||||
Exclude:
|
||||
- 'app/controllers/management/document_verifications_controller.rb'
|
||||
|
||||
# Offense count: 70
|
||||
# Configuration parameters: Blacklist.
|
||||
# Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters
|
||||
|
||||
@@ -9,7 +9,7 @@ class Management::BaseController < ActionController::Base
|
||||
private
|
||||
|
||||
def verify_manager
|
||||
raise ActionController::RoutingError.new('Not Found') unless current_manager.present?
|
||||
raise ActionController::RoutingError.new('Not Found') if current_manager.blank?
|
||||
end
|
||||
|
||||
def current_manager
|
||||
|
||||
@@ -6,7 +6,7 @@ class SandboxController < ApplicationController
|
||||
helper_method(:namespace)
|
||||
|
||||
def index
|
||||
@templates = Dir.glob(Rails.root.join('app/views/sandbox/*.html.erb').to_s).map do |filename|
|
||||
@templates = Dir.glob(Rails.root.join('app', 'views', 'sandbox', '*.html.erb').to_s).map do |filename|
|
||||
filename = File.basename(filename, File.extname(filename))
|
||||
filename unless filename.starts_with?('_') || filename == 'index.html'
|
||||
end.compact
|
||||
|
||||
@@ -3,7 +3,7 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
|
||||
# new action, PATCH does not exist in the default Devise::ConfirmationsController
|
||||
# PATCH /resource/confirmation
|
||||
def update
|
||||
self.resource = resource_class.find_by_confirmation_token(params[:confirmation_token])
|
||||
self.resource = resource_class.find_by(confirmation_token: params[:confirmation_token])
|
||||
|
||||
if resource.encrypted_password.blank?
|
||||
resource.assign_attributes(resource_params)
|
||||
@@ -27,7 +27,7 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
|
||||
def show
|
||||
# In the default implementation, this already confirms the resource:
|
||||
# self.resource = self.resource = resource_class.confirm_by_token(params[:confirmation_token])
|
||||
self.resource = resource_class.find_by_confirmation_token(params[:confirmation_token])
|
||||
self.resource = resource_class.find_by(confirmation_token: params[:confirmation_token])
|
||||
|
||||
yield resource if block_given?
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
||||
end
|
||||
|
||||
def check_username
|
||||
if User.find_by_username params[:username]
|
||||
if User.find_by username: params[:username]
|
||||
render json: {available: false, message: t("devise_views.users.registrations.new.username_is_not_available")}
|
||||
else
|
||||
render json: {available: true, message: t("devise_views.users.registrations.new.username_is_available")}
|
||||
|
||||
@@ -58,9 +58,7 @@ class Poll::Question < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def answerable_by?(user)
|
||||
poll.answerable_by?(user)
|
||||
end
|
||||
delegate :answerable_by?, to: :poll
|
||||
|
||||
def self.answerable_by(user)
|
||||
return none if user.nil? || user.unverified?
|
||||
|
||||
@@ -24,7 +24,7 @@ feature 'Users' do
|
||||
expect(page).to have_content "We have sent an email"
|
||||
expect(page).to_not have_content "Autogenerated password is"
|
||||
|
||||
user = User.find_by_email('pepe@gmail.com')
|
||||
user = User.find_by(email: 'pepe@gmail.com')
|
||||
|
||||
expect(user).to be_level_three_verified
|
||||
expect(user).to be_residence_verified
|
||||
@@ -64,7 +64,7 @@ feature 'Users' do
|
||||
expect(page).to_not have_content "We have sent an email"
|
||||
expect(page).to have_content "Autogenerated password is"
|
||||
|
||||
user = User.find_by_username('Kelly Sue')
|
||||
user = User.find_by(username: 'Kelly Sue')
|
||||
|
||||
expect(user).to be_level_three_verified
|
||||
expect(user).to be_residence_verified
|
||||
|
||||
@@ -40,7 +40,7 @@ RSpec.configure do |config|
|
||||
config.before(:each) do |example|
|
||||
DatabaseCleaner.strategy = :transaction
|
||||
I18n.locale = :en
|
||||
load "#{Rails.root}/db/seeds.rb"
|
||||
load Rails.root.join('db', 'seeds.rb').to_s
|
||||
end
|
||||
|
||||
config.before(:each, type: :feature) do
|
||||
|
||||
Reference in New Issue
Block a user