ruby-watchr 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/watchr/analysers/reek.rb +1 -1
- data/lib/watchr/file_analyse.rb +0 -2
- data/lib/watchr/version.rb +1 -1
- data/lib/watchr.rb +2 -2
- metadata +4 -7
- data/lib/watchr/rating.rb +0 -38
- data/spec/watchr/rating_spec.rb +0 -46
data/lib/watchr/file_analyse.rb
CHANGED
@@ -3,7 +3,6 @@ require 'watchr/metrics/reek/report'
|
|
3
3
|
require 'watchr/smells_collector'
|
4
4
|
require 'watchr/analysers/flog'
|
5
5
|
require 'watchr/analysers/reek'
|
6
|
-
require 'watchr/rating'
|
7
6
|
|
8
7
|
module Watchr
|
9
8
|
#
|
@@ -14,7 +13,6 @@ module Watchr
|
|
14
13
|
class FileAnalyse
|
15
14
|
include Analysers::Flog
|
16
15
|
include Analysers::Reek
|
17
|
-
include Rating
|
18
16
|
|
19
17
|
attr_reader :path
|
20
18
|
|
data/lib/watchr/version.rb
CHANGED
data/lib/watchr.rb
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Petr Janda
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-08-
|
17
|
+
date: 2012-08-08 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -99,7 +99,6 @@ files:
|
|
99
99
|
- lib/watchr/metrics/flog/report.rb
|
100
100
|
- lib/watchr/metrics/reek/report.rb
|
101
101
|
- lib/watchr/paths.rb
|
102
|
-
- lib/watchr/rating.rb
|
103
102
|
- lib/watchr/smell.rb
|
104
103
|
- lib/watchr/smell_builder.rb
|
105
104
|
- lib/watchr/smell_types.rb
|
@@ -116,7 +115,6 @@ files:
|
|
116
115
|
- spec/watchr/metrics/flay/report_spec.rb
|
117
116
|
- spec/watchr/metrics/flog/flog_report_spec.rb
|
118
117
|
- spec/watchr/paths_spec.rb
|
119
|
-
- spec/watchr/rating_spec.rb
|
120
118
|
- spec/watchr/smell_builder_spec.rb
|
121
119
|
- spec/watchr/smell_spec.rb
|
122
120
|
- spec/watchr/smells_collector_spec.rb
|
@@ -165,7 +163,6 @@ test_files:
|
|
165
163
|
- spec/watchr/metrics/flay/report_spec.rb
|
166
164
|
- spec/watchr/metrics/flog/flog_report_spec.rb
|
167
165
|
- spec/watchr/paths_spec.rb
|
168
|
-
- spec/watchr/rating_spec.rb
|
169
166
|
- spec/watchr/smell_builder_spec.rb
|
170
167
|
- spec/watchr/smell_spec.rb
|
171
168
|
- spec/watchr/smells_collector_spec.rb
|
data/lib/watchr/rating.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'watchr/smell_types'
|
2
|
-
|
3
|
-
module Watchr
|
4
|
-
#
|
5
|
-
# Component responsible to rate a file considering found smells.
|
6
|
-
#
|
7
|
-
module Rating
|
8
|
-
include SmellTypes
|
9
|
-
|
10
|
-
def rating
|
11
|
-
total = smells.reduce(0) {|total, smell| total += rate(smell)}
|
12
|
-
|
13
|
-
[200, 140, 90, 50, 20, 0].each_with_index do |limit, index|
|
14
|
-
return %w(F E D C B A)[index] if total >= limit
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def rate(smell)
|
21
|
-
case smell.type
|
22
|
-
when :complex_method,
|
23
|
-
:very_complex_method
|
24
|
-
0.45 * smell.details[:complexity]
|
25
|
-
|
26
|
-
when :complex_object,
|
27
|
-
:very_complex_object
|
28
|
-
0.65 * smell.details[:complexity]
|
29
|
-
|
30
|
-
when :identical_code,
|
31
|
-
:similar_code
|
32
|
-
smell.details[:mass]
|
33
|
-
else
|
34
|
-
0
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/spec/watchr/rating_spec.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'watchr/rating'
|
3
|
-
|
4
|
-
describe Watchr::Rating do
|
5
|
-
|
6
|
-
let(:complexity_smell) {
|
7
|
-
stub('smell',
|
8
|
-
:type => :complex_method,
|
9
|
-
:details => {:complexity => 29.3}
|
10
|
-
)
|
11
|
-
}
|
12
|
-
|
13
|
-
let(:other_smell) {
|
14
|
-
stub('smell',
|
15
|
-
:type => 'other'
|
16
|
-
)
|
17
|
-
}
|
18
|
-
|
19
|
-
let(:duplication_smell) {
|
20
|
-
stub('smell',
|
21
|
-
:type => :identical_code,
|
22
|
-
:details => {:mass => 72})
|
23
|
-
}
|
24
|
-
|
25
|
-
let(:smells) { [complexity_smell, other_smell, duplication_smell] }
|
26
|
-
|
27
|
-
let(:analyse) {
|
28
|
-
analyse = stub('analyse', :smells => smells)
|
29
|
-
analyse.extend Watchr::Rating
|
30
|
-
|
31
|
-
analyse
|
32
|
-
}
|
33
|
-
|
34
|
-
describe '#rating' do
|
35
|
-
subject { analyse.rating }
|
36
|
-
|
37
|
-
context 'C' do
|
38
|
-
it { should == 'C' }
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'A' do
|
42
|
-
let(:smells) { [] }
|
43
|
-
it { should == 'A' }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|