Fix all Rails/Validation rubocop issues and remove files from rubocop_todo list

This commit is contained in:
Bertocq
2017-06-21 20:49:44 +02:00
parent d759aca522
commit 8d84ed712a
7 changed files with 12 additions and 23 deletions

View File

@@ -130,17 +130,6 @@ Rails/OutputSafety:
- 'app/helpers/users_helper.rb' - 'app/helpers/users_helper.rb'
- 'app/helpers/valuation_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 # Offense count: 9
Style/AccessorMethodName: Style/AccessorMethodName:
Exclude: Exclude:

View File

@@ -25,8 +25,8 @@ class Budget
validates :author, presence: true validates :author, presence: true
validates :description, presence: true validates :description, presence: true
validates :heading_id, presence: true validates :heading_id, presence: true
validates_presence_of :unfeasibility_explanation, if: :unfeasibility_explanation_required? validates :unfeasibility_explanation, presence: { if: :unfeasibility_explanation_required? }
validates_presence_of :price, if: :price_required? validates :price, presence: { if: :price_required? }
validates :title, length: { in: 4..Budget::Investment.title_max_length } validates :title, length: { in: 4..Budget::Investment.title_max_length }
validates :description, length: { maximum: Budget::Investment.description_max_length } validates :description, length: { maximum: Budget::Investment.description_max_length }

View File

@@ -13,7 +13,7 @@ class Comment < ActiveRecord::Base
validates :body, presence: true validates :body, presence: true
validates :user, 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 validate :validate_body_length

View File

@@ -6,9 +6,9 @@ class Officing::Residence
before_validation :call_census_api before_validation :call_census_api
validates_presence_of :document_number validates :document_number, presence: true
validates_presence_of :document_type validates :document_type, presence: true
validates_presence_of :year_of_birth validates :year_of_birth, presence: true
validate :allowed_age validate :allowed_age
validate :residence_in_madrid validate :residence_in_madrid

View File

@@ -15,7 +15,7 @@ class SpendingProposal < ActiveRecord::Base
validates :title, presence: true validates :title, presence: true
validates :author, presence: true validates :author, presence: true
validates :description, 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 :title, length: { in: 4..SpendingProposal.title_max_length }
validates :description, length: { maximum: SpendingProposal.description_max_length } validates :description, length: { maximum: SpendingProposal.description_max_length }

View File

@@ -7,10 +7,10 @@ class Verification::Residence
before_validation :call_census_api before_validation :call_census_api
validates_presence_of :document_number validates :document_number, presence: true
validates_presence_of :document_type validates :document_type, presence: true
validates_presence_of :date_of_birth validates :date_of_birth, presence: true
validates_presence_of :postal_code validates :postal_code, presence: true
validates :terms_of_service, acceptance: { allow_nil: false } validates :terms_of_service, acceptance: { allow_nil: false }
validates :postal_code, length: { is: 5 } validates :postal_code, length: { is: 5 }

View File

@@ -3,7 +3,7 @@ class Verification::Sms
attr_accessor :user, :phone, :confirmation_code attr_accessor :user, :phone, :confirmation_code
validates_presence_of :phone validates :phone, presence: true
validates :phone, format: { with: /\A[\d \+]+\z/ } validates :phone, format: { with: /\A[\d \+]+\z/ }
validate :uniqness_phone validate :uniqness_phone