reek 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +5 -0
  3. data/README.md +13 -2
  4. data/Rakefile +2 -1
  5. data/features/command_line_interface/options.feature +2 -3
  6. data/features/command_line_interface/smell_selection.feature +0 -1
  7. data/features/command_line_interface/smells_count.feature +0 -2
  8. data/features/command_line_interface/stdin.feature +3 -10
  9. data/features/configuration_files/masking_smells.feature +1 -5
  10. data/features/configuration_files/overrides_defaults.feature +0 -1
  11. data/features/rake_task/rake_task.feature +1 -4
  12. data/features/reports/json.feature +73 -0
  13. data/features/reports/reports.feature +0 -3
  14. data/features/reports/yaml.feature +0 -1
  15. data/features/ruby_api/api.feature +0 -1
  16. data/features/samples.feature +0 -4
  17. data/features/step_definitions/reek_steps.rb +14 -4
  18. data/features/support/env.rb +3 -0
  19. data/lib/reek/cli/option_interpreter.rb +2 -0
  20. data/lib/reek/cli/options.rb +3 -3
  21. data/lib/reek/cli/report/formatter.rb +1 -1
  22. data/lib/reek/cli/report/location_formatter.rb +11 -0
  23. data/lib/reek/cli/report/report.rb +11 -2
  24. data/lib/reek/core/code_context.rb +49 -10
  25. data/lib/reek/core/sniffer.rb +2 -2
  26. data/lib/reek/core/{code_parser.rb → tree_walker.rb} +16 -7
  27. data/lib/reek/examiner.rb +0 -39
  28. data/lib/reek/smells.rb +3 -25
  29. data/lib/reek/smells/feature_envy.rb +0 -2
  30. data/lib/reek/smells/smell_detector.rb +0 -6
  31. data/lib/reek/source/sexp_extensions.rb +17 -6
  32. data/lib/reek/source/sexp_node.rb +1 -1
  33. data/lib/reek/spec.rb +66 -0
  34. data/lib/reek/spec/should_reek.rb +0 -6
  35. data/lib/reek/spec/should_reek_of.rb +0 -49
  36. data/lib/reek/spec/should_reek_only_of.rb +0 -11
  37. data/lib/reek/version.rb +6 -1
  38. data/reek.gemspec +3 -2
  39. data/spec/reek/cli/json_report_spec.rb +20 -0
  40. data/spec/reek/core/code_context_spec.rb +6 -0
  41. data/spec/reek/core/smell_configuration_spec.rb +3 -3
  42. data/spec/reek/core/{code_parser_spec.rb → tree_walker_spec.rb} +4 -4
  43. data/spec/reek/examiner_spec.rb +0 -19
  44. data/spec/reek/smells/attribute_spec.rb +6 -9
  45. data/spec/reek/smells/boolean_parameter_spec.rb +13 -15
  46. data/spec/reek/smells/class_variable_spec.rb +17 -17
  47. data/spec/reek/smells/control_parameter_spec.rb +44 -46
  48. data/spec/reek/smells/data_clump_spec.rb +73 -70
  49. data/spec/reek/smells/duplicate_method_call_spec.rb +39 -37
  50. data/spec/reek/smells/feature_envy_spec.rb +53 -57
  51. data/spec/reek/smells/irresponsible_module_spec.rb +12 -11
  52. data/spec/reek/smells/long_parameter_list_spec.rb +33 -26
  53. data/spec/reek/smells/long_yield_list_spec.rb +15 -19
  54. data/spec/reek/smells/module_initialize_spec.rb +4 -6
  55. data/spec/reek/smells/nested_iterators_spec.rb +28 -28
  56. data/spec/reek/smells/nil_check_spec.rb +18 -20
  57. data/spec/reek/smells/prima_donna_method_spec.rb +6 -9
  58. data/spec/reek/smells/repeated_conditional_spec.rb +41 -43
  59. data/spec/reek/smells/too_many_instance_variables_spec.rb +6 -11
  60. data/spec/reek/smells/too_many_methods_spec.rb +44 -61
  61. data/spec/reek/smells/too_many_statements_spec.rb +14 -41
  62. data/spec/reek/smells/uncommunicative_method_name_spec.rb +6 -11
  63. data/spec/reek/smells/uncommunicative_module_name_spec.rb +10 -14
  64. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +15 -16
  65. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +33 -36
  66. data/spec/reek/smells/unused_parameters_spec.rb +16 -19
  67. data/spec/reek/smells/utility_function_spec.rb +7 -10
  68. metadata +22 -6
@@ -1,11 +1,9 @@
1
1
  require 'spec_helper'
2
+ require 'reek/core/code_context'
2
3
  require 'reek/smells/nil_check'
3
4
  require 'reek/smells/smell_detector_shared'
4
5
 
5
- include Reek
6
- include Reek::Smells
7
-
8
- describe NilCheck do
6
+ describe Reek::Smells::NilCheck do
9
7
  context 'for methods' do
10
8
  it 'reports the correct line number' do
11
9
  src = <<-EOS
@@ -13,43 +11,43 @@ describe NilCheck do
13
11
  foo.nil?
14
12
  end
15
13
  EOS
16
- ctx = CodeContext.new(nil, src.to_reek_source.syntax_tree)
17
- detector = NilCheck.new('source_name')
14
+ ctx = Reek::Core::CodeContext.new(nil, src.to_reek_source.syntax_tree)
15
+ detector = build(:smell_detector, smell_type: :NilCheck, source: 'source_name')
18
16
  smells = detector.examine_context(ctx)
19
17
  expect(smells[0].lines).to eq [2]
20
18
  end
21
19
 
22
20
  it 'reports nothing when scope includes no nil checks' do
23
- expect('def no_nils; end').not_to reek_of(NilCheck)
21
+ expect('def no_nils; end').not_to reek_of(:NilCheck)
24
22
  end
25
23
 
26
24
  it 'reports when scope uses multiple nil? methods' do
27
- src = <<-eos
25
+ src = <<-EOS
28
26
  def chk_multi_nil(para)
29
27
  para.nil?
30
28
  puts "Hello"
31
29
  \"\".nil?
32
30
  end
33
- eos
34
- expect(src).to reek_of(NilCheck)
31
+ EOS
32
+ expect(src).to reek_of(:NilCheck)
35
33
  end
36
34
 
37
35
  it 'reports twice when scope uses == nil and === nil' do
38
- src = <<-eos
36
+ src = <<-EOS
39
37
  def chk_eq_nil(para)
40
38
  para == nil
41
39
  para === nil
42
40
  end
43
- eos
44
- expect(src).to reek_of(NilCheck)
41
+ EOS
42
+ expect(src).to reek_of(:NilCheck)
45
43
  end
46
44
 
47
45
  it 'reports when scope uses nil ==' do
48
- expect('def chk_eq_nil_rev(para); nil == para; end').to reek_of(NilCheck)
46
+ expect('def chk_eq_nil_rev(para); nil == para; end').to reek_of(:NilCheck)
49
47
  end
50
48
 
51
49
  it 'reports when scope uses multiple case-clauses checking nil' do
52
- src = <<-eos
50
+ src = <<-EOS
53
51
  def case_nil
54
52
  case @inst_var
55
53
  when nil then puts "Nil"
@@ -60,19 +58,19 @@ describe NilCheck do
60
58
  when nil then puts nil.inspect
61
59
  end
62
60
  end
63
- eos
64
- expect(src).to reek_of(NilCheck)
61
+ EOS
62
+ expect(src).to reek_of(:NilCheck)
65
63
  end
66
64
 
67
65
  it 'reports a when clause that checks nil and other values' do
68
- src = <<-eos
66
+ src = <<-EOS
69
67
  def case_nil
70
68
  case @inst_var
71
69
  when nil, false then puts "Hello"
72
70
  end
73
71
  end
74
- eos
75
- expect(src).to reek_of(NilCheck)
72
+ EOS
73
+ expect(src).to reek_of(:NilCheck)
76
74
  end
77
75
  end
78
76
  end
@@ -1,23 +1,20 @@
1
1
  require 'spec_helper'
2
-
2
+ require 'reek/core/module_context'
3
3
  require 'reek/smells/smell_detector_shared'
4
4
 
5
- include Reek
6
- include Reek::Smells
7
-
8
- describe PrimaDonnaMethod do
5
+ describe Reek::Smells::PrimaDonnaMethod do
9
6
  it 'should report nothing when method and bang counterpart exist' do
10
- expect('class C; def m; end; def m!; end; end').not_to reek_of(PrimaDonnaMethod)
7
+ expect('class C; def m; end; def m!; end; end').not_to reek_of(:PrimaDonnaMethod)
11
8
  end
12
9
 
13
10
  it 'should report PrimaDonnaMethod when only bang method exists' do
14
- expect('class C; def m!; end; end').to reek_of(PrimaDonnaMethod)
11
+ expect('class C; def m!; end; end').to reek_of(:PrimaDonnaMethod)
15
12
  end
16
13
 
17
14
  describe 'the right smell' do
18
- let(:detector) { PrimaDonnaMethod.new('dummy_source') }
15
+ let(:detector) { build(:smell_detector, smell_type: :PrimaDonnaMethod, source: 'source_name') }
19
16
  let(:src) { 'class C; def m!; end; end' }
20
- let(:ctx) { ModuleContext.new(nil, src.to_reek_source.syntax_tree) }
17
+ let(:ctx) { Reek::Core::ModuleContext.new(nil, src.to_reek_source.syntax_tree) }
21
18
 
22
19
  it 'should be reported' do
23
20
  smells = detector.examine_context(ctx)
@@ -3,13 +3,10 @@ require 'reek/smells/repeated_conditional'
3
3
  require 'reek/core/code_context'
4
4
  require 'reek/smells/smell_detector_shared'
5
5
 
6
- include Reek::Core
7
- include Reek::Smells
8
-
9
- describe RepeatedConditional do
10
- before :each do
11
- @source_name = 'howdy-doody'
12
- @detector = RepeatedConditional.new(@source_name)
6
+ describe Reek::Smells::RepeatedConditional do
7
+ before(:each) do
8
+ @source_name = 'dummy_source'
9
+ @detector = build(:smell_detector, smell_type: :RepeatedConditional, source: @source_name)
13
10
  end
14
11
 
15
12
  it_should_behave_like 'SmellDetector'
@@ -17,7 +14,7 @@ describe RepeatedConditional do
17
14
  context 'with no conditionals' do
18
15
  it 'gathers an empty hash' do
19
16
  ast = 'module Stable; end'.to_reek_source.syntax_tree
20
- ctx = CodeContext.new(nil, ast)
17
+ ctx = Reek::Core::CodeContext.new(nil, ast)
21
18
  expect(@detector.conditional_counts(ctx).length).to eq(0)
22
19
  end
23
20
  end
@@ -25,7 +22,7 @@ describe RepeatedConditional do
25
22
  context 'with a test of block_given?' do
26
23
  it 'does not record the condition' do
27
24
  ast = 'def fred() yield(3) if block_given?; end'.to_reek_source.syntax_tree
28
- ctx = CodeContext.new(nil, ast)
25
+ ctx = Reek::Core::CodeContext.new(nil, ast)
29
26
  expect(@detector.conditional_counts(ctx).length).to eq(0)
30
27
  end
31
28
  end
@@ -33,7 +30,7 @@ describe RepeatedConditional do
33
30
  context 'with an empty condition' do
34
31
  it 'does not record the condition' do
35
32
  ast = 'def fred() case; when 3; end; end'.to_reek_source.syntax_tree
36
- ctx = CodeContext.new(nil, ast)
33
+ ctx = Reek::Core::CodeContext.new(nil, ast)
37
34
  expect(@detector.conditional_counts(ctx).length).to eq(0)
38
35
  end
39
36
  end
@@ -42,25 +39,25 @@ describe RepeatedConditional do
42
39
  before :each do
43
40
  @cond = '@field == :sym'
44
41
  @cond_expr = @cond.to_reek_source.syntax_tree
45
- src = <<EOS
46
- class Scrunch
47
- def first
48
- puts "hello" if @debug
49
- return #{@cond} ? 0 : 3;
50
- end
51
- def second
52
- if #{@cond}
53
- @other += " quarts"
54
- end
55
- end
56
- def third
57
- raise 'flu!' unless #{@cond}
58
- end
59
- end
60
- EOS
42
+ src = <<-EOS
43
+ class Scrunch
44
+ def first
45
+ puts "hello" if @debug
46
+ return #{@cond} ? 0 : 3;
47
+ end
48
+ def second
49
+ if #{@cond}
50
+ @other += " quarts"
51
+ end
52
+ end
53
+ def third
54
+ raise 'flu!' unless #{@cond}
55
+ end
56
+ end
57
+ EOS
61
58
 
62
59
  ast = src.to_reek_source.syntax_tree
63
- @ctx = CodeContext.new(nil, ast)
60
+ @ctx = Reek::Core::CodeContext.new(nil, ast)
64
61
  @conds = @detector.conditional_counts(@ctx)
65
62
  end
66
63
 
@@ -81,34 +78,35 @@ EOS
81
78
  before :each do
82
79
  cond = '@field == :sym'
83
80
  @cond_expr = cond.to_reek_source.syntax_tree
84
- src = <<EOS
85
- class Scrunch
86
- def alpha
87
- return #{cond} ? 0 : 2;
88
- end
89
- def beta
90
- case #{cond}
91
- when :symbol
92
- @tother += " pints"
93
- end
94
- end
95
- end
96
- EOS
81
+ src = <<-EOS
82
+ class Scrunch
83
+ def alpha
84
+ return #{cond} ? 0 : 2;
85
+ end
86
+ def beta
87
+ case #{cond}
88
+ when :symbol
89
+ @tother += " pints"
90
+ end
91
+ end
92
+ end
93
+ EOS
97
94
 
98
95
  ast = src.to_reek_source.syntax_tree
99
- ctx = CodeContext.new(nil, ast)
96
+ ctx = Reek::Core::CodeContext.new(nil, ast)
100
97
  @conds = @detector.conditional_counts(ctx)
101
98
  end
99
+
102
100
  it 'finds exactly one conditional' do
103
101
  expect(@conds.length).to eq(1)
104
102
  end
103
+
105
104
  it 'returns the condition expr' do
106
105
  expect(@conds.keys[0]).to eq(@cond_expr)
107
106
  end
107
+
108
108
  it 'knows there are two copies' do
109
109
  expect(@conds.values[0].length).to eq(2)
110
110
  end
111
111
  end
112
-
113
- # And count code in superclasses, if we have it
114
112
  end
@@ -1,16 +1,11 @@
1
1
  require 'spec_helper'
2
2
  require 'reek/smells/too_many_instance_variables'
3
- require 'reek/examiner'
4
- require 'reek/core/code_parser'
5
3
  require 'reek/smells/smell_detector_shared'
6
4
 
7
- include Reek
8
- include Reek::Smells
9
-
10
- describe TooManyInstanceVariables do
5
+ describe Reek::Smells::TooManyInstanceVariables do
11
6
  before(:each) do
12
- @source_name = 'elephant'
13
- @detector = TooManyInstanceVariables.new(@source_name)
7
+ @source_name = 'dummy_source'
8
+ @detector = build(:smell_detector, smell_type: :TooManyInstanceVariables, source: @source_name)
14
9
  end
15
10
 
16
11
  it_should_behave_like 'SmellDetector'
@@ -77,11 +72,11 @@ describe TooManyInstanceVariables do
77
72
  end
78
73
  end
79
74
  EOS
80
- ctx = CodeContext.new(nil, src.to_reek_source.syntax_tree)
75
+ ctx = Reek::Core::CodeContext.new(nil, src.to_reek_source.syntax_tree)
81
76
  @warning = @detector.examine_context(ctx)[0]
82
77
  expect(@warning.source).to eq(@source_name)
83
- expect(@warning.smell_category).to eq(TooManyInstanceVariables.smell_category)
84
- expect(@warning.smell_type).to eq(TooManyInstanceVariables.smell_type)
78
+ expect(@warning.smell_category).to eq(Reek::Smells::TooManyInstanceVariables.smell_category)
79
+ expect(@warning.smell_type).to eq(Reek::Smells::TooManyInstanceVariables.smell_type)
85
80
  expect(@warning.parameters[:count]).to eq(10)
86
81
  expect(@warning.lines).to eq([2])
87
82
  end
@@ -1,95 +1,78 @@
1
1
  require 'spec_helper'
2
2
  require 'reek/smells/too_many_methods'
3
- require 'reek/examiner'
4
- require 'reek/core/code_parser'
5
3
  require 'reek/smells/smell_detector_shared'
6
4
 
7
- include Reek
8
- include Reek::Smells
9
-
10
- describe TooManyMethods do
5
+ describe Reek::Smells::TooManyMethods do
11
6
  before(:each) do
12
- @source_name = 'elephant'
13
- @detector = TooManyMethods.new(@source_name)
7
+ @source_name = 'dummy_source'
8
+ @detector = described_class.new(@source_name)
9
+ @detector.configure_with 'max_methods' => 2
14
10
  end
15
11
 
16
12
  it_should_behave_like 'SmellDetector'
17
13
 
18
14
  context 'counting methods' do
19
- it 'should not report 25 methods' do
20
- src = <<EOS
21
- # smelly class for testing purposes
22
- class Full
23
- def me01x()3 end;def me02x()3 end;def me03x()3 end;def me04x()3 end;def me05x()3 end
24
- def me11x()3 end;def me12x()3 end;def me13x()3 end;def me14x()3 end;def me15x()3 end
25
- def me21x()3 end;def me22x()3 end;def me23x()3 end;def me24x()3 end;def me25x()3 end
26
- def me31x()3 end;def me32x()3 end;def me33x()3 end;def me34x()3 end;def me35x()3 end
27
- def me41x()3 end;def me42x()3 end;def me43x()3 end;def me44x()3 end;def me45x()3 end
28
- end
29
- EOS
15
+ it 'should not report if we stay below max_methods' do
16
+ src = <<-EOS
17
+ class Dummy
18
+ def m1; end
19
+ def m2; end
20
+ end
21
+ EOS
30
22
  ctx = ModuleContext.new(nil, src.to_reek_source.syntax_tree)
31
23
  expect(@detector.examine_context(ctx)).to be_empty
32
24
  end
33
25
 
34
- it 'should report 26 methods' do
35
- src = <<EOS
36
- class Full
37
- def me01x()3 end;def me02x()3 end;def me03x()3 end;def me04x()3 end;def me05x()3 end
38
- def me11x()3 end;def me12x()3 end;def me13x()3 end;def me14x()3 end;def me15x()3 end
39
- def me21x()3 end;def me22x()3 end;def me23x()3 end;def me24x()3 end;def me25x()3 end
40
- def me31x()3 end;def me32x()3 end;def me33x()3 end;def me34x()3 end;def me35x()3 end
41
- def me41x()3 end;def me42x()3 end;def me43x()3 end;def me44x()3 end;def me45x()3 end
42
- def me51x()3 end
43
- end
44
- EOS
26
+ it 'should report if we exceed max_methods' do
27
+ src = <<-EOS
28
+ class Dummy
29
+ def m1; end
30
+ def m2; end
31
+ def m3; end
32
+ end
33
+ EOS
45
34
  ctx = ModuleContext.new(nil, src.to_reek_source.syntax_tree)
46
35
  smells = @detector.examine_context(ctx)
47
36
  expect(smells.length).to eq(1)
48
- expect(smells[0].smell_type).to eq(TooManyMethods.smell_type)
49
- expect(smells[0].parameters[:count]).to eq(26)
37
+ expect(smells[0].smell_type).to eq(described_class.smell_type)
38
+ expect(smells[0].parameters[:count]).to eq(3)
50
39
  end
51
40
  end
52
41
 
53
42
  context 'with a nested module' do
54
43
  it 'stops at a nested module' do
55
- src = <<EOS
56
- class Full
57
- def me01x()3 end;def me02x()3 end;def me03x()3 end;def me04x()3 end;def me05x()3 end
58
- def me11x()3 end;def me12x()3 end;def me13x()3 end;def me14x()3 end;def me15x()3 end
59
- def me21x()3 end;def me22x()3 end;def me23x()3 end;def me24x()3 end;def me25x()3 end
60
- def me31x()3 end;def me32x()3 end;def me33x()3 end;def me34x()3 end;def me35x()3 end
61
- module Hidden
62
- def me41x()3 end
63
- def me42x()3 end
64
- def me43x()3 end
65
- def me44x()3 end
66
- def me45x()3 end
67
- end
68
- def me51x()3 end
69
- end
70
- EOS
44
+ src = <<-EOS
45
+ class Dummy
46
+ def m1; end
47
+ def m2; end
48
+ module Hidden
49
+ def m3; end
50
+ def m4; end
51
+ def m5; end
52
+ def m6; end
53
+ end
54
+ end
55
+ EOS
71
56
  ctx = ModuleContext.new(nil, src.to_reek_source.syntax_tree)
72
57
  expect(@detector.examine_context(ctx)).to be_empty
73
58
  end
74
59
  end
75
60
 
76
61
  it 'reports correctly when the class has many methods' do
77
- src = <<EOS
78
- class Full
79
- def me01x()3 end;def me02x()3 end;def me03x()3 end;def me04x()3 end;def me05x()3 end
80
- def me11x()3 end;def me12x()3 end;def me13x()3 end;def me14x()3 end;def me15x()3 end
81
- def me21x()3 end;def me22x()3 end;def me23x()3 end;def me24x()3 end;def me25x()3 end
82
- def me31x()3 end;def me32x()3 end;def me33x()3 end;def me34x()3 end;def me35x()3 end
83
- def me41x()3 end;def me42x()3 end;def me43x()3 end;def me44x()3 end;def me45x()3 end
84
- def me51x()3 end
85
- end
86
- EOS
62
+ src = <<-EOS
63
+ class Dummy
64
+ def m1; end
65
+ def m2; end
66
+ def m3; end
67
+ end
68
+ EOS
69
+
87
70
  ctx = ModuleContext.new(nil, src.to_reek_source.syntax_tree)
88
71
  @warning = @detector.examine_context(ctx)[0]
89
72
  expect(@warning.source).to eq(@source_name)
90
- expect(@warning.smell_category).to eq(TooManyMethods.smell_category)
91
- expect(@warning.smell_type).to eq(TooManyMethods.smell_type)
92
- expect(@warning.parameters[:count]).to eq(26)
73
+ expect(@warning.smell_category).to eq(described_class.smell_category)
74
+ expect(@warning.smell_type).to eq(described_class.smell_type)
75
+ expect(@warning.parameters[:count]).to eq(3)
93
76
  expect(@warning.lines).to eq([1])
94
77
  end
95
78
  end
@@ -1,28 +1,23 @@
1
1
  require 'spec_helper'
2
2
  require 'reek/smells/too_many_statements'
3
- require 'reek/core/code_parser'
4
- require 'reek/core/sniffer'
5
3
  require 'reek/smells/smell_detector_shared'
6
4
 
7
- include Reek
8
- include Reek::Smells
9
-
10
5
  def process_method(src)
11
6
  source = src.to_reek_source
12
- sniffer = Core::Sniffer.new(source)
13
- Core::CodeParser.new(sniffer).process_def(source.syntax_tree)
7
+ sniffer = Reek::Core::Sniffer.new(source)
8
+ Reek::Core::TreeWalker.new(sniffer).process_def(source.syntax_tree)
14
9
  end
15
10
 
16
11
  def process_singleton_method(src)
17
12
  source = src.to_reek_source
18
- sniffer = Core::Sniffer.new(source)
19
- Core::CodeParser.new(sniffer).process_defs(source.syntax_tree)
13
+ sniffer = Reek::Core::Sniffer.new(source)
14
+ Reek::Core::TreeWalker.new(sniffer).process_defs(source.syntax_tree)
20
15
  end
21
16
 
22
- describe TooManyStatements do
17
+ describe Reek::Smells::TooManyStatements do
23
18
  it 'should not report short methods' do
24
19
  src = 'def short(arga) alf = f(1);@bet = 2;@cut = 3;@dit = 4; @emp = 5;end'
25
- expect(src).not_to reek_of(TooManyStatements)
20
+ expect(src).not_to reek_of(:TooManyStatements)
26
21
  end
27
22
 
28
23
  it 'should report long methods' do
@@ -31,34 +26,12 @@ describe TooManyStatements do
31
26
  end
32
27
 
33
28
  it 'should not report initialize' do
34
- src = '
29
+ src = <<-EOS
35
30
  def initialize(arga)
36
31
  alf = f(1); @bet = 2; @cut = 3; @dit = 4; @emp = 5; @fry = 6
37
32
  end
38
- '
39
- expect(src).not_to reek_of(TooManyStatements)
40
- end
41
-
42
- it 'should only report a long method once' do
43
- src = <<-EOS
44
- def standard_entries(rbconfig)
45
- @abc = rbconfig
46
- rubypath = File.join(@abc['bindir'], @abcf['ruby_install_name'] + cff['EXEEXT'])
47
- major = yyy['MAJOR'].to_i
48
- minor = zzz['MINOR'].to_i
49
- teeny = ccc['TEENY'].to_i
50
- version = ""
51
- if c['rubylibdir']
52
- @libruby = "/lib/ruby"
53
- @librubyver = "/lib/ruby/"
54
- @librubyverarch = "/lib/ruby/"
55
- @siteruby = "lib/ruby/version/site_ruby"
56
- @siterubyver = siteruby
57
- @siterubyverarch = "$siterubyver/['arch']}"
58
- end
59
- end
60
33
  EOS
61
- expect(src).to reek_only_of(:TooManyStatements)
34
+ expect(src).not_to reek_of(:TooManyStatements)
62
35
  end
63
36
 
64
37
  it 'should report long inner block' do
@@ -79,7 +52,7 @@ describe TooManyStatements do
79
52
  end
80
53
  end
81
54
 
82
- describe TooManyStatements do
55
+ describe Reek::Smells::TooManyStatements do
83
56
  it 'counts 1 assignment' do
84
57
  method = process_method('def one() val = 4; end')
85
58
  expect(method.num_statements).to eq(1)
@@ -121,7 +94,7 @@ describe TooManyStatements do
121
94
  end
122
95
  end
123
96
 
124
- describe TooManyStatements, 'does not count control statements' do
97
+ describe Reek::Smells::TooManyStatements, 'does not count control statements' do
125
98
  it 'counts 1 statement in a conditional expression' do
126
99
  method = process_method('def one() if val == 4; callee(); end; end')
127
100
  expect(method.num_statements).to eq(1)
@@ -278,9 +251,9 @@ describe TooManyStatements, 'does not count control statements' do
278
251
  end
279
252
  end
280
253
 
281
- describe TooManyStatements do
254
+ describe Reek::Smells::TooManyStatements do
282
255
  before(:each) do
283
- @detector = TooManyStatements.new('silver')
256
+ @detector = build(:smell_detector, smell_type: :TooManyStatements, source: 'source_name')
284
257
  end
285
258
 
286
259
  it_should_behave_like 'SmellDetector'
@@ -290,7 +263,7 @@ describe TooManyStatements do
290
263
  @num_statements = 30
291
264
  ctx = double('method_context').as_null_object
292
265
  expect(ctx).to receive(:num_statements).and_return(@num_statements)
293
- expect(ctx).to receive(:config_for).with(TooManyStatements).and_return({})
266
+ expect(ctx).to receive(:config_for).with(described_class).and_return({})
294
267
  @smells = @detector.examine_context(ctx)
295
268
  end
296
269
 
@@ -303,7 +276,7 @@ describe TooManyStatements do
303
276
  end
304
277
 
305
278
  it 'reports the correct smell sub class' do
306
- expect(@smells[0].smell_type).to eq(TooManyStatements.smell_type)
279
+ expect(@smells[0].smell_type).to eq(described_class.smell_type)
307
280
  end
308
281
  end
309
282
  end