Sha256: 80d4a6b90e068022addc8ffbad317cb64931a8a6049d95fb10933a2159c7d13b

Contents?: true

Size: 744 Bytes

Versions: 14

Compression:

Stored size: 744 Bytes

Contents

# frozen_string_literal: true

require_relative '../model_helpers'

module Gitlab
  module Styles
    module Rubocop
      module Cop
        # Cop that prevents the use of polymorphic associations
        class PolymorphicAssociations < RuboCop::Cop::Cop
          include ModelHelpers

          MSG = 'Do not use polymorphic associations, use separate tables instead'

          def on_send(node)
            return unless in_model?(node)
            return unless node.children[1] == :belongs_to

            node.children.last.each_node(:pair) do |pair|
              key_name = pair.children[0].children[0]

              add_offense(pair) if key_name == :polymorphic
            end
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
gitlab-styles-7.1.0 lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
gitlab-styles-7.0.0 lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
gitlab-styles-6.6.0 lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
gitlab-styles-6.5.0 lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
gitlab-styles-6.4.0 lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
gitlab-styles-6.3.0 lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
gitlab-styles-6.2.1 lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
gitlab-styles-6.2.0 lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
gitlab-styles-6.1.0 lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
gitlab-styles-6.0.0 lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
gitlab-styles-5.4.0 lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
gitlab-styles-5.3.0 lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
gitlab-styles-5.2.0 lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
gitlab-styles-5.1.0 lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb