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
@@ -6,22 +6,22 @@ include Reek::Core
6
6
 
7
7
  describe ModuleContext do
8
8
  it 'should report module name for smell in method' do
9
- 'module Fred; def simple(x) x + 1; end; end'.should reek_of(:UncommunicativeParameterName, /x/, /simple/)
9
+ expect('module Fred; def simple(x) x + 1; end; end').to reek_of(:UncommunicativeParameterName, /x/, /simple/)
10
10
  end
11
11
 
12
12
  it 'should not report module with empty class' do
13
- '# module for test
13
+ expect('# module for test
14
14
  module Fred
15
15
  # module for test
16
- class Jim; end; end'.should_not reek
16
+ class Jim; end; end').not_to reek
17
17
  end
18
18
  end
19
19
 
20
20
  describe ModuleContext do
21
21
  it 'should recognise global constant' do
22
- '# module for test
22
+ expect('# module for test
23
23
  module ::Global
24
24
  # module for test
25
- class Inside; end; end'.should_not reek
25
+ class Inside; end; end').not_to reek
26
26
  end
27
27
  end
@@ -10,11 +10,11 @@ describe ObjectRefs do
10
10
 
11
11
  context 'when empty' do
12
12
  it 'should report no refs to self' do
13
- @refs.references_to(:self).should == 0
13
+ expect(@refs.references_to(:self)).to eq(0)
14
14
  end
15
15
  end
16
16
 
17
- context "with references to a, b, and a" do
17
+ context 'with references to a, b, and a' do
18
18
  context 'with no refs to self' do
19
19
  before(:each) do
20
20
  @refs.record_reference_to('a')
@@ -23,33 +23,33 @@ describe ObjectRefs do
23
23
  end
24
24
 
25
25
  it 'should report no refs to self' do
26
- @refs.references_to(:self).should == 0
26
+ expect(@refs.references_to(:self)).to eq(0)
27
27
  end
28
28
 
29
29
  it 'should report :a as the max' do
30
- @refs.max_keys.should == {'a' => 2}
30
+ expect(@refs.max_keys).to eq('a' => 2)
31
31
  end
32
32
 
33
33
  it 'should not report self as the max' do
34
- @refs.self_is_max?.should == false
34
+ expect(@refs.self_is_max?).to eq(false)
35
35
  end
36
36
 
37
- context "with one reference to self" do
37
+ context 'with one reference to self' do
38
38
  before(:each) do
39
39
  @refs.record_reference_to(:self)
40
40
  end
41
41
 
42
42
  it 'should report 1 ref to self' do
43
- @refs.references_to(:self).should == 1
43
+ expect(@refs.references_to(:self)).to eq(1)
44
44
  end
45
45
 
46
46
  it 'should not report self among the max' do
47
- @refs.max_keys.should include('a')
48
- @refs.max_keys.should_not include(:self)
47
+ expect(@refs.max_keys).to include('a')
48
+ expect(@refs.max_keys).not_to include(:self)
49
49
  end
50
50
 
51
51
  it 'should not report self as the max' do
52
- @refs.self_is_max?.should == false
52
+ expect(@refs.self_is_max?).to eq(false)
53
53
  end
54
54
  end
55
55
  end
@@ -67,15 +67,15 @@ describe ObjectRefs do
67
67
  end
68
68
 
69
69
  it 'should report all refs to self' do
70
- @refs.references_to(:self).should == 4
70
+ expect(@refs.references_to(:self)).to eq(4)
71
71
  end
72
72
 
73
73
  it 'should report self among the max' do
74
- @refs.max_keys.should == { :self => 4}
74
+ expect(@refs.max_keys).to eq(self: 4)
75
75
  end
76
76
 
77
77
  it 'should report self as the max' do
78
- @refs.self_is_max?.should == true
78
+ expect(@refs.self_is_max?).to eq(true)
79
79
  end
80
80
  end
81
81
 
@@ -89,16 +89,16 @@ describe ObjectRefs do
89
89
  end
90
90
 
91
91
  it 'should report all refs to self' do
92
- @refs.references_to(:self).should == 2
92
+ expect(@refs.references_to(:self)).to eq(2)
93
93
  end
94
94
 
95
95
  it 'should report self among the max' do
96
- @refs.max_keys.should include('a')
97
- @refs.max_keys.should include(:self)
96
+ expect(@refs.max_keys).to include('a')
97
+ expect(@refs.max_keys).to include(:self)
98
98
  end
99
99
 
100
100
  it 'should report self as the max' do
101
- @refs.self_is_max?.should == true
101
+ expect(@refs.self_is_max?).to eq(true)
102
102
  end
103
103
  end
104
104
 
@@ -111,17 +111,16 @@ describe ObjectRefs do
111
111
  end
112
112
 
113
113
  it 'should report all refs to self' do
114
- @refs.references_to(:self).should == 0
114
+ expect(@refs.references_to(:self)).to eq(0)
115
115
  end
116
116
 
117
117
  it 'should not report self among the max' do
118
- @refs.max_keys.should include('a')
119
- @refs.max_keys.should include('b')
118
+ expect(@refs.max_keys).to include('a')
119
+ expect(@refs.max_keys).to include('b')
120
120
  end
121
121
 
122
122
  it 'should not report self as the max' do
123
- @refs.self_is_max?.should == false
123
+ expect(@refs.self_is_max?).to eq(false)
124
124
  end
125
125
  end
126
126
  end
127
-
@@ -6,42 +6,43 @@ include Reek::Core
6
6
  describe SmellConfiguration do
7
7
  it 'returns the default value when key not found' do
8
8
  cf = SmellConfiguration.new({})
9
- cf.value('fred', nil, 27).should == 27
9
+ expect(cf.value('fred', nil, 27)).to eq(27)
10
10
  end
11
11
 
12
12
  context 'when overriding default configs' do
13
13
  before(:each) do
14
- @base_config = {"enabled"=>true, "exclude"=>[],
15
- "reject"=>[/^.$/, /[0-9]$/, /[A-Z]/],
16
- "accept"=>["_"]}
14
+ @base_config = { 'enabled' => true, 'exclude' => [],
15
+ 'reject' => [/^.$/, /[0-9]$/, /[A-Z]/],
16
+ 'accept' => ['_'] }
17
17
  @smell_config = SmellConfiguration.new(@base_config)
18
18
  end
19
19
 
20
- it { @smell_config.merge!({}).should == @base_config }
21
- it { @smell_config.merge!({"enabled"=>true}).should == @base_config }
22
- it { @smell_config.merge!({"exclude"=>[]}).should == @base_config }
23
- it { @smell_config.merge!({"accept"=>["_"]}).should == @base_config }
24
- it { @smell_config.merge!({"reject"=>[/^.$/, /[0-9]$/, /[A-Z]/]}).should == @base_config }
25
- it { @smell_config.merge!({"enabled"=>true, "accept"=>["_"]}).should == @base_config }
20
+ it { expect(@smell_config.merge!({})).to eq(@base_config) }
21
+ it { expect(@smell_config.merge!('enabled' => true)).to eq(@base_config) }
22
+ it { expect(@smell_config.merge!('exclude' => [])).to eq(@base_config) }
23
+ it { expect(@smell_config.merge!('accept' => ['_'])).to eq(@base_config) }
24
+ it { expect(@smell_config.merge!('reject' => [/^.$/, /[0-9]$/, /[A-Z]/])).to eq(@base_config) }
25
+ it { expect(@smell_config.merge!('enabled' => true, 'accept' => ['_'])).to eq(@base_config) }
26
26
 
27
27
  it 'should override single values' do
28
- @smell_config.merge!({"enabled"=>false}).should == {"enabled"=>false, "exclude"=>[],
29
- "reject"=>[/^.$/, /[0-9]$/, /[A-Z]/],
30
- "accept"=>["_"]}
28
+ expect(@smell_config.merge!('enabled' => false)).to eq('enabled' => false, 'exclude' => [],
29
+ 'reject' => [/^.$/, /[0-9]$/, /[A-Z]/],
30
+ 'accept' => ['_'])
31
31
  end
32
32
 
33
33
  it 'should override arrays of values' do
34
- @smell_config.merge!({"reject"=>[/^.$/, /[3-9]$/]}).should == {"enabled"=>true,
35
- "exclude"=>[],
36
- "reject"=>[/^.$/, /[3-9]$/],
37
- "accept"=>["_"]}
34
+ expect(@smell_config.merge!('reject' => [/^.$/, /[3-9]$/])).to eq('enabled' => true,
35
+ 'exclude' => [],
36
+ 'reject' => [/^.$/, /[3-9]$/],
37
+ 'accept' => ['_'])
38
38
  end
39
39
 
40
40
  it 'should override multiple values' do
41
- @smell_config.merge!({"enabled"=>false, "accept"=>[/[A-Z]$/]}).should ==
42
- {"enabled"=>false, "exclude"=>[],
43
- "reject"=>[/^.$/, /[0-9]$/, /[A-Z]/],
44
- "accept"=>[/[A-Z]$/]}
41
+ expect(@smell_config.merge!('enabled' => false, 'accept' => [/[A-Z]$/])).to eq(
42
+ 'enabled' => false, 'exclude' => [],
43
+ 'reject' => [/^.$/, /[0-9]$/, /[A-Z]/],
44
+ 'accept' => [/[A-Z]$/]
45
+ )
45
46
  end
46
47
  end
47
48
  end
@@ -10,8 +10,8 @@ describe StopContext do
10
10
  end
11
11
 
12
12
  context 'full_name' do
13
- it "reports full context" do
14
- @stop.full_name.should == ''
13
+ it 'reports full context' do
14
+ expect(@stop.full_name).to eq('')
15
15
  end
16
16
  end
17
17
  end
@@ -11,17 +11,17 @@ describe WarningCollector do
11
11
 
12
12
  context 'when empty' do
13
13
  it 'reports no warnings' do
14
- @collector.warnings.should == []
14
+ expect(@collector.warnings).to eq([])
15
15
  end
16
16
  end
17
17
 
18
18
  context 'with one warning' do
19
19
  before :each do
20
- @warning = Reek::SmellWarning.new('ControlCouple', 'fred', [1,2,3], 'hello')
20
+ @warning = Reek::SmellWarning.new('ControlCouple', 'fred', [1, 2, 3], 'hello')
21
21
  @collector.found_smell(@warning)
22
22
  end
23
23
  it 'reports that warning' do
24
- @collector.warnings.should == [@warning]
24
+ expect(@collector.warnings).to eq([@warning])
25
25
  end
26
26
  end
27
27
  end
@@ -5,25 +5,25 @@ include Reek
5
5
 
6
6
  shared_examples_for 'supports the deprecated api' do
7
7
  it 'returns all smells as active' do
8
- @examiner.all_active_smells.should == @examiner.smells
8
+ expect(@examiner.all_active_smells).to eq(@examiner.smells)
9
9
  end
10
10
  it 'returns all smells as active' do
11
- @examiner.all_smells.should == @examiner.smells
11
+ expect(@examiner.all_smells).to eq(@examiner.smells)
12
12
  end
13
13
  it 'counts all smells as active smells' do
14
- @examiner.num_active_smells.should == @examiner.smells.length
14
+ expect(@examiner.num_active_smells).to eq(@examiner.smells.length)
15
15
  end
16
16
  it 'never reports masked smells' do
17
- @examiner.num_masked_smells.should == 0
17
+ expect(@examiner.num_masked_smells).to eq(0)
18
18
  end
19
19
  end
20
20
 
21
21
  shared_examples_for 'no smells found' do
22
22
  it 'is not smelly' do
23
- @examiner.should_not be_smelly
23
+ expect(@examiner).not_to be_smelly
24
24
  end
25
25
  it 'finds no smells' do
26
- @examiner.smells.length.should == 0
26
+ expect(@examiner.smells.length).to eq(0)
27
27
  end
28
28
 
29
29
  it_should_behave_like 'supports the deprecated api'
@@ -31,13 +31,13 @@ end
31
31
 
32
32
  shared_examples_for 'one smell found' do
33
33
  it 'is smelly' do
34
- @examiner.should be_smelly
34
+ expect(@examiner).to be_smelly
35
35
  end
36
36
  it 'reports the smell' do
37
- @examiner.smells.length.should == 1
37
+ expect(@examiner.smells.length).to eq(1)
38
38
  end
39
39
  it 'reports the correct smell' do
40
- @examiner.smells[0].smell_class.should == @expected_first_smell
40
+ expect(@examiner.smells[0].smell_class).to eq(@expected_first_smell)
41
41
  end
42
42
 
43
43
  it_should_behave_like 'supports the deprecated api'
@@ -7,24 +7,24 @@ describe SmellWarning do
7
7
  context 'sort order' do
8
8
  shared_examples_for 'first sorts ahead of second' do
9
9
  it 'hash differently' do
10
- @first.hash.should_not == @second.hash
10
+ expect(@first.hash).not_to eq(@second.hash)
11
11
  end
12
12
  it 'are not equal' do
13
- @first.should_not == @second
13
+ expect(@first).not_to eq(@second)
14
14
  end
15
15
  it 'sort correctly' do
16
- (@first <=> @second).should be < 0
16
+ expect(@first <=> @second).to be < 0
17
17
  end
18
18
  it 'does not match using eql?' do
19
- @first.should_not eql(@second)
20
- @second.should_not eql(@first)
19
+ expect(@first).not_to eql(@second)
20
+ expect(@second).not_to eql(@first)
21
21
  end
22
22
  end
23
23
 
24
24
  context 'smells differing only by detector' do
25
25
  before :each do
26
- @first = SmellWarning.new('Duplication', "self", 27, "self", false)
27
- @second = SmellWarning.new('FeatureEnvy', "self", 27, "self", true)
26
+ @first = SmellWarning.new('Duplication', 'self', 27, 'self', false)
27
+ @second = SmellWarning.new('FeatureEnvy', 'self', 27, 'self', true)
28
28
  end
29
29
 
30
30
  it_should_behave_like 'first sorts ahead of second'
@@ -32,8 +32,8 @@ describe SmellWarning do
32
32
 
33
33
  context 'smells differing only by context' do
34
34
  before :each do
35
- @first = SmellWarning.new('FeatureEnvy', "first", 27, "self", true)
36
- @second = SmellWarning.new('FeatureEnvy', "second", 27, "self", false)
35
+ @first = SmellWarning.new('FeatureEnvy', 'first', 27, 'self', true)
36
+ @second = SmellWarning.new('FeatureEnvy', 'second', 27, 'self', false)
37
37
  end
38
38
 
39
39
  it_should_behave_like 'first sorts ahead of second'
@@ -41,8 +41,8 @@ describe SmellWarning do
41
41
 
42
42
  context 'smells differing only by message' do
43
43
  before :each do
44
- @first = SmellWarning.new('FeatureEnvy', "context", 27, "first", true)
45
- @second = SmellWarning.new('FeatureEnvy', "context", 27, "second", false)
44
+ @first = SmellWarning.new('FeatureEnvy', 'context', 27, 'first', true)
45
+ @second = SmellWarning.new('FeatureEnvy', 'context', 27, 'second', false)
46
46
  end
47
47
 
48
48
  it_should_behave_like 'first sorts ahead of second'
@@ -50,8 +50,8 @@ describe SmellWarning do
50
50
 
51
51
  context 'message takes precedence over smell name' do
52
52
  before :each do
53
- @first = SmellWarning.new('UtilityFunction', "context", 27, "first", true)
54
- @second = SmellWarning.new('FeatureEnvy', "context", 27, "second", false)
53
+ @first = SmellWarning.new('UtilityFunction', 'context', 27, 'first', true)
54
+ @second = SmellWarning.new('FeatureEnvy', 'context', 27, 'second', false)
55
55
  end
56
56
 
57
57
  it_should_behave_like 'first sorts ahead of second'
@@ -59,8 +59,8 @@ describe SmellWarning do
59
59
 
60
60
  context 'smells differing everywhere' do
61
61
  before :each do
62
- @first = SmellWarning.new('UncommunicativeName', "Dirty", 27, "has the variable name '@s'", true)
63
- @second = SmellWarning.new('Duplication', 'Dirty#a', 27, "calls @s.title twice", false)
62
+ @first = SmellWarning.new('UncommunicativeName', 'Dirty', 27, "has the variable name '@s'", true)
63
+ @second = SmellWarning.new('Duplication', 'Dirty#a', 27, 'calls @s.title twice', false)
64
64
  end
65
65
 
66
66
  it_should_behave_like 'first sorts ahead of second'
@@ -78,20 +78,20 @@ describe SmellWarning do
78
78
 
79
79
  shared_examples_for 'common fields' do
80
80
  it 'includes the smell class' do
81
- @yaml.should match(/class:\s*FeatureEnvy/)
81
+ expect(@yaml).to match(/class:\s*FeatureEnvy/)
82
82
  end
83
83
  it 'includes the context' do
84
- @yaml.should match(/context:\s*#{@context_name}/)
84
+ expect(@yaml).to match(/context:\s*#{@context_name}/)
85
85
  end
86
86
  it 'includes the message' do
87
- @yaml.should match(/message:\s*#{@message}/)
87
+ expect(@yaml).to match(/message:\s*#{@message}/)
88
88
  end
89
89
  it 'indicates the masking' do
90
- @yaml.should match(/is_active:\s*true/)
90
+ expect(@yaml).to match(/is_active:\s*true/)
91
91
  end
92
92
  it 'includes the line numbers' do
93
93
  @lines.each do |line|
94
- @yaml.should match(/lines:[\s\d-]*- #{line}/)
94
+ expect(@yaml).to match(/lines:[\s\d-]*- #{line}/)
95
95
  end
96
96
  end
97
97
  end
@@ -100,23 +100,23 @@ describe SmellWarning do
100
100
  before :each do
101
101
  @source = 'a/ruby/source/file.rb'
102
102
  @subclass = 'TooManyParties'
103
- @parameters = {'one' => 34, 'two' => 'second'}
103
+ @parameters = { 'one' => 34, 'two' => 'second' }
104
104
  @warning = SmellWarning.new(@class, @context_name, @lines, @message,
105
- @source, @subclass, @parameters)
105
+ @source, @subclass, @parameters)
106
106
  @yaml = @warning.to_yaml
107
107
  end
108
108
 
109
109
  it_should_behave_like 'common fields'
110
110
 
111
111
  it 'includes the subclass' do
112
- @yaml.should match(/subclass:\s*#{@subclass}/)
112
+ expect(@yaml).to match(/subclass:\s*#{@subclass}/)
113
113
  end
114
114
  it 'includes the source' do
115
- @yaml.should match(/source:\s*#{@source}/)
115
+ expect(@yaml).to match(/source:\s*#{@source}/)
116
116
  end
117
117
  it 'includes the parameters' do
118
- @parameters.each do |key,value|
119
- @yaml.should match(/#{key}:\s*#{value}/)
118
+ @parameters.each do |key, value|
119
+ expect(@yaml).to match(/#{key}:\s*#{value}/)
120
120
  end
121
121
  end
122
122
  end
@@ -130,13 +130,13 @@ describe SmellWarning do
130
130
  it_should_behave_like 'common fields'
131
131
 
132
132
  it 'includes no subclass' do
133
- @yaml.should match(/subclass: ["']{2}/)
133
+ expect(@yaml).to match(/subclass: ["']{2}/)
134
134
  end
135
135
  it 'includes no source' do
136
- @yaml.should match(/source: ["']{2}/)
136
+ expect(@yaml).to match(/source: ["']{2}/)
137
137
  end
138
138
  it 'includes empty parameters' do
139
- @yaml.should_not match(/parameter/)
139
+ expect(@yaml).not_to match(/parameter/)
140
140
  end
141
141
  end
142
142
  end
@@ -18,7 +18,7 @@ describe Attribute do
18
18
  it 'records nothing in the module' do
19
19
  src = 'module Fred; end'
20
20
  ctx = CodeContext.new(nil, src.to_reek_source.syntax_tree)
21
- @detector.examine_context(ctx).should be_empty
21
+ expect(@detector.examine_context(ctx)).to be_empty
22
22
  end
23
23
  end
24
24
 
@@ -34,19 +34,19 @@ describe Attribute do
34
34
  end
35
35
 
36
36
  it 'records only that attribute' do
37
- @smells.length.should == 1
37
+ expect(@smells.length).to eq(1)
38
38
  end
39
39
  it 'reports the attribute name' do
40
- @smells[0].smell[Attribute::ATTRIBUTE_KEY].should == @attr_name
40
+ expect(@smells[0].smell[Attribute::ATTRIBUTE_KEY]).to eq(@attr_name)
41
41
  end
42
42
  it 'reports the declaration line number' do
43
- @smells[0].lines.should == [1]
43
+ expect(@smells[0].lines).to eq([1])
44
44
  end
45
45
  it 'reports the correct smell class' do
46
- @smells[0].smell_class.should == Attribute::SMELL_CLASS
46
+ expect(@smells[0].smell_class).to eq(Attribute::SMELL_CLASS)
47
47
  end
48
48
  it 'reports the context fq name' do
49
- @smells[0].context.should == 'Fred'
49
+ expect(@smells[0].context).to eq('Fred')
50
50
  end
51
51
  end
52
52