Class: MetricFu::Reek
Constant Summary
collapse
- REEK_REGEX =
/^(\S+) (.*) \((.*)\)$/
Instance Attribute Summary
Attributes inherited from Generator
#report, #template
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Generator
class_name, #create_data_dir_if_missing, #create_metric_dir_if_missing, #create_output_dir_if_missing, generate_report, #generate_report, #initialize, #metric_directory, metric_directory, #round_to_tenths, #to_graph
Class Method Details
.verify_dependencies! ⇒ Object
6
7
8
9
|
# File 'lib/generators/reek.rb', line 6
def self.verify_dependencies!
`reek --help`
raise 'sudo gem install reek # if you want the reek tasks' unless $?.success?
end
|
Instance Method Details
#analyze ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/generators/reek.rb', line 16
def analyze
@matches = @output.chomp.split("\n\n").map{|m| m.split("\n") }
@matches = @matches.map do |match|
file_path = match.shift.split('--').first
file_path = file_path.gsub('"', ' ').strip
code_smells = match.map do |smell|
match_object = smell.match(REEK_REGEX)
next unless match_object
{:method => match_object[1].strip,
:message => match_object[2].strip,
:type => match_object[3].strip}
end.compact
{:file_path => file_path, :code_smells => code_smells}
end
end
|
#emit ⇒ Object
11
12
13
14
|
# File 'lib/generators/reek.rb', line 11
def emit
files_to_reek = MetricFu.reek[:dirs_to_reek].map{|dir| Dir[File.join(dir, "**/*.rb")] }
@output = `reek #{files_to_reek.join(" ")}`
end
|
#to_h ⇒ Object
32
33
34
|
# File 'lib/generators/reek.rb', line 32
def to_h
{:reek => {:matches => @matches}}
end
|