excellent 1.7.2 → 2.0.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.
- data/History.txt +9 -0
- data/MIT-LICENSE +20 -0
- data/README.md +123 -0
- data/bin/excellent +49 -12
- data/lib/simplabs/excellent.rb +2 -2
- data/lib/simplabs/excellent/checks.rb +1 -1
- data/lib/simplabs/excellent/checks/abc_metric_method_check.rb +1 -1
- data/lib/simplabs/excellent/checks/assignment_in_conditional_check.rb +1 -1
- data/lib/simplabs/excellent/checks/base.rb +12 -9
- data/lib/simplabs/excellent/checks/case_missing_else_check.rb +1 -1
- data/lib/simplabs/excellent/checks/class_line_count_check.rb +3 -3
- data/lib/simplabs/excellent/checks/class_name_check.rb +5 -5
- data/lib/simplabs/excellent/checks/{singleton_variable_check.rb → class_variable_check.rb} +3 -3
- data/lib/simplabs/excellent/checks/control_coupling_check.rb +1 -1
- data/lib/simplabs/excellent/checks/cyclomatic_complexity_block_check.rb +4 -4
- data/lib/simplabs/excellent/checks/cyclomatic_complexity_check.rb +3 -3
- data/lib/simplabs/excellent/checks/cyclomatic_complexity_method_check.rb +2 -2
- data/lib/simplabs/excellent/checks/empty_rescue_body_check.rb +1 -1
- data/lib/simplabs/excellent/checks/flog_block_check.rb +2 -2
- data/lib/simplabs/excellent/checks/flog_check.rb +3 -3
- data/lib/simplabs/excellent/checks/flog_class_check.rb +2 -2
- data/lib/simplabs/excellent/checks/flog_method_check.rb +2 -2
- data/lib/simplabs/excellent/checks/for_loop_check.rb +1 -1
- data/lib/simplabs/excellent/checks/global_variable_check.rb +5 -2
- data/lib/simplabs/excellent/checks/line_count_check.rb +3 -3
- data/lib/simplabs/excellent/checks/method_line_count_check.rb +2 -2
- data/lib/simplabs/excellent/checks/method_name_check.rb +5 -4
- data/lib/simplabs/excellent/checks/module_line_count_check.rb +2 -2
- data/lib/simplabs/excellent/checks/module_name_check.rb +3 -3
- data/lib/simplabs/excellent/checks/name_check.rb +4 -4
- data/lib/simplabs/excellent/checks/nested_iterators_check.rb +2 -2
- data/lib/simplabs/excellent/checks/parameter_number_check.rb +1 -1
- data/lib/simplabs/excellent/checks/rails/attr_accessible_check.rb +1 -1
- data/lib/simplabs/excellent/checks/rails/attr_protected_check.rb +1 -1
- data/lib/simplabs/excellent/checks/rails/custom_initialize_method_check.rb +1 -1
- data/lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb +1 -1
- data/lib/simplabs/excellent/checks/rails/params_hash_in_view_check.rb +1 -1
- data/lib/simplabs/excellent/checks/rails/session_hash_in_view_check.rb +1 -1
- data/lib/simplabs/excellent/checks/rails/validations_check.rb +1 -1
- data/lib/simplabs/excellent/formatters/text.rb +7 -1
- data/lib/simplabs/excellent/parsing/gvar_context.rb +0 -8
- data/lib/simplabs/excellent/parsing/loc_parser.rb +94 -0
- data/lib/simplabs/excellent/parsing/resbody_context.rb +0 -6
- data/lib/simplabs/excellent/runner.rb +49 -32
- data/lib/simplabs/excellent/warning.rb +1 -4
- metadata +23 -49
- data/README.rdoc +0 -72
- data/VERSION.yml +0 -4
- data/lib/simplabs/excellent/extensions/string.rb +0 -28
- data/spec/checks/abc_metric_method_check_spec.rb +0 -122
- data/spec/checks/assignment_in_conditional_check_spec.rb +0 -90
- data/spec/checks/case_missing_else_check_spec.rb +0 -46
- data/spec/checks/class_line_count_check_spec.rb +0 -62
- data/spec/checks/class_name_check_spec.rb +0 -48
- data/spec/checks/control_coupling_check_spec.rb +0 -103
- data/spec/checks/cyclomatic_complexity_block_check_spec.rb +0 -47
- data/spec/checks/cyclomatic_complexity_method_check_spec.rb +0 -210
- data/spec/checks/empty_rescue_body_check_spec.rb +0 -170
- data/spec/checks/flog_block_check_spec.rb +0 -28
- data/spec/checks/flog_class_check_spec.rb +0 -28
- data/spec/checks/flog_method_check_spec.rb +0 -46
- data/spec/checks/for_loop_check_spec.rb +0 -52
- data/spec/checks/global_variable_check_spec.rb +0 -66
- data/spec/checks/method_line_count_check_spec.rb +0 -49
- data/spec/checks/method_name_check_spec.rb +0 -112
- data/spec/checks/module_line_count_check_spec.rb +0 -48
- data/spec/checks/module_name_check_spec.rb +0 -61
- data/spec/checks/nested_iterators_check_spec.rb +0 -44
- data/spec/checks/parameter_number_check_spec.rb +0 -97
- data/spec/checks/rails/attr_accessible_check_spec.rb +0 -79
- data/spec/checks/rails/attr_protected_check_spec.rb +0 -77
- data/spec/checks/rails/custom_initialize_method_check_spec.rb +0 -58
- data/spec/checks/rails/instance_var_in_partial_check_spec.rb +0 -40
- data/spec/checks/rails/params_hash_in_view_check_spec.rb +0 -40
- data/spec/checks/rails/session_hash_in_view_check_spec.rb +0 -40
- data/spec/checks/rails/validations_check_spec.rb +0 -81
- data/spec/checks/singleton_variable_check_spec.rb +0 -66
- data/spec/extensions/string_spec.rb +0 -13
- data/spec/spec_helper.rb +0 -13
@@ -1,46 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Simplabs::Excellent::Checks::CaseMissingElseCheck do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@excellent = Simplabs::Excellent::Runner.new(Simplabs::Excellent::Checks::CaseMissingElseCheck.new)
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '#evaluate' do
|
10
|
-
|
11
|
-
it 'should accept case statements that do have an else clause' do
|
12
|
-
code = <<-END
|
13
|
-
case foo
|
14
|
-
when "bar"
|
15
|
-
"ok"
|
16
|
-
else
|
17
|
-
"good"
|
18
|
-
end
|
19
|
-
END
|
20
|
-
@excellent.check_code(code)
|
21
|
-
warnings = @excellent.warnings
|
22
|
-
|
23
|
-
warnings.should be_empty
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should reject case statements that do not have an else clause' do
|
27
|
-
code = <<-END
|
28
|
-
case foo
|
29
|
-
when "bar"
|
30
|
-
"ok"
|
31
|
-
when "bar"
|
32
|
-
"bad"
|
33
|
-
end
|
34
|
-
END
|
35
|
-
@excellent.check_code(code)
|
36
|
-
warnings = @excellent.warnings
|
37
|
-
|
38
|
-
warnings.should_not be_empty
|
39
|
-
warnings[0].info.should == {}
|
40
|
-
warnings[0].line_number.should == 1
|
41
|
-
warnings[0].message.should == 'Case statement is missing else clause.'
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Simplabs::Excellent::Checks::ClassLineCountCheck do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@excellent = Simplabs::Excellent::Runner.new(Simplabs::Excellent::Checks::ClassLineCountCheck.new({ :threshold => 3 }))
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '#evaluate' do
|
10
|
-
|
11
|
-
it 'should accept classes with less lines than the threshold' do
|
12
|
-
code = <<-END
|
13
|
-
class OneLineClass; end
|
14
|
-
END
|
15
|
-
@excellent.check_code(code)
|
16
|
-
|
17
|
-
@excellent.warnings.should be_empty
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should accept classes with the same number of lines as the threshold' do
|
21
|
-
code = <<-END
|
22
|
-
class ThreeLineClass
|
23
|
-
@foo = 1
|
24
|
-
end
|
25
|
-
END
|
26
|
-
@excellent.check_code(code)
|
27
|
-
|
28
|
-
@excellent.warnings.should be_empty
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should not count blank lines' do
|
32
|
-
code = <<-END
|
33
|
-
class ThreeLineClass
|
34
|
-
|
35
|
-
@foo = 1
|
36
|
-
|
37
|
-
end
|
38
|
-
END
|
39
|
-
@excellent.check_code(code)
|
40
|
-
|
41
|
-
@excellent.warnings.should be_empty
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'should reject classes with more lines than the threshold' do
|
45
|
-
code = <<-END
|
46
|
-
class FourLineClass
|
47
|
-
@foo = 1
|
48
|
-
@bar = 2
|
49
|
-
end
|
50
|
-
END
|
51
|
-
@excellent.check_code(code)
|
52
|
-
warnings = @excellent.warnings
|
53
|
-
|
54
|
-
warnings.should_not be_empty
|
55
|
-
warnings[0].info.should == { :class => 'FourLineClass', :count => 4 }
|
56
|
-
warnings[0].line_number.should == 1
|
57
|
-
warnings[0].message.should == 'FourLineClass has 4 lines.'
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Simplabs::Excellent::Checks::ClassNameCheck do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@excellent = Simplabs::Excellent::Runner.new(Simplabs::Excellent::Checks::ClassNameCheck.new)
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '#evaluate' do
|
10
|
-
|
11
|
-
it 'should accept camel case class names starting in capitals' do
|
12
|
-
code = <<-END
|
13
|
-
class GoodClassName; end
|
14
|
-
END
|
15
|
-
@excellent.check_code(code)
|
16
|
-
|
17
|
-
@excellent.warnings.should be_empty
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should be able to parse scoped class names' do
|
21
|
-
code = <<-END
|
22
|
-
class Outer::Inner::GoodClassName
|
23
|
-
def method
|
24
|
-
end
|
25
|
-
end
|
26
|
-
END
|
27
|
-
@excellent.check_code(code)
|
28
|
-
s
|
29
|
-
@excellent.warnings.should be_empty
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should reject class names with underscores' do
|
33
|
-
code = <<-END
|
34
|
-
class Bad_ClassName
|
35
|
-
end
|
36
|
-
END
|
37
|
-
@excellent.check_code(code)
|
38
|
-
warnings = @excellent.warnings
|
39
|
-
|
40
|
-
warnings.should_not be_empty
|
41
|
-
warnings[0].info.should == { :class => 'Bad_ClassName' }
|
42
|
-
warnings[0].line_number.should == 1
|
43
|
-
warnings[0].message.should == 'Bad class name Bad_ClassName.'
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Simplabs::Excellent::Checks::ControlCouplingCheck do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@excellent = Simplabs::Excellent::Runner.new(Simplabs::Excellent::Checks::ControlCouplingCheck.new)
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '#evaluate' do
|
10
|
-
|
11
|
-
it 'should accept methods that just print out the parameter' do
|
12
|
-
code = <<-END
|
13
|
-
def write(quoted)
|
14
|
-
pp quoted
|
15
|
-
end
|
16
|
-
END
|
17
|
-
@excellent.check_code(code)
|
18
|
-
warnings = @excellent.warnings
|
19
|
-
|
20
|
-
warnings.should be_empty
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should accept methods with ternary operators using an instance variable' do
|
24
|
-
code = <<-END
|
25
|
-
def write(quoted)
|
26
|
-
@quoted ? write_quoted('1') : write_quoted('2')
|
27
|
-
end
|
28
|
-
END
|
29
|
-
|
30
|
-
@excellent.check_code(code)
|
31
|
-
warnings = @excellent.warnings
|
32
|
-
|
33
|
-
warnings.should be_empty
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should accept methods with ternary operators using a local variable' do
|
37
|
-
code = <<-END
|
38
|
-
def write(quoted)
|
39
|
-
test = false
|
40
|
-
test ? write_quoted('1') : write_quoted('2')
|
41
|
-
end
|
42
|
-
END
|
43
|
-
|
44
|
-
@excellent.check_code(code)
|
45
|
-
warnings = @excellent.warnings
|
46
|
-
|
47
|
-
warnings.should be_empty
|
48
|
-
end
|
49
|
-
|
50
|
-
%w(if unless).each do |conditional|
|
51
|
-
|
52
|
-
it "should reject methods with #{conditional} checks using a parameter" do
|
53
|
-
code = <<-END
|
54
|
-
def write(quoted)
|
55
|
-
#{conditional} quoted
|
56
|
-
write_quoted('test')
|
57
|
-
end
|
58
|
-
end
|
59
|
-
END
|
60
|
-
|
61
|
-
verify_warning_found(code, 2)
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'should reject methods with ternary operators using a parameter' do
|
67
|
-
code = <<-END
|
68
|
-
def write(quoted)
|
69
|
-
quoted ? write_quoted('1') : write_quoted('2')
|
70
|
-
end
|
71
|
-
END
|
72
|
-
|
73
|
-
verify_warning_found(code, 3) # this should actually be line 2
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should reject methods with case statements using a parameter" do
|
77
|
-
code = <<-END
|
78
|
-
def write(quoted)
|
79
|
-
case quoted
|
80
|
-
when 1
|
81
|
-
write_quoted('1')
|
82
|
-
when 2
|
83
|
-
write_quoted('2')
|
84
|
-
end
|
85
|
-
end
|
86
|
-
END
|
87
|
-
|
88
|
-
verify_warning_found(code, 2)
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
def verify_warning_found(code, line)
|
94
|
-
@excellent.check_code(code)
|
95
|
-
warnings = @excellent.warnings
|
96
|
-
|
97
|
-
warnings.should_not be_empty
|
98
|
-
warnings[0].info.should == { :method => 'write', :argument => 'quoted' }
|
99
|
-
warnings[0].line_number.should == line
|
100
|
-
warnings[0].message.should == 'write is coupled to quoted.'
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Simplabs::Excellent::Checks::CyclomaticComplexityBlockCheck do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@excellent = Simplabs::Excellent::Runner.new(Simplabs::Excellent::Checks::CyclomaticComplexityBlockCheck.new({ :threshold => 0 }))
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '#evaluate' do
|
10
|
-
|
11
|
-
it 'should find a simple block' do
|
12
|
-
code = <<-END
|
13
|
-
it 'should be a simple block' do
|
14
|
-
call_foo
|
15
|
-
end
|
16
|
-
END
|
17
|
-
|
18
|
-
verify_code_complexity(code, 1)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should find a block with multiple paths' do
|
22
|
-
code = <<-END
|
23
|
-
it 'should be a complex block' do
|
24
|
-
if some_condition
|
25
|
-
call_foo
|
26
|
-
else
|
27
|
-
call_bar
|
28
|
-
end
|
29
|
-
end
|
30
|
-
END
|
31
|
-
|
32
|
-
verify_code_complexity(code, 2)
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
def verify_code_complexity(code, score)
|
38
|
-
@excellent.check_code(code)
|
39
|
-
warnings = @excellent.warnings
|
40
|
-
|
41
|
-
warnings.should_not be_empty
|
42
|
-
warnings[0].info.should == { :block => 'block', :score => score }
|
43
|
-
warnings[0].line_number.should == 1
|
44
|
-
warnings[0].message.should == "block has cyclomatic complexity of #{score}."
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
@@ -1,210 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Simplabs::Excellent::Checks::CyclomaticComplexityMethodCheck do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@excellent = Simplabs::Excellent::Runner.new(Simplabs::Excellent::Checks::CyclomaticComplexityMethodCheck.new({ :threshold => 0 }))
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '#evaluate' do
|
10
|
-
|
11
|
-
it 'should find an if block' do
|
12
|
-
code = <<-END
|
13
|
-
def method_name
|
14
|
-
call_foo if some_condition
|
15
|
-
end
|
16
|
-
END
|
17
|
-
|
18
|
-
verify_code_complexity(code, 2)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should find an unless block' do
|
22
|
-
code = <<-END
|
23
|
-
def method_name
|
24
|
-
call_foo unless some_condition
|
25
|
-
end
|
26
|
-
END
|
27
|
-
|
28
|
-
verify_code_complexity(code, 2)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should find an elsif block' do
|
32
|
-
code = <<-END
|
33
|
-
def method_name
|
34
|
-
if first_condition then
|
35
|
-
call_foo
|
36
|
-
elsif second_condition then
|
37
|
-
call_bar
|
38
|
-
else
|
39
|
-
call_bam
|
40
|
-
end
|
41
|
-
end
|
42
|
-
END
|
43
|
-
|
44
|
-
verify_code_complexity(code, 3)
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should find a ternary operator' do
|
48
|
-
code = <<-END
|
49
|
-
def method_name
|
50
|
-
value = some_condition ? 1 : 2
|
51
|
-
end
|
52
|
-
END
|
53
|
-
|
54
|
-
verify_code_complexity(code, 2)
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should find a while loop' do
|
58
|
-
code = <<-END
|
59
|
-
def method_name
|
60
|
-
while some_condition do
|
61
|
-
call_foo
|
62
|
-
end
|
63
|
-
end
|
64
|
-
END
|
65
|
-
|
66
|
-
verify_code_complexity(code, 2)
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'should find an until loop' do
|
70
|
-
code = <<-END
|
71
|
-
def method_name
|
72
|
-
until some_condition do
|
73
|
-
call_foo
|
74
|
-
end
|
75
|
-
end
|
76
|
-
END
|
77
|
-
|
78
|
-
verify_code_complexity(code, 2)
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'should find a for loop' do
|
82
|
-
code = <<-END
|
83
|
-
def method_name
|
84
|
-
for i in 1..2 do
|
85
|
-
call_method
|
86
|
-
end
|
87
|
-
end
|
88
|
-
END
|
89
|
-
|
90
|
-
verify_code_complexity(code, 2)
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'should find a rescue block' do
|
94
|
-
code = <<-END
|
95
|
-
def method_name
|
96
|
-
begin
|
97
|
-
call_foo
|
98
|
-
rescue Exception
|
99
|
-
call_bar
|
100
|
-
end
|
101
|
-
end
|
102
|
-
END
|
103
|
-
|
104
|
-
verify_code_complexity(code, 2)
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'should find a case and when block' do
|
108
|
-
code = <<-END
|
109
|
-
def method_name
|
110
|
-
case value
|
111
|
-
when 1
|
112
|
-
call_foo
|
113
|
-
when 2
|
114
|
-
call_bar
|
115
|
-
end
|
116
|
-
end
|
117
|
-
END
|
118
|
-
|
119
|
-
verify_code_complexity(code, 4)
|
120
|
-
end
|
121
|
-
|
122
|
-
describe 'when processing operators' do
|
123
|
-
|
124
|
-
['&&', 'and', '||', 'or'].each do |operator|
|
125
|
-
|
126
|
-
it "should find #{operator}" do
|
127
|
-
code = <<-END
|
128
|
-
def method_name
|
129
|
-
call_foo #{operator} call_bar
|
130
|
-
end
|
131
|
-
END
|
132
|
-
|
133
|
-
verify_code_complexity(code, 2)
|
134
|
-
end
|
135
|
-
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
it 'should deal with nested if blocks containing && and ||' do
|
141
|
-
code = <<-END
|
142
|
-
def method_name
|
143
|
-
if first_condition then
|
144
|
-
call_foo if second_condition && third_condition
|
145
|
-
call_bar if fourth_condition || fifth_condition
|
146
|
-
end
|
147
|
-
end
|
148
|
-
END
|
149
|
-
|
150
|
-
verify_code_complexity(code, 6)
|
151
|
-
end
|
152
|
-
|
153
|
-
it 'should count stupid nested if and else blocks' do
|
154
|
-
code = <<-END
|
155
|
-
def method_name
|
156
|
-
if first_condition then
|
157
|
-
call_foo
|
158
|
-
else
|
159
|
-
if second_condition then
|
160
|
-
call_bar
|
161
|
-
else
|
162
|
-
call_bam if third_condition
|
163
|
-
end
|
164
|
-
call_baz if fourth_condition
|
165
|
-
end
|
166
|
-
end
|
167
|
-
END
|
168
|
-
|
169
|
-
verify_code_complexity(code, 5)
|
170
|
-
end
|
171
|
-
|
172
|
-
it 'should also work on singleton methods' do
|
173
|
-
code = <<-END
|
174
|
-
class Class
|
175
|
-
def self.method_name
|
176
|
-
if first_condition then
|
177
|
-
call_foo
|
178
|
-
else
|
179
|
-
if second_condition then
|
180
|
-
call_bar
|
181
|
-
else
|
182
|
-
call_bam if third_condition
|
183
|
-
end
|
184
|
-
call_baz if fourth_condition
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
END
|
189
|
-
@excellent.check_code(code)
|
190
|
-
warnings = @excellent.warnings
|
191
|
-
|
192
|
-
warnings.should_not be_empty
|
193
|
-
warnings[0].info.should == { :method => 'Class.method_name', :score => 5 }
|
194
|
-
warnings[0].line_number.should == 2
|
195
|
-
warnings[0].message.should == "Class.method_name has cyclomatic complexity of 5."
|
196
|
-
end
|
197
|
-
|
198
|
-
end
|
199
|
-
|
200
|
-
def verify_code_complexity(code, score)
|
201
|
-
@excellent.check_code(code)
|
202
|
-
warnings = @excellent.warnings
|
203
|
-
|
204
|
-
warnings.should_not be_empty
|
205
|
-
warnings[0].info.should == { :method => 'method_name', :score => score }
|
206
|
-
warnings[0].line_number.should == 1
|
207
|
-
warnings[0].message.should == "method_name has cyclomatic complexity of #{score}."
|
208
|
-
end
|
209
|
-
|
210
|
-
end
|