Class: Txray::Analyzer
- Inherits:
-
Object
- Object
- Txray::Analyzer
- Defined in:
- lib/txray/analyzer.rb
Defined Under Namespace
Instance Method Summary collapse
- #call(source) ⇒ Object
-
#initialize(index:, clients:, config:) ⇒ Analyzer
constructor
A new instance of Analyzer.
Constructor Details
#initialize(index:, clients:, config:) ⇒ Analyzer
Returns a new instance of Analyzer.
5 6 7 8 9 10 11 |
# File 'lib/txray/analyzer.rb', line 5 def initialize(index:, clients:, config:) @index = index @clients = clients @config = config @classifier = Classifier.new(config) @scope_finder = ScopeFinder.new(index) end |
Instance Method Details
#call(source) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/txray/analyzer.rb', line 13 def call(source) offenses = {} @scope_finder.call(source).each do |scope| walk = Walk.new(scope: scope, suppressed: Set.new, visited: Set.new) explore(scope.body, scope.namespace, scope.source, walk, 0, []) do |offense| current = offenses[offense.key] offenses[offense.key] = offense if current.nil? || offense.trace.size < current.trace.size end end offenses.values end |