Class: RubyCritic::Analyser::FlaySmells

Inherits:
Object
  • Object
show all
Includes:
Colorize
Defined in:
lib/rubycritic/analysers/smells/flay.rb

Instance Method Summary collapse

Methods included from Colorize

#colorize, #green, #red

Constructor Details

#initialize(analysed_modules) ⇒ FlaySmells

Returns a new instance of FlaySmells.


10
11
12
13
# File 'lib/rubycritic/analysers/smells/flay.rb', line 10

def initialize(analysed_modules)
  @analysed_modules = paths_to_analysed_modules(analysed_modules)
  @flay = Flay.new(@analysed_modules.keys)
end

Instance Method Details

#runObject


15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rubycritic/analysers/smells/flay.rb', line 15

def run
  @flay.hashes.each do |structural_hash, nodes|
    smell = create_smell(structural_hash, nodes)
    nodes.map(&:file).uniq.each do |file|
      @analysed_modules[file].smells << smell
    end

    nodes.each do |node|
      @analysed_modules[node.file].duplication += node.mass
    end
    print green '.'
  end
  puts ''
end

#to_sObject


30
31
32
# File 'lib/rubycritic/analysers/smells/flay.rb', line 30

def to_s
  'flay smells'
end