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, #metric, #metric_config, metric_directory, #metric_directory, not_implemented, #remove_excluded_files, #round_to_tenths, #run!, #silence_streams
Constructor Details
Returns a new instance of RailsBestPracticesGenerator.
7
8
9
|
# File 'lib/metric_fu/metrics/rails_best_practices/generator.rb', line 7
def initialize(options = {})
super(MetricFu::Utility.stringify_keys(options))
end
|
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
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/metric_fu/metrics/rails_best_practices/generator.rb', line 19
def analyze
@problems = @output.collect do |problem|
{
file: problem.short_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
11
12
13
14
15
16
17
|
# File 'lib/metric_fu/metrics/rails_best_practices/generator.rb', line 11
def emit
mf_debug "** Rails Best Practices"
path = "."
analyzer = ::RailsBestPractices::Analyzer.new(path, options)
analyzer.analyze
@output = analyzer.errors
end
|
#per_file_info(out) ⇒ Object
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/metric_fu/metrics/rails_best_practices/generator.rb', line 36
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
32
33
34
|
# File 'lib/metric_fu/metrics/rails_best_practices/generator.rb', line 32
def to_h
{ rails_best_practices: @rails_best_practices_results }
end
|