lib/metric_fu/metrics/cane/cane.rb in metric_fu-4.3.1 vs lib/metric_fu/metrics/cane/cane.rb in metric_fu-4.4.0
- old
+ new
@@ -1,9 +1,13 @@
module MetricFu
- class Cane < Generator
+ class CaneGenerator < Generator
attr_reader :violations, :total_violations
+ def self.metric
+ :cane
+ end
+
def emit
command = %Q{mf-cane#{abc_max_param}#{style_measure_param}#{no_doc_param}#{no_readme_param}}
mf_debug "** #{command}"
@output = `#{command}`
end
@@ -17,22 +21,22 @@
{:cane => {:total_violations => @total_violations, :violations => @violations}}
end
private
def abc_max_param
- MetricFu.cane[:abc_max] ? " --abc-max #{MetricFu.cane[:abc_max]}" : ""
+ options[:abc_max] ? " --abc-max #{options[:abc_max]}" : ""
end
def style_measure_param
- MetricFu.cane[:line_length] ? " --style-measure #{MetricFu.cane[:line_length]}" : ""
+ options[:line_length] ? " --style-measure #{options[:line_length]}" : ""
end
def no_doc_param
- MetricFu.cane[:no_doc] == 'y' ? " --no-doc" : ""
+ options[:no_doc] == 'y' ? " --no-doc" : ""
end
def no_readme_param
- MetricFu.cane[:no_readme] == 'y' ? " --no-readme" : ""
+ options[:no_readme] == 'y' ? " --no-readme" : ""
end
def violations_by_category
violations_output = @output.scan(/(.*?)\n\n(.*?)\n\n/m)
violations_output.each_with_object({}) do |(category_desc, violation_list), violations|