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.
@@ -9,12 +9,12 @@ describe Simplabs::Excellent::Checks::FlogBlockCheck do
9
9
  describe '#evaluate' do
10
10
 
11
11
  it 'should calculate the score correctly' do
12
- content = <<-END
12
+ code = <<-END
13
13
  method_name do
14
14
  puts 'test'
15
15
  end
16
16
  END
17
- @excellent.check_content(content)
17
+ @excellent.check_code(code)
18
18
  warnings = @excellent.warnings
19
19
 
20
20
  warnings.should_not be_empty
@@ -9,12 +9,12 @@ describe Simplabs::Excellent::Checks::FlogClassCheck do
9
9
  describe '#evaluate' do
10
10
 
11
11
  it 'should calculate the score correctly' do
12
- content = <<-END
12
+ code = <<-END
13
13
  class User < ActiveRecord::Base
14
14
  has_many :projects
15
15
  end
16
16
  END
17
- @excellent.check_content(content)
17
+ @excellent.check_code(code)
18
18
  warnings = @excellent.warnings
19
19
 
20
20
  warnings.should_not be_empty
@@ -9,17 +9,17 @@ describe Simplabs::Excellent::Checks::FlogMethodCheck do
9
9
  describe '#evaluate' do
10
10
 
11
11
  it 'should calculate the score correctly' do
12
- content = <<-END
12
+ code = <<-END
13
13
  def method_name
14
14
  puts 'test'
15
15
  end
16
16
  END
17
17
 
18
- verify_content_score(content, 1)
18
+ verify_code_score(code, 1)
19
19
  end
20
20
 
21
21
  it 'should calculate the score that uses special metaprogramming methods correctly' do
22
- content = <<-END
22
+ code = <<-END
23
23
  def method_name
24
24
  @instance.instance_eval do
25
25
  def some_method
@@ -28,13 +28,13 @@ describe Simplabs::Excellent::Checks::FlogMethodCheck do
28
28
  end
29
29
  END
30
30
 
31
- verify_content_score(content, 6)
31
+ verify_code_score(code, 6)
32
32
  end
33
33
 
34
34
  end
35
35
 
36
- def verify_content_score(content, score)
37
- @excellent.check_content(content)
36
+ def verify_code_score(code, score)
37
+ @excellent.check_code(code)
38
38
  warnings = @excellent.warnings
39
39
 
40
40
  warnings.should_not be_empty
@@ -9,38 +9,38 @@ describe Simplabs::Excellent::Checks::ForLoopCheck do
9
9
  describe '#evaluate' do
10
10
 
11
11
  it 'should accept iterators' do
12
- content = <<-END
12
+ code = <<-END
13
13
  [:sym1, :sym2].each do |sym|
14
14
  end
15
15
  END
16
- @excellent.check_content(content)
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 for loops on ranges' do
23
- content = <<-END
23
+ code = <<-END
24
24
  for i in 1..2
25
25
  end
26
26
  END
27
27
 
28
- verify_warning_found(content)
28
+ verify_warning_found(code)
29
29
  end
30
30
 
31
31
  it 'should reject for loops on enumerations' do
32
- content = <<-END
32
+ code = <<-END
33
33
  for symbol in [:sym1, :sym2]
34
34
  end
35
35
  END
36
36
 
37
- verify_warning_found(content)
37
+ verify_warning_found(code)
38
38
  end
39
39
 
40
40
  end
41
41
 
42
- def verify_warning_found(content)
43
- @excellent.check_content(content)
42
+ def verify_warning_found(code)
43
+ @excellent.check_code(code)
44
44
  warnings = @excellent.warnings
45
45
 
46
46
  warnings.should_not be_empty
@@ -9,33 +9,33 @@ describe Simplabs::Excellent::Checks::MethodLineCountCheck do
9
9
  describe '#evaluate' do
10
10
 
11
11
  it 'should accept methods with less lines than the threshold' do
12
- content = <<-END
12
+ code = <<-END
13
13
  def one_line_method
14
14
  end
15
15
  END
16
- @excellent.check_content(content)
16
+ @excellent.check_code(code)
17
17
 
18
18
  @excellent.warnings.should be_empty
19
19
  end
20
20
 
21
21
  it 'should accept methods with the same number of lines as the threshold' do
22
- content = <<-END
22
+ code = <<-END
23
23
  def two_line_method
24
24
  end
25
25
  END
26
- @excellent.check_content(content)
26
+ @excellent.check_code(code)
27
27
 
28
28
  @excellent.warnings.should be_empty
29
29
  end
30
30
 
31
31
  it 'should reject methods with more lines than the threshold' do
32
- content = <<-END
32
+ code = <<-END
33
33
  def four_line_method
34
34
  puts 1
35
35
  puts 2
36
36
  end
37
37
  END
38
- @excellent.check_content(content)
38
+ @excellent.check_code(code)
39
39
  warnings = @excellent.warnings
40
40
 
41
41
  warnings.should_not be_empty
@@ -9,51 +9,51 @@ describe Simplabs::Excellent::Checks::MethodNameCheck do
9
9
  describe '#evaluate' do
10
10
 
11
11
  it 'should accept method names with underscores' do
12
- content = <<-END
12
+ code = <<-END
13
13
  def good_method_name
14
14
  end
15
15
  END
16
- @excellent.check_content(content)
16
+ @excellent.check_code(code)
17
17
 
18
18
  @excellent.warnings.should be_empty
19
19
  end
20
20
 
21
21
  it 'should accept method names with numbers' do
22
- content = <<-END
22
+ code = <<-END
23
23
  def good_method_name_1
24
24
  end
25
25
  END
26
- @excellent.check_content(content)
26
+ @excellent.check_code(code)
27
27
 
28
28
  @excellent.warnings.should be_empty
29
29
  end
30
30
 
31
31
  it 'should accept method names ending with a question mark' do
32
- content = <<-END
32
+ code = <<-END
33
33
  def good_method_name?
34
34
  end
35
35
  END
36
- @excellent.check_content(content)
36
+ @excellent.check_code(code)
37
37
 
38
38
  @excellent.warnings.should be_empty
39
39
  end
40
40
 
41
41
  it 'should accept method names ending with an exclamation mark' do
42
- content = <<-END
42
+ code = <<-END
43
43
  def good_method_name!
44
44
  end
45
45
  END
46
- @excellent.check_content(content)
46
+ @excellent.check_code(code)
47
47
 
48
48
  @excellent.warnings.should be_empty
49
49
  end
50
50
 
51
51
  it 'should accept method names ending an equals sign' do
52
- content = <<-END
52
+ code = <<-END
53
53
  def good_method_name=
54
54
  end
55
55
  END
56
- @excellent.check_content(content)
56
+ @excellent.check_code(code)
57
57
 
58
58
  @excellent.warnings.should be_empty
59
59
  end
@@ -61,11 +61,11 @@ describe Simplabs::Excellent::Checks::MethodNameCheck do
61
61
  ['<<', '>>', '==', '<', '<=', '>', '>=', '[]', '[]=', '+', '-', '*', '~', '/', '%', '&', '^', '|'].each do |operator|
62
62
 
63
63
  it "should accept #{operator} as a method name" do
64
- content = <<-END
64
+ code = <<-END
65
65
  def #{operator}
66
66
  end
67
67
  END
68
- @excellent.check_content(content)
68
+ @excellent.check_code(code)
69
69
 
70
70
  @excellent.warnings.should be_empty
71
71
  end
@@ -75,11 +75,11 @@ describe Simplabs::Excellent::Checks::MethodNameCheck do
75
75
  end
76
76
 
77
77
  it 'should reject camel cased method names' do
78
- content = <<-END
78
+ code = <<-END
79
79
  def badMethodName
80
80
  end
81
81
  END
82
- @excellent.check_content(content)
82
+ @excellent.check_code(code)
83
83
  warnings = @excellent.warnings
84
84
 
85
85
  warnings.should_not be_empty
@@ -89,7 +89,7 @@ describe Simplabs::Excellent::Checks::MethodNameCheck do
89
89
  end
90
90
 
91
91
  it "should correctly return the method's full name" do
92
- content = <<-END
92
+ code = <<-END
93
93
  class Class
94
94
  def badMethodName
95
95
  end
@@ -97,7 +97,7 @@ describe Simplabs::Excellent::Checks::MethodNameCheck do
97
97
  end
98
98
  end
99
99
  END
100
- @excellent.check_content(content)
100
+ @excellent.check_code(code)
101
101
  warnings = @excellent.warnings
102
102
 
103
103
  warnings.should_not be_empty
@@ -9,32 +9,32 @@ describe Simplabs::Excellent::Checks::ModuleLineCountCheck do
9
9
  describe '#evaluate' do
10
10
 
11
11
  it 'should accept modules with less lines than the threshold' do
12
- content = <<-END
12
+ code = <<-END
13
13
  module OneLineModule; end
14
14
  END
15
- @excellent.check_content(content)
15
+ @excellent.check_code(code)
16
16
 
17
17
  @excellent.warnings.should be_empty
18
18
  end
19
19
 
20
20
  it 'should accept modules with the same number of lines as the threshold' do
21
- content = <<-END
21
+ code = <<-END
22
22
  module TwoLinesModule
23
23
  end
24
24
  END
25
- @excellent.check_content(content)
25
+ @excellent.check_code(code)
26
26
 
27
27
  @excellent.warnings.should be_empty
28
28
  end
29
29
 
30
30
  it 'should reject modules with more lines than the threshold' do
31
- content = <<-END
31
+ code = <<-END
32
32
  module FourLinesModule
33
33
  @foo = 1
34
34
  @bar = 2
35
35
  end
36
36
  END
37
- @excellent.check_content(content)
37
+ @excellent.check_code(code)
38
38
  warnings = @excellent.warnings
39
39
 
40
40
  warnings.should_not be_empty
@@ -9,31 +9,31 @@ describe Simplabs::Excellent::Checks::ModuleNameCheck do
9
9
  describe '#evaluate' do
10
10
 
11
11
  it 'should accept camel case module names starting in capitals' do
12
- content = <<-END
12
+ code = <<-END
13
13
  module GoodModuleName
14
14
  end
15
15
  END
16
- @excellent.check_content(content)
16
+ @excellent.check_code(code)
17
17
 
18
18
  @excellent.warnings.should be_empty
19
19
  end
20
20
 
21
21
  it 'should accept namespaced modules' do
22
- content = <<-END
22
+ code = <<-END
23
23
  module Outer::Inner::GoodModuleName
24
24
  end
25
25
  END
26
- @excellent.check_content(content)
26
+ @excellent.check_code(code)
27
27
 
28
28
  @excellent.warnings.should be_empty
29
29
  end
30
30
 
31
31
  it 'should reject module names with underscores' do
32
- content = <<-END
32
+ code = <<-END
33
33
  module Bad_ModuleName
34
34
  end
35
35
  END
36
- @excellent.check_content(content)
36
+ @excellent.check_code(code)
37
37
  warnings = @excellent.warnings
38
38
 
39
39
  warnings.should_not be_empty
@@ -43,11 +43,11 @@ describe Simplabs::Excellent::Checks::ModuleNameCheck do
43
43
  end
44
44
 
45
45
  it 'should correctly report bad names of namespaced modules' do
46
- content = <<-END
46
+ code = <<-END
47
47
  module Outer::Inner::Bad_ModuleName
48
48
  end
49
49
  END
50
- @excellent.check_content(content)
50
+ @excellent.check_code(code)
51
51
  warnings = @excellent.warnings
52
52
 
53
53
  warnings.should_not be_empty
@@ -9,13 +9,13 @@ describe Simplabs::Excellent::Checks::NestedIteratorsCheck do
9
9
  describe '#evaluate' do
10
10
 
11
11
  it 'should reject a block inside a block' do
12
- content = <<-END
12
+ code = <<-END
13
13
  method1 do
14
14
  method2 do
15
15
  end
16
16
  end
17
17
  END
18
- @excellent.check_content(content)
18
+ @excellent.check_code(code)
19
19
  warnings = @excellent.warnings
20
20
 
21
21
  warnings.should_not be_empty
@@ -25,7 +25,7 @@ describe Simplabs::Excellent::Checks::NestedIteratorsCheck do
25
25
  end
26
26
 
27
27
  it 'should accept 2 blocks inside a method that are not nested' do
28
- content = <<-END
28
+ code = <<-END
29
29
  def method
30
30
  method1 do
31
31
  end
@@ -33,7 +33,7 @@ describe Simplabs::Excellent::Checks::NestedIteratorsCheck do
33
33
  end
34
34
  end
35
35
  END
36
- @excellent.check_content(content)
36
+ @excellent.check_code(code)
37
37
  warnings = @excellent.warnings
38
38
 
39
39
  warnings.should be_empty
@@ -9,83 +9,83 @@ describe Simplabs::Excellent::Checks::ParameterNumberCheck do
9
9
  describe '#evaluate' do
10
10
 
11
11
  it 'should accept methods with less parameters than the threshold' do
12
- content = <<-END
12
+ code = <<-END
13
13
  def zero_parameter_method
14
14
  end
15
15
  END
16
- @excellent.check_content(content)
16
+ @excellent.check_code(code)
17
17
 
18
18
  @excellent.warnings.should be_empty
19
19
  end
20
20
 
21
21
  it 'should accept methods with the same number of parameters as the threshold' do
22
- content = <<-END
22
+ code = <<-END
23
23
  def one_parameter_method(first_parameter)
24
24
  end
25
25
  END
26
- @excellent.check_content(content)
26
+ @excellent.check_code(code)
27
27
 
28
28
  @excellent.warnings.should be_empty
29
29
  end
30
30
 
31
31
  it 'should reject methods with more parameters than the threshold' do
32
- content = <<-END
32
+ code = <<-END
33
33
  def two_parameter_method(first_parameter, second_parameter)
34
34
  end
35
35
  END
36
36
 
37
- verify_warning_found(content, 'two_parameter_method')
37
+ verify_warning_found(code, 'two_parameter_method')
38
38
  end
39
39
 
40
40
  it 'should work with default values on parameters' do
41
- content = <<-END
41
+ code = <<-END
42
42
  def two_parameter_method(first_parameter = 1, second_parameter = 2)
43
43
  end
44
44
  END
45
45
 
46
- verify_warning_found(content, 'two_parameter_method')
46
+ verify_warning_found(code, 'two_parameter_method')
47
47
  end
48
48
 
49
49
  it 'should work with methods defined on objects' do
50
- content = <<-END
50
+ code = <<-END
51
51
  def object.two_parameter_method(first_parameter = 1, second_parameter = 2)
52
52
  end
53
53
  END
54
54
 
55
- verify_warning_found(content, 'object.two_parameter_method')
55
+ verify_warning_found(code, 'object.two_parameter_method')
56
56
  end
57
57
 
58
58
  it 'should work with methods defined directly on classes' do
59
- content = <<-END
59
+ code = <<-END
60
60
  def Class.two_parameter_method(first_parameter = 1, second_parameter = 2)
61
61
  end
62
62
  END
63
63
 
64
- verify_warning_found(content, 'Class.two_parameter_method')
64
+ verify_warning_found(code, 'Class.two_parameter_method')
65
65
  end
66
66
 
67
67
  it 'should reject yield calls with more parameters than the threshold' do
68
- content = <<-END
68
+ code = <<-END
69
69
  two_parameter_method do |first_parameter, second_parameter|
70
70
  end
71
71
  END
72
72
 
73
- verify_warning_found(content, 'block')
73
+ verify_warning_found(code, 'block')
74
74
  end
75
75
 
76
76
  it 'should reject yield calls on a receiver with more parameters than the threshold' do
77
- content = <<-END
77
+ code = <<-END
78
78
  receiver.two_parameter_method do |first_parameter, second_parameter|
79
79
  end
80
80
  END
81
81
 
82
- verify_warning_found(content, 'block')
82
+ verify_warning_found(code, 'block')
83
83
  end
84
84
 
85
85
  end
86
86
 
87
- def verify_warning_found(content, name)
88
- @excellent.check_content(content)
87
+ def verify_warning_found(code, name)
88
+ @excellent.check_code(code)
89
89
  warnings = @excellent.warnings
90
90
 
91
91
  warnings.should_not be_empty