reek 4.4.1 → 4.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +46 -0
  3. data/CHANGELOG.md +4 -0
  4. data/Gemfile +5 -1
  5. data/docs/Duplicate-Method-Call.md +96 -0
  6. data/docs/How-To-Write-New-Detectors.md +16 -0
  7. data/docs/Large-Class.md +2 -1
  8. data/docs/Simulated-Polymorphism.md +1 -1
  9. data/features/configuration_via_source_comments/erroneous_source_comments.feature +39 -0
  10. data/lib/reek/ast/node.rb +4 -0
  11. data/lib/reek/code_comment.rb +11 -3
  12. data/lib/reek/context/code_context.rb +3 -1
  13. data/lib/reek/context/module_context.rb +1 -1
  14. data/lib/reek/errors.rb +32 -0
  15. data/lib/reek/examiner.rb +6 -1
  16. data/lib/reek/rake/task.rb +0 -2
  17. data/lib/reek/smells/boolean_parameter.rb +1 -1
  18. data/lib/reek/smells/class_variable.rb +2 -2
  19. data/lib/reek/smells/instance_variable_assumption.rb +1 -1
  20. data/lib/reek/smells/prima_donna_method.rb +18 -17
  21. data/lib/reek/smells/smell_detector.rb +19 -2
  22. data/lib/reek/smells/unused_private_method.rb +1 -1
  23. data/lib/reek/spec/should_reek_of.rb +2 -0
  24. data/lib/reek/version.rb +1 -1
  25. data/spec/factories/factories.rb +11 -0
  26. data/spec/quality/reek_source_spec.rb +1 -1
  27. data/spec/reek/ast/node_spec.rb +40 -0
  28. data/spec/reek/ast/object_refs_spec.rb +20 -59
  29. data/spec/reek/ast/sexp_extensions_spec.rb +16 -19
  30. data/spec/reek/cli/application_spec.rb +25 -25
  31. data/spec/reek/cli/command/report_command_spec.rb +1 -2
  32. data/spec/reek/cli/command/todo_list_command_spec.rb +1 -1
  33. data/spec/reek/cli/options_spec.rb +7 -5
  34. data/spec/reek/code_comment_spec.rb +74 -44
  35. data/spec/reek/configuration/default_directive_spec.rb +3 -3
  36. data/spec/reek/configuration/directory_directives_spec.rb +10 -10
  37. data/spec/reek/configuration/excluded_paths_spec.rb +2 -2
  38. data/spec/reek/context/code_context_spec.rb +22 -26
  39. data/spec/reek/context/ghost_context_spec.rb +1 -1
  40. data/spec/reek/context/method_context_spec.rb +13 -7
  41. data/spec/reek/context/module_context_spec.rb +4 -4
  42. data/spec/reek/context/root_context_spec.rb +1 -1
  43. data/spec/reek/context_builder_spec.rb +34 -38
  44. data/spec/reek/examiner_spec.rb +43 -22
  45. data/spec/reek/rake/task_spec.rb +3 -3
  46. data/spec/reek/report/code_climate_formatter_spec.rb +42 -40
  47. data/spec/reek/report/code_climate_report_spec.rb +1 -1
  48. data/spec/reek/report/html_report_spec.rb +1 -1
  49. data/spec/reek/report/json_report_spec.rb +1 -1
  50. data/spec/reek/report/location_formatter_spec.rb +18 -16
  51. data/spec/reek/report/text_report_spec.rb +12 -8
  52. data/spec/reek/report/xml_report_spec.rb +1 -1
  53. data/spec/reek/report/yaml_report_spec.rb +1 -1
  54. data/spec/reek/report_spec.rb +4 -4
  55. data/spec/reek/smells/attribute_spec.rb +7 -10
  56. data/spec/reek/smells/boolean_parameter_spec.rb +14 -20
  57. data/spec/reek/smells/class_variable_spec.rb +6 -5
  58. data/spec/reek/smells/control_parameter_spec.rb +3 -2
  59. data/spec/reek/smells/data_clump_spec.rb +3 -6
  60. data/spec/reek/smells/duplicate_method_call_spec.rb +10 -14
  61. data/spec/reek/smells/feature_envy_spec.rb +34 -25
  62. data/spec/reek/smells/instance_variable_assumption_spec.rb +6 -9
  63. data/spec/reek/smells/irresponsible_module_spec.rb +3 -6
  64. data/spec/reek/smells/long_parameter_list_spec.rb +5 -7
  65. data/spec/reek/smells/long_yield_list_spec.rb +3 -6
  66. data/spec/reek/smells/manual_dispatch_spec.rb +3 -6
  67. data/spec/reek/smells/nested_iterators_spec.rb +10 -8
  68. data/spec/reek/smells/nil_check_spec.rb +2 -1
  69. data/spec/reek/smells/prima_donna_method_spec.rb +5 -8
  70. data/spec/reek/smells/smell_configuration_spec.rb +3 -3
  71. data/spec/reek/smells/smell_detector_spec.rb +10 -0
  72. data/spec/reek/smells/smell_repository_spec.rb +6 -6
  73. data/spec/reek/smells/smell_warning_spec.rb +35 -39
  74. data/spec/reek/smells/subclassed_from_core_class_spec.rb +5 -5
  75. data/spec/reek/smells/too_many_constants_spec.rb +10 -10
  76. data/spec/reek/smells/too_many_instance_variables_spec.rb +1 -1
  77. data/spec/reek/smells/too_many_methods_spec.rb +1 -1
  78. data/spec/reek/smells/too_many_statements_spec.rb +3 -6
  79. data/spec/reek/smells/uncommunicative_method_name_spec.rb +9 -6
  80. data/spec/reek/smells/uncommunicative_module_name_spec.rb +3 -3
  81. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +6 -9
  82. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +20 -24
  83. data/spec/reek/smells/unused_parameters_spec.rb +35 -24
  84. data/spec/reek/smells/unused_private_method_spec.rb +25 -33
  85. data/spec/reek/smells/utility_function_spec.rb +27 -14
  86. data/spec/reek/source/source_code_spec.rb +6 -6
  87. data/spec/reek/source/source_locator_spec.rb +34 -17
  88. data/spec/reek/spec/should_reek_of_spec.rb +17 -12
  89. data/spec/reek/spec/should_reek_only_of_spec.rb +5 -5
  90. data/spec/reek/spec/should_reek_spec.rb +3 -3
  91. data/spec/reek/tree_dresser_spec.rb +6 -4
  92. data/spec/spec_helper.rb +3 -0
  93. data/tasks/rubocop.rake +9 -3
  94. metadata +4 -2
@@ -30,30 +30,31 @@ module Reek
30
30
  end
31
31
 
32
32
  def sniff(ctx)
33
- ctx.node_instance_methods.map do |method_sexp|
34
- check_for_smells(method_sexp, ctx)
35
- end.compact
33
+ ctx.node_instance_methods.select do |method_sexp|
34
+ prima_donna_method?(method_sexp, ctx)
35
+ end.map do |method_sexp|
36
+ name = method_sexp.name
37
+ smell_warning(
38
+ context: ctx,
39
+ lines: [ctx.exp.line],
40
+ message: "has prima donna method '#{name}'",
41
+ parameters: { name: name.to_s })
42
+ end
36
43
  end
37
44
 
38
45
  private
39
46
 
40
- # :reek:FeatureEnvy
41
- # :reek:TooManyStatements: { max_statements: 6 }
42
- def check_for_smells(method_sexp, ctx)
43
- return unless method_sexp.ends_with_bang?
47
+ def prima_donna_method?(method_sexp, ctx)
48
+ return false unless method_sexp.ends_with_bang?
49
+ return false if version_without_bang_exists?(method_sexp, ctx)
50
+ true
51
+ end
44
52
 
45
- version_without_bang = ctx.node_instance_methods.find do |sexp_item|
53
+ # :reek:UtilityFunction
54
+ def version_without_bang_exists?(method_sexp, ctx)
55
+ ctx.node_instance_methods.find do |sexp_item|
46
56
  sexp_item.name.to_s == method_sexp.name_without_bang
47
57
  end
48
-
49
- return if version_without_bang
50
-
51
- name = method_sexp.name
52
- smell_warning(
53
- context: ctx,
54
- lines: [ctx.exp.line],
55
- message: "has prima donna method '#{name}'",
56
- parameters: { name: name })
57
58
  end
58
59
  end
59
60
  end
@@ -72,9 +72,8 @@ module Reek
72
72
  def smell_warning(options = {})
73
73
  context = options.fetch(:context)
74
74
  exp = context.exp
75
- ctx_source = exp.loc.expression.source_buffer.name
76
75
  SmellWarning.new(self,
77
- source: ctx_source,
76
+ source: exp.source,
78
77
  context: context.full_name,
79
78
  lines: options.fetch(:lines),
80
79
  message: options.fetch(:message),
@@ -102,9 +101,27 @@ module Reek
102
101
  descendants << subclass
103
102
  end
104
103
 
104
+ #
105
+ # Returns all descendants of SmellDetector
106
+ #
107
+ # @return [Array<Constant>], e.g.:
108
+ # [Reek::Smells::Attribute,
109
+ # Reek::Smells::BooleanParameter,
110
+ # Reek::Smells::ClassVariable,
111
+ # ...]
112
+ #
105
113
  def descendants
106
114
  @descendants ||= []
107
115
  end
116
+
117
+ #
118
+ # @param detector [String] the detector in question, e.g. 'DuplicateMethodCall'
119
+ # @return [Boolean]
120
+ #
121
+ def valid_detector?(detector)
122
+ descendants.map { |descendant| descendant.to_s.split('::').last }.
123
+ include?(detector)
124
+ end
108
125
  end
109
126
  end
110
127
  end
@@ -44,7 +44,7 @@ module Reek
44
44
  context: ctx,
45
45
  lines: [hit.line],
46
46
  message: "has the unused private instance method '#{name}'",
47
- parameters: { name: name })
47
+ parameters: { name: name.to_s })
48
48
  end
49
49
  end
50
50
 
@@ -9,6 +9,8 @@ module Reek
9
9
  # code smell.
10
10
  #
11
11
  class ShouldReekOf
12
+ include RSpec::Matchers::Composable
13
+
12
14
  # Variant of Examiner that doesn't swallow exceptions
13
15
  class UnsafeExaminer < Examiner
14
16
  def run
@@ -7,6 +7,6 @@ module Reek
7
7
  # @public
8
8
  module Version
9
9
  # @public
10
- STRING = '4.4.1'.freeze
10
+ STRING = '4.4.2'.freeze
11
11
  end
12
12
  end
@@ -52,4 +52,15 @@ FactoryGirl.define do
52
52
  parameters: parameters)
53
53
  end
54
54
  end
55
+
56
+ factory :code_comment, class: Reek::CodeComment do
57
+ comment ''
58
+ line 1
59
+ source 'string'
60
+ initialize_with do
61
+ new comment: comment,
62
+ line: line,
63
+ source: source
64
+ end
65
+ end
55
66
  end
@@ -3,7 +3,7 @@ require_relative '../spec_helper'
3
3
  RSpec.describe 'Reek source code' do
4
4
  it 'has no smells' do
5
5
  Pathname.glob('lib/**/*.rb').each do |pathname|
6
- expect(pathname).to_not reek
6
+ expect(pathname).not_to reek
7
7
  end
8
8
  end
9
9
  end
@@ -75,4 +75,44 @@ RSpec.describe Reek::AST::Node do
75
75
  expect(sexp(:foo).length).to eq 1
76
76
  end
77
77
  end
78
+
79
+ describe '#line' do
80
+ context 'source from file' do
81
+ let(:file) { SAMPLES_PATH.join('smelly.rb') }
82
+ let(:ast) { Reek::Source::SourceCode.from(file).syntax_tree }
83
+
84
+ it 'returns the right line number' do
85
+ expect(ast.line).to eq(2)
86
+ end
87
+ end
88
+
89
+ context 'source from string' do
90
+ let(:source) { File.read(SAMPLES_PATH.join('smelly.rb')) }
91
+ let(:ast) { Reek::Source::SourceCode.from(source).syntax_tree }
92
+
93
+ it 'returns the right line number' do
94
+ expect(ast.line).to eq(2)
95
+ end
96
+ end
97
+ end
98
+
99
+ describe '#source' do
100
+ context 'source from file' do
101
+ let(:file) { SAMPLES_PATH.join('smelly.rb') }
102
+ let(:ast) { Reek::Source::SourceCode.from(file).syntax_tree }
103
+
104
+ it 'returns the file name' do
105
+ expect(ast.source).to eq(SAMPLES_PATH.join('smelly.rb').to_s)
106
+ end
107
+ end
108
+
109
+ context 'source from string' do
110
+ let(:source) { File.read(SAMPLES_PATH.join('smelly.rb')) }
111
+ let(:ast) { Reek::Source::SourceCode.from(source).syntax_tree }
112
+
113
+ it 'returns "string"' do
114
+ expect(ast.source).to eq('string')
115
+ end
116
+ end
117
+ end
78
118
  end
@@ -2,57 +2,16 @@ require_relative '../../spec_helper'
2
2
  require_lib 'reek/ast/object_refs'
3
3
 
4
4
  RSpec.describe Reek::AST::ObjectRefs do
5
- let(:refs) { Reek::AST::ObjectRefs.new }
5
+ let(:refs) { described_class.new }
6
6
 
7
7
  context 'when empty' do
8
- it 'should report no refs to self' do
8
+ it 'reports no refs to self' do
9
9
  expect(refs.references_to(:self)).to be_empty
10
10
  end
11
11
  end
12
12
 
13
- context 'with references to a, b, and a' do
14
- context 'with no refs to self' do
15
- before(:each) do
16
- refs.record_reference(name: :a)
17
- refs.record_reference(name: :b)
18
- refs.record_reference(name: :a)
19
- end
20
-
21
- it 'should report no refs to self' do
22
- expect(refs.references_to(:self)).to be_empty
23
- end
24
-
25
- it 'should report :a as the max' do
26
- expect(refs.most_popular).to include(:a)
27
- end
28
-
29
- it 'should not report self as the max' do
30
- expect(refs.self_is_max?).to eq(false)
31
- end
32
-
33
- context 'with one reference to self' do
34
- before(:each) do
35
- refs.record_reference(name: :self)
36
- end
37
-
38
- it 'should report 1 ref to self' do
39
- expect(refs.references_to(:self).size).to eq(1)
40
- end
41
-
42
- it 'should not report self among the max' do
43
- expect(refs.most_popular).to include(:a)
44
- expect(refs.most_popular).not_to include(:self)
45
- end
46
-
47
- it 'should not report self as the max' do
48
- expect(refs.self_is_max?).to eq(false)
49
- end
50
- end
51
- end
52
- end
53
-
54
13
  context 'with many refs to self' do
55
- before(:each) do
14
+ before do
56
15
  refs.record_reference(name: :self)
57
16
  refs.record_reference(name: :self)
58
17
  refs.record_reference(name: :a)
@@ -62,21 +21,21 @@ RSpec.describe Reek::AST::ObjectRefs do
62
21
  refs.record_reference(name: :self)
63
22
  end
64
23
 
65
- it 'should report all refs to self' do
24
+ it 'reports all refs to self' do
66
25
  expect(refs.references_to(:self).size).to eq(4)
67
26
  end
68
27
 
69
- it 'should report self among the max' do
28
+ it 'reports self among the max' do
70
29
  expect(refs.most_popular).to include(:self)
71
30
  end
72
31
 
73
- it 'should report self as the max' do
32
+ it 'reports self as the max' do
74
33
  expect(refs.self_is_max?).to eq(true)
75
34
  end
76
35
  end
77
36
 
78
37
  context 'when self is not the only max' do
79
- before(:each) do
38
+ before do
80
39
  refs.record_reference(name: :a)
81
40
  refs.record_reference(name: :self)
82
41
  refs.record_reference(name: :self)
@@ -84,38 +43,40 @@ RSpec.describe Reek::AST::ObjectRefs do
84
43
  refs.record_reference(name: :a)
85
44
  end
86
45
 
87
- it 'should report all refs to self' do
46
+ it 'reports all refs to self' do
88
47
  expect(refs.references_to(:self).size).to eq(2)
89
48
  end
90
49
 
91
- it 'should report self among the max' do
92
- expect(refs.most_popular).to include(:a)
50
+ it 'reports self among the max' do
93
51
  expect(refs.most_popular).to include(:self)
94
52
  end
95
53
 
96
- it 'should report self as the max' do
54
+ it 'reports the other max among the max' do
55
+ expect(refs.most_popular).to include(:a)
56
+ end
57
+
58
+ it 'reports self as the max' do
97
59
  expect(refs.self_is_max?).to eq(true)
98
60
  end
99
61
  end
100
62
 
101
- context 'when self is not among the max' do
102
- before(:each) do
63
+ context 'when self is not recorded' do
64
+ before do
103
65
  refs.record_reference(name: :a)
104
66
  refs.record_reference(name: :b)
105
67
  refs.record_reference(name: :a)
106
68
  refs.record_reference(name: :b)
107
69
  end
108
70
 
109
- it 'should report all refs to self' do
71
+ it 'reports no refs to self' do
110
72
  expect(refs.references_to(:self).size).to eq(0)
111
73
  end
112
74
 
113
- it 'should not report self among the max' do
114
- expect(refs.most_popular).to include(:a)
115
- expect(refs.most_popular).to include(:b)
75
+ it 'does not report self among the max' do
76
+ expect(refs.most_popular).not_to include(:self)
116
77
  end
117
78
 
118
- it 'should not report self as the max' do
79
+ it 'does not report self as the max' do
119
80
  expect(refs.self_is_max?).to eq(false)
120
81
  end
121
82
  end
@@ -402,60 +402,60 @@ end
402
402
 
403
403
  RSpec.describe Reek::AST::SexpExtensions::ModuleNode do
404
404
  context 'with a simple name' do
405
- subject do
405
+ let(:exp) do
406
406
  Reek::Source::SourceCode.from('module Fred; end').syntax_tree
407
407
  end
408
408
 
409
409
  it 'has the correct #name' do
410
- expect(subject.name).to eq 'Fred'
410
+ expect(exp.name).to eq 'Fred'
411
411
  end
412
412
 
413
413
  it 'has the correct #simple_name' do
414
- expect(subject.simple_name).to eq 'Fred'
414
+ expect(exp.simple_name).to eq 'Fred'
415
415
  end
416
416
 
417
417
  it 'has a simple full_name' do
418
- expect(subject.full_name('')).to eq 'Fred'
418
+ expect(exp.full_name('')).to eq 'Fred'
419
419
  end
420
420
 
421
421
  it 'has a fq full_name' do
422
- expect(subject.full_name('Blimey::O::Reilly')).to eq 'Blimey::O::Reilly::Fred'
422
+ expect(exp.full_name('Blimey::O::Reilly')).to eq 'Blimey::O::Reilly::Fred'
423
423
  end
424
424
  end
425
425
 
426
426
  context 'with a scoped name' do
427
- subject do
427
+ let(:exp) do
428
428
  Reek::Source::SourceCode.from('module Foo::Bar; end').syntax_tree
429
429
  end
430
430
 
431
431
  it 'has the correct #name' do
432
- expect(subject.name).to eq 'Foo::Bar'
432
+ expect(exp.name).to eq 'Foo::Bar'
433
433
  end
434
434
 
435
435
  it 'has the correct #simple_name' do
436
- expect(subject.simple_name).to eq 'Bar'
436
+ expect(exp.simple_name).to eq 'Bar'
437
437
  end
438
438
 
439
439
  it 'has a simple full_name' do
440
- expect(subject.full_name('')).to eq 'Foo::Bar'
440
+ expect(exp.full_name('')).to eq 'Foo::Bar'
441
441
  end
442
442
 
443
- it 'has a fq full_name' do
444
- expect(subject.full_name('Blimey::O::Reilly')).to eq 'Blimey::O::Reilly::Foo::Bar'
443
+ it 'has a fully qualified full_name' do
444
+ expect(exp.full_name('Blimey::O::Reilly')).to eq 'Blimey::O::Reilly::Foo::Bar'
445
445
  end
446
446
  end
447
447
 
448
448
  context 'with a name scoped in a namespace that is not a constant' do
449
- subject do
449
+ let(:exp) do
450
450
  Reek::Source::SourceCode.from('module foo::Bar; end').syntax_tree
451
451
  end
452
452
 
453
453
  it 'has the correct #name' do
454
- expect(subject.name).to eq 'foo::Bar'
454
+ expect(exp.name).to eq 'foo::Bar'
455
455
  end
456
456
 
457
457
  it 'has the correct #simple_name' do
458
- expect(subject.simple_name).to eq 'Bar'
458
+ expect(exp.simple_name).to eq 'Bar'
459
459
  end
460
460
  end
461
461
  end
@@ -463,12 +463,9 @@ end
463
463
  RSpec.describe Reek::AST::SexpExtensions::CasgnNode do
464
464
  describe '#defines_module?' do
465
465
  context 'with single assignment' do
466
- subject do
467
- sexp(:casgn, nil, :Foo)
468
- end
469
-
470
466
  it 'does not define a module' do
471
- expect(subject.defines_module?).to be_falsey
467
+ exp = sexp(:casgn, nil, :Foo)
468
+ expect(exp.defines_module?).to be_falsey
472
469
  end
473
470
  end
474
471
 
@@ -6,7 +6,7 @@ RSpec.describe Reek::CLI::Application do
6
6
  it 'exits with default error code on invalid options' do
7
7
  call = lambda do
8
8
  Reek::CLI::Silencer.silently do
9
- Reek::CLI::Application.new ['--foo']
9
+ described_class.new ['--foo']
10
10
  end
11
11
  end
12
12
  expect(call).to raise_error(SystemExit) do |error|
@@ -22,8 +22,8 @@ RSpec.describe Reek::CLI::Application do
22
22
  let(:configuration) { test_configuration_for(CONFIG_PATH.join('with_excluded_paths.reek')) }
23
23
 
24
24
  describe '#execute' do
25
- let(:command) { double 'reek_command' }
26
- let(:app) { Reek::CLI::Application.new [] }
25
+ let(:command) { instance_double 'Reek::CLI::Command::ReportCommand' }
26
+ let(:app) { described_class.new [] }
27
27
 
28
28
  before do
29
29
  allow(Reek::CLI::Command::ReportCommand).to receive(:new).and_return command
@@ -40,7 +40,7 @@ RSpec.describe Reek::CLI::Application do
40
40
  allow_any_instance_of(IO).to receive(:tty?).and_return(false)
41
41
  end
42
42
 
43
- it 'should use source form pipe' do
43
+ it 'uses source form pipe' do
44
44
  app.execute
45
45
  expect(Reek::CLI::Command::ReportCommand).to have_received(:new).
46
46
  with(sources: [$stdin],
@@ -54,7 +54,7 @@ RSpec.describe Reek::CLI::Application do
54
54
  allow_any_instance_of(IO).to receive(:tty?).and_return(true)
55
55
  end
56
56
 
57
- it 'should use working directory as source' do
57
+ it 'uses working directory as source' do
58
58
  expected_sources = Reek::Source::SourceLocator.new(['.']).sources
59
59
  app.execute
60
60
  expect(Reek::CLI::Command::ReportCommand).to have_received(:new).
@@ -62,37 +62,37 @@ RSpec.describe Reek::CLI::Application do
62
62
  configuration: Reek::Configuration::AppConfiguration,
63
63
  options: Reek::CLI::Options)
64
64
  end
65
- end
66
65
 
67
- context 'when source files are excluded through configuration' do
68
- let(:app) { Reek::CLI::Application.new ['--config', 'some_file.reek'] }
66
+ context 'when source files are excluded through configuration' do
67
+ let(:app) { described_class.new ['--config', 'some_file.reek'] }
69
68
 
70
- before do
71
- allow(Reek::Configuration::AppConfiguration).
72
- to receive(:from_path).
73
- with(Pathname.new('some_file.reek')).
74
- and_return configuration
75
- end
69
+ before do
70
+ allow(Reek::Configuration::AppConfiguration).
71
+ to receive(:from_path).
72
+ with(Pathname.new('some_file.reek')).
73
+ and_return configuration
74
+ end
76
75
 
77
- it 'should use configuration for excluded paths' do
78
- expected_sources = Reek::Source::SourceLocator.
79
- new(['.'], configuration: configuration).sources
80
- expect(expected_sources).not_to include(path_excluded_in_configuration)
76
+ it 'uses configuration for excluded paths' do
77
+ expected_sources = Reek::Source::SourceLocator.
78
+ new(['.'], configuration: configuration).sources
79
+ expect(expected_sources).not_to include(path_excluded_in_configuration)
81
80
 
82
- app.execute
81
+ app.execute
83
82
 
84
- expect(Reek::CLI::Command::ReportCommand).to have_received(:new).
85
- with(sources: expected_sources,
86
- configuration: configuration,
87
- options: Reek::CLI::Options)
83
+ expect(Reek::CLI::Command::ReportCommand).to have_received(:new).
84
+ with(sources: expected_sources,
85
+ configuration: configuration,
86
+ options: Reek::CLI::Options)
87
+ end
88
88
  end
89
89
  end
90
90
  end
91
91
 
92
92
  context 'when source files given' do
93
- let(:app) { Reek::CLI::Application.new ['.'] }
93
+ let(:app) { described_class.new ['.'] }
94
94
 
95
- it 'should use sources from argv' do
95
+ it 'uses sources from argv' do
96
96
  expected_sources = Reek::Source::SourceLocator.new(['.']).sources
97
97
  app.execute
98
98
  expect(Reek::CLI::Command::ReportCommand).to have_received(:new).