Rails/HttpPositionalArguments:
Enabled: false
-Rails/InverseOf:
- Enabled: false
-
Rails/ReflectionClassName:
Enabled: false
# This configuration was generated by
# `rubocop --auto-gen-config`
-# on 2021-12-28 19:44:27 UTC using RuboCop version 1.24.0.
+# on 2022-02-23 19:11:04 UTC using RuboCop version 1.25.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
- rubocop-rails
- rubocop-rake
-# Offense count: 544
+# Offense count: 550
# Cop supports --auto-correct.
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
- 'app/controllers/geocoder_controller.rb'
- 'app/helpers/browse_tags_helper.rb'
-# Offense count: 663
+# Offense count: 665
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 189
-# Offense count: 72
+# Offense count: 73
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# IgnoredMethods: refine
Metrics/BlockLength:
Metrics/ClassLength:
Max: 313
-# Offense count: 57
+# Offense count: 58
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 25
-# Offense count: 739
+# Offense count: 742
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 179
Metrics/PerceivedComplexity:
Max: 26
-# Offense count: 549
+# Offense count: 550
Minitest/MultipleAssertions:
Max: 52
Exclude:
- 'app/helpers/title_helper.rb'
-# Offense count: 1
+# Offense count: 16
+# Configuration parameters: IgnoreScopes, Include.
+# Include: app/models/**/*.rb
+Rails/InverseOf:
+ Exclude:
+ - 'app/models/changeset.rb'
+ - 'app/models/diary_entry.rb'
+ - 'app/models/friendship.rb'
+ - 'app/models/issue.rb'
+ - 'app/models/message.rb'
+ - 'app/models/note.rb'
+ - 'app/models/user.rb'
+
+# Offense count: 2
# Configuration parameters: Include.
# Include: app/controllers/**/*.rb
Rails/LexicallyScopedActionFilter:
- 'lib/tasks/subscribe_diary_authors.rake'
- 'lib/tasks/subscribe_old_changesets.rake'
-# Offense count: 609
+# Offense count: 617
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
class DiaryEntry < ApplicationRecord
belongs_to :user, :counter_cache => true
- belongs_to :language, :foreign_key => "language_code"
+ belongs_to :language, :foreign_key => "language_code", :inverse_of => :diary_entries
- has_many :comments, -> { order(:id).preload(:user) }, :class_name => "DiaryComment"
+ has_many :comments, -> { order(:id).preload(:user) }, :class_name => "DiaryComment", :inverse_of => :diary_entry
has_many :visible_comments, -> { joins(:user).where(:visible => true, :users => { :status => %w[active confirmed] }).order(:id) }, :class_name => "DiaryComment"
has_many :subscriptions, :class_name => "DiaryEntrySubscription"
has_many :subscribers, :through => :subscriptions, :source => :user
class Language < ApplicationRecord
self.primary_key = "code"
- has_many :diary_entries, :foreign_key => "language"
+ has_many :diary_entries, :foreign_key => "language", :inverse_of => :language
def self.load(file)
Language.transaction do
belongs_to :changeset
- has_many :old_nodes, -> { order(:version) }
+ has_many :old_nodes, -> { order(:version) }, :inverse_of => :current_node
has_many :way_nodes
has_many :ways, :through => :way_nodes
include GeoRecord
has_many :comments, -> { left_joins(:author).where(:visible => true, :users => { :status => [nil, "active", "confirmed"] }).order(:created_at) }, :class_name => "NoteComment", :foreign_key => :note_id
- has_many :all_comments, -> { left_joins(:author).order(:created_at) }, :class_name => "NoteComment", :foreign_key => :note_id
+ has_many :all_comments, -> { left_joins(:author).order(:created_at) }, :class_name => "NoteComment", :foreign_key => :note_id, :inverse_of => :note
validates :id, :uniqueness => true, :presence => { :on => :update },
:numericality => { :on => :update, :only_integer => true }
belongs_to :changeset
belongs_to :redaction, :optional => true
- belongs_to :current_node, :class_name => "Node", :foreign_key => "node_id"
+ belongs_to :current_node, :class_name => "Node", :foreign_key => "node_id", :inverse_of => :old_nodes
- has_many :old_tags, :class_name => "OldNodeTag", :foreign_key => [:node_id, :version]
+ has_many :old_tags, :class_name => "OldNodeTag", :foreign_key => [:node_id, :version], :inverse_of => :old_node
def validate_position
errors.add(:base, "Node is not in the world") unless in_world?
self.table_name = "node_tags"
self.primary_keys = "node_id", "version", "k"
- belongs_to :old_node, :foreign_key => [:node_id, :version]
+ belongs_to :old_node, :foreign_key => [:node_id, :version], :inverse_of => :old_tags
validates :old_node, :associated => true
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
belongs_to :changeset
belongs_to :redaction, :optional => true
- belongs_to :current_relation, :class_name => "Relation", :foreign_key => "relation_id"
+ belongs_to :current_relation, :class_name => "Relation", :foreign_key => "relation_id", :inverse_of => :old_relations
- 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_members, -> { order(:sequence_id) }, :class_name => "OldRelationMember", :foreign_key => [:relation_id, :version], :inverse_of => :old_relation
+ has_many :old_tags, :class_name => "OldRelationTag", :foreign_key => [:relation_id, :version], :inverse_of => :old_relation
validates :changeset, :associated => true
validates :timestamp, :presence => true
self.table_name = "relation_members"
self.primary_keys = "relation_id", "version", "sequence_id"
- belongs_to :old_relation, :foreign_key => [:relation_id, :version]
+ belongs_to :old_relation, :foreign_key => [:relation_id, :version], :inverse_of => :old_members
# A bit messy, referring to the current tables, should do for the data browser for now
belongs_to :member, :polymorphic => true
end
self.table_name = "relation_tags"
self.primary_keys = "relation_id", "version", "k"
- belongs_to :old_relation, :foreign_key => [:relation_id, :version]
+ belongs_to :old_relation, :foreign_key => [:relation_id, :version], :inverse_of => :old_tags
validates :old_relation, :associated => true
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
belongs_to :changeset
belongs_to :redaction, :optional => true
- belongs_to :current_way, :class_name => "Way", :foreign_key => "way_id"
+ belongs_to :current_way, :class_name => "Way", :foreign_key => "way_id", :inverse_of => :old_ways
- 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_nodes, :class_name => "OldWayNode", :foreign_key => [:way_id, :version], :inverse_of => :old_way
+ has_many :old_tags, :class_name => "OldWayTag", :foreign_key => [:way_id, :version], :inverse_of => :old_way
validates :changeset, :associated => true
validates :timestamp, :presence => true
self.table_name = "way_nodes"
self.primary_keys = "way_id", "version", "sequence_id"
- belongs_to :old_way, :foreign_key => [:way_id, :version]
+ belongs_to :old_way, :foreign_key => [:way_id, :version], :inverse_of => :old_nodes
# A bit messy, referring to current nodes and ways, should do for the data browser for now
belongs_to :node
belongs_to :way
self.table_name = "way_tags"
self.primary_keys = "way_id", "version", "k"
- belongs_to :old_way, :foreign_key => [:way_id, :version]
+ belongs_to :old_way, :foreign_key => [:way_id, :version], :inverse_of => :old_tags
validates :old_way, :associated => true
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
belongs_to :changeset
- has_many :old_relations, -> { order(:version) }
+ has_many :old_relations, -> { order(:version) }, :inverse_of => :current_relation
- has_many :relation_members, -> { order(:sequence_id) }
+ has_many :relation_members, -> { order(:sequence_id) }, :inverse_of => :relation
has_many :relation_tags
has_many :containing_relation_members, :class_name => "RelationMember", :as => :member
validates :trace, :associated => true
validates :timestamp, :presence => true
- belongs_to :trace, :foreign_key => "gpx_id"
+ belongs_to :trace, :foreign_key => "gpx_id", :inverse_of => :points
end
class Tracetag < ApplicationRecord
self.table_name = "gpx_file_tags"
- belongs_to :trace, :foreign_key => "gpx_id"
+ belongs_to :trace, :foreign_key => "gpx_id", :inverse_of => :tags
validates :trace, :associated => true
validates :tag, :length => 1..255, :characters => { :url_safe => true }
include AASM
has_many :traces, -> { where(:visible => true) }
- has_many :diary_entries, -> { order(:created_at => :desc) }
- has_many :diary_comments, -> { order(:created_at => :desc) }
+ has_many :diary_entries, -> { order(:created_at => :desc) }, :inverse_of => :user
+ has_many :diary_comments, -> { order(:created_at => :desc) }, :inverse_of => :user
has_many :diary_entry_subscriptions, :class_name => "DiaryEntrySubscription"
has_many :diary_subscriptions, :through => :diary_entry_subscriptions, :source => :diary_entry
has_many :messages, -> { where(:to_user_visible => true).order(:sent_on => :desc).preload(:sender, :recipient) }, :foreign_key => :to_user_id
has_many :friends, :through => :friendships, :source => :befriendee
has_many :tokens, :class_name => "UserToken", :dependent => :destroy
has_many :preferences, :class_name => "UserPreference"
- has_many :changesets, -> { order(:created_at => :desc) }
- has_many :changeset_comments, :foreign_key => :author_id
+ has_many :changesets, -> { order(:created_at => :desc) }, :inverse_of => :user
+ has_many :changeset_comments, :foreign_key => :author_id, :inverse_of => :author
has_and_belongs_to_many :changeset_subscriptions, :class_name => "Changeset", :join_table => "changesets_subscribers", :foreign_key => "subscriber_id"
- has_many :note_comments, :foreign_key => :author_id
+ has_many :note_comments, :foreign_key => :author_id, :inverse_of => :author
has_many :notes, :through => :note_comments
has_many :client_applications
- has_many :oauth_tokens, -> { order(:authorized_at => :desc).preload(:client_application) }, :class_name => "OauthToken"
+ has_many :oauth_tokens, -> { order(:authorized_at => :desc).preload(:client_application) }, :class_name => "OauthToken", :inverse_of => :user
has_many :oauth2_applications, :class_name => Doorkeeper.config.application_model.name, :as => :owner
has_many :access_grants, :class_name => Doorkeeper.config.access_grant_model.name, :foreign_key => :resource_owner_id
has_many :access_tokens, :class_name => Doorkeeper.config.access_token_model.name, :foreign_key => :resource_owner_id
has_many :blocks, :class_name => "UserBlock"
- has_many :blocks_created, :class_name => "UserBlock", :foreign_key => :creator_id
- has_many :blocks_revoked, :class_name => "UserBlock", :foreign_key => :revoker_id
+ has_many :blocks_created, :class_name => "UserBlock", :foreign_key => :creator_id, :inverse_of => :creator
+ has_many :blocks_revoked, :class_name => "UserBlock", :foreign_key => :revoker_id, :inverse_of => :revoker
has_many :roles, :class_name => "UserRole"
- has_many :issues, :class_name => "Issue", :foreign_key => :reported_user_id
+ has_many :issues, :class_name => "Issue", :foreign_key => :reported_user_id, :inverse_of => :reported_user
has_many :issue_comments
has_many :reports
belongs_to :changeset
- has_many :old_ways, -> { order(:version) }
+ has_many :old_ways, -> { order(:version) }, :inverse_of => :current_way
- has_many :way_nodes, -> { order(:sequence_id) }
+ has_many :way_nodes, -> { order(:sequence_id) }, :inverse_of => :way
has_many :nodes, :through => :way_nodes
has_many :way_tags