From 05bfbda5f56e1077c79b100ff6ee712ad1e98928 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 4 Jun 2018 16:18:49 +1200 Subject: [PATCH] Rubocop style fix ups --- app/controllers/application_controller.rb | 4 ++-- app/controllers/passwords_controller.rb | 2 +- app/controllers/registrations_controller.rb | 2 +- app/validators/approved_validator.rb | 2 +- bin/setup | 1 - bin/yarn | 2 +- config/unicorn.rb | 4 ++-- 7 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index eb775ee4a..9ef6783e5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -23,11 +23,11 @@ class ApplicationController < ActionController::Base render file: 'app/views/errors/404', status: :not_found, layout: false end - def after_sign_in_path_for(resource) + def after_sign_in_path_for(_resource) stored_location_for(:member) || root_path end - def after_sign_out_path_for(resource_or_scope) + def after_sign_out_path_for(_resource_or_scope) request.referer end diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb index c14a02b40..fb6852ea9 100644 --- a/app/controllers/passwords_controller.rb +++ b/app/controllers/passwords_controller.rb @@ -1,7 +1,7 @@ class PasswordsController < Devise::PasswordsController protected - def after_resetting_password_path_for(resource) + def after_resetting_password_path_for(_resource) root_path end end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 72e92b9fd..b9ed73dfe 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -46,7 +46,7 @@ class RegistrationsController < Devise::RegistrationsController end # check if we need the current password to update fields -def needs_password?(member, params) +def needs_password?(_member, params) params[:member][:password].present? || params[:member][:password_confirmation].present? end diff --git a/app/validators/approved_validator.rb b/app/validators/approved_validator.rb index e845b9529..8a77fa2da 100644 --- a/app/validators/approved_validator.rb +++ b/app/validators/approved_validator.rb @@ -1,5 +1,5 @@ class ApprovedValidator < ActiveModel::EachValidator - def validate_each(record, attribute, value) + def validate_each(record, attribute, _value) record.errors[attribute] << (options[:message] || 'must be approved') unless record.crop.try(:approved?) end end diff --git a/bin/setup b/bin/setup index d5163f8c1..b2293a35a 100755 --- a/bin/setup +++ b/bin/setup @@ -21,7 +21,6 @@ chdir APP_ROOT do # Install JavaScript dependencies if using Yarn # system('bin/yarn') - # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') # cp 'config/database.yml.sample', 'config/database.yml' diff --git a/bin/yarn b/bin/yarn index ad111a882..4d2c50e52 100755 --- a/bin/yarn +++ b/bin/yarn @@ -2,7 +2,7 @@ VENDOR_PATH = File.expand_path('..', __dir__) Dir.chdir(VENDOR_PATH) do begin - exec "yarnpkg #{ARGV.join(" ")}" + exec "yarnpkg #{ARGV.join(' ')}" rescue Errno::ENOENT warn "Yarn executable was not detected in the system." warn "Download Yarn at https://yarnpkg.com/en/docs/install" diff --git a/config/unicorn.rb b/config/unicorn.rb index 6a63af23f..fa76bae3a 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -9,7 +9,7 @@ before_fork do |_server, _worker| Process.kill 'QUIT', Process.pid end - defined?(ActiveRecord::Base) and + defined?(ActiveRecord::Base) && ActiveRecord::Base.connection.disconnect! end @@ -18,6 +18,6 @@ after_fork do |_server, _worker| puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT' end - defined?(ActiveRecord::Base) and + defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection end