Class: MetricFu::ReekGenerator
Instance Attribute Summary
Attributes inherited from Generator
#options, #result, #template
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Generator
#generate_result, generators, get_generator, #initialize, #metric, #metric_config, metric_directory, #metric_directory, not_implemented, #remove_excluded_files, #round_to_tenths
Class Method Details
.metric ⇒ Object
3
4
5
|
# File 'lib/metric_fu/metrics/reek/generator.rb', line 3
def self.metric
:reek
end
|
Instance Method Details
#analyze ⇒ Object
21
22
23
24
25
26
|
# File 'lib/metric_fu/metrics/reek/generator.rb', line 21
def analyze
@matches = @output.smells.group_by(&:source).collect do |file_path, smells|
{ file_path: file_path,
code_smells: analyze_smells(smells) }
end
end
|
#emit ⇒ Object
7
8
9
10
11
12
13
14
15
|
# File 'lib/metric_fu/metrics/reek/generator.rb', line 7
def emit
files = files_to_analyze
if files.empty?
mf_log "Skipping Reek, no files found to analyze"
@output = run!([], config_files)
else
@output = run!(files, config_files)
end
end
|
#per_file_info(out) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/metric_fu/metrics/reek/generator.rb', line 32
def per_file_info(out)
@matches.each do |file_data|
file_path = file_data[:file_path]
next if File.extname(file_path) =~ /\.erb|\.html|\.haml/
begin
line_numbers = MetricFu::LineNumbers.new(File.read(file_path), file_path)
rescue StandardError => e
raise e unless e.message =~ /you shouldn't be able to get here/
mf_log "ruby_parser blew up while trying to parse #{file_path}. You won't have method level reek information for this file."
next
end
file_data[:code_smells].each do |smell_data|
line = line_numbers.start_line_for_method(smell_data[:method])
out[file_data[:file_path]][line.to_s] << { type: :reek,
description: "#{smell_data[:type]} - #{smell_data[:message]}" }
end
end
end
|
#run!(files, config_files) ⇒ Object
17
18
19
|
# File 'lib/metric_fu/metrics/reek/generator.rb', line 17
def run!(files, config_files)
examiner.new(files, config_files)
end
|
#to_h ⇒ Object
28
29
30
|
# File 'lib/metric_fu/metrics/reek/generator.rb', line 28
def to_h
{ reek: { matches: @matches } }
end
|