metric_fu 4.4.4 → 4.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +14 -6
  2. checksums.yaml.gz.sig +3 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +1 -0
  5. data/.metrics +0 -3
  6. data/.travis.yml +1 -1
  7. data/.yardopts +0 -1
  8. data/CONTRIBUTING.md +1 -0
  9. data/CONTRIBUTORS +61 -2
  10. data/Gemfile +14 -11
  11. data/Gemfile.devtools +40 -0
  12. data/Guardfile +30 -0
  13. data/HISTORY.md +54 -1
  14. data/README.md +86 -56
  15. data/bin/mf-cane +8 -6
  16. data/bin/mf-churn +8 -7
  17. data/bin/mf-flay +8 -7
  18. data/bin/mf-reek +8 -7
  19. data/bin/mf-roodi +8 -7
  20. data/bin/mf-saikuro +8 -6
  21. data/certs/bf4.pem +22 -0
  22. data/checksum/metric_fu-4.4.4.gem.sha512 +1 -0
  23. data/checksum/metric_fu-4.5.0.gem.sha512 +1 -0
  24. data/etc/README.md +16 -0
  25. data/etc/erd.dot +173 -0
  26. data/etc/erd.png +0 -0
  27. data/lib/metric_fu.rb +56 -12
  28. data/lib/metric_fu/cli/helper.rb +8 -2
  29. data/lib/metric_fu/cli/parser.rb +86 -50
  30. data/lib/metric_fu/configuration.rb +4 -31
  31. data/lib/metric_fu/environment.rb +1 -1
  32. data/lib/metric_fu/formatter/html.rb +5 -5
  33. data/lib/metric_fu/gem_run.rb +68 -0
  34. data/lib/metric_fu/gem_version.rb +57 -0
  35. data/lib/metric_fu/io.rb +1 -1
  36. data/lib/metric_fu/load_files.rb +3 -5
  37. data/lib/metric_fu/loader.rb +31 -2
  38. data/lib/metric_fu/logging/mf_debugger.rb +1 -0
  39. data/lib/metric_fu/metric.rb +23 -1
  40. data/lib/metric_fu/metrics/cane/cane.rb +7 -3
  41. data/lib/metric_fu/metrics/cane/cane_grapher.rb +19 -0
  42. data/lib/metric_fu/metrics/cane/template_awesome/cane.html.erb +0 -4
  43. data/lib/metric_fu/metrics/churn/churn.rb +6 -7
  44. data/lib/metric_fu/metrics/flay/flay.rb +2 -4
  45. data/lib/metric_fu/metrics/flay/flay_grapher.rb +19 -0
  46. data/lib/metric_fu/metrics/flay/template_awesome/flay.html.erb +0 -4
  47. data/lib/metric_fu/metrics/flog/flog.rb +0 -2
  48. data/lib/metric_fu/metrics/flog/flog_grapher.rb +19 -0
  49. data/lib/metric_fu/metrics/flog/template_awesome/flog.html.erb +0 -4
  50. data/lib/metric_fu/metrics/generator.rb +34 -24
  51. data/lib/metric_fu/metrics/graph.rb +8 -14
  52. data/lib/metric_fu/metrics/hotspots/hotspot.rb +7 -5
  53. data/lib/metric_fu/metrics/hotspots/template_awesome/hotspots.html.erb +4 -6
  54. data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb +0 -2
  55. data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices_grapher.rb +19 -0
  56. data/lib/metric_fu/metrics/rails_best_practices/template_awesome/rails_best_practices.html.erb +0 -4
  57. data/lib/metric_fu/metrics/rcov/rcov_grapher.rb +19 -0
  58. data/lib/metric_fu/metrics/rcov/template_awesome/rcov.html.erb +0 -4
  59. data/lib/metric_fu/metrics/reek/init.rb +1 -1
  60. data/lib/metric_fu/metrics/reek/reek.rb +12 -8
  61. data/lib/metric_fu/metrics/reek/reek_grapher.rb +19 -0
  62. data/lib/metric_fu/metrics/reek/template_awesome/reek.html.erb +0 -4
  63. data/lib/metric_fu/metrics/roodi/roodi.rb +2 -3
  64. data/lib/metric_fu/metrics/roodi/roodi_grapher.rb +19 -0
  65. data/lib/metric_fu/metrics/roodi/template_awesome/roodi.html.erb +0 -4
  66. data/lib/metric_fu/metrics/saikuro/saikuro.rb +69 -33
  67. data/lib/metric_fu/metrics/saikuro/scratch_file.rb +8 -9
  68. data/lib/metric_fu/metrics/stats/stats_grapher.rb +20 -0
  69. data/lib/metric_fu/metrics/stats/template_awesome/stats.html.erb +0 -4
  70. data/lib/metric_fu/reporting/graphs/grapher.rb +69 -3
  71. data/lib/metric_fu/reporting/result.rb +5 -1
  72. data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +7 -3
  73. data/lib/metric_fu/run.rb +13 -7
  74. data/lib/metric_fu/tasks/metric_fu.rake +50 -3
  75. data/lib/metric_fu/utility.rb +10 -0
  76. data/lib/metric_fu/version.rb +1 -1
  77. data/metric_fu.gemspec +7 -4
  78. data/spec/dummy/.gitignore +1 -0
  79. data/spec/dummy/.gitkeep +0 -0
  80. data/spec/dummy/.metrics +4 -0
  81. data/spec/dummy/lib/.gitkeep +0 -0
  82. data/spec/dummy/spec/.gitkeep +0 -0
  83. data/spec/{resources/yml → fixtures}/20090630.yml +1 -1
  84. data/spec/{resources/yml → fixtures}/hotspots/flog.yml +0 -0
  85. data/spec/{resources/yml → fixtures}/hotspots/generator.yml +0 -0
  86. data/spec/{resources/yml → fixtures}/hotspots/generator_analysis.yml +0 -0
  87. data/spec/{resources/yml → fixtures}/hotspots/reek.yml +0 -0
  88. data/spec/{resources/yml → fixtures}/hotspots/roodi.yml +0 -0
  89. data/spec/{resources/yml → fixtures}/hotspots/saikuro.yml +0 -0
  90. data/spec/{resources/yml → fixtures}/hotspots/several_metrics.yml +0 -0
  91. data/spec/{resources/yml → fixtures}/hotspots/stats.yml +0 -0
  92. data/spec/{resources/yml → fixtures}/hotspots/three_metrics_on_same_file.yml +0 -0
  93. data/spec/{resources → fixtures}/line_numbers/foo.rb +0 -0
  94. data/spec/{resources → fixtures}/line_numbers/module.rb +0 -0
  95. data/spec/{resources → fixtures}/line_numbers/module_surrounds_class.rb +0 -0
  96. data/spec/{resources → fixtures}/line_numbers/two_classes.rb +0 -0
  97. data/spec/{resources/yml → fixtures}/metric_missing.yml +0 -0
  98. data/spec/{resources → fixtures}/saikuro/app/controllers/sessions_controller.rb_cyclo.html +0 -0
  99. data/spec/{resources → fixtures}/saikuro/app/controllers/users_controller.rb_cyclo.html +0 -0
  100. data/spec/{resources → fixtures}/saikuro/index_cyclo.html +0 -0
  101. data/spec/{resources → fixtures}/saikuro_sfiles/thing.rb_cyclo.html +0 -0
  102. data/spec/metric_fu/configuration_spec.rb +1 -1
  103. data/spec/metric_fu/data_structures/line_numbers_spec.rb +13 -11
  104. data/spec/metric_fu/formatter/html_spec.rb +2 -2
  105. data/spec/metric_fu/gem_version_spec.rb +14 -0
  106. data/spec/metric_fu/loader_spec.rb +12 -0
  107. data/spec/metric_fu/metrics/base_template_spec.rb +9 -7
  108. data/spec/metric_fu/metrics/cane/cane_spec.rb +7 -7
  109. data/spec/metric_fu/metrics/churn/churn_spec.rb +1 -1
  110. data/spec/metric_fu/metrics/flay/flay_grapher_spec.rb +2 -2
  111. data/spec/metric_fu/metrics/flay/flay_spec.rb +2 -2
  112. data/spec/metric_fu/metrics/flog/flog_grapher_spec.rb +3 -3
  113. data/spec/metric_fu/metrics/generator_spec.rb +1 -35
  114. data/spec/metric_fu/metrics/graph_spec.rb +7 -24
  115. data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +2 -2
  116. data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +2 -2
  117. data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +5 -5
  118. data/spec/metric_fu/metrics/hotspots/hotspots_spec.rb +2 -3
  119. data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_grapher_spec.rb +2 -2
  120. data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_spec.rb +1 -1
  121. data/spec/metric_fu/metrics/rcov/rcov_grapher_spec.rb +2 -2
  122. data/spec/metric_fu/metrics/rcov/rcov_spec.rb +1 -4
  123. data/spec/metric_fu/metrics/reek/reek_grapher_spec.rb +2 -2
  124. data/spec/metric_fu/metrics/reek/reek_spec.rb +1 -1
  125. data/spec/metric_fu/metrics/roodi/roodi_grapher_spec.rb +2 -2
  126. data/spec/metric_fu/metrics/roodi/roodi_spec.rb +3 -3
  127. data/spec/metric_fu/metrics/saikuro/saikuro_spec.rb +14 -10
  128. data/spec/metric_fu/metrics/stats/stats_grapher_spec.rb +2 -2
  129. data/spec/metric_fu/reporting/graphs/{engines/bluff_spec.rb → grapher_spec.rb} +8 -2
  130. data/spec/{run_spec.rb → metric_fu/run_spec.rb} +8 -13
  131. data/spec/spec_helper.rb +30 -5
  132. data/spec/support/deferred_garbaged_collection.rb +34 -0
  133. data/spec/support/helper_methods.rb +1 -15
  134. data/spec/support/suite.rb +4 -24
  135. data/spec/support/test_fixtures.rb +39 -0
  136. data/spec/support/timeout.rb +7 -0
  137. metadata +129 -104
  138. metadata.gz.sig +1 -0
  139. data/lib/metric_fu/metrics/cane/cane_bluff_grapher.rb +0 -16
  140. data/lib/metric_fu/metrics/cane/cane_gchart_grapher.rb +0 -25
  141. data/lib/metric_fu/metrics/flay/flay_bluff_grapher.rb +0 -16
  142. data/lib/metric_fu/metrics/flay/flay_gchart_grapher.rb +0 -20
  143. data/lib/metric_fu/metrics/flog/flog_bluff_grapher.rb +0 -17
  144. data/lib/metric_fu/metrics/flog/flog_gchart_grapher.rb +0 -28
  145. data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices_bluff_grapher.rb +0 -16
  146. data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices_gchart_grapher.rb +0 -27
  147. data/lib/metric_fu/metrics/rcov/rcov_bluff_grapher.rb +0 -16
  148. data/lib/metric_fu/metrics/rcov/rcov_gchart_grapher.rb +0 -22
  149. data/lib/metric_fu/metrics/reek/reek_bluff_grapher.rb +0 -16
  150. data/lib/metric_fu/metrics/reek/reek_gchart_grapher.rb +0 -30
  151. data/lib/metric_fu/metrics/roodi/roodi_bluff_grapher.rb +0 -16
  152. data/lib/metric_fu/metrics/roodi/roodi_gchart_grapher.rb +0 -20
  153. data/lib/metric_fu/metrics/stats/stats_bluff_grapher.rb +0 -17
  154. data/lib/metric_fu/metrics/stats/stats_gchart_grapher.rb +0 -27
  155. data/lib/metric_fu/reporting/graphs/engines/bluff.rb +0 -33
  156. data/lib/metric_fu/reporting/graphs/engines/gchart.rb +0 -72
  157. data/lib/metric_fu/reporting/graphs/engines/init.rb +0 -19
  158. data/lib/metric_fu_requires.rb +0 -63
  159. data/spec/metric_fu/reporting/graphs/engines/gchart_spec.rb +0 -161
@@ -1,19 +0,0 @@
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
19
- end
@@ -1,63 +0,0 @@
1
- # Used to find which version, if any, of a gem to use when running command-line tools
2
- module MetricFu
3
- module MetricVersion
4
- extend self
5
-
6
- # @return [Array] rcov version if running rcov
7
- # Rcov is not a dependency in the gemspec
8
- # but is available to be shelled out
9
- def rcov
10
- ['~> 0.8']
11
- end
12
-
13
- # @example MetricFu::MetricVersion.flog will return the gem version of Flog to require
14
- # @return [nil] when the metric_fu gem dependency isn't specified
15
- # @return [Array] represenation of the metric_fu gem dependency if specified
16
- # in the gemspec.
17
- # Will raise method missing if :version_for is falsy
18
- # @see gems
19
- def method_missing(method,*args,&block)
20
- if (gem_version = version_for(method.to_s))
21
- gem_version != [] ? gem_version : nil
22
- else
23
- super
24
- end
25
- end
26
-
27
- private
28
-
29
- # Generates and returns an abstract syntax tree from the gemspec
30
- # @return [Sexp]
31
- def ast
32
- require 'ruby_parser'
33
- parser = RubyParser.new
34
- parser.parse(gemspec)
35
- end
36
-
37
-
38
- # Uses the ast to find all the specified runtime dependencies and their version requirements
39
- # @return Array<Array<gem_name,gem_version>>, where gem_name is a string and gem_version is an Array
40
- def gems
41
- @gems ||= ast.find{|node| node[0] == :iter}.
42
- find{|node| node[0] == :block}. # in the specification block
43
- select{|node| node[0] == :call }. # select all the methods
44
- select{|node| node[2] == :add_runtime_dependency }. # that are :add_runtime_dependency
45
- map{|node| [ # return a mapped array of
46
- node[3][1].downcase.sub('metric_fu-',''), # the downcased gem name (with any metric_fu- prefix removed)
47
- Array(Array(node[4])[1..-1]).map{|node|node[1]} # and an Array of the specified gem version(s)
48
- ]}
49
- end
50
-
51
- # @return Array<String> where the strings are valid gem version requires
52
- # The Array is empty if no gem version is specified
53
- def version_for(gem_name)
54
- node = gems.find{|node|node[0] == gem_name.downcase} # find the gem in the ast with the given downcased name
55
- node && node[1] # if found, return its version specification
56
- end
57
-
58
- # Read in the contents of the gemspec
59
- def gemspec
60
- File.read(File.expand_path('../../metric_fu.gemspec', __FILE__))
61
- end
62
- end
63
- end
@@ -1,161 +0,0 @@
1
- require "spec_helper"
2
- require 'googlecharts'
3
-
4
- describe MetricFu::Grapher do
5
- describe "require_graphing_gem" do
6
- it "should give a warning if trying to use gchart but gem is not installed" do
7
- MetricFu.configuration.configure_graph_engine(:gchart)
8
- MetricFu::Grapher.should_receive(:require).with('gchart').and_raise(LoadError)
9
- MetricFu::Grapher.should_receive(:mf_log).with(/If you want to use google charts/)
10
- MetricFu::Grapher.require_graphing_gem
11
- end
12
- end
13
- end
14
-
15
- describe MetricFu::GchartGrapher do
16
- describe "determine_y_axis_scale" do
17
- it "should set defaults when empty array" do
18
- grapher = Object.new.extend(MetricFu::GchartGrapher)
19
- grapher.determine_y_axis_scale([])
20
- grapher.instance_variable_get(:@max_value).should == 10
21
- grapher.instance_variable_get(:@yaxis).should == [0, 2, 4, 6, 8, 10]
22
- end
23
-
24
- it "should set max value of the graph above largest value" do
25
- grapher = Object.new.extend(MetricFu::GchartGrapher)
26
- grapher.determine_y_axis_scale([19])
27
- grapher.instance_variable_get(:@max_value).should == 20
28
-
29
- grapher.determine_y_axis_scale([20])
30
- grapher.instance_variable_get(:@max_value).should == 25
31
- end
32
- end
33
- end
34
-
35
- describe "Gchart graphers" do
36
- before :each do
37
- MetricFu.configuration.configure_graph_engine(:gchart)
38
- end
39
- def output_directory
40
- directory('output_directory')
41
- end
42
-
43
- describe "FlayGchartGrapher graph! method" do
44
- it "should set static values for graph" do
45
- grapher = FlayGchartGrapher.new
46
- expected = {
47
- :size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
48
- :title => URI.encode("Flay: duplication"),
49
- :axis_with_labels => 'x,y',
50
- :format => 'file',
51
- :filename => File.join(output_directory, 'flay.png'),
52
- }
53
- Gchart.should_receive(:line).with(hash_including(expected))
54
- grapher.graph!
55
- end
56
- end
57
-
58
- describe "FlogGchartGrapher graph! method" do
59
- it "should set static values for graph" do
60
- grapher = FlogGchartGrapher.new
61
- expected = {
62
- :size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
63
- :title => URI.encode("Flog: code complexity"),
64
- :stacked => false,
65
- :bar_colors => MetricFu::GchartGrapher::COLORS[0..1],
66
- :legend => ['average', 'top 5% average'],
67
- :custom => "chdlp=t",
68
- :axis_with_labels => 'x,y',
69
- :format => 'file',
70
- :filename => File.join(output_directory, 'flog.png'),
71
- }
72
- Gchart.should_receive(:line).with(hash_including(expected))
73
- grapher.graph!
74
- end
75
- end
76
-
77
- describe "RcovGchartGrapher graph! method" do
78
- it "should set static values for graph" do
79
- grapher = RcovGchartGrapher.new
80
- expected = {
81
- :size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
82
- :title => URI.encode("Rcov: code coverage"),
83
- :max_value => 101,
84
- :axis_with_labels => 'x,y',
85
- :axis_labels => [grapher.labels.values, [0,20,40,60,80,100]],
86
- :format => 'file',
87
- :filename => File.join(output_directory, 'rcov.png'),
88
- }
89
- Gchart.should_receive(:line).with(hash_including(expected))
90
- grapher.graph!
91
- end
92
- end
93
-
94
- describe "ReekGchartGrapher graph! method" do
95
- it "should set static values for graph" do
96
- grapher = ReekGchartGrapher.new
97
- expected = {
98
- :size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
99
- :title => URI.encode("Reek: code smells"),
100
- :stacked => false,
101
- :bar_colors => MetricFu::GchartGrapher::COLORS,
102
- :axis_with_labels => 'x,y',
103
- :format => 'file',
104
- :filename => File.join(output_directory, 'reek.png'),
105
- }
106
- Gchart.should_receive(:line).with(hash_including(expected))
107
- grapher.graph!
108
- end
109
- end
110
-
111
- describe "RoodiGchartGrapher graph! method" do
112
- it "should set static values for graph" do
113
- grapher = RoodiGchartGrapher.new
114
- expected = {
115
- :size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
116
- :title => URI.encode("Roodi: potential design problems"),
117
- :axis_with_labels => 'x,y',
118
- :format => 'file',
119
- :filename => File.join(output_directory, 'roodi.png'),
120
- }
121
- Gchart.should_receive(:line).with(hash_including(expected))
122
- grapher.graph!
123
- end
124
- end
125
-
126
- describe "StatsGchartGrapher graph! method" do
127
- it "should set static values for graph" do
128
- grapher = StatsGchartGrapher.new
129
- expected = {
130
- :size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
131
- :title => URI.encode("Stats: LOC & LOT"),
132
- :bar_colors => MetricFu::GchartGrapher::COLORS[0..1],
133
- :legend => ['Lines of code', 'Lines of test'],
134
- :custom => "chdlp=t",
135
- :axis_with_labels => 'x,y',
136
- :format => 'file',
137
- :filename => File.join(output_directory, 'stats.png'),
138
- }
139
- Gchart.should_receive(:line).with(hash_including(expected))
140
- grapher.graph!
141
- end
142
- end
143
-
144
- describe "RailsBestPracticesGchartGrapher graph! method" do
145
- it "should set static values for graph" do
146
- grapher = RailsBestPracticesGchartGrapher.new
147
- expected = {
148
- :size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
149
- :title => URI.encode("Rails Best Practices: design problems"),
150
- :bar_colors => MetricFu::GchartGrapher::COLORS[0..1],
151
- :legend => ['Problems'],
152
- :custom => "chdlp=t",
153
- :axis_with_labels => 'x,y',
154
- :format => 'file',
155
- :filename => File.join(output_directory, 'rails_best_practices.png'),
156
- }
157
- Gchart.should_receive(:line).with(hash_including(expected))
158
- grapher.graph!
159
- end
160
- end
161
- end