From ddd7cb315a5d86b582c2acee8552b18fdcc6c51e Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Sat, 5 May 2018 19:03:14 +0200 Subject: [PATCH] Fixed rubocop complains by restoring the deactivation of Rails/InverseOf. --- app/models/history.rb | 3 +++ app/models/link.rb | 3 +++ app/models/organization.rb | 3 +++ app/models/store.rb | 3 +++ app/models/tag.rb | 3 +++ app/models/ticket.rb | 3 +++ app/models/ticket/article.rb | 3 +++ app/models/ticket/state.rb | 2 ++ 8 files changed, 23 insertions(+) diff --git a/app/models/history.rb b/app/models/history.rb index 0ab4d4e64..15fae7bc8 100644 --- a/app/models/history.rb +++ b/app/models/history.rb @@ -4,9 +4,12 @@ class History < ApplicationModel include History::Assets self.table_name = 'histories' + + # rubocop:disable Rails/InverseOf belongs_to :history_type, class_name: 'History::Type' belongs_to :history_object, class_name: 'History::Object' belongs_to :history_attribute, class_name: 'History::Attribute' + # rubocop:enable Rails/InverseOf # the noop is needed since Layout/EmptyLines detects # the block commend below wrongly as the measurement of diff --git a/app/models/link.rb b/app/models/link.rb index b5d129a2f..0361ce474 100644 --- a/app/models/link.rb +++ b/app/models/link.rb @@ -1,8 +1,11 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Link < ApplicationModel + + # rubocop:disable Rails/InverseOf belongs_to :link_type, class_name: 'Link::Type' belongs_to :link_object, class_name: 'Link::Object' + # rubocop:enable Rails/InverseOf after_destroy :touch_link_references diff --git a/app/models/organization.rb b/app/models/organization.rb index 861b53902..3c2f8c45a 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -12,7 +12,10 @@ class Organization < ApplicationModel include Organization::Assets include Organization::Search include Organization::SearchIndex + + # rubocop:disable Rails/InverseOf has_many :members, class_name: 'User' + # rubocop:enable Rails/InverseOf before_create :domain_cleanup before_update :domain_cleanup diff --git a/app/models/store.rb b/app/models/store.rb index b05be3d89..2b9e1cca5 100644 --- a/app/models/store.rb +++ b/app/models/store.rb @@ -4,8 +4,11 @@ require_dependency 'store/object' require_dependency 'store/file' class Store < ApplicationModel + + # rubocop:disable Rails/InverseOf belongs_to :store_object, class_name: 'Store::Object' belongs_to :store_file, class_name: 'Store::File' + # rubocop:enable Rails/InverseOf validates :filename, presence: true diff --git a/app/models/tag.rb b/app/models/tag.rb index 749ec992b..8410b2aa3 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -1,8 +1,11 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Tag < ApplicationModel + + # rubocop:disable Rails/InverseOf belongs_to :tag_object, class_name: 'Tag::Object' belongs_to :tag_item, class_name: 'Tag::Item' + # rubocop:enable Rails/InverseOf # the noop is needed since Layout/EmptyLines detects # the block commend below wrongly as the measurement of diff --git a/app/models/ticket.rb b/app/models/ticket.rb index d9efdc0b3..f71bc5300 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -57,6 +57,8 @@ class Ticket < ApplicationModel belongs_to :organization has_many :articles, class_name: 'Ticket::Article', after_add: :cache_update, after_remove: :cache_update, dependent: :destroy, inverse_of: :ticket has_many :ticket_time_accounting, class_name: 'Ticket::TimeAccounting', dependent: :destroy, inverse_of: :ticket + + # rubocop:disable Rails/InverseOf belongs_to :state, class_name: 'Ticket::State' belongs_to :priority, class_name: 'Ticket::Priority' belongs_to :owner, class_name: 'User' @@ -65,6 +67,7 @@ class Ticket < ApplicationModel belongs_to :updated_by, class_name: 'User' belongs_to :create_article_type, class_name: 'Ticket::Article::Type' belongs_to :create_article_sender, class_name: 'Ticket::Article::Sender' + # rubocop:enable Rails/InverseOf self.inheritance_column = nil diff --git a/app/models/ticket/article.rb b/app/models/ticket/article.rb index a1eab06dd..a6442bc1d 100644 --- a/app/models/ticket/article.rb +++ b/app/models/ticket/article.rb @@ -11,11 +11,14 @@ class Ticket::Article < ApplicationModel belongs_to :ticket has_one :ticket_time_accounting, class_name: 'Ticket::TimeAccounting', foreign_key: :ticket_article_id, dependent: :destroy, inverse_of: :ticket_article + + # rubocop:disable Rails/InverseOf belongs_to :type, class_name: 'Ticket::Article::Type' belongs_to :sender, class_name: 'Ticket::Article::Sender' belongs_to :created_by, class_name: 'User' belongs_to :updated_by, class_name: 'User' belongs_to :origin_by, class_name: 'User' + # rubocop:enable Rails/InverseOf before_create :check_subject, :check_body, :check_message_id_md5 before_update :check_subject, :check_body, :check_message_id_md5 diff --git a/app/models/ticket/state.rb b/app/models/ticket/state.rb index 7f6f7dc6a..98f1597e1 100644 --- a/app/models/ticket/state.rb +++ b/app/models/ticket/state.rb @@ -2,8 +2,10 @@ class Ticket::State < ApplicationModel include ChecksLatestChangeObserved + # rubocop:disable Rails/InverseOf belongs_to :state_type, class_name: 'Ticket::StateType', inverse_of: :states belongs_to :next_state, class_name: 'Ticket::State' + # rubocop:enable Rails/InverseOf after_create :ensure_defaults after_update :ensure_defaults