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
def verifying_via_email?
return false unless resource.present?
return false if resource.blank?
stored_path = session[stored_location_key_for(resource)] || ""
stored_path[0..5] == "/email"
end

View File

@@ -59,7 +59,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
end
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
def valuation_params

View File

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

View File

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

View File

@@ -1,9 +1,9 @@
module PollsHelper
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)]
}
end
options << all_polls if include_all
options_for_select(options, request.fullpath)
end

View File

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

View File

@@ -116,7 +116,7 @@ class Officing::Residence
end
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
def random_password

View File

@@ -14,7 +14,7 @@ class Poll
before_validation :set_demographic_info, :set_document_info
def set_demographic_info
return unless user.present?
return if user.blank?
self.gender = user.gender
self.age = user.age
@@ -22,7 +22,7 @@ class Poll
end
def set_document_info
return unless user.present?
return if user.blank?
self.document_type = user.document_type
self.document_number = user.document_number
@@ -51,7 +51,7 @@ class Poll
nil
else
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

View File

@@ -9,7 +9,7 @@ class SiteCustomization::Image < ActiveRecord::Base
has_attached_file :image
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
def self.all_images

View File

@@ -154,7 +154,7 @@ class User < ActiveRecord::Base
def has_official_email?
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
def display_official_position_badge?
@@ -289,7 +289,7 @@ class User < ActiveRecord::Base
private
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
def validate_username_length

View File

@@ -81,7 +81,7 @@ class Verification::Residence
end
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

View File

@@ -1,7 +1,7 @@
module Age
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
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

View File

@@ -26,7 +26,7 @@ module DocumentParser
else
letter = nil
end
return document_number, letter
[document_number, letter]
end
# 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
variants = []
variants << document_number unless document_number.blank?
variants << document_number if document_number.present?
while document_number.size < digits
document_number = "0#{document_number}"
variants << document_number
@@ -50,7 +50,7 @@ module DocumentParser
# ['1234a', '1234A', '01234a', '01234A']
def get_letter_variants(number_variants, letter)
variants = []
if letter.present? then
if letter.present?
number_variants.each do |number|
variants << number + letter.downcase << number + letter.upcase
end