Class: Simplabs::Excellent::Checks::NestedIteratorsCheck

Inherits:
Base
  • Object
show all
Defined in:
lib/simplabs/excellent/checks/nested_iterators_check.rb

Overview

This check reports nested iterators. Nested iterators lead to introduce performance issues.

Applies to

  • blocks

Instance Attribute Summary

Attributes inherited from Base

#interesting_files, #interesting_nodes, #warnings

Instance Method Summary collapse

Methods inherited from Base

#add_warning, #evaluate_node, #warnings_for

Constructor Details

#initializeNestedIteratorsCheck

:nodoc:

[View source]

16
17
18
19
20
# File 'lib/simplabs/excellent/checks/nested_iterators_check.rb', line 16

def initialize #:nodoc:
  super
  @interesting_nodes = [:iter]
  @interesting_files = [/\.rb$/, /\.erb$/]
end

Instance Method Details

#evaluate(context) ⇒ Object

:nodoc:

[View source]

22
23
24
25
26
# File 'lib/simplabs/excellent/checks/nested_iterators_check.rb', line 22

def evaluate(context) #:nodoc:
  if context.inside_block?
    add_warning(context, '{{block}} inside of {{parent}}.', { :block => context.full_name, :parent => context.parent.full_name })
  end
end