Class: EagerEye::Analyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/eager_eye/analyzer.rb

Constant Summary collapse

DETECTOR_CLASSES =
{
  loop_association: Detectors::LoopAssociation,
  serializer_nesting: Detectors::SerializerNesting,
  missing_counter_cache: Detectors::MissingCounterCache,
  custom_method_query: Detectors::CustomMethodQuery,
  count_in_iteration: Detectors::CountInIteration,
  callback_query: Detectors::CallbackQuery,
  pluck_to_array: Detectors::PluckToArray,
  delegation_n_plus_one: Detectors::DelegationNPlusOne
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths: nil) ⇒ Analyzer

Returns a new instance of Analyzer.



20
21
22
23
24
25
# File 'lib/eager_eye/analyzer.rb', line 20

def initialize(paths: nil)
  @paths = Array(paths || EagerEye.configuration.app_path)
  @issues = []
  @association_preloads = {}
  @delegation_maps = {}
end

Instance Attribute Details

#association_preloadsObject (readonly)

Returns the value of attribute association_preloads.



18
19
20
# File 'lib/eager_eye/analyzer.rb', line 18

def association_preloads
  @association_preloads
end

#delegation_mapsObject (readonly)

Returns the value of attribute delegation_maps.



18
19
20
# File 'lib/eager_eye/analyzer.rb', line 18

def delegation_maps
  @delegation_maps
end

#issuesObject (readonly)

Returns the value of attribute issues.



18
19
20
# File 'lib/eager_eye/analyzer.rb', line 18

def issues
  @issues
end

#pathsObject (readonly)

Returns the value of attribute paths.



18
19
20
# File 'lib/eager_eye/analyzer.rb', line 18

def paths
  @paths
end

Instance Method Details

#runObject



27
28
29
30
31
32
33
# File 'lib/eager_eye/analyzer.rb', line 27

def run
  @issues = []
  collect_association_preloads
  collect_delegation_maps
  analyze_files
  @issues
end