Class: EagerEye::Analyzer
- Inherits:
-
Object
- Object
- EagerEye::Analyzer
- 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, decorator_n_plus_one: Detectors::DecoratorNPlusOne, scope_chain_n_plus_one: Detectors::ScopeChainNPlusOne, validation_n_plus_one: Detectors::ValidationNPlusOne }.freeze
- DETECTOR_EXTRA_ARGS =
{ Detectors::LoopAssociation => %i[association_preloads association_names method_queries associations_by_model], Detectors::SerializerNesting => %i[association_names method_queries], Detectors::MissingCounterCache => %i[association_names], Detectors::DecoratorNPlusOne => %i[association_names method_queries], Detectors::CustomMethodQuery => %i[method_queries associations_by_model], Detectors::DelegationNPlusOne => %i[delegation_maps], Detectors::ScopeChainNPlusOne => %i[scope_maps], Detectors::ValidationNPlusOne => %i[uniqueness_models] }.freeze
Instance Attribute Summary collapse
-
#association_names ⇒ Object
readonly
Returns the value of attribute association_names.
-
#association_preloads ⇒ Object
readonly
Returns the value of attribute association_preloads.
-
#associations_by_model ⇒ Object
readonly
Returns the value of attribute associations_by_model.
-
#delegation_maps ⇒ Object
readonly
Returns the value of attribute delegation_maps.
-
#issues ⇒ Object
readonly
Returns the value of attribute issues.
-
#method_queries ⇒ Object
readonly
Returns the value of attribute method_queries.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#scope_maps ⇒ Object
readonly
Returns the value of attribute scope_maps.
-
#uniqueness_models ⇒ Object
readonly
Returns the value of attribute uniqueness_models.
Instance Method Summary collapse
-
#initialize(paths: nil) ⇒ Analyzer
constructor
A new instance of Analyzer.
- #run ⇒ Object
Constructor Details
#initialize(paths: nil) ⇒ Analyzer
Returns a new instance of Analyzer.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/eager_eye/analyzer.rb', line 35 def initialize(paths: nil) @paths = Array(paths || EagerEye.configuration.app_path) @issues = [] @association_preloads = {} @association_names = Set.new @associations_by_model = {} @method_queries = {} @delegation_maps = {} @scope_maps = {} @uniqueness_models = Set.new end |
Instance Attribute Details
#association_names ⇒ Object (readonly)
Returns the value of attribute association_names.
32 33 34 |
# File 'lib/eager_eye/analyzer.rb', line 32 def association_names @association_names end |
#association_preloads ⇒ Object (readonly)
Returns the value of attribute association_preloads.
32 33 34 |
# File 'lib/eager_eye/analyzer.rb', line 32 def association_preloads @association_preloads end |
#associations_by_model ⇒ Object (readonly)
Returns the value of attribute associations_by_model.
32 33 34 |
# File 'lib/eager_eye/analyzer.rb', line 32 def associations_by_model @associations_by_model end |
#delegation_maps ⇒ Object (readonly)
Returns the value of attribute delegation_maps.
32 33 34 |
# File 'lib/eager_eye/analyzer.rb', line 32 def delegation_maps @delegation_maps end |
#issues ⇒ Object (readonly)
Returns the value of attribute issues.
32 33 34 |
# File 'lib/eager_eye/analyzer.rb', line 32 def issues @issues end |
#method_queries ⇒ Object (readonly)
Returns the value of attribute method_queries.
32 33 34 |
# File 'lib/eager_eye/analyzer.rb', line 32 def method_queries @method_queries end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
32 33 34 |
# File 'lib/eager_eye/analyzer.rb', line 32 def paths @paths end |
#scope_maps ⇒ Object (readonly)
Returns the value of attribute scope_maps.
32 33 34 |
# File 'lib/eager_eye/analyzer.rb', line 32 def scope_maps @scope_maps end |
#uniqueness_models ⇒ Object (readonly)
Returns the value of attribute uniqueness_models.
32 33 34 |
# File 'lib/eager_eye/analyzer.rb', line 32 def uniqueness_models @uniqueness_models end |
Instance Method Details
#run ⇒ Object
47 48 49 50 51 52 |
# File 'lib/eager_eye/analyzer.rb', line 47 def run @issues = [] ruby_files.each { |file_path| analyze_file(file_path) } @issues end |