simplabs-excellent 1.2.1 → 1.2.2
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 +4 -0
- data/VERSION.yml +1 -1
- data/lib/simplabs/excellent.rb +1 -1
- data/spec/checks/abc_metric_method_check_spec.rb +17 -17
- data/spec/checks/assignment_in_conditional_check_spec.rb +18 -18
- data/spec/checks/case_missing_else_check_spec.rb +4 -4
- data/spec/checks/class_line_count_check_spec.rb +8 -8
- data/spec/checks/class_name_check_spec.rb +7 -7
- data/spec/checks/control_coupling_check_spec.rb +14 -14
- data/spec/checks/cyclomatic_complexity_block_check_spec.rb +6 -6
- data/spec/checks/cyclomatic_complexity_method_check_spec.rb +28 -28
- data/spec/checks/duplication_check_spec.rb +24 -24
- data/spec/checks/empty_rescue_body_check_spec.rb +29 -29
- data/spec/checks/flog_block_check_spec.rb +2 -2
- data/spec/checks/flog_class_check_spec.rb +2 -2
- data/spec/checks/flog_method_check_spec.rb +6 -6
- data/spec/checks/for_loop_check_spec.rb +8 -8
- data/spec/checks/method_line_count_check_spec.rb +6 -6
- data/spec/checks/method_name_check_spec.rb +16 -16
- data/spec/checks/module_line_count_check_spec.rb +6 -6
- data/spec/checks/module_name_check_spec.rb +8 -8
- data/spec/checks/nested_iterators_check_spec.rb +4 -4
- data/spec/checks/parameter_number_check_spec.rb +18 -18
- data/spec/checks/rails/attr_accessible_check_spec.rb +10 -10
- data/spec/checks/rails/attr_protected_check_spec.rb +10 -10
- data/spec/checks/singleton_variable_check_spec.rb +6 -6
- metadata +1 -1
@@ -9,22 +9,22 @@ describe Simplabs::Excellent::Checks::Rails::AttrAccessibleCheck do
|
|
9
9
|
describe '#evaluate' do
|
10
10
|
|
11
11
|
it 'should ignore classes that are not active record models' do
|
12
|
-
|
12
|
+
code = <<-END
|
13
13
|
class Test
|
14
14
|
end
|
15
15
|
END
|
16
|
-
@excellent.
|
16
|
+
@excellent.check_code(code)
|
17
17
|
warnings = @excellent.warnings
|
18
18
|
|
19
19
|
warnings.should be_empty
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'should reject an active record model that does not specify attr_accessible' do
|
23
|
-
|
23
|
+
code = <<-END
|
24
24
|
class User < ActiveRecord::Base
|
25
25
|
end
|
26
26
|
END
|
27
|
-
@excellent.
|
27
|
+
@excellent.check_code(code)
|
28
28
|
warnings = @excellent.warnings
|
29
29
|
|
30
30
|
warnings.should_not be_empty
|
@@ -34,12 +34,12 @@ describe Simplabs::Excellent::Checks::Rails::AttrAccessibleCheck do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should reject an active record model that does specify attr_protected' do
|
37
|
-
|
37
|
+
code = <<-END
|
38
38
|
class User < ActiveRecord::Base
|
39
39
|
attr_protected :first_name
|
40
40
|
end
|
41
41
|
END
|
42
|
-
@excellent.
|
42
|
+
@excellent.check_code(code)
|
43
43
|
warnings = @excellent.warnings
|
44
44
|
|
45
45
|
warnings.should_not be_empty
|
@@ -49,23 +49,23 @@ describe Simplabs::Excellent::Checks::Rails::AttrAccessibleCheck do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should accept an active record model that does specify attr_accessible' do
|
52
|
-
|
52
|
+
code = <<-END
|
53
53
|
class User < ActiveRecord::Base
|
54
54
|
attr_accessible :first_name
|
55
55
|
end
|
56
56
|
END
|
57
|
-
@excellent.
|
57
|
+
@excellent.check_code(code)
|
58
58
|
warnings = @excellent.warnings
|
59
59
|
|
60
60
|
warnings.should be_empty
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'should also work with namespaced models' do
|
64
|
-
|
64
|
+
code = <<-END
|
65
65
|
class Backend::User < ActiveRecord::Base
|
66
66
|
end
|
67
67
|
END
|
68
|
-
@excellent.
|
68
|
+
@excellent.check_code(code)
|
69
69
|
warnings = @excellent.warnings
|
70
70
|
|
71
71
|
warnings.should_not be_empty
|
@@ -9,23 +9,23 @@ describe Simplabs::Excellent::Checks::Rails::AttrProtectedCheck do
|
|
9
9
|
describe '#evaluate' do
|
10
10
|
|
11
11
|
it 'should ignore classes that are not active record models' do
|
12
|
-
|
12
|
+
code = <<-END
|
13
13
|
class Test
|
14
14
|
end
|
15
15
|
END
|
16
|
-
@excellent.
|
16
|
+
@excellent.check_code(code)
|
17
17
|
warnings = @excellent.warnings
|
18
18
|
|
19
19
|
warnings.should be_empty
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'should reject an active record model that does specify attr_protected' do
|
23
|
-
|
23
|
+
code = <<-END
|
24
24
|
class User < ActiveRecord::Base
|
25
25
|
attr_protected :first_name
|
26
26
|
end
|
27
27
|
END
|
28
|
-
@excellent.
|
28
|
+
@excellent.check_code(code)
|
29
29
|
warnings = @excellent.warnings
|
30
30
|
|
31
31
|
warnings.should_not be_empty
|
@@ -35,35 +35,35 @@ describe Simplabs::Excellent::Checks::Rails::AttrProtectedCheck do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'should accept an active record model that does specify attr_accessible' do
|
38
|
-
|
38
|
+
code = <<-END
|
39
39
|
class User < ActiveRecord::Base
|
40
40
|
attr_accessible :first_name
|
41
41
|
end
|
42
42
|
END
|
43
|
-
@excellent.
|
43
|
+
@excellent.check_code(code)
|
44
44
|
warnings = @excellent.warnings
|
45
45
|
|
46
46
|
warnings.should be_empty
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'should accept an active record model that specifies neither attr_accessible not attr_protected' do
|
50
|
-
|
50
|
+
code = <<-END
|
51
51
|
class User < ActiveRecord::Base
|
52
52
|
end
|
53
53
|
END
|
54
|
-
@excellent.
|
54
|
+
@excellent.check_code(code)
|
55
55
|
warnings = @excellent.warnings
|
56
56
|
|
57
57
|
warnings.should be_empty
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'should also work with namespaced models' do
|
61
|
-
|
61
|
+
code = <<-END
|
62
62
|
class Backend::User < ActiveRecord::Base
|
63
63
|
attr_protected :first_name
|
64
64
|
end
|
65
65
|
END
|
66
|
-
@excellent.
|
66
|
+
@excellent.check_code(code)
|
67
67
|
warnings = @excellent.warnings
|
68
68
|
|
69
69
|
warnings.should_not be_empty
|
@@ -9,10 +9,10 @@ describe Simplabs::Excellent::Checks::SingletonVariableCheck do
|
|
9
9
|
describe '#evaluate' do
|
10
10
|
|
11
11
|
it 'should reject singleton variables' do
|
12
|
-
|
12
|
+
code = <<-END
|
13
13
|
@@foo
|
14
14
|
END
|
15
|
-
@excellent.
|
15
|
+
@excellent.check_code(code)
|
16
16
|
warnings = @excellent.warnings
|
17
17
|
|
18
18
|
warnings.should_not be_empty
|
@@ -22,7 +22,7 @@ describe Simplabs::Excellent::Checks::SingletonVariableCheck do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'should also work for namespaced classes' do
|
25
|
-
|
25
|
+
code = <<-END
|
26
26
|
module Outer
|
27
27
|
module Inner
|
28
28
|
class Class
|
@@ -31,7 +31,7 @@ describe Simplabs::Excellent::Checks::SingletonVariableCheck do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
END
|
34
|
-
@excellent.
|
34
|
+
@excellent.check_code(code)
|
35
35
|
warnings = @excellent.warnings
|
36
36
|
|
37
37
|
warnings.should_not be_empty
|
@@ -41,7 +41,7 @@ describe Simplabs::Excellent::Checks::SingletonVariableCheck do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'should also work for singleton variables that occur within methods' do
|
44
|
-
|
44
|
+
code = <<-END
|
45
45
|
module Outer
|
46
46
|
module Inner
|
47
47
|
class Class
|
@@ -52,7 +52,7 @@ describe Simplabs::Excellent::Checks::SingletonVariableCheck do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
END
|
55
|
-
@excellent.
|
55
|
+
@excellent.check_code(code)
|
56
56
|
warnings = @excellent.warnings
|
57
57
|
|
58
58
|
warnings.should_not be_empty
|