Class: SplitMethods
- Inherits:
-
Parser::AST::Processor
- Object
- Parser::AST::Processor
- SplitMethods
- Includes:
- RuboCop::AST::Traversal
- Defined in:
- app/services/split_methods.rb
Overview
require ‘fast’
Defined Under Namespace
Classes: DisplayMethod
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.call(event) ⇒ Object
6 7 8 |
# File 'app/services/split_methods.rb', line 6 def self.call(event) new.call(event) end |
Instance Method Details
#call(event) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/split_methods.rb', line 10 def call(event) raw_code = File.readlines(event.path.path) code = raw_code.join source = RuboCop::ProcessedSource.new(code, 3.2) method_name = event.method.to_sym method = source.ast .each_node .select do |n| # Will need to add method name here, and the delegate param # n.type == :def && method_name == n.method_name # || n.type == :send && n.method_name == :delegate end method = method.first DisplayMethod.call(code: code, node: method) rescue => e Rails.logger.info("Missing method: #{method_name}") end |