Class: RailsCodeHealth::RubyAnalyzer
- Inherits:
-
Object
- Object
- RailsCodeHealth::RubyAnalyzer
- Includes:
- ASTHelpers
- Defined in:
- lib/rails_code_health/ruby_analyzer.rb
Constant Summary
Constants included from ASTHelpers
ASTHelpers::SCOPE_BOUNDARY_TYPES, ASTHelpers::VISIBILITY_MODIFIERS
Instance Method Summary collapse
- #analyze ⇒ Object
-
#initialize(file_path) ⇒ RubyAnalyzer
constructor
A new instance of RubyAnalyzer.
Methods included from ASTHelpers
#class_body_sends, #defs_by_visibility, #erb_ruby_fragments, #find_nodes, #find_nodes_in_scope
Constructor Details
#initialize(file_path) ⇒ RubyAnalyzer
Returns a new instance of RubyAnalyzer.
4 5 6 7 8 9 10 11 |
# File 'lib/rails_code_health/ruby_analyzer.rb', line 4 def initialize(file_path) @file_path = file_path @source = File.read(file_path) @ast = Parser::CurrentRuby.parse(@source) rescue Parser::SyntaxError => e @parse_error = e @ast = nil end |
Instance Method Details
#analyze ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rails_code_health/ruby_analyzer.rb', line 13 def analyze return { parse_error: @parse_error. } if @parse_error { file_metrics: analyze_file, class_metrics: analyze_classes, method_metrics: analyze_methods, complexity_metrics: analyze_complexity, code_smells: detect_code_smells } end |