diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c9a834849..654a80644 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -130,17 +130,6 @@ Rails/OutputSafety: - 'app/helpers/users_helper.rb' - 'app/helpers/valuation_helper.rb' -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/Validation: - Exclude: - - 'app/models/comment.rb' - - 'app/models/spending_proposal.rb' - - 'app/models/verification/residence.rb' - - 'app/models/verification/sms.rb' - # Offense count: 9 Style/AccessorMethodName: Exclude: diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index b3b51996c..9d38d06d3 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -25,8 +25,8 @@ class Budget validates :author, presence: true validates :description, presence: true validates :heading_id, presence: true - validates_presence_of :unfeasibility_explanation, if: :unfeasibility_explanation_required? - validates_presence_of :price, if: :price_required? + validates :unfeasibility_explanation, presence: { if: :unfeasibility_explanation_required? } + validates :price, presence: { if: :price_required? } validates :title, length: { in: 4..Budget::Investment.title_max_length } validates :description, length: { maximum: Budget::Investment.description_max_length } diff --git a/app/models/comment.rb b/app/models/comment.rb index ffa02d09c..522b7324b 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -13,7 +13,7 @@ class Comment < ActiveRecord::Base validates :body, presence: true validates :user, presence: true - validates_inclusion_of :commentable_type, in: ["Debate", "Proposal", "Budget::Investment", "Poll::Question", "Legislation::Question", "Legislation::Annotation"] + validates :commentable_type, inclusion: { in: ["Debate", "Proposal", "Budget::Investment", "Poll::Question", "Legislation::Question", "Legislation::Annotation"] } validate :validate_body_length diff --git a/app/models/officing/residence.rb b/app/models/officing/residence.rb index 92333cc80..1714bbf0e 100644 --- a/app/models/officing/residence.rb +++ b/app/models/officing/residence.rb @@ -6,9 +6,9 @@ class Officing::Residence before_validation :call_census_api - validates_presence_of :document_number - validates_presence_of :document_type - validates_presence_of :year_of_birth + validates :document_number, presence: true + validates :document_type, presence: true + validates :year_of_birth, presence: true validate :allowed_age validate :residence_in_madrid diff --git a/app/models/spending_proposal.rb b/app/models/spending_proposal.rb index 223e9adfe..a37446117 100644 --- a/app/models/spending_proposal.rb +++ b/app/models/spending_proposal.rb @@ -15,7 +15,7 @@ class SpendingProposal < ActiveRecord::Base validates :title, presence: true validates :author, presence: true validates :description, presence: true - validates_presence_of :feasible_explanation, if: :feasible_explanation_required? + validates :feasible_explanation, presence: { if: :feasible_explanation_required? } validates :title, length: { in: 4..SpendingProposal.title_max_length } validates :description, length: { maximum: SpendingProposal.description_max_length } diff --git a/app/models/verification/residence.rb b/app/models/verification/residence.rb index bafff129b..e1b2f6363 100644 --- a/app/models/verification/residence.rb +++ b/app/models/verification/residence.rb @@ -7,10 +7,10 @@ class Verification::Residence before_validation :call_census_api - validates_presence_of :document_number - validates_presence_of :document_type - validates_presence_of :date_of_birth - validates_presence_of :postal_code + validates :document_number, presence: true + validates :document_type, presence: true + validates :date_of_birth, presence: true + validates :postal_code, presence: true validates :terms_of_service, acceptance: { allow_nil: false } validates :postal_code, length: { is: 5 } diff --git a/app/models/verification/sms.rb b/app/models/verification/sms.rb index 1a013f1d8..7c1a1bfa6 100644 --- a/app/models/verification/sms.rb +++ b/app/models/verification/sms.rb @@ -3,7 +3,7 @@ class Verification::Sms attr_accessor :user, :phone, :confirmation_code - validates_presence_of :phone + validates :phone, presence: true validates :phone, format: { with: /\A[\d \+]+\z/ } validate :uniqness_phone