metric_fu 4.3.1 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.metrics +55 -26
- data/.travis.yml +4 -1
- data/AUTHORS +12 -0
- data/Gemfile +1 -0
- data/HISTORY.md +24 -0
- data/README.md +27 -22
- data/checksum/metric_fu-4.3.1.gem.sha512 +1 -0
- data/checksum/metric_fu-4.4.0.gem.sha512 +1 -0
- data/lib/metric_fu.rb +28 -79
- data/lib/metric_fu/cli/helper.rb +1 -1
- data/lib/metric_fu/cli/parser.rb +1 -1
- data/lib/metric_fu/configuration.rb +104 -150
- data/lib/metric_fu/environment.rb +88 -0
- data/lib/metric_fu/formatter.rb +23 -0
- data/lib/metric_fu/formatter/html.rb +12 -9
- data/lib/metric_fu/initial_requires.rb +1 -0
- data/lib/metric_fu/io.rb +60 -1
- data/lib/metric_fu/load_files.rb +4 -2
- data/lib/metric_fu/loader.rb +62 -0
- data/lib/metric_fu/metric.rb +102 -0
- data/lib/metric_fu/metrics/base_template.rb +15 -9
- data/lib/metric_fu/metrics/cane/cane.rb +9 -5
- data/lib/metric_fu/metrics/cane/init.rb +35 -13
- data/lib/metric_fu/metrics/churn/churn.rb +5 -1
- data/lib/metric_fu/metrics/churn/init.rb +24 -4
- data/lib/metric_fu/metrics/flay/flay.rb +7 -3
- data/lib/metric_fu/metrics/flay/init.rb +29 -13
- data/lib/metric_fu/metrics/flay/template_awesome/flay.html.erb +1 -1
- data/lib/metric_fu/metrics/flog/flog.rb +14 -38
- data/lib/metric_fu/metrics/flog/init.rb +30 -7
- data/lib/metric_fu/metrics/generator.rb +21 -6
- data/lib/metric_fu/metrics/graph.rb +2 -2
- data/lib/metric_fu/metrics/hotspots/hotspots.rb +5 -1
- data/lib/metric_fu/metrics/hotspots/init.rb +21 -5
- data/lib/metric_fu/metrics/rails_best_practices/init.rb +29 -5
- data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb +20 -27
- data/lib/metric_fu/metrics/rails_best_practices/template_awesome/rails_best_practices.html.erb +1 -1
- data/lib/metric_fu/metrics/rcov/init.rb +40 -15
- data/lib/metric_fu/metrics/rcov/rcov.rb +15 -10
- data/lib/metric_fu/metrics/reek/init.rb +25 -6
- data/lib/metric_fu/metrics/reek/reek.rb +52 -31
- data/lib/metric_fu/metrics/reek/template_awesome/reek.html.erb +1 -1
- data/lib/metric_fu/metrics/roodi/init.rb +25 -6
- data/lib/metric_fu/metrics/roodi/roodi.rb +7 -3
- data/lib/metric_fu/metrics/saikuro/init.rb +22 -6
- data/lib/metric_fu/metrics/saikuro/saikuro.rb +8 -3
- data/lib/metric_fu/metrics/stats/init.rb +28 -5
- data/lib/metric_fu/metrics/stats/stats.rb +24 -6
- data/lib/metric_fu/metrics/stats/template_awesome/stats.html.erb +2 -2
- data/lib/metric_fu/parser_ext.rb +15 -0
- data/lib/metric_fu/reporting/graphs/engines/gchart.rb +1 -1
- data/lib/metric_fu/reporting/graphs/engines/init.rb +18 -4
- data/lib/metric_fu/reporting/graphs/grapher.rb +1 -1
- data/lib/metric_fu/reporting/result.rb +13 -6
- data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +1 -1
- data/lib/metric_fu/run.rb +7 -10
- data/lib/metric_fu/sexp_ext.rb +11 -0
- data/lib/metric_fu/version.rb +1 -1
- data/metric_fu.gemspec +23 -20
- data/spec/cli/helper_spec.rb +5 -16
- data/spec/metric_fu/configuration_spec.rb +62 -88
- data/spec/metric_fu/formatter/html_spec.rb +26 -16
- data/spec/metric_fu/formatter/yaml_spec.rb +2 -2
- data/spec/metric_fu/metric_spec.rb +50 -0
- data/spec/metric_fu/metrics/base_template_spec.rb +9 -7
- data/spec/metric_fu/metrics/cane/cane_spec.rb +19 -24
- data/spec/metric_fu/metrics/churn/churn_spec.rb +8 -8
- data/spec/metric_fu/metrics/flay/flay_spec.rb +7 -13
- data/spec/metric_fu/metrics/flog/flog_spec.rb +63 -58
- data/spec/metric_fu/metrics/generator_spec.rb +4 -0
- data/spec/metric_fu/metrics/hotspots/hotspots_spec.rb +7 -7
- data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_spec.rb +14 -33
- data/spec/metric_fu/metrics/rcov/rcov_spec.rb +17 -18
- data/spec/metric_fu/metrics/reek/reek_spec.rb +9 -10
- data/spec/metric_fu/metrics/roodi/roodi_spec.rb +5 -11
- data/spec/metric_fu/metrics/saikuro/saikuro_spec.rb +15 -14
- data/spec/metric_fu/metrics/stats/stats_spec.rb +5 -6
- data/spec/metric_fu/reporting/graphs/engines/bluff_spec.rb +2 -3
- data/spec/metric_fu/reporting/graphs/engines/gchart_spec.rb +12 -9
- data/spec/metric_fu/reporting/result_spec.rb +3 -3
- data/spec/run_spec.rb +45 -29
- data/spec/spec_helper.rb +7 -0
- data/spec/support/helper_methods.rb +9 -0
- data/spec/support/suite.rb +17 -11
- metadata +59 -56
- data/bin/mf-rails_best_practices +0 -9
- data/bin/mf-stats +0 -7
@@ -1,12 +1,17 @@
|
|
1
1
|
module MetricFu
|
2
2
|
|
3
3
|
class Saikuro < Generator
|
4
|
+
|
5
|
+
def self.metric
|
6
|
+
:saikuro
|
7
|
+
end
|
8
|
+
|
4
9
|
def emit
|
5
|
-
options_string =
|
10
|
+
options_string = options.inject("") do |options, option|
|
6
11
|
option[0] == :input_directory ? options : options + "--#{option.join(' ')} "
|
7
12
|
end
|
8
13
|
|
9
|
-
|
14
|
+
options[:input_directory].each do |input_dir|
|
10
15
|
options_string += "--input_directory #{input_dir} "
|
11
16
|
end
|
12
17
|
|
@@ -16,7 +21,7 @@ module MetricFu
|
|
16
21
|
end
|
17
22
|
|
18
23
|
def format_directories
|
19
|
-
dirs =
|
24
|
+
dirs = options[:input_directory].join(" | ")
|
20
25
|
"\"#{dirs}\""
|
21
26
|
end
|
22
27
|
|
@@ -1,7 +1,30 @@
|
|
1
|
-
MetricFu
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module MetricFu
|
2
|
+
class MetricStats < Metric
|
3
|
+
|
4
|
+
def name
|
5
|
+
:stats
|
6
|
+
end
|
7
|
+
|
8
|
+
def default_run_options
|
9
|
+
{
|
10
|
+
# returns a list of directories that contains the glob of files that have the file_pattern in the file names
|
11
|
+
:additional_test_directories => [{glob_pattern: File.join('.','spec','**','*_spec.rb'), file_pattern: 'spec'}],
|
12
|
+
:additional_app_directories => [{glob_pattern: File.join('.','engines','**','*.rb'), file_pattern: ''}],
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def has_graph?
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def enable
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def activate
|
25
|
+
activate_library 'code_metrics'
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
6
29
|
end
|
7
30
|
end
|
@@ -1,16 +1,20 @@
|
|
1
1
|
module MetricFu
|
2
2
|
|
3
|
-
class
|
3
|
+
class StatsGenerator < Generator
|
4
|
+
|
5
|
+
def self.metric
|
6
|
+
:stats
|
7
|
+
end
|
4
8
|
|
5
9
|
def emit
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
require 'code_metrics/statistics'
|
11
|
+
@output = MfDebugger::Logger.capture_output do
|
12
|
+
CodeMetrics::Statistics.new(*dirs).to_s
|
13
|
+
end
|
9
14
|
end
|
10
15
|
|
11
16
|
def analyze
|
12
|
-
|
13
|
-
lines = remove_noise(output).compact
|
17
|
+
lines = remove_noise(@output).compact
|
14
18
|
|
15
19
|
@stats = {}
|
16
20
|
|
@@ -57,5 +61,19 @@ module MetricFu
|
|
57
61
|
end
|
58
62
|
end
|
59
63
|
|
64
|
+
# @return [Array<[ 'Acceptance specs', 'spec/acceptance' ]>]
|
65
|
+
def dirs
|
66
|
+
require 'code_metrics/stats_directories'
|
67
|
+
require 'code_metrics/statistics'
|
68
|
+
stats_dirs = CodeMetrics::StatsDirectories.new
|
69
|
+
options.fetch(:additional_test_directories).each do |option|
|
70
|
+
stats_dirs.add_test_directories(option.fetch(:glob_pattern), option.fetch(:file_pattern))
|
71
|
+
end
|
72
|
+
options.fetch(:additional_app_directories).each do |option|
|
73
|
+
stats_dirs.add_directories(option.fetch(:glob_pattern), option.fetch(:file_pattern))
|
74
|
+
end
|
75
|
+
stats_dirs.directories
|
76
|
+
end
|
77
|
+
|
60
78
|
end
|
61
79
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<h3>
|
1
|
+
<h3>Lines of Code/Tests Metric Results</h3>
|
2
2
|
|
3
3
|
<% graph_name = 'stats' %>
|
4
4
|
<% if MetricFu.configuration.graph_engine == :gchart %>
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<% end %>
|
10
10
|
|
11
11
|
|
12
|
-
<p>
|
12
|
+
<p>Lines of Code/Tests Metrics Results</p>
|
13
13
|
<table>
|
14
14
|
<tr>
|
15
15
|
<th>Lines of Code</th>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# For Flog
|
2
|
+
# TODO: Do we still need this?
|
3
|
+
require 'ruby_parser'
|
4
|
+
class RubyParser
|
5
|
+
alias_method :original_process, :process
|
6
|
+
def process(s,f,t)
|
7
|
+
original_process(s,f,t)
|
8
|
+
rescue => e
|
9
|
+
if e.message =~ /wrong number of arguments/
|
10
|
+
original_process(s,f)
|
11
|
+
else
|
12
|
+
raise
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,5 +1,19 @@
|
|
1
|
-
MetricFu
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module MetricFu
|
2
|
+
class GraphEngine
|
3
|
+
|
4
|
+
attr_accessor :graph_engines, :graph_engine
|
5
|
+
def initialize
|
6
|
+
@graph_engines = [:bluff, :gchart]
|
7
|
+
@graph_engine = :bluff
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_graph_engine(graph_engine)
|
11
|
+
self.graph_engines = (graph_engines << graph_engine).uniq
|
12
|
+
end
|
13
|
+
|
14
|
+
def configure_graph_engine(graph_engine)
|
15
|
+
self.graph_engine = graph_engine
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
5
19
|
end
|
@@ -38,14 +38,21 @@ module MetricFu
|
|
38
38
|
# The hash to add to the aggregate result_hash
|
39
39
|
def add(result_type)
|
40
40
|
mf_debug "result requested #{result_type}"
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
metric_options = metric_options_for_result_type(result_type)
|
42
|
+
generator_class = MetricFu::Generator.get_generator(result_type)
|
43
|
+
mf_debug "result class found #{generator_class}"
|
44
|
+
generator = generator_class.new(metric_options)
|
45
45
|
|
46
|
-
result_hash.merge!(
|
46
|
+
result_hash.merge!(generator.generate_result)
|
47
47
|
|
48
|
-
|
48
|
+
generator.per_file_info(per_file_data) if generator.respond_to?(:per_file_info)
|
49
49
|
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def metric_options_for_result_type(result_type)
|
54
|
+
MetricFu::Metric.get_metric(result_type).run_options
|
55
|
+
end
|
56
|
+
|
50
57
|
end
|
51
58
|
end
|
@@ -91,7 +91,7 @@ class AwesomeTemplate < MetricFu::Template
|
|
91
91
|
out << " "
|
92
92
|
end
|
93
93
|
out << "</td>"
|
94
|
-
if MetricFu.
|
94
|
+
if MetricFu::Formatter::Templates.option('syntax_highlighting')
|
95
95
|
line_for_display = convert_ruby_to_html(line, line_number)
|
96
96
|
else
|
97
97
|
line_for_display = "<a name='n#{line_number}' href='n#{line_number}'>#{line_number}</a>#{line}"
|
data/lib/metric_fu/run.rb
CHANGED
@@ -11,10 +11,8 @@ module MetricFu
|
|
11
11
|
display_results if options[:open]
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
MetricFu.configuration.metrics.sort_by! {|x| x == :hotspots ? 1 : 0 }
|
17
|
-
MetricFu.configuration.metrics
|
14
|
+
def report_metrics(metrics=MetricFu::Metric.enabled_metrics)
|
15
|
+
metrics.map(&:name)
|
18
16
|
end
|
19
17
|
def measure
|
20
18
|
reporter.start
|
@@ -45,24 +43,23 @@ module MetricFu
|
|
45
43
|
mf_debug "using metric #{metric}"
|
46
44
|
else
|
47
45
|
mf_debug "disabling metric #{metric}"
|
48
|
-
MetricFu.
|
49
|
-
|
50
|
-
mf_debug "active metrics are #{MetricFu.configuration.metrics.inspect}"
|
46
|
+
MetricFu::Metric.get_metric(metric).enabled = false
|
47
|
+
mf_debug "active metrics are #{MetricFu::Metric.enabled_metrics.inspect}"
|
51
48
|
end
|
52
49
|
end
|
53
50
|
end
|
54
51
|
def configure_formatters(options)
|
55
52
|
# Configure from command line if any.
|
56
53
|
if options[:format]
|
57
|
-
MetricFu.formatters.clear # Command-line format takes precedence.
|
54
|
+
MetricFu.configuration.formatters.clear # Command-line format takes precedence.
|
58
55
|
Array(options[:format]).each do |format, o|
|
59
|
-
MetricFu.configuration.
|
56
|
+
MetricFu.configuration.configure_formatter(format, o)
|
60
57
|
end
|
61
58
|
end
|
62
59
|
# If no formatters specified, use defaults.
|
63
60
|
if MetricFu.configuration.formatters.empty?
|
64
61
|
Array(MetricFu::Formatter::DEFAULT).each do |format, o|
|
65
|
-
MetricFu.configuration.
|
62
|
+
MetricFu.configuration.configure_formatter(format, o)
|
66
63
|
end
|
67
64
|
end
|
68
65
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# until https://github.com/flyerhzm/code_analyzer/pull/4 is merged and released
|
2
|
+
# see https://github.com/metricfu/metric_fu/issues/123
|
3
|
+
require 'code_analyzer'
|
4
|
+
class Sexp
|
5
|
+
begin
|
6
|
+
alias_method :block_type, :block
|
7
|
+
undef :block
|
8
|
+
rescue NameError
|
9
|
+
# we're a-okay
|
10
|
+
end
|
11
|
+
end
|
data/lib/metric_fu/version.rb
CHANGED
data/metric_fu.gemspec
CHANGED
@@ -1,39 +1,42 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
3
|
require 'metric_fu/version'
|
4
|
-
require 'metric_fu_requires'
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
6
|
s.name = "metric_fu"
|
8
|
-
s.
|
9
|
-
s.version = MetricFu::VERSION
|
7
|
+
s.homepage = "https://github.com/metricfu/metric_fu"
|
10
8
|
s.summary = "A fistful of code metrics, with awesome templates and graphs"
|
9
|
+
s.description = "Code metrics from Flog, Flay, Saikuro, Churn, Reek, Roodi, Code Statistics, and Rails Best Practices. (and optionally RCov)"
|
11
10
|
s.email = "github@benjaminfleischer.com"
|
12
|
-
s.
|
13
|
-
|
14
|
-
s.
|
15
|
-
s.
|
16
|
-
s.
|
17
|
-
s.
|
18
|
-
s.
|
19
|
-
s.
|
20
|
-
|
21
|
-
s.
|
22
|
-
s.
|
23
|
-
s.
|
24
|
-
s.
|
25
|
-
s.
|
26
|
-
|
11
|
+
s.authors = File.readlines('AUTHORS').map(&:strip)
|
12
|
+
|
13
|
+
s.rubyforge_project = 'metric_fu'
|
14
|
+
s.license = 'MIT'
|
15
|
+
s.platform = Gem::Platform::RUBY
|
16
|
+
s.version = MetricFu::VERSION
|
17
|
+
s.required_ruby_version = ">= 1.9.0"
|
18
|
+
s.required_rubygems_version = ">= 1.3.6"
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split($\)
|
21
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
22
|
+
s.default_executable = %q{metric_fu}
|
23
|
+
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
|
26
|
+
s.has_rdoc = true
|
27
|
+
s.extra_rdoc_files = ["HISTORY.md", "CONTRIBUTING.md", "TODO.md", "MIT-LICENSE"]
|
28
|
+
s.rdoc_options = ["--main", "README.md"]
|
27
29
|
|
28
30
|
# metric dependencies
|
29
31
|
s.add_runtime_dependency 'flay', ['~> 2.0.1']
|
30
32
|
s.add_runtime_dependency 'churn', ['~> 0.0.28']
|
31
|
-
s.add_runtime_dependency 'flog', ['~>
|
33
|
+
s.add_runtime_dependency 'flog', ['~> 4.1.1']
|
32
34
|
s.add_runtime_dependency 'reek', ['~> 1.3.1']
|
33
35
|
s.add_runtime_dependency 'cane', ['~> 2.5.2']
|
34
|
-
s.add_runtime_dependency 'rails_best_practices', ['
|
36
|
+
s.add_runtime_dependency 'rails_best_practices', ['>= 1.14.1', '~> 1.14']
|
35
37
|
s.add_runtime_dependency 'metric_fu-Saikuro', ['>= 1.1.1.0']
|
36
38
|
s.add_runtime_dependency 'metric_fu-roodi', ['>= 2.2.1']
|
39
|
+
s.add_runtime_dependency 'code_metrics', ['~> 0.1']
|
37
40
|
|
38
41
|
# other dependencies
|
39
42
|
# ruby version identification
|
data/spec/cli/helper_spec.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'metric_fu/cli/helper'
|
3
|
-
MetricFu.
|
3
|
+
MetricFu.configuration.configure_metric(:rcov) do |rcov|
|
4
|
+
rcov.enabled = true
|
5
|
+
end
|
6
|
+
MetricFu.configure
|
4
7
|
|
5
8
|
describe MetricFu::Cli::Helper do
|
6
9
|
|
@@ -55,25 +58,11 @@ describe MetricFu::Cli::Helper do
|
|
55
58
|
end
|
56
59
|
|
57
60
|
if MetricFu.configuration.mri?
|
58
|
-
context "on Ruby 1.8.7" do
|
59
|
-
|
60
|
-
before { helper.stub(:ruby).and_return("1.8.7") }
|
61
61
|
|
62
|
-
it "
|
63
|
-
defaults[:rails_best_practices].should be_false
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
context "on Ruby 1.9" do
|
69
|
-
|
70
|
-
before { helper.stub(:ruby).and_return("1.9.3") }
|
71
|
-
|
72
|
-
xit "enables Rails Best Practices" do
|
62
|
+
it "enables Rails Best Practices" do
|
73
63
|
defaults[:rails_best_practices].should be_true
|
74
64
|
end
|
75
65
|
|
76
|
-
end
|
77
66
|
end
|
78
67
|
|
79
68
|
end
|
@@ -6,34 +6,42 @@ describe MetricFu::Configuration do
|
|
6
6
|
ENV['CC_BUILD_ARTIFACTS'] = nil
|
7
7
|
@config = MetricFu.configuration
|
8
8
|
@config.reset
|
9
|
+
MetricFu.configuration.configure_metric(:rcov) do |rcov|
|
10
|
+
rcov.enabled = true
|
11
|
+
end
|
9
12
|
MetricFu.configure
|
10
|
-
MetricFu.
|
11
|
-
|
13
|
+
mri_only_metrics = MetricFu.mri_only_metrics.reject {|metric| MetricFu::Metric.get_metric(metric).enabled }
|
14
|
+
MetricFu.stub(:mri_only_metrics).and_return(mri_only_metrics)
|
15
|
+
MetricFu::Io::FileSystem.stub(:create_directories) # no need to create directories for the tests
|
12
16
|
@config
|
13
17
|
end
|
14
18
|
|
19
|
+
def directory(name)
|
20
|
+
MetricFu::Io::FileSystem.directory(name)
|
21
|
+
end
|
22
|
+
|
15
23
|
def base_directory
|
16
|
-
|
24
|
+
directory('base_directory')
|
17
25
|
end
|
18
26
|
|
19
27
|
def output_directory
|
20
|
-
|
28
|
+
directory('output_directory')
|
21
29
|
end
|
22
30
|
|
23
31
|
def scratch_directory
|
24
|
-
|
32
|
+
directory('scratch_directory')
|
25
33
|
end
|
26
34
|
|
27
35
|
def template_directory
|
28
|
-
|
36
|
+
directory('template_directory')
|
29
37
|
end
|
30
38
|
|
31
39
|
def template_class
|
32
|
-
|
40
|
+
MetricFu::Formatter::Templates.option('template_class')
|
33
41
|
end
|
34
42
|
|
35
43
|
def metric_fu_root
|
36
|
-
|
44
|
+
directory('root_directory')
|
37
45
|
end
|
38
46
|
def load_metric(metric)
|
39
47
|
load File.join(MetricFu.metrics_dir, metric, 'init.rb')
|
@@ -97,27 +105,31 @@ describe MetricFu::Configuration do
|
|
97
105
|
|
98
106
|
it 'should set @flay to {:dirs_to_flay => @code_dirs}' do
|
99
107
|
load_metric 'flay'
|
100
|
-
|
101
|
-
|
108
|
+
expect(MetricFu::Metric.get_metric(:flay).run_options).to eq(
|
109
|
+
{:dirs_to_flay => ['lib'], :filetypes=>["rb"], :minimum_score=>nil}
|
110
|
+
)
|
102
111
|
end
|
103
112
|
|
104
113
|
it 'should set @reek to {:dirs_to_reek => @code_dirs}' do
|
105
114
|
load_metric 'reek'
|
106
|
-
|
107
|
-
|
115
|
+
expect(MetricFu::Metric.get_metric(:reek).run_options).to eq(
|
116
|
+
{:config_file_pattern=>nil, :dirs_to_reek => ['lib']}
|
117
|
+
)
|
108
118
|
end
|
109
119
|
|
110
120
|
it 'should set @roodi to {:dirs_to_roodi => @code_dirs}' do
|
111
121
|
load_metric 'roodi'
|
112
|
-
|
113
|
-
|
114
|
-
:roodi_config => "#{
|
122
|
+
expect(MetricFu::Metric.get_metric(:roodi).run_options).to eq(
|
123
|
+
{ :dirs_to_roodi => directory('code_dirs'),
|
124
|
+
:roodi_config => "#{directory('root_directory')}/config/roodi_config.yml"}
|
125
|
+
)
|
115
126
|
end
|
116
127
|
|
117
128
|
it 'should set @churn to {}' do
|
118
129
|
load_metric 'churn'
|
119
|
-
|
120
|
-
|
130
|
+
expect(MetricFu::Metric.get_metric(:churn).run_options).to eq(
|
131
|
+
{ :start_date => %q("1 year ago"), :minimum_churn_count => 10}
|
132
|
+
)
|
121
133
|
end
|
122
134
|
|
123
135
|
|
@@ -134,8 +146,8 @@ describe MetricFu::Configuration do
|
|
134
146
|
"-Ispec"
|
135
147
|
]) do
|
136
148
|
load_metric 'rcov'
|
137
|
-
|
138
|
-
|
149
|
+
expect(MetricFu::Metric.get_metric(:rcov).run_options).to eq(
|
150
|
+
{ :environment => 'test',
|
139
151
|
:test_files => Dir['{spec,test}/**/*_{spec,test}.rb'],
|
140
152
|
:rcov_opts => [
|
141
153
|
"--sort coverage",
|
@@ -148,6 +160,7 @@ describe MetricFu::Configuration do
|
|
148
160
|
"-Ispec"
|
149
161
|
],
|
150
162
|
:external => nil}
|
163
|
+
)
|
151
164
|
end
|
152
165
|
|
153
166
|
it 'should set @saikuro to { :output_directory => @scratch_directory + "/saikuro",
|
@@ -158,33 +171,39 @@ describe MetricFu::Configuration do
|
|
158
171
|
:error_cyclo => "7",
|
159
172
|
:formater => "text" }' do
|
160
173
|
load_metric 'saikuro'
|
161
|
-
|
162
|
-
|
174
|
+
expect(MetricFu::Metric.get_metric(:saikuro).run_options).to eq(
|
175
|
+
{ :output_directory => "#{scratch_directory}/saikuro",
|
163
176
|
:input_directory => ['lib'],
|
164
177
|
:cyclo => "",
|
165
178
|
:filter_cyclo => "0",
|
166
179
|
:warn_cyclo => "5",
|
167
180
|
:error_cyclo => "7",
|
168
181
|
:formater => "text"}
|
182
|
+
)
|
169
183
|
end
|
170
184
|
|
171
185
|
if MetricFu.configuration.mri?
|
172
186
|
it 'should set @flog to {:dirs_to_flog => @code_dirs}' do
|
173
187
|
load_metric 'flog'
|
174
|
-
|
175
|
-
|
188
|
+
expect(MetricFu::Metric.get_metric(:flog).run_options).to eq({
|
189
|
+
:all => true,
|
190
|
+
:continue => true,
|
191
|
+
:dirs_to_flog => ["lib"],
|
192
|
+
:quiet => true
|
193
|
+
})
|
176
194
|
end
|
177
195
|
it 'should set @cane to ' +
|
178
196
|
%q(:dirs_to_cane => @code_dirs, :abc_max => 15, :line_length => 80, :no_doc => 'n', :no_readme => 'y') do
|
179
197
|
load_metric 'cane'
|
180
|
-
|
181
|
-
|
182
|
-
:dirs_to_cane =>
|
198
|
+
expect(MetricFu::Metric.get_metric(:cane).run_options).to eq(
|
199
|
+
{
|
200
|
+
:dirs_to_cane => directory('code_dirs'),
|
183
201
|
:filetypes => ["rb"],
|
184
202
|
:abc_max => 15,
|
185
203
|
:line_length => 80,
|
186
204
|
:no_doc => "n",
|
187
205
|
:no_readme => "n"}
|
206
|
+
)
|
188
207
|
end
|
189
208
|
end
|
190
209
|
|
@@ -204,32 +223,33 @@ describe MetricFu::Configuration do
|
|
204
223
|
|
205
224
|
describe '#set_metrics ' do
|
206
225
|
it 'should set the metrics to include stats' do
|
207
|
-
|
226
|
+
MetricFu::Metric.enabled_metrics.map(&:name).should include(:stats)
|
208
227
|
end
|
209
228
|
end
|
210
229
|
|
211
230
|
describe '#set_graphs ' do
|
212
231
|
it 'should set the graphs to include rails_best_practices' do
|
213
|
-
|
232
|
+
expect(MetricFu::Metric.get_metric(:rails_best_practices).has_graph?).to be_true
|
214
233
|
end
|
215
234
|
end
|
216
235
|
|
217
236
|
describe '#set_code_dirs ' do
|
218
237
|
it 'should set the @code_dirs instance var to ["app", "lib"]' do
|
219
|
-
|
238
|
+
directory('code_dirs').
|
220
239
|
should == ['app','lib']
|
221
240
|
end
|
222
241
|
end
|
223
242
|
it 'should set @stats to {}' do
|
224
243
|
load_metric 'stats'
|
225
|
-
|
226
|
-
|
244
|
+
expect(MetricFu::Metric.get_metric(:stats).run_options).to eq({
|
245
|
+
:additional_test_directories=>[{:glob_pattern=>"./spec/**/*_spec.rb", :file_pattern=>"spec"}],
|
246
|
+
:additional_app_directories=>[{:glob_pattern=>"./engines/**/*.rb", :file_pattern=>""}]
|
247
|
+
})
|
227
248
|
end
|
228
249
|
|
229
250
|
it 'should set @rails_best_practices to {}' do
|
230
251
|
load_metric 'rails_best_practices'
|
231
|
-
|
232
|
-
should == {}
|
252
|
+
expect(MetricFu::Metric.get_metric(:rails_best_practices).run_options).to eql({})
|
233
253
|
end
|
234
254
|
end
|
235
255
|
|
@@ -243,57 +263,11 @@ describe MetricFu::Configuration do
|
|
243
263
|
end
|
244
264
|
|
245
265
|
it 'should set the available metrics' do
|
246
|
-
|
247
|
-
end
|
248
|
-
|
249
|
-
it 'should set the @code_dirs instance var to ["lib"]' do
|
250
|
-
@config.send(:code_dirs).should == ['lib']
|
251
|
-
end
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
describe '#add_attr_accessors_to_self' do
|
256
|
-
|
257
|
-
before(:each) { get_new_config }
|
258
|
-
|
259
|
-
(
|
260
|
-
[:churn, :flog, :flay, :reek, :roodi, :rcov, :hotspots, :saikuro] -
|
261
|
-
MetricFu.mri_only_metrics
|
262
|
-
).each do |metric|
|
263
|
-
it "should have a reader for #{metric}" do
|
264
|
-
expect {
|
265
|
-
@config.send(metric.to_sym)
|
266
|
-
}.to_not raise_error
|
266
|
+
MetricFu::Metric.enabled_metrics.map(&:name).should =~ [:churn, :flog, :flay, :reek, :roodi, :rcov, :hotspots, :saikuro, :cane, :stats] - MetricFu.mri_only_metrics
|
267
267
|
end
|
268
268
|
|
269
|
-
it
|
270
|
-
|
271
|
-
@config.send((metric.to_s + '=').to_sym, '')
|
272
|
-
}.to_not raise_error
|
273
|
-
end
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
describe '#add_class_methods_to_metric_fu' do
|
278
|
-
|
279
|
-
before(:each) { get_new_config }
|
280
|
-
|
281
|
-
(
|
282
|
-
[:churn, :flog, :flay, :reek, :roodi, :rcov, :hotspots, :saikuro, :cane] -
|
283
|
-
MetricFu.mri_only_metrics
|
284
|
-
|
285
|
-
).each do |metric|
|
286
|
-
it "should add a #{metric} class method to the MetricFu module " do
|
287
|
-
MetricFu.should respond_to(metric)
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
(
|
292
|
-
[:churn, :flog, :flay, :reek, :roodi, :rcov, :hotspots, :saikuro, :cane] -
|
293
|
-
MetricFu.mri_only_metrics
|
294
|
-
).each do |graph|
|
295
|
-
it "should add a #{graph} class metrhod to the MetricFu module" do
|
296
|
-
MetricFu.should respond_to(graph)
|
269
|
+
it 'should set the registered code_dirs to ["lib"]' do
|
270
|
+
directory('code_dirs').should == ['lib']
|
297
271
|
end
|
298
272
|
end
|
299
273
|
end
|
@@ -330,12 +304,12 @@ describe MetricFu::Configuration do
|
|
330
304
|
end
|
331
305
|
end
|
332
306
|
|
333
|
-
describe '#
|
307
|
+
describe '#configure_formatter' do
|
334
308
|
before(:each) { get_new_config }
|
335
309
|
|
336
310
|
context 'given a built-in formatter' do
|
337
311
|
before do
|
338
|
-
@config.
|
312
|
+
@config.configure_formatter('html')
|
339
313
|
end
|
340
314
|
|
341
315
|
it 'adds to the list of formatters' do
|
@@ -346,7 +320,7 @@ describe MetricFu::Configuration do
|
|
346
320
|
context 'given a custom formatter by class name' do
|
347
321
|
before do
|
348
322
|
stub_const('MyCustomFormatter', Class.new() { def initialize(*); end })
|
349
|
-
@config.
|
323
|
+
@config.configure_formatter('MyCustomFormatter')
|
350
324
|
end
|
351
325
|
|
352
326
|
it 'adds to the list of formatters' do
|
@@ -357,9 +331,9 @@ describe MetricFu::Configuration do
|
|
357
331
|
context 'given multiple formatters' do
|
358
332
|
before do
|
359
333
|
stub_const('MyCustomFormatter', Class.new() { def initialize(*); end })
|
360
|
-
@config.
|
361
|
-
@config.
|
362
|
-
@config.
|
334
|
+
@config.configure_formatter('html')
|
335
|
+
@config.configure_formatter('yaml')
|
336
|
+
@config.configure_formatter('MyCustomFormatter')
|
363
337
|
end
|
364
338
|
|
365
339
|
it 'adds each to the list of formatters' do
|