Class: MetricFu::RoodiGenerator
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, #run!
Class Method Details
.metric ⇒ Object
3
4
5
|
# File 'lib/metric_fu/metrics/roodi/generator.rb', line 3
def self.metric
:roodi
end
|
Instance Method Details
#analyze ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/metric_fu/metrics/roodi/generator.rb', line 15
def analyze
@output = MetricFu::Utility.strip_escape_codes(@output)
@matches = @output.chomp.split("\n").map { |m| m.split(" - ") }
total = @matches.pop
@matches.reject! { |array| array.size < 2 }
@matches.map! do |match|
file, line = match[0].split(":")
problem = match[1]
{ file: file, line: line, problem: problem }
end
total << "Found #{@matches.size} errors."
@roodi_results = { total: total, problems: @matches }
end
|
#emit ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/metric_fu/metrics/roodi/generator.rb', line 7
def emit
files_to_analyze = options[:dirs_to_roodi].map { |dir| Dir[File.join(dir, "**/*.rb")] }
files = remove_excluded_files(files_to_analyze.flatten)
config = options[:roodi_config] ? "-config=#{options[:roodi_config]}" : ""
args = "#{config} #{files.join(' ')}"
@output = run!(args)
end
|
#per_file_info(out) ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/metric_fu/metrics/roodi/generator.rb', line 33
def per_file_info(out)
@matches.each do |match|
out[match[:file]] ||= {}
out[match[:file]][match[:line]] ||= []
out[match[:file]][match[:line]] << { type: :roodi, description: match[:problem] }
end
end
|
#to_h ⇒ Object
29
30
31
|
# File 'lib/metric_fu/metrics/roodi/generator.rb', line 29
def to_h
{ roodi: @roodi_results }
end
|