Commit 6ffaed106a2066b5371e6a2ee45a337221cb4fab
Committed by
João M. M. da Silva
1 parent
9766d9cc
Exists in
master
and in
29 other branches
[Mezuro] Completed base_tool model and changed metric model and fixtures.
Showing
8 changed files
with
57 additions
and
49 deletions
Show diff stats
plugins/mezuro/lib/kalibro/base_tool.rb
... | ... | @@ -16,7 +16,7 @@ class Kalibro::BaseTool < Kalibro::Model |
16 | 16 | end |
17 | 17 | |
18 | 18 | def supported_metric=(value) |
19 | - @supported_metric = Kalibro::NativeMetric.to_objects_array value | |
19 | + @supported_metric = Kalibro::Metric.to_objects_array value | |
20 | 20 | end |
21 | 21 | |
22 | 22 | def supported_metrics | ... | ... |
plugins/mezuro/lib/kalibro/compound_metric.rb
plugins/mezuro/lib/kalibro/metric.rb
1 | 1 | class Kalibro::Metric < Kalibro::Model |
2 | 2 | |
3 | - attr_accessor :name, :scope, :description | |
3 | + attr_accessor :name, :compound, :scope, :description, :script, :origin, :language | |
4 | + | |
5 | + def languages | |
6 | + @language | |
7 | + end | |
8 | + | |
9 | + def languages=(languages) | |
10 | + @language = languages | |
11 | + end | |
12 | + | |
13 | + def language=(value) | |
14 | + @language = Kalibro::Model.to_objects_array value | |
15 | + end | |
4 | 16 | |
5 | 17 | end | ... | ... |
plugins/mezuro/lib/kalibro/native_metric.rb
... | ... | @@ -1,17 +0,0 @@ |
1 | -class Kalibro::NativeMetric < Kalibro::Metric | |
2 | - | |
3 | - attr_accessor :origin, :language | |
4 | - | |
5 | - def languages | |
6 | - @language | |
7 | - end | |
8 | - | |
9 | - def languages=(languages) | |
10 | - @language = languages | |
11 | - end | |
12 | - | |
13 | - def language=(value) | |
14 | - @language = Kalibro::Model.to_objects_array value | |
15 | - end | |
16 | - | |
17 | -end |
plugins/mezuro/test/fixtures/base_tool_fixtures.rb
1 | -require File.dirname(__FILE__) + '/native_metric_fixtures' | |
1 | +require File.dirname(__FILE__) + '/metric_fixtures' | |
2 | 2 | |
3 | 3 | class BaseToolFixtures |
4 | 4 | |
... | ... | @@ -6,10 +6,14 @@ class BaseToolFixtures |
6 | 6 | Kalibro::BaseTool.new base_tool_hash |
7 | 7 | end |
8 | 8 | |
9 | - def self.base_tool_hash | |
10 | - {:name => 'Analizo', :supported_metric => [ | |
11 | - NativeMetricFixtures.total_cof_hash, | |
12 | - NativeMetricFixtures.amloc_hash]} | |
9 | + def self.base_tool_hash | |
10 | + { | |
11 | + :name => 'Analizo', | |
12 | + :supported_metric => [ | |
13 | + MetricFixtures.total_cof_hash, | |
14 | + MetricFixtures.amloc_hash], | |
15 | + :collector_class_name => "org.analizo.AnalizoMetricCollector" | |
16 | + } | |
13 | 17 | end |
14 | 18 | |
15 | 19 | end | ... | ... |
plugins/mezuro/test/fixtures/compound_metric_fixtures.rb
... | ... | @@ -1,11 +0,0 @@ |
1 | -class CompoundMetricFixtures | |
2 | - | |
3 | - def self.compound_metric | |
4 | - Kalibro::CompoundMetric.new compound_metric_hash | |
5 | - end | |
6 | - | |
7 | - def self.compound_metric_hash | |
8 | - {:name => 'Structural Complexity', :scope => 'CLASS', :script => 'return 42;', :description => 'Calculate the Structural Complexity of the Code'} | |
9 | - end | |
10 | - | |
11 | -end |
... | ... | @@ -0,0 +1,27 @@ |
1 | +class MetricFixtures | |
2 | + | |
3 | + def self.compound_metric | |
4 | + Kalibro::Metric.new compound_metric_hash | |
5 | + end | |
6 | + | |
7 | + def self.compound_metric_hash | |
8 | + {:name => 'Structural Complexity', :compound => true, :scope => 'CLASS', :script => 'return 42;', :description => 'Calculate the Structural Complexity of the Code'} | |
9 | + end | |
10 | + | |
11 | + def self.total_cof | |
12 | + Kalibro::Metric.new total_cof_hash | |
13 | + end | |
14 | + | |
15 | + def self.total_cof_hash | |
16 | + {:name => 'Total Coupling Factor', :compound => false, :scope => 'APPLICATION', :origin => 'Analizo', :language => ['JAVA']} | |
17 | + end | |
18 | + | |
19 | + def self.amloc | |
20 | + Kalibro::Metric.new amloc_hash | |
21 | + end | |
22 | + | |
23 | + def self.amloc_hash | |
24 | + {:name => 'Average Method LOC', :compound => false, :scope => 'CLASS', :origin => 'Analizo', :language => ['JAVA']} | |
25 | + end | |
26 | + | |
27 | +end | ... | ... |
plugins/mezuro/test/unit/kalibro/base_tool_test.rb
... | ... | @@ -12,14 +12,16 @@ class BaseToolTest < ActiveSupport::TestCase |
12 | 12 | should 'create base tool from hash' do |
13 | 13 | assert_equal @base_tool.name, Kalibro::BaseTool.new(@hash).name |
14 | 14 | end |
15 | - | |
16 | - should 'convert base tool to hash' do | |
17 | - assert_equal @hash, @base_tool.to_hash | |
18 | - end | |
15 | + | |
16 | +# Mezuro will not send a base_tool hash back to Kalibro | |
17 | +# | |
18 | +# should 'convert base tool to hash' do | |
19 | +# assert_equal @hash, @base_tool.to_hash | |
20 | +# end | |
19 | 21 | |
20 | 22 | should 'get base tool names' do |
21 | 23 | names = ['Analizo', 'Checkstyle'] |
22 | - Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool_names).returns({:base_tool_name => names}) | |
24 | + Kalibro::BaseTool.expects(:request).with("BaseTool", :all_base_tool_names).returns({:base_tool_name => names}) | |
23 | 25 | assert_equal names, Kalibro::BaseTool.all_names |
24 | 26 | end |
25 | 27 | |
... | ... | @@ -29,8 +31,4 @@ class BaseToolTest < ActiveSupport::TestCase |
29 | 31 | assert_equal @base_tool.name, Kalibro::BaseTool.find_by_name(@base_tool.name).name |
30 | 32 | end |
31 | 33 | |
32 | - should 'get base tool metrics' do | |
33 | - assert_equal @base_tool.supported_metrics[0].name, @base_tool.metric('Total Coupling Factor').name | |
34 | - end | |
35 | - | |
36 | 34 | end | ... | ... |