Class: EagerEye::Detectors::SerializerNesting

Inherits:
Base
  • Object
show all
Includes:
Concerns::ClassInspector
Defined in:
lib/eager_eye/detectors/serializer_nesting.rb

Constant Summary collapse

SERIALIZER_PATTERNS =
%w[ActiveModel::Serializer ActiveModelSerializers::Model Blueprinter::Base Alba::Resource].freeze
ATTRIBUTE_METHODS =
%i[attribute field attributes].freeze
OBJECT_REFS =
%i[object record resource].freeze

Constants included from Concerns::ClassInspector

Concerns::ClassInspector::ACTIVE_STORAGE_METHODS, Concerns::ClassInspector::HAS_MANY_ASSOCIATIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

default_severity

Class Method Details

.detector_nameObject



14
15
16
# File 'lib/eager_eye/detectors/serializer_nesting.rb', line 14

def self.detector_name
  :serializer_nesting
end

Instance Method Details

#detect(ast, file_path, association_names = Set.new, method_queries = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/eager_eye/detectors/serializer_nesting.rb', line 18

def detect(ast, file_path, association_names = Set.new, method_queries = {})
  return [] unless ast

  @dynamic_associations = association_names
  @method_queries = method_queries
  issues = []
  traverse_ast(ast) do |node|
    next unless node.type == :class && serializer_class?(node)

    find_nested_associations(node, file_path, issues)
  end
  issues
end