metric_fu 4.4.0 → 4.4.1
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 +4 -4
- data/HISTORY.md +12 -0
- data/Rakefile +0 -1
- data/bin/mf-roodi +2 -2
- data/checksum/metric_fu-4.4.0.gem.sha512 +1 -1
- data/gem_tasks/build.rake +24 -22
- data/lib/metric_fu/configuration.rb +0 -10
- data/lib/metric_fu/data_structures/line_numbers.rb +2 -0
- data/lib/metric_fu/initial_requires.rb +0 -1
- data/lib/metric_fu/metric.rb +1 -1
- data/lib/metric_fu/metrics/churn/churn_hotspot.rb +10 -11
- data/lib/metric_fu/metrics/flay/flay_hotspot.rb +7 -20
- data/lib/metric_fu/metrics/flog/flog_hotspot.rb +7 -14
- data/lib/metric_fu/metrics/generator.rb +0 -14
- data/lib/metric_fu/metrics/graph.rb +50 -15
- data/lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb +21 -27
- data/lib/metric_fu/metrics/hotspots/analysis/analyzer_tables.rb +0 -6
- data/lib/metric_fu/metrics/hotspots/analysis/grouping.rb +2 -17
- data/lib/metric_fu/metrics/hotspots/analysis/groupings.rb +1 -9
- data/lib/metric_fu/metrics/hotspots/analysis/problems.rb +3 -7
- data/lib/metric_fu/metrics/hotspots/analysis/ranking.rb +3 -7
- data/lib/metric_fu/metrics/hotspots/analysis/rankings.rb +6 -6
- data/lib/metric_fu/metrics/hotspots/analysis/record.rb +3 -12
- data/lib/metric_fu/metrics/hotspots/analysis/scoring_strategies.rb +9 -14
- data/lib/metric_fu/metrics/hotspots/analysis/table.rb +3 -43
- data/lib/metric_fu/metrics/hotspots/hotspot.rb +59 -7
- data/lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb +1 -36
- data/lib/metric_fu/metrics/hotspots/hotspots.rb +0 -4
- data/lib/metric_fu/metrics/rails_best_practices/init.rb +0 -1
- data/lib/metric_fu/metrics/rcov/rcov_hotspot.rb +6 -13
- data/lib/metric_fu/metrics/reek/reek_hotspot.rb +6 -87
- data/lib/metric_fu/metrics/roodi/roodi_hotspot.rb +7 -18
- data/lib/metric_fu/metrics/saikuro/saikuro.rb +0 -5
- data/lib/metric_fu/metrics/saikuro/saikuro_hotspot.rb +7 -14
- data/lib/metric_fu/metrics/stats/stats_hotspot.rb +7 -7
- data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +2 -1
- data/lib/metric_fu/utility.rb +20 -0
- data/lib/metric_fu/version.rb +1 -1
- data/metric_fu.gemspec +6 -6
- data/spec/metric_fu/configuration_spec.rb +2 -21
- data/spec/metric_fu/metrics/flog/flog_grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/generator_spec.rb +0 -14
- data/spec/metric_fu/metrics/graph_spec.rb +7 -6
- data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +113 -0
- data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +71 -0
- data/spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb +3 -12
- data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +100 -0
- data/spec/metric_fu/metrics/hotspots/analysis/table_spec.rb +1 -30
- data/spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb +3 -442
- data/spec/metric_fu/metrics/rcov/rcov_spec.rb +2 -0
- data/spec/metric_fu/metrics/saikuro/saikuro_spec.rb +0 -11
- data/spec/resources/yml/hotspots/flog.yml +86 -0
- data/spec/resources/yml/hotspots/reek.yml +14 -0
- data/spec/resources/yml/hotspots/roodi.yml +13 -0
- data/spec/resources/yml/hotspots/saikuro.yml +27 -0
- data/spec/resources/yml/hotspots/several_metrics.yml +47 -0
- data/spec/resources/yml/hotspots/stats.yml +4 -0
- data/spec/resources/yml/hotspots/three_metrics_on_same_file.yml +36 -0
- data/spec/support/helper_methods.rb +13 -0
- metadata +62 -21
- data/lib/metric_fu/data_structures/careful_array.rb +0 -11
- data/lib/metric_fu/metrics/hotspots/analysis/code_issue.rb +0 -109
- data/lib/metric_fu/parser_ext.rb +0 -15
- data/lib/metric_fu/sexp_ext.rb +0 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5b6391c40e351ab9265635b6b35f32662bbe450c
|
|
4
|
+
data.tar.gz: eb534c71875d84de4e477332a365de843ec7dfb3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a9d4acd5a6b37a5ce18219ff9e8e363395e7f8c65f0fcaae138f0c6660172eefd49006371df55fd1cad2984e30cd91ccc64aaf6d7d1e170d1c37d2e6d3c9e12
|
|
7
|
+
data.tar.gz: c6dd298de619f6628ae7c5b46026bc7819ff38a9912f1bdd1e13da5e7b70fee82446397b3e6eb08fe602db6e3a7a78f395739874d95e357a6efda95e9eaa5acc
|
data/HISTORY.md
CHANGED
|
@@ -10,6 +10,18 @@ As such, a _Feature_ would map to either major or minor. A _bug fix_ to a patch.
|
|
|
10
10
|
* Fixes
|
|
11
11
|
* Misc
|
|
12
12
|
|
|
13
|
+
### MetricFu [4.4.1 / 2013-08-29](https://github.com/metricfu/metric_fu/compare/v4.4.0...v4.4.1)
|
|
14
|
+
|
|
15
|
+
* Features
|
|
16
|
+
* Fixes
|
|
17
|
+
* No longer consider an ampty sexp in LineNumbers an error. A file with only comments is empty of code. (Benjamin Fleischer)
|
|
18
|
+
* Prevent encoding errors when using syntax highlighting via coderay (Benjamin Fleischer #120, #131)
|
|
19
|
+
* Misc
|
|
20
|
+
* Update dependencies: cane, flay, flog, reek; switch from metric_fu-roodi to revived roodi (Benjamin Fleischer #130)
|
|
21
|
+
* Update to fully ruby_parser-compatible rails_best_practices (Benjamin Fleischer #133)
|
|
22
|
+
* Hotspots: remove legacy test code, reduce duplication (Benjamin Fleischer, #127, #77)
|
|
23
|
+
* Remove a lot of dead code (Benjamin Fleischer, #77)
|
|
24
|
+
|
|
13
25
|
### MetricFu 4.4.0 / 2013-08-15
|
|
14
26
|
|
|
15
27
|
* Features
|
data/Rakefile
CHANGED
data/bin/mf-roodi
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
c01694dc4a374806bd6cfaf5091808d223db1ea07a85d90a9749ed8e603c3abee283a36a6aacde81072b7c0ec2eec64f85d977caa6cd69687a532040a2137bd4
|
data/gem_tasks/build.rake
CHANGED
|
@@ -2,37 +2,25 @@
|
|
|
2
2
|
desc 'override bundler release task'
|
|
3
3
|
task :release => ['build'] do
|
|
4
4
|
STDOUT.puts "Running Bundler Release Task Override"
|
|
5
|
+
Rake::Task['checksum'].invoke
|
|
5
6
|
end
|
|
6
7
|
require 'bundler/gem_tasks'
|
|
7
8
|
|
|
8
9
|
GEMSPEC = Bundler::GemHelper.gemspec
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
# GEMSPEC = Gem::Specification.load('metric_fu.gemspec')
|
|
15
|
-
#
|
|
16
|
-
# Gem::PackageTask.new(GEMSPEC) do |pkg|
|
|
17
|
-
# pkg.need_tar = false
|
|
18
|
-
# pkg.need_zip = false
|
|
19
|
-
# end
|
|
20
|
-
|
|
21
|
-
# gem signing
|
|
22
|
-
# desc 'Builds and signs a new Gem'
|
|
23
|
-
# task :build => [:gem] do
|
|
24
|
-
# name = "#{GEMSPEC.name}-#{GEMSPEC.version}.gem"
|
|
25
|
-
# path = File.join(File.expand_path('../../pkg', __FILE__), name)
|
|
26
|
-
#
|
|
27
|
-
# sh("gem sign #{path}")
|
|
28
|
-
#
|
|
29
|
-
# Rake::Task['checksum'].invoke
|
|
30
|
-
# end
|
|
11
|
+
desc 'Builds and signs a new Gem'
|
|
12
|
+
task :signed_build => [:build] do
|
|
13
|
+
name = "#{GEMSPEC.name}-#{GEMSPEC.version}.gem"
|
|
14
|
+
path = File.join(File.expand_path('../../pkg', __FILE__), name)
|
|
31
15
|
|
|
16
|
+
sh("gem sign #{path}")
|
|
17
|
+
|
|
18
|
+
Rake::Task['checksum'].invoke
|
|
19
|
+
end
|
|
32
20
|
require 'digest/sha2'
|
|
33
21
|
|
|
34
22
|
desc 'Creates a SHA512 checksum of the current version'
|
|
35
|
-
task :checksum
|
|
23
|
+
task :checksum do
|
|
36
24
|
checksums = File.expand_path('../../checksum', __FILE__)
|
|
37
25
|
name = "#{GEMSPEC.name}-#{GEMSPEC.version}.gem"
|
|
38
26
|
path = File.join(File.expand_path('../../pkg', __FILE__), name)
|
|
@@ -44,3 +32,17 @@ task :checksum => ['build'] do
|
|
|
44
32
|
handle.write(checksum)
|
|
45
33
|
end
|
|
46
34
|
end
|
|
35
|
+
|
|
36
|
+
desc 'Creates a Git tag for the current version'
|
|
37
|
+
task :tag do
|
|
38
|
+
version = MetricFu::VERSION
|
|
39
|
+
|
|
40
|
+
sh %Q{git tag -a -m "Version #{version}" -s #{version}}
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
desc 'Extracts TODO tags and the likes'
|
|
44
|
+
task :todo do
|
|
45
|
+
regex = %w{NOTE: FIXME: TODO: THINK: @todo}.join('|')
|
|
46
|
+
|
|
47
|
+
sh "ack '#{regex}' lib"
|
|
48
|
+
end
|
|
@@ -19,16 +19,6 @@ module MetricFu
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
# TODO: Remove this method. It is really a test concern for identifying
|
|
23
|
-
# metrics turned off for environmental reasons
|
|
24
|
-
def self.mri_only_metrics
|
|
25
|
-
if MetricFu.configuration.mri?
|
|
26
|
-
[]
|
|
27
|
-
else
|
|
28
|
-
[:cane, :flog, :rails_best_practices]
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
22
|
# = Configuration
|
|
33
23
|
#
|
|
34
24
|
# The Configuration class, as it sounds, provides methods for
|
data/lib/metric_fu/metric.rb
CHANGED
|
@@ -20,7 +20,7 @@ module MetricFu
|
|
|
20
20
|
@libraries.each {|library| require(library) }
|
|
21
21
|
self.activated = true
|
|
22
22
|
rescue LoadError => e
|
|
23
|
-
|
|
23
|
+
mf_log "#{name} metric not activated, #{e.message}"
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
# @return metric name [Symbol]
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
class ChurnHotspot < MetricFu::Hotspot
|
|
2
|
-
include MetricFu::HotspotScoringStrategies
|
|
1
|
+
class MetricFu::ChurnHotspot < MetricFu::Hotspot
|
|
3
2
|
|
|
4
3
|
COLUMNS = %w{times_changed}
|
|
5
4
|
|
|
@@ -11,15 +10,19 @@ class ChurnHotspot < MetricFu::Hotspot
|
|
|
11
10
|
:churn
|
|
12
11
|
end
|
|
13
12
|
|
|
14
|
-
def
|
|
15
|
-
|
|
13
|
+
def map_strategy
|
|
14
|
+
:present
|
|
16
15
|
end
|
|
17
16
|
|
|
18
|
-
def
|
|
19
|
-
|
|
17
|
+
def reduce_strategy
|
|
18
|
+
:sum
|
|
20
19
|
end
|
|
21
20
|
|
|
22
|
-
def
|
|
21
|
+
def score_strategy
|
|
22
|
+
:calculate_score
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def calculate_score(metric_ranking, item)
|
|
23
26
|
flat_churn_score = 0.50
|
|
24
27
|
metric_ranking.scored?(item) ? flat_churn_score : 0
|
|
25
28
|
end
|
|
@@ -39,8 +42,4 @@ class ChurnHotspot < MetricFu::Hotspot
|
|
|
39
42
|
"detected high level of churn (changed #{group[0].times_changed} times)"
|
|
40
43
|
end
|
|
41
44
|
|
|
42
|
-
def present_group_details(group)
|
|
43
|
-
"detected high level of churn (changed #{group[0].times_changed} times)"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
45
|
end
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
class FlayHotspot < MetricFu::Hotspot
|
|
2
|
-
include MetricFu::HotspotScoringStrategies
|
|
1
|
+
class MetricFu::FlayHotspot < MetricFu::Hotspot
|
|
3
2
|
|
|
4
3
|
COLUMNS = %w{flay_reason flay_matching_reason}
|
|
5
4
|
|
|
@@ -11,16 +10,16 @@ class FlayHotspot < MetricFu::Hotspot
|
|
|
11
10
|
:flay
|
|
12
11
|
end
|
|
13
12
|
|
|
14
|
-
def
|
|
15
|
-
|
|
13
|
+
def map_strategy
|
|
14
|
+
:present
|
|
16
15
|
end
|
|
17
16
|
|
|
18
|
-
def
|
|
19
|
-
|
|
17
|
+
def reduce_strategy
|
|
18
|
+
:sum
|
|
20
19
|
end
|
|
21
20
|
|
|
22
|
-
def
|
|
23
|
-
|
|
21
|
+
def score_strategy
|
|
22
|
+
:percentile
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
def generate_records(data, table)
|
|
@@ -52,16 +51,4 @@ class FlayHotspot < MetricFu::Hotspot
|
|
|
52
51
|
"found #{occurences} code duplications"
|
|
53
52
|
end
|
|
54
53
|
|
|
55
|
-
def present_group_details(group)
|
|
56
|
-
occurences = group.size
|
|
57
|
-
message = "found #{occurences} code duplications<br/>"
|
|
58
|
-
group.each do |item|
|
|
59
|
-
problem = item.data["flay_reason"]
|
|
60
|
-
problem = problem.gsub(/^[0-9]*\)/,'')
|
|
61
|
-
problem = problem.gsub(/files\:/,' <br> files:')
|
|
62
|
-
message << "* #{problem}<br/>"
|
|
63
|
-
end
|
|
64
|
-
message
|
|
65
|
-
end
|
|
66
|
-
|
|
67
54
|
end
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
class FlogHotspot < MetricFu::Hotspot
|
|
2
|
-
include MetricFu::HotspotScoringStrategies
|
|
1
|
+
class MetricFu::FlogHotspot < MetricFu::Hotspot
|
|
3
2
|
|
|
4
3
|
COLUMNS = %w{score}
|
|
5
4
|
|
|
@@ -11,16 +10,16 @@ class FlogHotspot < MetricFu::Hotspot
|
|
|
11
10
|
:flog
|
|
12
11
|
end
|
|
13
12
|
|
|
14
|
-
def
|
|
15
|
-
|
|
13
|
+
def map_strategy
|
|
14
|
+
:score
|
|
16
15
|
end
|
|
17
16
|
|
|
18
|
-
def
|
|
19
|
-
|
|
17
|
+
def reduce_strategy
|
|
18
|
+
:average
|
|
20
19
|
end
|
|
21
20
|
|
|
22
|
-
def
|
|
23
|
-
|
|
21
|
+
def score_strategy
|
|
22
|
+
:identity
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
def generate_records(data, table)
|
|
@@ -46,10 +45,4 @@ class FlogHotspot < MetricFu::Hotspot
|
|
|
46
45
|
"#{"average " if occurences > 1}complexity is %.1f" % complexity
|
|
47
46
|
end
|
|
48
47
|
|
|
49
|
-
def present_group_details(group)
|
|
50
|
-
occurences = group.size
|
|
51
|
-
complexity = get_mean(group.column("score"))
|
|
52
|
-
"#{"average " if occurences > 1}complexity is %.1f" % complexity
|
|
53
|
-
end
|
|
54
|
-
|
|
55
48
|
end
|
|
@@ -54,20 +54,6 @@ module MetricFu
|
|
|
54
54
|
@generators << subclass
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
# Creates a new generator and returns the output of the
|
|
58
|
-
# #generate_result method. This is the typical way to
|
|
59
|
-
# generate a new MetricFu result. For more information see
|
|
60
|
-
# the #generate_result instance method.
|
|
61
|
-
#
|
|
62
|
-
# @params options Hash
|
|
63
|
-
# A currently unused hash to configure the Generator
|
|
64
|
-
#
|
|
65
|
-
# @see generate_result
|
|
66
|
-
def self.generate_result(options={})
|
|
67
|
-
generator = self.new(options)
|
|
68
|
-
generator.generate_result
|
|
69
|
-
end
|
|
70
|
-
|
|
71
57
|
# Provides the unqualified class name of an implemented concrete
|
|
72
58
|
# class, as a string. For example:
|
|
73
59
|
#
|
|
@@ -6,36 +6,71 @@ module MetricFu
|
|
|
6
6
|
|
|
7
7
|
class Graph
|
|
8
8
|
|
|
9
|
-
attr_accessor :
|
|
9
|
+
attr_accessor :graphers
|
|
10
10
|
|
|
11
11
|
def initialize
|
|
12
|
-
self.
|
|
12
|
+
self.graphers = []
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def add(graph_type, graph_engine, output_directory = MetricFu::Io::FileSystem.directory('output_directory'))
|
|
16
|
-
|
|
17
|
-
self.
|
|
16
|
+
grapher = grapher_from_type_and_engine(graph_type, graph_engine)
|
|
17
|
+
self.graphers.push grapher.new.tap{|g| g.output_directory = output_directory }
|
|
18
|
+
rescue NameError => e
|
|
19
|
+
mf_log "#{e.message} called in MetricFu::Graph.add with #{graph_type}"
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
|
|
21
23
|
def generate
|
|
22
|
-
return if self.
|
|
24
|
+
return if self.graphers.empty?
|
|
23
25
|
mf_log "Generating graphs"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
generate_graphs_for_files
|
|
27
|
+
graph!
|
|
28
|
+
rescue NameError => e
|
|
29
|
+
mf_log "#{e.message} called in MetricFu::Graph generate"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def grapher_from_type_and_engine(graph_type, graph_engine)
|
|
35
|
+
grapher_name = graph_type.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } + graph_engine.to_s.capitalize + "Grapher"
|
|
36
|
+
MetricFu.const_get(grapher_name)
|
|
37
|
+
end
|
|
38
|
+
def metric_files
|
|
39
|
+
Dir[File.join(MetricFu::Io::FileSystem.directory('data_directory'), '*.yml')].sort
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def generate_graphs_for_files
|
|
43
|
+
metric_files.each do |metric_file|
|
|
44
|
+
generate_graphs_for_file(metric_file)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def generate_graphs_for_file(metric_file)
|
|
49
|
+
mf_log "Generating graphs for #{metric_file}"
|
|
50
|
+
date_parts = year_month_day_from_filename(metric_file)
|
|
51
|
+
metrics = load_yaml_metric_file(metric_file)
|
|
52
|
+
|
|
53
|
+
build_graph(metrics, "#{date_parts[:m]}/#{date_parts[:d]}")
|
|
54
|
+
rescue NameError => e
|
|
55
|
+
mf_log "#{e.message} called in MetricFu::Graph.generate with #{metric_file}"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def load_yaml_metric_file(metric_file)
|
|
59
|
+
YAML.load(File.open(metric_file))
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def build_graph(metrics, sortable_prefix)
|
|
63
|
+
self.graphers.each do |grapher|
|
|
64
|
+
grapher.get_metrics(metrics, sortable_prefix)
|
|
32
65
|
end
|
|
33
|
-
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def graph!
|
|
69
|
+
self.graphers.each do |grapher|
|
|
34
70
|
grapher.graph!
|
|
35
71
|
end
|
|
36
72
|
end
|
|
37
73
|
|
|
38
|
-
private
|
|
39
74
|
def year_month_day_from_filename(path_to_file_with_date)
|
|
40
75
|
date = path_to_file_with_date.match(/\/(\d+).yml$/)[1]
|
|
41
76
|
{:y => date[0..3].to_i, :m => date[4..5].to_i, :d => date[6..7].to_i}
|
|
@@ -7,41 +7,35 @@ module MetricFu
|
|
|
7
7
|
@analyzer_tables = analyzer_tables
|
|
8
8
|
end
|
|
9
9
|
def worst_items
|
|
10
|
-
num = nil
|
|
11
10
|
worst_items = {}
|
|
12
|
-
worst_items[:files]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{:location => self.location(:file, worst_file),
|
|
16
|
-
:details => self.problems_with(:file, worst_file)}
|
|
17
|
-
array
|
|
18
|
-
end
|
|
19
|
-
worst_items[:classes] = @hotspot_rankings.worst_classes(num).inject([]) do |array, class_name|
|
|
20
|
-
location = self.location(:class, class_name)
|
|
21
|
-
array <<
|
|
22
|
-
{:location => location,
|
|
23
|
-
:details => self.problems_with(:class, class_name)}
|
|
24
|
-
array
|
|
25
|
-
end
|
|
26
|
-
worst_items[:methods] = @hotspot_rankings.worst_methods(num).inject([]) do |array, method_name|
|
|
27
|
-
location = self.location(:method, method_name)
|
|
28
|
-
array <<
|
|
29
|
-
{:location => location,
|
|
30
|
-
:details => self.problems_with(:method, method_name)}
|
|
31
|
-
array
|
|
32
|
-
end
|
|
11
|
+
worst_items[:files] = worst(@hotspot_rankings.worst_files, :file)
|
|
12
|
+
worst_items[:classes] = worst(@hotspot_rankings.worst_classes, :class)
|
|
13
|
+
worst_items[:methods] = worst(@hotspot_rankings.worst_methods, :method)
|
|
33
14
|
worst_items
|
|
34
15
|
end
|
|
16
|
+
|
|
35
17
|
private
|
|
36
|
-
|
|
18
|
+
|
|
19
|
+
# @param rankings [Array<MetricFu::HotspotRankings>]
|
|
20
|
+
# @param granularity [Symbol] one of :class, :method, :file
|
|
21
|
+
def worst(rankings,granularity)
|
|
22
|
+
rankings.map do |ranked_item_name|
|
|
23
|
+
location = location(granularity, ranked_item_name)
|
|
24
|
+
details = problems_with(granularity, ranked_item_name)
|
|
25
|
+
{:location => location, :details => details}
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# @todo redo as item,value, options = {}
|
|
37
30
|
# Note that the other option for 'details' is :detailed (this isn't
|
|
38
31
|
# at all clear from this method itself
|
|
39
|
-
def problems_with(item, value
|
|
32
|
+
def problems_with(item, value)
|
|
40
33
|
sub_table = get_sub_table(item, value)
|
|
41
34
|
#grouping = Ruport::Data::Grouping.new(sub_table, :by => 'metric')
|
|
42
35
|
grouping = get_grouping(sub_table, :by => 'metric')
|
|
43
|
-
MetricFu::HotspotProblems.new(grouping
|
|
36
|
+
MetricFu::HotspotProblems.new(grouping).problems
|
|
44
37
|
end
|
|
38
|
+
|
|
45
39
|
def location(item, value)
|
|
46
40
|
sub_table = get_sub_table(item, value)
|
|
47
41
|
assert_sub_table_has_data(item, sub_table, value)
|
|
@@ -64,14 +58,14 @@ module MetricFu
|
|
|
64
58
|
end
|
|
65
59
|
end
|
|
66
60
|
|
|
67
|
-
# just for testing
|
|
68
|
-
public :location, :problems_with
|
|
69
61
|
def get_sub_table(item, value)
|
|
70
62
|
tables = @analyzer_tables.tables_for(item)
|
|
71
63
|
tables[value]
|
|
72
64
|
end
|
|
65
|
+
|
|
73
66
|
def get_grouping(table, opts)
|
|
74
67
|
MetricFu::HotspotGroupings.new(table, opts).get_grouping
|
|
75
68
|
end
|
|
69
|
+
|
|
76
70
|
end
|
|
77
71
|
end
|