Class: MetricFu::RailsBestPracticesGenerator
- Inherits:
-
Generator
- Object
- Generator
- MetricFu::RailsBestPracticesGenerator
show all
- Defined in:
- lib/metric_fu/metrics/rails_best_practices/generator.rb
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/rails_best_practices/generator.rb', line 3
def self.metric
:rails_best_practices
end
|
Instance Method Details
#analyze ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/metric_fu/metrics/rails_best_practices/generator.rb', line 15
def analyze
@problems = @output.collect do |problem|
{
file: problem.filename,
line: problem.line_number,
problem: problem.message,
url: problem.url
}
end
total = ["Found #{@problems.count} errors."]
@rails_best_practices_results = { total: total, problems: @problems }
end
|
#emit ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/metric_fu/metrics/rails_best_practices/generator.rb', line 7
def emit
mf_debug "** Rails Best Practices"
path = "."
analyzer = ::RailsBestPractices::Analyzer.new(path, "silent" => true)
analyzer.analyze
@output = analyzer.errors
end
|
#per_file_info(out) ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/metric_fu/metrics/rails_best_practices/generator.rb', line 32
def per_file_info(out)
@rails_best_practices_results[:problems].each do |problem|
next if problem[:file] == "" || problem[:problem].nil?
lines = problem[:line].split(/\s*,\s*/)
lines.each do |line|
out[problem[:file]][line] << { type: :rails_best_practices, description: problem[:problem] }
end
end
end
|
#to_h ⇒ Object
28
29
30
|
# File 'lib/metric_fu/metrics/rails_best_practices/generator.rb', line 28
def to_h
{ rails_best_practices: @rails_best_practices_results }
end
|