Rubocop autocorrections (indentations, revers unless to if, extra spaces)

This commit is contained in:
Bertocq
2017-06-07 01:11:36 +02:00
parent c45c374256
commit 02524b164a
21 changed files with 65 additions and 65 deletions

View File

@@ -15,7 +15,7 @@ class Users::SessionsController < Devise::SessionsController
end end
def verifying_via_email? def verifying_via_email?
return false unless resource.present? return false if resource.blank?
stored_path = session[stored_location_key_for(resource)] || "" stored_path = session[stored_location_key_for(resource)] || ""
stored_path[0..5] == "/email" stored_path[0..5] == "/email"
end end

View File

@@ -59,7 +59,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
end end
def params_for_current_valuator def params_for_current_valuator
Budget::Investment.filter_params(params).merge({valuator_id: current_user.valuator.id, budget_id: @budget.id}) Budget::Investment.filter_params(params).merge(valuator_id: current_user.valuator.id, budget_id: @budget.id)
end end
def valuation_params def valuation_params

View File

@@ -31,7 +31,7 @@ module BudgetsHelper
end end
def css_for_ballot_heading(heading) def css_for_ballot_heading(heading)
return '' unless current_ballot.present? return '' if current_ballot.blank?
current_ballot.has_lines_in_heading?(heading) ? 'active' : '' current_ballot.has_lines_in_heading?(heading) ? 'active' : ''
end end

View File

@@ -11,7 +11,7 @@ module OfficingHelper
def booths_for_officer_select_options(officer_assignments) def booths_for_officer_select_options(officer_assignments)
options = [] options = []
officer_assignments.each do |oa| officer_assignments.each do |oa|
options << ["#{oa.booth_assignment.booth.name}", oa.id] options << [oa.booth_assignment.booth.name.to_s, oa.id]
end end
options.sort! {|x, y| x[0]<=>y[0]} options.sort! {|x, y| x[0]<=>y[0]}
options_for_select(options, params[:oa]) options_for_select(options, params[:oa])

View File

@@ -1,9 +1,9 @@
module PollsHelper module PollsHelper
def poll_select_options(include_all = nil) def poll_select_options(include_all = nil)
options = @polls.collect {|poll| options = @polls.collect do |poll|
[poll.name, current_path_with_query_params(poll_id: poll.id)] [poll.name, current_path_with_query_params(poll_id: poll.id)]
} end
options << all_polls if include_all options << all_polls if include_all
options_for_select(options, request.fullpath) options_for_select(options, request.fullpath)
end end

View File

@@ -152,7 +152,7 @@ class Budget
return :not_logged_in unless user return :not_logged_in unless user
return :organization if user.organization? return :organization if user.organization?
return :not_verified unless user.can?(:vote, Budget::Investment) return :not_verified unless user.can?(:vote, Budget::Investment)
return nil nil
end end
def permission_problem?(user) def permission_problem?(user)
@@ -177,8 +177,8 @@ class Budget
end end
def heading_voted_by_user?(user) def heading_voted_by_user?(user)
user.votes.for_budget_investments(budget.investments.where(group: group)). user.votes.for_budget_investments(budget.investments.where(group: group))
votables.map(&:heading_id).first .votables.map(&:heading_id).first
end end
def ballotable_by?(user) def ballotable_by?(user)
@@ -236,7 +236,7 @@ class Budget
budget.formatted_amount(price) budget.formatted_amount(price)
end end
def self.apply_filters_and_search(budget, params, current_filter=nil) def self.apply_filters_and_search(_budget, params, current_filter = nil)
investments = all investments = all
investments = investments.send(current_filter) if current_filter.present? investments = investments.send(current_filter) if current_filter.present?
investments = investments.by_heading(params[:heading_id]) if params[:heading_id].present? investments = investments.by_heading(params[:heading_id]) if params[:heading_id].present?

View File

@@ -116,7 +116,7 @@ class Officing::Residence
end end
def clean_document_number def clean_document_number
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase unless self.document_number.blank? self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase if self.document_number.present?
end end
def random_password def random_password

View File

@@ -14,7 +14,7 @@ class Poll
before_validation :set_demographic_info, :set_document_info before_validation :set_demographic_info, :set_document_info
def set_demographic_info def set_demographic_info
return unless user.present? return if user.blank?
self.gender = user.gender self.gender = user.gender
self.age = user.age self.age = user.age
@@ -22,7 +22,7 @@ class Poll
end end
def set_document_info def set_document_info
return unless user.present? return if user.blank?
self.document_type = user.document_type self.document_type = user.document_type
self.document_number = user.document_number self.document_number = user.document_number
@@ -51,7 +51,7 @@ class Poll
nil nil
else else
now = Time.current.to_date now = Time.current.to_date
now.year - dob.year - ((now.month > dob.month || (now.month == dob.month && now.day >= dob.day)) ? 0 : 1) now.year - dob.year - (now.month > dob.month || (now.month == dob.month && now.day >= dob.day) ? 0 : 1)
end end
end end

View File

@@ -9,7 +9,7 @@ class SiteCustomization::Image < ActiveRecord::Base
has_attached_file :image has_attached_file :image
validates :name, presence: true, uniqueness: true, inclusion: { in: VALID_IMAGES.keys } validates :name, presence: true, uniqueness: true, inclusion: { in: VALID_IMAGES.keys }
validates_attachment_content_type :image, :content_type => ["image/png"] validates_attachment_content_type :image, content_type: ["image/png"]
validate :check_image validate :check_image
def self.all_images def self.all_images

View File

@@ -154,7 +154,7 @@ class User < ActiveRecord::Base
def has_official_email? def has_official_email?
domain = Setting['email_domain_for_officials'] domain = Setting['email_domain_for_officials']
!email.blank? && ( (email.end_with? "@#{domain}") || (email.end_with? ".#{domain}") ) email.present? && ( (email.end_with? "@#{domain}") || (email.end_with? ".#{domain}") )
end end
def display_official_position_badge? def display_official_position_badge?
@@ -289,7 +289,7 @@ class User < ActiveRecord::Base
private private
def clean_document_number def clean_document_number
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase unless self.document_number.blank? self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase if self.document_number.present?
end end
def validate_username_length def validate_username_length

View File

@@ -81,7 +81,7 @@ class Verification::Residence
end end
def clean_document_number def clean_document_number
self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase unless self.document_number.blank? self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase if self.document_number.present?
end end
end end

View File

@@ -1,7 +1,7 @@
module Age module Age
def self.in_years(dob, now = Time.current.to_date) def self.in_years(dob, now = Time.current.to_date)
return nil unless dob.present? return nil if dob.blank?
# reference: http://stackoverflow.com/questions/819263/get-persons-age-in-ruby#comment21200772_819263 # reference: http://stackoverflow.com/questions/819263/get-persons-age-in-ruby#comment21200772_819263
now.year - dob.year - ((now.month > dob.month || (now.month == dob.month && now.day >= dob.day)) ? 0 : 1) now.year - dob.year - (now.month > dob.month || (now.month == dob.month && now.day >= dob.day) ? 0 : 1)
end end
end end

View File

@@ -26,7 +26,7 @@ module DocumentParser
else else
letter = nil letter = nil
end end
return document_number, letter [document_number, letter]
end end
# if the number has less digits than it should, pad with zeros to the left and add each variant to the list # if the number has less digits than it should, pad with zeros to the left and add each variant to the list
@@ -37,7 +37,7 @@ module DocumentParser
document_number = document_number.gsub(/^0+/, '') # Removes leading zeros document_number = document_number.gsub(/^0+/, '') # Removes leading zeros
variants = [] variants = []
variants << document_number unless document_number.blank? variants << document_number if document_number.present?
while document_number.size < digits while document_number.size < digits
document_number = "0#{document_number}" document_number = "0#{document_number}"
variants << document_number variants << document_number
@@ -50,7 +50,7 @@ module DocumentParser
# ['1234a', '1234A', '01234a', '01234A'] # ['1234a', '1234A', '01234a', '01234A']
def get_letter_variants(number_variants, letter) def get_letter_variants(number_variants, letter)
variants = [] variants = []
if letter.present? then if letter.present?
number_variants.each do |number| number_variants.each do |number|
variants << number + letter.downcase << number + letter.upcase variants << number + letter.downcase << number + letter.upcase
end end