reek 1.3.8 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +11 -0
  3. data/README.md +22 -14
  4. data/Rakefile +2 -15
  5. data/assets/html_output.html.erb +103 -0
  6. data/features/command_line_interface/options.feature +3 -0
  7. data/features/command_line_interface/smell_selection.feature +19 -0
  8. data/features/rake_task/rake_task.feature +1 -1
  9. data/features/reports/reports.feature +16 -0
  10. data/features/reports/yaml.feature +26 -23
  11. data/features/samples.feature +2 -1
  12. data/features/step_definitions/reek_steps.rb +15 -15
  13. data/features/support/env.rb +7 -9
  14. data/lib/reek/cli/application.rb +2 -4
  15. data/lib/reek/cli/command.rb +12 -0
  16. data/lib/reek/cli/help_command.rb +3 -6
  17. data/lib/reek/cli/options.rb +147 -0
  18. data/lib/reek/cli/reek_command.rb +18 -14
  19. data/lib/reek/cli/report/formatter.rb +56 -0
  20. data/lib/reek/cli/report/report.rb +106 -0
  21. data/lib/reek/cli/report/strategy.rb +63 -0
  22. data/lib/reek/cli/version_command.rb +3 -6
  23. data/lib/reek/config_file_exception.rb +0 -1
  24. data/lib/reek/core/code_context.rb +1 -3
  25. data/lib/reek/core/code_parser.rb +13 -12
  26. data/lib/reek/core/method_context.rb +13 -2
  27. data/lib/reek/core/module_context.rb +0 -4
  28. data/lib/reek/core/object_refs.rb +2 -3
  29. data/lib/reek/core/singleton_method_context.rb +0 -2
  30. data/lib/reek/core/smell_configuration.rb +3 -5
  31. data/lib/reek/core/smell_repository.rb +7 -8
  32. data/lib/reek/core/sniffer.rb +4 -10
  33. data/lib/reek/core/stop_context.rb +2 -4
  34. data/lib/reek/core/warning_collector.rb +0 -1
  35. data/lib/reek/examiner.rb +19 -17
  36. data/lib/reek/rake/task.rb +7 -10
  37. data/lib/reek/smell_warning.rb +4 -8
  38. data/lib/reek/smells.rb +0 -1
  39. data/lib/reek/smells/attribute.rb +8 -11
  40. data/lib/reek/smells/boolean_parameter.rb +5 -7
  41. data/lib/reek/smells/class_variable.rb +6 -7
  42. data/lib/reek/smells/control_parameter.rb +78 -45
  43. data/lib/reek/smells/data_clump.rb +13 -16
  44. data/lib/reek/smells/duplicate_method_call.rb +13 -11
  45. data/lib/reek/smells/feature_envy.rb +6 -7
  46. data/lib/reek/smells/irresponsible_module.rb +4 -6
  47. data/lib/reek/smells/long_parameter_list.rb +5 -7
  48. data/lib/reek/smells/long_yield_list.rb +2 -4
  49. data/lib/reek/smells/nested_iterators.rb +12 -22
  50. data/lib/reek/smells/nil_check.rb +35 -46
  51. data/lib/reek/smells/prima_donna_method.rb +24 -16
  52. data/lib/reek/smells/repeated_conditional.rb +8 -10
  53. data/lib/reek/smells/smell_detector.rb +9 -7
  54. data/lib/reek/smells/too_many_instance_variables.rb +7 -9
  55. data/lib/reek/smells/too_many_methods.rb +6 -8
  56. data/lib/reek/smells/too_many_statements.rb +4 -6
  57. data/lib/reek/smells/uncommunicative_method_name.rb +5 -7
  58. data/lib/reek/smells/uncommunicative_module_name.rb +5 -7
  59. data/lib/reek/smells/uncommunicative_parameter_name.rb +7 -9
  60. data/lib/reek/smells/uncommunicative_variable_name.rb +15 -18
  61. data/lib/reek/smells/unused_parameters.rb +5 -45
  62. data/lib/reek/smells/utility_function.rb +9 -10
  63. data/lib/reek/source.rb +0 -1
  64. data/lib/reek/source/code_comment.rb +7 -8
  65. data/lib/reek/source/config_file.rb +2 -4
  66. data/lib/reek/source/core_extras.rb +1 -1
  67. data/lib/reek/source/reference_collector.rb +1 -2
  68. data/lib/reek/source/sexp_extensions.rb +93 -10
  69. data/lib/reek/source/sexp_formatter.rb +2 -3
  70. data/lib/reek/source/sexp_node.rb +19 -15
  71. data/lib/reek/source/source_code.rb +4 -14
  72. data/lib/reek/source/source_file.rb +3 -5
  73. data/lib/reek/source/source_locator.rb +5 -6
  74. data/lib/reek/source/source_repository.rb +3 -3
  75. data/lib/reek/source/tree_dresser.rb +2 -2
  76. data/lib/reek/spec.rb +1 -2
  77. data/lib/reek/spec/should_reek.rb +8 -5
  78. data/lib/reek/spec/should_reek_of.rb +6 -4
  79. data/lib/reek/spec/should_reek_only_of.rb +10 -6
  80. data/lib/reek/version.rb +1 -1
  81. data/reek.gemspec +34 -30
  82. data/spec/gem/updates_spec.rb +3 -4
  83. data/spec/gem/yard_spec.rb +1 -2
  84. data/spec/matchers/smell_of_matcher.rb +12 -14
  85. data/spec/quality/reek_source_spec.rb +42 -0
  86. data/spec/reek/cli/help_command_spec.rb +7 -5
  87. data/spec/reek/cli/report_spec.rb +89 -22
  88. data/spec/reek/cli/version_command_spec.rb +8 -6
  89. data/spec/reek/core/code_context_spec.rb +25 -26
  90. data/spec/reek/core/code_parser_spec.rb +6 -6
  91. data/spec/reek/core/method_context_spec.rb +18 -18
  92. data/spec/reek/core/module_context_spec.rb +5 -5
  93. data/spec/reek/core/object_refs_spec.rb +21 -22
  94. data/spec/reek/core/smell_configuration_spec.rb +22 -21
  95. data/spec/reek/core/stop_context_spec.rb +2 -2
  96. data/spec/reek/core/warning_collector_spec.rb +3 -3
  97. data/spec/reek/examiner_spec.rb +9 -9
  98. data/spec/reek/smell_warning_spec.rb +29 -29
  99. data/spec/reek/smells/attribute_spec.rb +6 -6
  100. data/spec/reek/smells/behaves_like_variable_detector.rb +6 -6
  101. data/spec/reek/smells/boolean_parameter_spec.rb +17 -17
  102. data/spec/reek/smells/class_variable_spec.rb +9 -9
  103. data/spec/reek/smells/control_parameter_spec.rb +161 -137
  104. data/spec/reek/smells/data_clump_spec.rb +22 -19
  105. data/spec/reek/smells/duplicate_method_call_spec.rb +71 -27
  106. data/spec/reek/smells/feature_envy_spec.rb +32 -32
  107. data/spec/reek/smells/irresponsible_module_spec.rb +21 -21
  108. data/spec/reek/smells/long_parameter_list_spec.rb +14 -14
  109. data/spec/reek/smells/long_yield_list_spec.rb +6 -6
  110. data/spec/reek/smells/nested_iterators_spec.rb +21 -21
  111. data/spec/reek/smells/nil_check_spec.rb +23 -15
  112. data/spec/reek/smells/prima_donna_method_spec.rb +5 -5
  113. data/spec/reek/smells/repeated_conditional_spec.rb +14 -14
  114. data/spec/reek/smells/smell_detector_shared.rb +9 -9
  115. data/spec/reek/smells/too_many_instance_variables_spec.rb +12 -12
  116. data/spec/reek/smells/too_many_methods_spec.rb +10 -10
  117. data/spec/reek/smells/too_many_statements_spec.rb +41 -41
  118. data/spec/reek/smells/uncommunicative_method_name_spec.rb +4 -4
  119. data/spec/reek/smells/uncommunicative_module_name_spec.rb +12 -12
  120. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +21 -21
  121. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +49 -49
  122. data/spec/reek/smells/unused_parameters_spec.rb +26 -16
  123. data/spec/reek/smells/utility_function_spec.rb +20 -20
  124. data/spec/reek/source/code_comment_spec.rb +37 -37
  125. data/spec/reek/source/object_source_spec.rb +5 -5
  126. data/spec/reek/source/reference_collector_spec.rb +9 -9
  127. data/spec/reek/source/sexp_extensions_spec.rb +73 -52
  128. data/spec/reek/source/sexp_formatter_spec.rb +3 -4
  129. data/spec/reek/source/sexp_node_spec.rb +3 -3
  130. data/spec/reek/source/source_code_spec.rb +16 -15
  131. data/spec/reek/source/tree_dresser_spec.rb +2 -2
  132. data/spec/reek/spec/should_reek_of_spec.rb +11 -11
  133. data/spec/reek/spec/should_reek_only_of_spec.rb +11 -11
  134. data/spec/reek/spec/should_reek_spec.rb +11 -11
  135. data/spec/samples/one_smelly_file/dirty.rb +3 -0
  136. data/spec/spec_helper.rb +0 -6
  137. data/tasks/develop.rake +8 -16
  138. data/tasks/reek.rake +5 -13
  139. data/tasks/test.rake +5 -22
  140. metadata +56 -34
  141. data/lib/reek/cli/command_line.rb +0 -126
  142. data/lib/reek/cli/report.rb +0 -138
@@ -10,32 +10,32 @@ shared_examples_for 'SmellDetector' do
10
10
  allow(@ctx).to receive(:config_for).and_return({})
11
11
  end
12
12
  it 'when false' do
13
- @ctx.should_receive(:matches?).at_least(:once).and_return(false)
14
- @detector.exception?(@ctx).should == false
13
+ expect(@ctx).to receive(:matches?).at_least(:once).and_return(false)
14
+ expect(@detector.exception?(@ctx)).to eq(false)
15
15
  end
16
16
 
17
17
  it 'when true' do
18
- @ctx.should_receive(:matches?).at_least(:once).and_return(true)
19
- @detector.exception?(@ctx).should == true
18
+ expect(@ctx).to receive(:matches?).at_least(:once).and_return(true)
19
+ expect(@detector.exception?(@ctx)).to eq(true)
20
20
  end
21
21
  end
22
22
 
23
23
  context 'configuration' do
24
24
  it 'becomes disabled when disabled' do
25
- @detector.configure_with({SmellConfiguration::ENABLED_KEY => false})
26
- @detector.should_not be_enabled
25
+ @detector.configure_with(SmellConfiguration::ENABLED_KEY => false)
26
+ expect(@detector).not_to be_enabled
27
27
  end
28
28
  end
29
29
  end
30
30
 
31
31
  shared_examples_for 'common fields set correctly' do
32
32
  it 'reports the source' do
33
- @warning.source.should == @source_name
33
+ expect(@warning.source).to eq(@source_name)
34
34
  end
35
35
  it 'reports the class' do
36
- @warning.smell_class.should == @detector.class::SMELL_CLASS
36
+ expect(@warning.smell_class).to eq(@detector.class::SMELL_CLASS)
37
37
  end
38
38
  it 'reports the subclass' do
39
- @warning.subclass.should == @detector.class::SMELL_SUBCLASS
39
+ expect(@warning.subclass).to eq(@detector.class::SMELL_SUBCLASS)
40
40
  end
41
41
  end
@@ -17,18 +17,18 @@ describe TooManyInstanceVariables do
17
17
 
18
18
  context 'counting instance variables' do
19
19
  it 'should not report 9 ivars' do
20
- '# clean class for testing purposes
21
- class Empty;def ivars() @aa=@ab=@ac=@ad=@ae=@af=@ag=@ah=@ai=4; end;end'.should_not reek
20
+ expect('# clean class for testing purposes
21
+ class Empty;def ivars() @aa=@ab=@ac=@ad=@ae=@af=@ag=@ah=@ai=4; end;end').not_to reek
22
22
  end
23
23
 
24
24
  it 'counts each ivar only once' do
25
- '# clean class for testing purposes
26
- class Empty;def ivars() @aa=@ab=@ac=@ad=@ae=@af=@ag=@ah=@ai=4;@aa=3; end;end'.should_not reek
25
+ expect('# clean class for testing purposes
26
+ class Empty;def ivars() @aa=@ab=@ac=@ad=@ae=@af=@ag=@ah=@ai=4;@aa=3; end;end').not_to reek
27
27
  end
28
28
 
29
29
  it 'should report 10 ivars' do
30
- '# smelly class for testing purposes
31
- class Empty;def ivars() @aa=@ab=@ac=@ad=@ae=@af=@ag=@ah=@ai=@aj=4; end;end'.should reek_only_of(:TooManyInstanceVariables)
30
+ expect('# smelly class for testing purposes
31
+ class Empty;def ivars() @aa=@ab=@ac=@ad=@ae=@af=@ag=@ah=@ai=@aj=4; end;end').to reek_only_of(:TooManyInstanceVariables)
32
32
  end
33
33
 
34
34
  it 'should not report 10 ivars in 2 extensions' do
@@ -38,7 +38,7 @@ class Full;def ivars_a() @aa=@ab=@ac=@ad=@ae; end;end
38
38
  # clean class for testing purposes
39
39
  class Full;def ivars_b() @af=@ag=@ah=@ai=@aj; end;end
40
40
  EOS
41
- src.should_not reek
41
+ expect(src).not_to reek
42
42
  end
43
43
  end
44
44
 
@@ -53,10 +53,10 @@ end
53
53
  EOS
54
54
  ctx = CodeContext.new(nil, src.to_reek_source.syntax_tree)
55
55
  @warning = @detector.examine_context(ctx)[0]
56
- @warning.source.should == @source_name
57
- @warning.smell_class.should == 'LargeClass'
58
- @warning.subclass.should == TooManyInstanceVariables::SMELL_SUBCLASS
59
- @warning.smell[TooManyInstanceVariables::IVAR_COUNT_KEY].should == 10
60
- @warning.lines.should == [2]
56
+ expect(@warning.source).to eq(@source_name)
57
+ expect(@warning.smell_class).to eq('LargeClass')
58
+ expect(@warning.subclass).to eq(TooManyInstanceVariables::SMELL_SUBCLASS)
59
+ expect(@warning.smell[TooManyInstanceVariables::IVAR_COUNT_KEY]).to eq(10)
60
+ expect(@warning.lines).to eq([2])
61
61
  end
62
62
  end
@@ -29,7 +29,7 @@ class Full
29
29
  end
30
30
  EOS
31
31
  ctx = CodeContext.new(nil, src.to_reek_source.syntax_tree)
32
- @detector.examine_context(ctx).should be_empty
32
+ expect(@detector.examine_context(ctx)).to be_empty
33
33
  end
34
34
 
35
35
  it 'should report 26 methods' do
@@ -45,9 +45,9 @@ end
45
45
  EOS
46
46
  ctx = CodeContext.new(nil, src.to_reek_source.syntax_tree)
47
47
  smells = @detector.examine_context(ctx)
48
- smells.length.should == 1
49
- smells[0].subclass.should == TooManyMethods::SMELL_SUBCLASS
50
- smells[0].smell[TooManyMethods::METHOD_COUNT_KEY].should == 26
48
+ expect(smells.length).to eq(1)
49
+ expect(smells[0].subclass).to eq(TooManyMethods::SMELL_SUBCLASS)
50
+ expect(smells[0].smell[TooManyMethods::METHOD_COUNT_KEY]).to eq(26)
51
51
  end
52
52
  end
53
53
 
@@ -64,7 +64,7 @@ class Full
64
64
  end
65
65
  EOS
66
66
  ctx = CodeContext.new(nil, src.to_reek_source.syntax_tree)
67
- @detector.examine_context(ctx).should be_empty
67
+ expect(@detector.examine_context(ctx)).to be_empty
68
68
  end
69
69
  end
70
70
 
@@ -81,10 +81,10 @@ end
81
81
  EOS
82
82
  ctx = CodeContext.new(nil, src.to_reek_source.syntax_tree)
83
83
  @warning = @detector.examine_context(ctx)[0]
84
- @warning.source.should == @source_name
85
- @warning.smell_class.should == 'LargeClass'
86
- @warning.subclass.should == TooManyMethods::SMELL_SUBCLASS
87
- @warning.smell[TooManyMethods::METHOD_COUNT_KEY].should == 26
88
- @warning.lines.should == [1]
84
+ expect(@warning.source).to eq(@source_name)
85
+ expect(@warning.smell_class).to eq('LargeClass')
86
+ expect(@warning.subclass).to eq(TooManyMethods::SMELL_SUBCLASS)
87
+ expect(@warning.smell[TooManyMethods::METHOD_COUNT_KEY]).to eq(26)
88
+ expect(@warning.lines).to eq([1])
89
89
  end
90
90
  end
@@ -22,17 +22,17 @@ end
22
22
  describe TooManyStatements do
23
23
  it 'should not report short methods' do
24
24
  src = 'def short(arga) alf = f(1);@bet = 2;@cut = 3;@dit = 4; @emp = 5;end'
25
- src.should_not smell_of(TooManyStatements)
25
+ expect(src).not_to smell_of(TooManyStatements)
26
26
  end
27
27
 
28
28
  it 'should report long methods' do
29
29
  src = 'def long() alf = f(1);@bet = 2;@cut = 3;@dit = 4; @emp = 5;@fry = 6;end'
30
- src.should reek_only_of(:TooManyStatements, /6 statements/)
30
+ expect(src).to reek_only_of(:TooManyStatements, /6 statements/)
31
31
  end
32
32
 
33
33
  it 'should not report initialize' do
34
34
  src = 'def initialize(arga) alf = f(1);@bet = 2;@cut = 3;@dit = 4; @emp = 5;@fry = 6;end'
35
- src.should_not smell_of(TooManyStatements)
35
+ expect(src).not_to smell_of(TooManyStatements)
36
36
  end
37
37
 
38
38
  it 'should only report a long method once' do
@@ -54,7 +54,7 @@ def standard_entries(rbconfig)
54
54
  end
55
55
  end
56
56
  EOS
57
- src.should reek_only_of(:TooManyStatements)
57
+ expect(src).to reek_only_of(:TooManyStatements)
58
58
  end
59
59
 
60
60
  it 'should report long inner block' do
@@ -71,166 +71,166 @@ def long()
71
71
  end
72
72
  end
73
73
  EOS
74
- src.should reek_only_of(:TooManyStatements)
74
+ expect(src).to reek_only_of(:TooManyStatements)
75
75
  end
76
76
  end
77
77
 
78
78
  describe TooManyStatements do
79
79
  it 'counts 1 assignment' do
80
80
  method = process_method('def one() val = 4; end')
81
- method.num_statements.should == 1
81
+ expect(method.num_statements).to eq(1)
82
82
  end
83
83
 
84
84
  it 'counts 3 assignments' do
85
85
  method = process_method('def one() val = 4; val = 4; val = 4; end')
86
- method.num_statements.should == 3
86
+ expect(method.num_statements).to eq(3)
87
87
  end
88
88
 
89
89
  it 'counts 1 attr assignment' do
90
90
  method = process_method('def one() val[0] = 4; end')
91
- method.num_statements.should == 1
91
+ expect(method.num_statements).to eq(1)
92
92
  end
93
93
 
94
94
  it 'counts 1 increment assignment' do
95
95
  method = process_method('def one() val += 4; end')
96
- method.num_statements.should == 1
96
+ expect(method.num_statements).to eq(1)
97
97
  end
98
98
 
99
99
  it 'counts 1 increment attr assignment' do
100
100
  method = process_method('def one() val[0] += 4; end')
101
- method.num_statements.should == 1
101
+ expect(method.num_statements).to eq(1)
102
102
  end
103
103
 
104
104
  it 'counts 1 nested assignment' do
105
105
  method = process_method('def one() val = fred = 4; end')
106
- method.num_statements.should == 1
106
+ expect(method.num_statements).to eq(1)
107
107
  end
108
108
 
109
109
  it 'counts returns' do
110
110
  method = process_method('def one() val = 4; true; end')
111
- method.num_statements.should == 2
111
+ expect(method.num_statements).to eq(2)
112
112
  end
113
113
 
114
114
  it 'counts nil returns' do
115
115
  method = process_method('def one() val = 4; nil; end')
116
- method.num_statements.should == 2
116
+ expect(method.num_statements).to eq(2)
117
117
  end
118
118
  end
119
119
 
120
120
  describe TooManyStatements, 'does not count control statements' do
121
121
  it 'counts 1 statement in a conditional expression' do
122
122
  method = process_method('def one() if val == 4; callee(); end; end')
123
- method.num_statements.should == 1
123
+ expect(method.num_statements).to eq(1)
124
124
  end
125
125
 
126
126
  it 'counts 3 statements in a conditional expression' do
127
127
  method = process_method('def one() if val == 4; callee(); callee(); callee(); end; end')
128
- method.num_statements.should == 3
128
+ expect(method.num_statements).to eq(3)
129
129
  end
130
130
 
131
131
  it 'counts 1 statements in an else' do
132
132
  method = process_method('def one() if val == 4; callee(); else; callee(); end; end')
133
- method.num_statements.should == 2
133
+ expect(method.num_statements).to eq(2)
134
134
  end
135
135
 
136
136
  it 'counts 3 statements in an else' do
137
137
  method = process_method('def one() if val == 4; callee(); callee(); callee(); else; callee(); callee(); callee(); end; end')
138
- method.num_statements.should == 6
138
+ expect(method.num_statements).to eq(6)
139
139
  end
140
140
 
141
141
  it 'does not count empty conditional expression' do
142
142
  method = process_method('def one() if val == 4; ; end; end')
143
- method.num_statements.should == 0
143
+ expect(method.num_statements).to eq(0)
144
144
  end
145
145
 
146
146
  it 'does not count empty else' do
147
147
  method = process_method('def one() if val == 4; ; else; ; end; end')
148
- method.num_statements.should == 0
148
+ expect(method.num_statements).to eq(0)
149
149
  end
150
150
 
151
151
  it 'counts 1 statement in a while loop' do
152
152
  method = process_method('def one() while val < 4; callee(); end; end')
153
- method.num_statements.should == 1
153
+ expect(method.num_statements).to eq(1)
154
154
  end
155
155
 
156
156
  it 'counts 3 statements in a while loop' do
157
157
  method = process_method('def one() while val < 4; callee(); callee(); callee(); end; end')
158
- method.num_statements.should == 3
158
+ expect(method.num_statements).to eq(3)
159
159
  end
160
160
 
161
161
  it 'counts 1 statement in a until loop' do
162
162
  method = process_method('def one() until val < 4; callee(); end; end')
163
- method.num_statements.should == 1
163
+ expect(method.num_statements).to eq(1)
164
164
  end
165
165
 
166
166
  it 'counts 3 statements in a until loop' do
167
167
  method = process_method('def one() until val < 4; callee(); callee(); callee(); end; end')
168
- method.num_statements.should == 3
168
+ expect(method.num_statements).to eq(3)
169
169
  end
170
170
 
171
171
  it 'counts 1 statement in a for loop' do
172
172
  method = process_method('def one() for i in 0..4; callee(); end; end')
173
- method.num_statements.should == 1
173
+ expect(method.num_statements).to eq(1)
174
174
  end
175
175
 
176
176
  it 'counts 3 statements in a for loop' do
177
177
  method = process_method('def one() for i in 0..4; callee(); callee(); callee(); end; end')
178
- method.num_statements.should == 3
178
+ expect(method.num_statements).to eq(3)
179
179
  end
180
180
 
181
181
  it 'counts 1 statement in a rescue' do
182
182
  method = process_method('def one() begin; callee(); rescue; callee(); end; end')
183
- method.num_statements.should == 2
183
+ expect(method.num_statements).to eq(2)
184
184
  end
185
185
 
186
186
  it 'counts 3 statements in a rescue' do
187
187
  method = process_method('def one() begin; callee(); callee(); callee(); rescue; callee(); callee(); callee(); end; end')
188
- method.num_statements.should == 6
188
+ expect(method.num_statements).to eq(6)
189
189
  end
190
190
 
191
191
  it 'counts 1 statement in a when' do
192
192
  method = process_method('def one() case fred; when "hi"; callee(); end; end')
193
- method.num_statements.should == 1
193
+ expect(method.num_statements).to eq(1)
194
194
  end
195
195
 
196
196
  it 'counts 3 statements in a when' do
197
197
  method = process_method('def one() case fred; when "hi"; callee(); callee(); when "lo"; callee(); end; end')
198
- method.num_statements.should == 3
198
+ expect(method.num_statements).to eq(3)
199
199
  end
200
200
 
201
201
  it 'counts 1 statement in a case else' do
202
202
  method = process_method('def one() case fred; when "hi"; callee(); else; callee(); end; end')
203
- method.num_statements.should == 2
203
+ expect(method.num_statements).to eq(2)
204
204
  end
205
205
 
206
206
  it 'counts 3 statements in a case else' do
207
207
  method = process_method('def one() case fred; when "hi"; callee(); callee(); callee(); else; callee(); callee(); callee(); end; end')
208
- method.num_statements.should == 6
208
+ expect(method.num_statements).to eq(6)
209
209
  end
210
210
 
211
211
  it 'does not count empty case' do
212
212
  method = process_method('def one() case fred; when "hi"; ; when "lo"; ; end; end')
213
- method.num_statements.should == 0
213
+ expect(method.num_statements).to eq(0)
214
214
  end
215
215
 
216
216
  it 'does not count empty case else' do
217
217
  method = process_method('def one() case fred; when "hi"; ; else; ; end; end')
218
- method.num_statements.should == 0
218
+ expect(method.num_statements).to eq(0)
219
219
  end
220
220
 
221
221
  it 'counts 2 statement in an iterator' do
222
222
  method = process_method('def one() fred.each do; callee(); end; end')
223
- method.num_statements.should == 2
223
+ expect(method.num_statements).to eq(2)
224
224
  end
225
225
 
226
226
  it 'counts 4 statements in an iterator' do
227
227
  method = process_method('def one() fred.each do; callee(); callee(); callee(); end; end')
228
- method.num_statements.should == 4
228
+ expect(method.num_statements).to eq(4)
229
229
  end
230
230
 
231
231
  it 'counts 1 statement in a singleton method' do
232
232
  method = process_singleton_method('def self.foo; callee(); end')
233
- method.num_statements.should == 1
233
+ expect(method.num_statements).to eq(1)
234
234
  end
235
235
  end
236
236
 
@@ -245,18 +245,18 @@ describe TooManyStatements do
245
245
  before :each do
246
246
  @num_statements = 30
247
247
  ctx = double('method_context').as_null_object
248
- ctx.should_receive(:num_statements).and_return(@num_statements)
249
- ctx.should_receive(:config_for).with(TooManyStatements).and_return({})
248
+ expect(ctx).to receive(:num_statements).and_return(@num_statements)
249
+ expect(ctx).to receive(:config_for).with(TooManyStatements).and_return({})
250
250
  @smells = @detector.examine_context(ctx)
251
251
  end
252
252
  it 'reports only 1 smell' do
253
- @smells.length.should == 1
253
+ expect(@smells.length).to eq(1)
254
254
  end
255
255
  it 'reports the number of statements' do
256
- @smells[0].smell[TooManyStatements::STATEMENT_COUNT_KEY].should == @num_statements
256
+ expect(@smells[0].smell[TooManyStatements::STATEMENT_COUNT_KEY]).to eq(@num_statements)
257
257
  end
258
258
  it 'reports the correct subclass' do
259
- @smells[0].subclass.should == TooManyStatements::SMELL_SUBCLASS
259
+ expect(@smells[0].subclass).to eq(TooManyStatements::SMELL_SUBCLASS)
260
260
  end
261
261
  end
262
262
  end
@@ -17,7 +17,7 @@ describe UncommunicativeMethodName do
17
17
 
18
18
  ['help', '+', '-', '/', '*'].each do |method_name|
19
19
  it "accepts the method name '#{method_name}'" do
20
- "def #{method_name}(fred) basics(17) end".should_not smell_of(UncommunicativeMethodName)
20
+ expect("def #{method_name}(fred) basics(17) end").not_to smell_of(UncommunicativeMethodName)
21
21
  end
22
22
  end
23
23
 
@@ -33,9 +33,9 @@ describe UncommunicativeMethodName do
33
33
  it_should_behave_like 'common fields set correctly'
34
34
 
35
35
  it 'reports the correct values' do
36
- @warning.smell[UncommunicativeMethodName::METHOD_NAME_KEY].should == method_name
37
- @warning.lines.should == [1]
38
- @warning.context.should == method_name
36
+ expect(@warning.smell[UncommunicativeMethodName::METHOD_NAME_KEY]).to eq(method_name)
37
+ expect(@warning.lines).to eq([1])
38
+ expect(@warning.context).to eq(method_name)
39
39
  end
40
40
  end
41
41
  end
@@ -17,26 +17,26 @@ describe UncommunicativeModuleName do
17
17
 
18
18
  ['class', 'module'].each do |type|
19
19
  it 'does not report one-word name' do
20
- "#{type} Helper; end".should_not reek_of(:UncommunicativeModuleName)
20
+ expect("#{type} Helper; end").not_to reek_of(:UncommunicativeModuleName)
21
21
  end
22
22
  it 'reports one-letter name' do
23
- "#{type} X; end".should reek_of(:UncommunicativeModuleName, /X/)
23
+ expect("#{type} X; end").to reek_of(:UncommunicativeModuleName, /X/)
24
24
  end
25
25
  it 'reports name of the form "x2"' do
26
- "#{type} X2; end".should reek_of(:UncommunicativeModuleName, /X2/)
26
+ expect("#{type} X2; end").to reek_of(:UncommunicativeModuleName, /X2/)
27
27
  end
28
28
  it 'reports long name ending in a number' do
29
- "#{type} Printer2; end".should reek_of(:UncommunicativeModuleName, /Printer2/)
29
+ expect("#{type} Printer2; end").to reek_of(:UncommunicativeModuleName, /Printer2/)
30
30
  end
31
31
  it 'reports a bad scoped name' do
32
32
  src = "#{type} Foo::X; end"
33
33
  ctx = CodeContext.new(nil, src.to_reek_source.syntax_tree)
34
34
  smells = @detector.examine_context(ctx)
35
- smells.length.should == 1
36
- smells[0].smell_class.should == UncommunicativeModuleName::SMELL_CLASS
37
- smells[0].subclass.should == UncommunicativeModuleName::SMELL_SUBCLASS
38
- smells[0].smell[UncommunicativeModuleName::MODULE_NAME_KEY].should == 'X'
39
- smells[0].context.should match(/#{smells[0].smell[UncommunicativeModuleName::MODULE_NAME_KEY]}/)
35
+ expect(smells.length).to eq(1)
36
+ expect(smells[0].smell_class).to eq(UncommunicativeModuleName::SMELL_CLASS)
37
+ expect(smells[0].subclass).to eq(UncommunicativeModuleName::SMELL_SUBCLASS)
38
+ expect(smells[0].smell[UncommunicativeModuleName::MODULE_NAME_KEY]).to eq('X')
39
+ expect(smells[0].context).to match(/#{smells[0].smell[UncommunicativeModuleName::MODULE_NAME_KEY]}/)
40
40
  end
41
41
  end
42
42
 
@@ -44,7 +44,7 @@ describe UncommunicativeModuleName do
44
44
  it 'accepts Inline::C' do
45
45
  src = 'module Inline::C; end'
46
46
  ctx = CodeContext.new(nil, src.to_reek_source.syntax_tree)
47
- @detector.examine_context(ctx).should be_empty
47
+ expect(@detector.examine_context(ctx)).to be_empty
48
48
  end
49
49
  end
50
50
 
@@ -59,8 +59,8 @@ describe UncommunicativeModuleName do
59
59
  it_should_behave_like 'common fields set correctly'
60
60
 
61
61
  it 'reports the correct values' do
62
- @warning.smell[UncommunicativeModuleName::MODULE_NAME_KEY].should == 'Printer2'
63
- @warning.lines.should == [1]
62
+ expect(@warning.smell[UncommunicativeModuleName::MODULE_NAME_KEY]).to eq('Printer2')
63
+ expect(@warning.lines).to eq([1])
64
64
  end
65
65
  end
66
66
  end