Merge remote-tracking branch 'upstream/pull/3482'

This commit is contained in:
Tom Hughes 2022-03-01 10:27:30 +00:00
commit 73426ea383
22 changed files with 16 additions and 33 deletions

View file

@ -183,11 +183,6 @@ Rails/OutputSafety:
- 'lib/rich_text.rb' - 'lib/rich_text.rb'
- 'test/helpers/application_helper_test.rb' - 'test/helpers/application_helper_test.rb'
# Offense count: 23
# Cop supports --auto-correct.
Rails/RedundantPresenceValidationOnBelongsTo:
Enabled: false
# Offense count: 90 # Offense count: 90
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle. # Configuration parameters: EnforcedStyle.

View file

@ -44,8 +44,6 @@ class Changeset < ApplicationRecord
validates :id, :uniqueness => true, :presence => { :on => :update }, validates :id, :uniqueness => true, :presence => { :on => :update },
:numericality => { :on => :update, :only_integer => true } :numericality => { :on => :update, :only_integer => true }
validates :user_id, :presence => true,
:numericality => { :only_integer => true }
validates :num_changes, :presence => true, validates :num_changes, :presence => true,
:numericality => { :only_integer => true, :numericality => { :only_integer => true,
:greater_than_or_equal_to => 0 } :greater_than_or_equal_to => 0 }

View file

@ -25,8 +25,8 @@ class ChangesetComment < ApplicationRecord
validates :id, :uniqueness => true, :presence => { :on => :update }, validates :id, :uniqueness => true, :presence => { :on => :update },
:numericality => { :on => :update, :only_integer => true } :numericality => { :on => :update, :only_integer => true }
validates :changeset, :presence => true, :associated => true validates :changeset, :associated => true
validates :author, :presence => true, :associated => true validates :author, :associated => true
validates :visible, :inclusion => [true, false] validates :visible, :inclusion => [true, false]
validates :body, :characters => true validates :body, :characters => true

View file

@ -20,7 +20,7 @@ class ChangesetTag < ApplicationRecord
belongs_to :changeset belongs_to :changeset
validates :changeset, :presence => true, :associated => true validates :changeset, :associated => true
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
validates :k, :uniqueness => { :scope => :changeset_id } validates :k, :uniqueness => { :scope => :changeset_id }
end end

View file

@ -25,6 +25,4 @@ class IssueComment < ApplicationRecord
belongs_to :user belongs_to :user
validates :body, :presence => true, :characters => true validates :body, :presence => true, :characters => true
validates :user, :presence => true
validates :issue, :presence => true
end end

View file

@ -29,7 +29,7 @@ class Message < ApplicationRecord
belongs_to :recipient, :class_name => "User", :foreign_key => :to_user_id belongs_to :recipient, :class_name => "User", :foreign_key => :to_user_id
validates :title, :presence => true, :utf8 => true, :length => 1..255 validates :title, :presence => true, :utf8 => true, :length => 1..255
validates :body, :sent_on, :sender, :recipient, :presence => true validates :body, :sent_on, :presence => true
validates :title, :body, :characters => true validates :title, :body, :characters => true
def self.from_mail(mail, from, to) def self.from_mail(mail, from, to)

View file

@ -49,8 +49,6 @@ class Node < ApplicationRecord
:numericality => { :on => :update, :only_integer => true } :numericality => { :on => :update, :only_integer => true }
validates :version, :presence => true, validates :version, :presence => true,
:numericality => { :only_integer => true } :numericality => { :only_integer => true }
validates :changeset_id, :presence => true,
:numericality => { :only_integer => true }
validates :latitude, :presence => true, validates :latitude, :presence => true,
:numericality => { :only_integer => true } :numericality => { :only_integer => true }
validates :longitude, :presence => true, validates :longitude, :presence => true,

View file

@ -17,7 +17,7 @@ class NodeTag < ApplicationRecord
belongs_to :node belongs_to :node
validates :node, :presence => true, :associated => true validates :node, :associated => true
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
validates :k, :uniqueness => { :scope => :node_id } validates :k, :uniqueness => { :scope => :node_id }
end end

View file

@ -29,7 +29,7 @@ class NoteComment < ApplicationRecord
validates :id, :uniqueness => true, :presence => { :on => :update }, validates :id, :uniqueness => true, :presence => { :on => :update },
:numericality => { :on => :update, :only_integer => true } :numericality => { :on => :update, :only_integer => true }
validates :note, :presence => true, :associated => true validates :note, :associated => true
validates :visible, :inclusion => [true, false] validates :visible, :inclusion => [true, false]
validates :author, :associated => true validates :author, :associated => true
validates :event, :inclusion => %w[opened closed reopened commented hidden] validates :event, :inclusion => %w[opened closed reopened commented hidden]

View file

@ -35,7 +35,7 @@ class OldNode < ApplicationRecord
# the queries generated by Redactable will use the wrong table name. # the queries generated by Redactable will use the wrong table name.
include Redactable include Redactable
validates :changeset, :presence => true, :associated => true validates :changeset, :associated => true
validates :latitude, :presence => true, validates :latitude, :presence => true,
:numericality => { :only_integer => true } :numericality => { :only_integer => true }
validates :longitude, :presence => true, validates :longitude, :presence => true,

View file

@ -18,7 +18,7 @@ class OldNodeTag < ApplicationRecord
belongs_to :old_node, :foreign_key => [:node_id, :version] belongs_to :old_node, :foreign_key => [:node_id, :version]
validates :old_node, :presence => true, :associated => true validates :old_node, :associated => true
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
validates :k, :uniqueness => { :scope => [:node_id, :version] } validates :k, :uniqueness => { :scope => [:node_id, :version] }
end end

View file

@ -37,7 +37,7 @@ class OldRelation < ApplicationRecord
has_many :old_members, -> { order(:sequence_id) }, :class_name => "OldRelationMember", :foreign_key => [:relation_id, :version] has_many :old_members, -> { order(:sequence_id) }, :class_name => "OldRelationMember", :foreign_key => [:relation_id, :version]
has_many :old_tags, :class_name => "OldRelationTag", :foreign_key => [:relation_id, :version] has_many :old_tags, :class_name => "OldRelationTag", :foreign_key => [:relation_id, :version]
validates :changeset, :presence => true, :associated => true validates :changeset, :associated => true
validates :timestamp, :presence => true validates :timestamp, :presence => true
validates :visible, :inclusion => [true, false] validates :visible, :inclusion => [true, false]

View file

@ -18,7 +18,7 @@ class OldRelationTag < ApplicationRecord
belongs_to :old_relation, :foreign_key => [:relation_id, :version] belongs_to :old_relation, :foreign_key => [:relation_id, :version]
validates :old_relation, :presence => true, :associated => true validates :old_relation, :associated => true
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
validates :k, :uniqueness => { :scope => [:relation_id, :version] } validates :k, :uniqueness => { :scope => [:relation_id, :version] }
end end

View file

@ -37,7 +37,7 @@ class OldWay < ApplicationRecord
has_many :old_nodes, :class_name => "OldWayNode", :foreign_key => [:way_id, :version] has_many :old_nodes, :class_name => "OldWayNode", :foreign_key => [:way_id, :version]
has_many :old_tags, :class_name => "OldWayTag", :foreign_key => [:way_id, :version] has_many :old_tags, :class_name => "OldWayTag", :foreign_key => [:way_id, :version]
validates :changeset, :presence => true, :associated => true validates :changeset, :associated => true
validates :timestamp, :presence => true validates :timestamp, :presence => true
validates :visible, :inclusion => [true, false] validates :visible, :inclusion => [true, false]

View file

@ -18,7 +18,7 @@ class OldWayTag < ApplicationRecord
belongs_to :old_way, :foreign_key => [:way_id, :version] belongs_to :old_way, :foreign_key => [:way_id, :version]
validates :old_way, :presence => true, :associated => true validates :old_way, :associated => true
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
validates :k, :uniqueness => { :scope => [:way_id, :version] } validates :k, :uniqueness => { :scope => [:way_id, :version] }
end end

View file

@ -39,8 +39,6 @@ class Relation < ApplicationRecord
:numericality => { :on => :update, :only_integer => true } :numericality => { :on => :update, :only_integer => true }
validates :version, :presence => true, validates :version, :presence => true,
:numericality => { :only_integer => true } :numericality => { :only_integer => true }
validates :changeset_id, :presence => true,
:numericality => { :only_integer => true }
validates :timestamp, :presence => true validates :timestamp, :presence => true
validates :changeset, :associated => true validates :changeset, :associated => true
validates :visible, :inclusion => [true, false] validates :visible, :inclusion => [true, false]

View file

@ -17,7 +17,7 @@ class RelationTag < ApplicationRecord
belongs_to :relation belongs_to :relation
validates :relation, :presence => true, :associated => true validates :relation, :associated => true
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
validates :k, :uniqueness => { :scope => :relation_id } validates :k, :uniqueness => { :scope => :relation_id }
end end

View file

@ -25,8 +25,6 @@ class Report < ApplicationRecord
belongs_to :issue, :counter_cache => true belongs_to :issue, :counter_cache => true
belongs_to :user belongs_to :user
validates :issue, :presence => true
validates :user, :presence => true
validates :details, :presence => true, :characters => true validates :details, :presence => true, :characters => true
validates :category, :presence => true validates :category, :presence => true

View file

@ -43,7 +43,7 @@ class Trace < ApplicationRecord
has_one_attached :image, :service => Settings.trace_image_storage has_one_attached :image, :service => Settings.trace_image_storage
has_one_attached :icon, :service => Settings.trace_icon_storage has_one_attached :icon, :service => Settings.trace_icon_storage
validates :user, :presence => true, :associated => true validates :user, :associated => true
validates :name, :presence => true, :length => 1..255, :characters => true validates :name, :presence => true, :length => 1..255, :characters => true
validates :description, :presence => { :on => :create }, :length => 1..255, :characters => true validates :description, :presence => { :on => :create }, :length => 1..255, :characters => true
validates :timestamp, :presence => true validates :timestamp, :presence => true

View file

@ -16,6 +16,6 @@ class UserPreference < ApplicationRecord
belongs_to :user belongs_to :user
validates :user, :presence => true, :associated => true validates :user, :associated => true
validates :k, :v, :length => 1..255, :characters => true validates :k, :v, :length => 1..255, :characters => true
end end

View file

@ -41,8 +41,6 @@ class Way < ApplicationRecord
:numericality => { :on => :update, :only_integer => true } :numericality => { :on => :update, :only_integer => true }
validates :version, :presence => true, validates :version, :presence => true,
:numericality => { :only_integer => true } :numericality => { :only_integer => true }
validates :changeset_id, :presence => true,
:numericality => { :only_integer => true }
validates :timestamp, :presence => true validates :timestamp, :presence => true
validates :changeset, :associated => true validates :changeset, :associated => true
validates :visible, :inclusion => [true, false] validates :visible, :inclusion => [true, false]

View file

@ -17,7 +17,7 @@ class WayTag < ApplicationRecord
belongs_to :way belongs_to :way
validates :way, :presence => true, :associated => true validates :way, :associated => true
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
validates :k, :uniqueness => { :scope => :way_id } validates :k, :uniqueness => { :scope => :way_id }
end end