reek 4.4.2 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +10 -1
  3. data/CHANGELOG.md +16 -0
  4. data/CONTRIBUTING.md +52 -23
  5. data/README.md +16 -3
  6. data/ataru_setup.rb +1 -1
  7. data/docs/API.md +1 -4
  8. data/docs/How-reek-works-internally.md +5 -5
  9. data/docs/Style-Guide.md +7 -0
  10. data/features/command_line_interface/options.feature +1 -0
  11. data/features/command_line_interface/show_progress.feature +33 -0
  12. data/features/configuration_files/masking_smells.feature +0 -1
  13. data/features/configuration_via_source_comments/erroneous_source_comments.feature +18 -4
  14. data/features/configuration_via_source_comments/well_formed_source_comments.feature +116 -0
  15. data/features/step_definitions/sample_file_steps.rb +5 -0
  16. data/features/todo_list.feature +42 -14
  17. data/lib/reek.rb +1 -1
  18. data/lib/reek/cli/application.rb +5 -0
  19. data/lib/reek/cli/command/report_command.rb +6 -1
  20. data/lib/reek/cli/command/todo_list_command.rb +1 -2
  21. data/lib/reek/cli/options.rb +19 -3
  22. data/lib/reek/code_comment.rb +83 -11
  23. data/lib/reek/configuration/configuration_validator.rb +2 -2
  24. data/lib/reek/errors/bad_detector_in_comment_error.rb +35 -0
  25. data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +34 -0
  26. data/lib/reek/examiner.rb +36 -14
  27. data/lib/reek/report.rb +28 -9
  28. data/lib/reek/report/base_report.rb +77 -0
  29. data/lib/reek/report/code_climate.rb +4 -0
  30. data/lib/reek/report/code_climate/code_climate_fingerprint.rb +48 -0
  31. data/lib/reek/report/code_climate/code_climate_formatter.rb +5 -0
  32. data/lib/reek/report/code_climate/code_climate_report.rb +19 -0
  33. data/lib/reek/report/formatter.rb +5 -56
  34. data/lib/reek/report/{heading_formatter.rb → formatter/heading_formatter.rb} +4 -4
  35. data/lib/reek/report/formatter/location_formatter.rb +41 -0
  36. data/lib/reek/report/formatter/progress_formatter.rb +80 -0
  37. data/lib/reek/report/formatter/simple_warning_formatter.rb +35 -0
  38. data/lib/reek/report/formatter/wiki_link_warning_formatter.rb +35 -0
  39. data/lib/reek/report/html_report.rb +21 -0
  40. data/lib/reek/report/{html_report.html.erb → html_report/html_report.html.erb} +0 -0
  41. data/lib/reek/report/json_report.rb +18 -0
  42. data/lib/reek/report/text_report.rb +68 -0
  43. data/lib/reek/report/xml_report.rb +61 -0
  44. data/lib/reek/report/yaml_report.rb +18 -0
  45. data/lib/reek/smell_detectors.rb +30 -0
  46. data/lib/reek/{smells → smell_detectors}/attribute.rb +3 -3
  47. data/lib/reek/{smells/smell_detector.rb → smell_detectors/base_detector.rb} +3 -3
  48. data/lib/reek/{smells → smell_detectors}/boolean_parameter.rb +3 -3
  49. data/lib/reek/{smells → smell_detectors}/class_variable.rb +3 -3
  50. data/lib/reek/{smells → smell_detectors}/control_parameter.rb +3 -3
  51. data/lib/reek/{smells → smell_detectors}/data_clump.rb +3 -3
  52. data/lib/reek/{smells/smell_repository.rb → smell_detectors/detector_repository.rb} +9 -9
  53. data/lib/reek/{smells → smell_detectors}/duplicate_method_call.rb +3 -3
  54. data/lib/reek/{smells → smell_detectors}/feature_envy.rb +3 -3
  55. data/lib/reek/{smells → smell_detectors}/instance_variable_assumption.rb +3 -3
  56. data/lib/reek/{smells → smell_detectors}/irresponsible_module.rb +3 -3
  57. data/lib/reek/{smells → smell_detectors}/long_parameter_list.rb +3 -3
  58. data/lib/reek/{smells → smell_detectors}/long_yield_list.rb +3 -3
  59. data/lib/reek/{smells → smell_detectors}/manual_dispatch.rb +3 -3
  60. data/lib/reek/{smells → smell_detectors}/module_initialize.rb +3 -3
  61. data/lib/reek/{smells → smell_detectors}/nested_iterators.rb +3 -3
  62. data/lib/reek/{smells → smell_detectors}/nil_check.rb +3 -3
  63. data/lib/reek/{smells → smell_detectors}/prima_donna_method.rb +3 -3
  64. data/lib/reek/{smells → smell_detectors}/repeated_conditional.rb +3 -3
  65. data/lib/reek/{smells → smell_detectors}/smell_configuration.rb +1 -1
  66. data/lib/reek/{smells → smell_detectors}/smell_warning.rb +1 -1
  67. data/lib/reek/{smells → smell_detectors}/subclassed_from_core_class.rb +3 -3
  68. data/lib/reek/{smells → smell_detectors}/too_many_constants.rb +3 -3
  69. data/lib/reek/{smells → smell_detectors}/too_many_instance_variables.rb +3 -3
  70. data/lib/reek/{smells → smell_detectors}/too_many_methods.rb +3 -3
  71. data/lib/reek/{smells → smell_detectors}/too_many_statements.rb +3 -3
  72. data/lib/reek/{smells → smell_detectors}/uncommunicative_method_name.rb +3 -3
  73. data/lib/reek/{smells → smell_detectors}/uncommunicative_module_name.rb +3 -3
  74. data/lib/reek/{smells → smell_detectors}/uncommunicative_parameter_name.rb +3 -3
  75. data/lib/reek/{smells → smell_detectors}/uncommunicative_variable_name.rb +3 -3
  76. data/lib/reek/{smells → smell_detectors}/unused_parameters.rb +3 -3
  77. data/lib/reek/{smells → smell_detectors}/unused_private_method.rb +3 -3
  78. data/lib/reek/{smells → smell_detectors}/utility_function.rb +3 -3
  79. data/lib/reek/spec/should_reek_of.rb +1 -1
  80. data/lib/reek/version.rb +1 -1
  81. data/reek.gemspec +1 -1
  82. data/spec/factories/factories.rb +6 -6
  83. data/spec/reek/cli/command/report_command_spec.rb +3 -1
  84. data/spec/reek/cli/options_spec.rb +12 -2
  85. data/spec/reek/code_comment_spec.rb +18 -6
  86. data/spec/reek/configuration/app_configuration_spec.rb +12 -12
  87. data/spec/reek/configuration/default_directive_spec.rb +1 -1
  88. data/spec/reek/configuration/directory_directives_spec.rb +2 -2
  89. data/spec/reek/examiner_spec.rb +56 -28
  90. data/spec/reek/report/code_climate/code_climate_fingerprint_spec.rb +122 -0
  91. data/spec/reek/report/{code_climate_formatter_spec.rb → code_climate/code_climate_formatter_spec.rb} +6 -2
  92. data/spec/reek/report/{code_climate_report_spec.rb → code_climate/code_climate_report_spec.rb} +7 -5
  93. data/spec/reek/report/{location_formatter_spec.rb → formatter/location_formatter_spec.rb} +4 -4
  94. data/spec/reek/report/formatter/progress_formatter_spec.rb +68 -0
  95. data/spec/reek/report/html_report_spec.rb +1 -1
  96. data/spec/reek/report/json_report_spec.rb +2 -2
  97. data/spec/reek/report/text_report_spec.rb +3 -4
  98. data/spec/reek/report/xml_report_spec.rb +1 -1
  99. data/spec/reek/report/yaml_report_spec.rb +2 -2
  100. data/spec/reek/report_spec.rb +3 -3
  101. data/spec/reek/{smells → smell_detectors}/attribute_spec.rb +2 -2
  102. data/spec/reek/{smells/smell_detector_spec.rb → smell_detectors/base_detector_spec.rb} +5 -5
  103. data/spec/reek/{smells → smell_detectors}/boolean_parameter_spec.rb +2 -2
  104. data/spec/reek/{smells → smell_detectors}/class_variable_spec.rb +2 -2
  105. data/spec/reek/{smells → smell_detectors}/control_parameter_spec.rb +2 -2
  106. data/spec/reek/{smells → smell_detectors}/data_clump_spec.rb +2 -2
  107. data/spec/reek/smell_detectors/detector_repository_spec.rb +22 -0
  108. data/spec/reek/{smells → smell_detectors}/duplicate_method_call_spec.rb +6 -6
  109. data/spec/reek/{smells → smell_detectors}/feature_envy_spec.rb +2 -2
  110. data/spec/reek/{smells → smell_detectors}/instance_variable_assumption_spec.rb +2 -2
  111. data/spec/reek/{smells → smell_detectors}/irresponsible_module_spec.rb +2 -2
  112. data/spec/reek/{smells → smell_detectors}/long_parameter_list_spec.rb +2 -2
  113. data/spec/reek/{smells → smell_detectors}/long_yield_list_spec.rb +2 -2
  114. data/spec/reek/{smells → smell_detectors}/manual_dispatch_spec.rb +2 -2
  115. data/spec/reek/{smells → smell_detectors}/module_initialize_spec.rb +2 -2
  116. data/spec/reek/{smells → smell_detectors}/nested_iterators_spec.rb +4 -4
  117. data/spec/reek/{smells → smell_detectors}/nil_check_spec.rb +2 -2
  118. data/spec/reek/{smells → smell_detectors}/prima_donna_method_spec.rb +2 -2
  119. data/spec/reek/{smells → smell_detectors}/repeated_conditional_spec.rb +2 -2
  120. data/spec/reek/{smells → smell_detectors}/smell_configuration_spec.rb +2 -2
  121. data/spec/reek/{smells → smell_detectors}/smell_warning_spec.rb +3 -3
  122. data/spec/reek/{smells → smell_detectors}/subclassed_from_core_class_spec.rb +2 -2
  123. data/spec/reek/{smells → smell_detectors}/too_many_constants_spec.rb +3 -3
  124. data/spec/reek/{smells → smell_detectors}/too_many_instance_variables_spec.rb +3 -3
  125. data/spec/reek/{smells → smell_detectors}/too_many_methods_spec.rb +3 -3
  126. data/spec/reek/{smells → smell_detectors}/too_many_statements_spec.rb +3 -3
  127. data/spec/reek/{smells → smell_detectors}/uncommunicative_method_name_spec.rb +2 -2
  128. data/spec/reek/{smells → smell_detectors}/uncommunicative_module_name_spec.rb +2 -2
  129. data/spec/reek/{smells → smell_detectors}/uncommunicative_parameter_name_spec.rb +2 -2
  130. data/spec/reek/{smells → smell_detectors}/uncommunicative_variable_name_spec.rb +2 -2
  131. data/spec/reek/{smells → smell_detectors}/unused_parameters_spec.rb +2 -2
  132. data/spec/reek/{smells → smell_detectors}/unused_private_method_spec.rb +4 -4
  133. data/spec/reek/{smells → smell_detectors}/utility_function_spec.rb +3 -3
  134. data/spec/reek/spec/should_reek_of_spec.rb +3 -3
  135. data/tasks/configuration.rake +2 -2
  136. metadata +95 -81
  137. data/features/smells/subclassed_from_core_class.feature +0 -14
  138. data/features/smells/too_many_constants.feature +0 -19
  139. data/lib/reek/errors.rb +0 -32
  140. data/lib/reek/report/location_formatter.rb +0 -39
  141. data/lib/reek/report/report.rb +0 -229
  142. data/lib/reek/smells.rb +0 -30
  143. data/spec/reek/smells/smell_repository_spec.rb +0 -22
@@ -1,11 +1,11 @@
1
- require_relative '../../spec_helper'
1
+ require_relative '../../../spec_helper'
2
2
  require_lib 'reek/report/code_climate/code_climate_formatter'
3
3
 
4
4
  RSpec.describe Reek::Report::CodeClimateFormatter do
5
5
  describe '#render' do
6
6
  let(:warning) do
7
7
  FactoryGirl.build(:smell_warning,
8
- smell_detector: Reek::Smells::UtilityFunction.new,
8
+ smell_detector: Reek::SmellDetectors::UtilityFunction.new,
9
9
  context: 'context foo',
10
10
  message: 'message bar',
11
11
  lines: [1, 2],
@@ -43,5 +43,9 @@ RSpec.describe Reek::Report::CodeClimateFormatter do
43
43
  it 'sets remediation points based on the smell detector' do
44
44
  expect(json['remediation_points']).to eq 250_000
45
45
  end
46
+
47
+ it 'sets fingerprint based on warning context' do
48
+ expect(json['fingerprint']).to eq '70c530e45999af129d520f1f579f967f'
49
+ end
46
50
  end
47
51
  end
@@ -1,7 +1,6 @@
1
- require_relative '../../spec_helper'
1
+ require_relative '../../../spec_helper'
2
2
  require_lib 'reek/examiner'
3
- require_lib 'reek/report/report'
4
- require_lib 'reek/report/formatter'
3
+ require_lib 'reek/report/code_climate'
5
4
 
6
5
  require 'json'
7
6
  require 'stringio'
@@ -38,7 +37,8 @@ RSpec.describe Reek::Report::CodeClimateReport do
38
37
  doesn't communicate its intent well enough.\\n\\nPoor names make it hard for the reader
39
38
  to build a mental picture of what's going on in the code. They can also be
40
39
  mis-interpreted; and they hurt the flow of reading, because the reader must slow down
41
- to interpret the names.\\n\"}}\u0000
40
+ to interpret the names.\\n\"},
41
+ \"fingerprint\":\"09970037d92b5a628bf682a3e2bb126d\"}\u0000
42
42
  {\"type\":\"issue\",
43
43
  \"check_name\":\"UtilityFunction\",
44
44
  \"description\":\"simple doesn't depend on instance state (maybe move it to another class?)\",
@@ -46,8 +46,10 @@ RSpec.describe Reek::Report::CodeClimateReport do
46
46
  \"location\":{\"path\":\"string\",\"lines\":{\"begin\":1,\"end\":1}},
47
47
  \"remediation_points\":250000,
48
48
  \"content\":{\"body\":\"A _Utility Function_ is any instance method that has no
49
- dependency on the state of the instance.\\n\"}}\u0000
49
+ dependency on the state of the instance.\\n\"},
50
+ \"fingerprint\":\"db456db7cb344bb5a98b8fc54a2f382e\"}\u0000
50
51
  EOS
52
+
51
53
  expect { instance.show }.to output(expected).to_stdout
52
54
  end
53
55
  end
@@ -1,7 +1,7 @@
1
- require_relative '../../spec_helper'
1
+ require_relative '../../../spec_helper'
2
2
  require_lib 'reek/report/formatter'
3
3
 
4
- RSpec.describe Reek::Report::BlankLocationFormatter do
4
+ RSpec.describe Reek::Report::Formatter::BlankLocationFormatter do
5
5
  let(:warning) { build(:smell_warning, lines: [11, 9, 250, 100]) }
6
6
 
7
7
  describe '.format' do
@@ -11,7 +11,7 @@ RSpec.describe Reek::Report::BlankLocationFormatter do
11
11
  end
12
12
  end
13
13
 
14
- RSpec.describe Reek::Report::DefaultLocationFormatter do
14
+ RSpec.describe Reek::Report::Formatter::DefaultLocationFormatter do
15
15
  let(:warning) { build(:smell_warning, lines: [11, 9, 250, 100]) }
16
16
 
17
17
  describe '.format' do
@@ -21,7 +21,7 @@ RSpec.describe Reek::Report::DefaultLocationFormatter do
21
21
  end
22
22
  end
23
23
 
24
- RSpec.describe Reek::Report::SingleLineLocationFormatter do
24
+ RSpec.describe Reek::Report::Formatter::SingleLineLocationFormatter do
25
25
  let(:warning) { build(:smell_warning, lines: [11, 9, 250, 100]) }
26
26
 
27
27
  describe '.format' do
@@ -0,0 +1,68 @@
1
+ require_relative '../../../spec_helper'
2
+ require_lib 'reek/report/formatter/progress_formatter'
3
+
4
+ RSpec.describe Reek::Report::Formatter::ProgressFormatter::Dots do
5
+ let(:sources_count) { 23 }
6
+ let(:formatter) { described_class.new(sources_count) }
7
+
8
+ describe '#header' do
9
+ it 'announces the number of files to be inspected' do
10
+ expect(formatter.header).to eq "Inspecting 23 file(s):\n"
11
+ end
12
+ end
13
+
14
+ describe '#progress' do
15
+ let(:clean_examiner) { instance_double(Reek::Examiner, smelly?: false) }
16
+ let(:smelly_examiner) { instance_double(Reek::Examiner, smelly?: true) }
17
+
18
+ context 'with colors disabled' do
19
+ before do
20
+ Rainbow.enabled = false
21
+ end
22
+
23
+ it 'returns a dot for clean files' do
24
+ expect(formatter.progress(clean_examiner)).to eq '.'
25
+ end
26
+
27
+ it 'returns an S for smelly files' do
28
+ expect(formatter.progress(smelly_examiner)).to eq 'S'
29
+ end
30
+ end
31
+ end
32
+
33
+ describe '#footer' do
34
+ it 'returns some blank lines to offset the output' do
35
+ expect(formatter.footer).to eq "\n\n"
36
+ end
37
+ end
38
+ end
39
+
40
+ RSpec.describe Reek::Report::Formatter::ProgressFormatter::Quiet do
41
+ let(:sources_count) { 23 }
42
+ let(:formatter) { described_class.new(sources_count) }
43
+
44
+ describe '#header' do
45
+ it 'is quiet' do
46
+ expect(formatter.header).to eq ''
47
+ end
48
+ end
49
+
50
+ describe '#progress' do
51
+ let(:clean_examiner) { instance_double(Reek::Examiner, smelly?: false) }
52
+ let(:smelly_examiner) { instance_double(Reek::Examiner, smelly?: true) }
53
+
54
+ it 'is quiet for clean files' do
55
+ expect(formatter.progress(clean_examiner)).to eq ''
56
+ end
57
+
58
+ it 'is quiet for smelly files' do
59
+ expect(formatter.progress(smelly_examiner)).to eq ''
60
+ end
61
+ end
62
+
63
+ describe '#footer' do
64
+ it 'is quiet' do
65
+ expect(formatter.footer).to eq ''
66
+ end
67
+ end
68
+ end
@@ -1,6 +1,6 @@
1
1
  require_relative '../../spec_helper'
2
2
  require_lib 'reek/examiner'
3
- require_lib 'reek/report/report'
3
+ require_lib 'reek/report/html_report'
4
4
 
5
5
  RSpec.describe Reek::Report::HTMLReport do
6
6
  let(:instance) { described_class.new }
@@ -1,6 +1,6 @@
1
1
  require_relative '../../spec_helper'
2
2
  require_lib 'reek/examiner'
3
- require_lib 'reek/report/report'
3
+ require_lib 'reek/report/json_report'
4
4
  require_lib 'reek/report/formatter'
5
5
 
6
6
  require 'json'
@@ -55,7 +55,7 @@ RSpec.describe Reek::Report::JSONReport do
55
55
  end
56
56
 
57
57
  context 'with link formatter' do
58
- let(:options) { { warning_formatter: Reek::Report::WikiLinkWarningFormatter.new } }
58
+ let(:options) { { warning_formatter: Reek::Report::Formatter::WikiLinkWarningFormatter.new } }
59
59
 
60
60
  it 'prints documentation links' do
61
61
  out = StringIO.new
@@ -1,16 +1,15 @@
1
1
  require_relative '../../spec_helper'
2
2
  require_lib 'reek/examiner'
3
- require_lib 'reek/report/report'
3
+ require_lib 'reek/report/text_report'
4
4
  require_lib 'reek/report/formatter'
5
- require_lib 'reek/report/heading_formatter'
6
5
  require 'rainbow'
7
6
 
8
7
  RSpec.describe Reek::Report::TextReport do
9
8
  let(:report_options) do
10
9
  {
11
- warning_formatter: Reek::Report::SimpleWarningFormatter.new,
10
+ warning_formatter: Reek::Report::Formatter::SimpleWarningFormatter.new,
12
11
  report_formatter: Reek::Report::Formatter,
13
- heading_formatter: Reek::Report::HeadingFormatter::Quiet
12
+ heading_formatter: Reek::Report::Formatter::QuietHeadingFormatter
14
13
  }
15
14
  end
16
15
  let(:instance) { described_class.new report_options }
@@ -1,6 +1,6 @@
1
1
  require_relative '../../spec_helper'
2
2
  require_lib 'reek/examiner'
3
- require_lib 'reek/report/report'
3
+ require_lib 'reek/report/xml_report'
4
4
 
5
5
  RSpec.describe Reek::Report::XMLReport do
6
6
  let(:xml_report) { described_class.new }
@@ -1,6 +1,6 @@
1
1
  require_relative '../../spec_helper'
2
2
  require_lib 'reek/examiner'
3
- require_lib 'reek/report/report'
3
+ require_lib 'reek/report/yaml_report'
4
4
  require_lib 'reek/report/formatter'
5
5
 
6
6
  require 'yaml'
@@ -51,7 +51,7 @@ RSpec.describe Reek::Report::YAMLReport do
51
51
  expect(result).to eq expected
52
52
  end
53
53
  context 'with link formatter' do
54
- let(:options) { { warning_formatter: Reek::Report::WikiLinkWarningFormatter.new } }
54
+ let(:options) { { warning_formatter: Reek::Report::Formatter::WikiLinkWarningFormatter.new } }
55
55
 
56
56
  it 'prints documentation links' do
57
57
  out = StringIO.new
@@ -10,19 +10,19 @@ RSpec.describe Reek::Report do
10
10
 
11
11
  describe '.location_formatter' do
12
12
  it 'returns the correct class' do
13
- expect(described_class.location_formatter(:plain)).to eq Reek::Report::BlankLocationFormatter
13
+ expect(described_class.location_formatter(:plain)).to eq Reek::Report::Formatter::BlankLocationFormatter
14
14
  end
15
15
  end
16
16
 
17
17
  describe '.heading_formatter' do
18
18
  it 'returns the correct class' do
19
- expect(described_class.heading_formatter(:quiet)).to eq Reek::Report::HeadingFormatter::Quiet
19
+ expect(described_class.heading_formatter(:quiet)).to eq Reek::Report::Formatter::QuietHeadingFormatter
20
20
  end
21
21
  end
22
22
 
23
23
  describe '.warning_formatter_class' do
24
24
  it 'returns the correct class' do
25
- expect(described_class.warning_formatter_class(:simple)).to eq Reek::Report::SimpleWarningFormatter
25
+ expect(described_class.warning_formatter_class(:simple)).to eq Reek::Report::Formatter::SimpleWarningFormatter
26
26
  end
27
27
  end
28
28
  end
@@ -1,7 +1,7 @@
1
1
  require_relative '../../spec_helper'
2
- require_lib 'reek/smells/attribute'
2
+ require_lib 'reek/smell_detectors/attribute'
3
3
 
4
- RSpec.describe Reek::Smells::Attribute do
4
+ RSpec.describe Reek::SmellDetectors::Attribute do
5
5
  it 'reports the right values' do
6
6
  src = <<-EOS
7
7
  class Alfa
@@ -1,24 +1,24 @@
1
1
  require_relative '../../spec_helper'
2
- require_lib 'reek/smells/smell_detector'
2
+ require_lib 'reek/smell_detectors/base_detector'
3
3
 
4
- RSpec.describe Reek::Smells::SmellDetector do
4
+ RSpec.describe Reek::SmellDetectors::BaseDetector do
5
5
  describe '.todo_configuration_for' do
6
6
  it 'returns exclusion configuration for the given smells' do
7
7
  detector = described_class.new
8
8
  smell = create(:smell_warning, smell_detector: detector, context: 'Foo#bar')
9
9
  result = described_class.todo_configuration_for([smell])
10
- expect(result).to eq('SmellDetector' => { 'exclude' => ['Foo#bar'] })
10
+ expect(result).to eq('BaseDetector' => { 'exclude' => ['Foo#bar'] })
11
11
  end
12
12
 
13
13
  it 'merges identical contexts' do
14
14
  detector = described_class.new
15
15
  smell = create(:smell_warning, smell_detector: detector, context: 'Foo#bar')
16
16
  result = described_class.todo_configuration_for([smell, smell])
17
- expect(result).to eq('SmellDetector' => { 'exclude' => ['Foo#bar'] })
17
+ expect(result).to eq('BaseDetector' => { 'exclude' => ['Foo#bar'] })
18
18
  end
19
19
 
20
20
  context 'with default exclusions present' do
21
- let(:subclass) { Reek::Smells::TooManyStatements }
21
+ let(:subclass) { Reek::SmellDetectors::TooManyStatements }
22
22
 
23
23
  before do
24
24
  expect(subclass.default_config['exclude']).to eq ['initialize']
@@ -1,7 +1,7 @@
1
1
  require_relative '../../spec_helper'
2
- require_lib 'reek/smells/boolean_parameter'
2
+ require_lib 'reek/smell_detectors/boolean_parameter'
3
3
 
4
- RSpec.describe Reek::Smells::BooleanParameter do
4
+ RSpec.describe Reek::SmellDetectors::BooleanParameter do
5
5
  it 'reports the right values' do
6
6
  src = <<-EOS
7
7
  def alfa(bravo = true)
@@ -1,7 +1,7 @@
1
1
  require_relative '../../spec_helper'
2
- require_lib 'reek/smells/class_variable'
2
+ require_lib 'reek/smell_detectors/class_variable'
3
3
 
4
- RSpec.describe Reek::Smells::ClassVariable do
4
+ RSpec.describe Reek::SmellDetectors::ClassVariable do
5
5
  it 'reports the right values' do
6
6
  src = <<-EOS
7
7
  class Alfa
@@ -1,7 +1,7 @@
1
1
  require_relative '../../spec_helper'
2
- require_lib 'reek/smells/control_parameter'
2
+ require_lib 'reek/smell_detectors/control_parameter'
3
3
 
4
- RSpec.describe Reek::Smells::ControlParameter do
4
+ RSpec.describe Reek::SmellDetectors::ControlParameter do
5
5
  it 'reports the right values' do
6
6
  src = <<-EOS
7
7
  def alfa(bravo)
@@ -1,7 +1,7 @@
1
1
  require_relative '../../spec_helper'
2
- require_lib 'reek/smells/data_clump'
2
+ require_lib 'reek/smell_detectors/data_clump'
3
3
 
4
- RSpec.describe Reek::Smells::DataClump do
4
+ RSpec.describe Reek::SmellDetectors::DataClump do
5
5
  it 'reports the right values' do
6
6
  src = <<-EOS
7
7
  class Alfa
@@ -0,0 +1,22 @@
1
+ require_relative '../../spec_helper'
2
+ require_lib 'reek/smell_detectors/base_detector'
3
+ require_lib 'reek/smell_detectors/detector_repository'
4
+
5
+ RSpec.describe Reek::SmellDetectors::DetectorRepository do
6
+ describe '.smell_types' do
7
+ let(:smell_types) { described_class.smell_types }
8
+
9
+ it 'includes existing smell_types' do
10
+ expect(smell_types).to include(Reek::SmellDetectors::IrresponsibleModule).
11
+ and include(Reek::SmellDetectors::TooManyStatements)
12
+ end
13
+
14
+ it 'excludes the smell detector base class' do
15
+ expect(smell_types).not_to include(Reek::SmellDetectors::BaseDetector)
16
+ end
17
+
18
+ it 'returns the smell types in alphabetic order' do
19
+ expect(smell_types).to eq(smell_types.sort_by(&:name))
20
+ end
21
+ end
22
+ end
@@ -1,7 +1,7 @@
1
1
  require_relative '../../spec_helper'
2
- require_lib 'reek/smells/duplicate_method_call'
2
+ require_lib 'reek/smell_detectors/duplicate_method_call'
3
3
 
4
- RSpec.describe Reek::Smells::DuplicateMethodCall do
4
+ RSpec.describe Reek::SmellDetectors::DuplicateMethodCall do
5
5
  it 'reports the right values' do
6
6
  src = <<-EOS
7
7
  class Alfa
@@ -164,7 +164,7 @@ RSpec.describe Reek::Smells::DuplicateMethodCall do
164
164
 
165
165
  context 'allowing up to 3 calls' do
166
166
  let(:config) do
167
- { Reek::Smells::DuplicateMethodCall::MAX_ALLOWED_CALLS_KEY => 3 }
167
+ { Reek::SmellDetectors::DuplicateMethodCall::MAX_ALLOWED_CALLS_KEY => 3 }
168
168
  end
169
169
 
170
170
  it 'does not report double calls' do
@@ -191,19 +191,19 @@ RSpec.describe Reek::Smells::DuplicateMethodCall do
191
191
 
192
192
  context 'allowing calls to some methods' do
193
193
  it 'does not report calls to some methods' do
194
- config = { Reek::Smells::DuplicateMethodCall::ALLOW_CALLS_KEY => ['@bravo.charlie'] }
194
+ config = { Reek::SmellDetectors::DuplicateMethodCall::ALLOW_CALLS_KEY => ['@bravo.charlie'] }
195
195
  src = 'def alfa; @bravo.charlie + @bravo.charlie; end'
196
196
  expect(src).not_to reek_of(:DuplicateMethodCall).with_config(config)
197
197
  end
198
198
 
199
199
  it 'reports calls to other methods' do
200
- config = { Reek::Smells::DuplicateMethodCall::ALLOW_CALLS_KEY => ['@delta.charlie'] }
200
+ config = { Reek::SmellDetectors::DuplicateMethodCall::ALLOW_CALLS_KEY => ['@delta.charlie'] }
201
201
  src = 'def alfa; @bravo.charlie + @bravo.charlie; end'
202
202
  expect(src).to reek_of(:DuplicateMethodCall, name: '@bravo.charlie').with_config(config)
203
203
  end
204
204
 
205
205
  it 'does not report calls to methods specifed with a regular expression' do
206
- config = { Reek::Smells::DuplicateMethodCall::ALLOW_CALLS_KEY => [/charlie/] }
206
+ config = { Reek::SmellDetectors::DuplicateMethodCall::ALLOW_CALLS_KEY => [/charlie/] }
207
207
  src = 'def alfa; puts @bravo.charlie; puts @bravo.charlie; end'
208
208
  expect(src).not_to reek_of(:DuplicateMethodCall, name: '@bravo.charlie').with_config(config)
209
209
  end
@@ -1,7 +1,7 @@
1
1
  require_relative '../../spec_helper'
2
- require_lib 'reek/smells/feature_envy'
2
+ require_lib 'reek/smell_detectors/feature_envy'
3
3
 
4
- RSpec.describe Reek::Smells::FeatureEnvy do
4
+ RSpec.describe Reek::SmellDetectors::FeatureEnvy do
5
5
  it 'reports the right values' do
6
6
  src = <<-EOS
7
7
  class Alfa
@@ -1,8 +1,8 @@
1
1
  require_relative '../../spec_helper'
2
2
 
3
- require_lib 'reek/smells/instance_variable_assumption'
3
+ require_lib 'reek/smell_detectors/instance_variable_assumption'
4
4
 
5
- RSpec.describe Reek::Smells::InstanceVariableAssumption do
5
+ RSpec.describe Reek::SmellDetectors::InstanceVariableAssumption do
6
6
  it 'reports the right values' do
7
7
  src = <<-EOS
8
8
  class Alfa
@@ -1,7 +1,7 @@
1
1
  require_relative '../../spec_helper'
2
- require_lib 'reek/smells/irresponsible_module'
2
+ require_lib 'reek/smell_detectors/irresponsible_module'
3
3
 
4
- RSpec.describe Reek::Smells::IrresponsibleModule do
4
+ RSpec.describe Reek::SmellDetectors::IrresponsibleModule do
5
5
  it 'reports the right values' do
6
6
  src = <<-EOS
7
7
  class Alfa
@@ -1,7 +1,7 @@
1
1
  require_relative '../../spec_helper'
2
- require_lib 'reek/smells/long_parameter_list'
2
+ require_lib 'reek/smell_detectors/long_parameter_list'
3
3
 
4
- RSpec.describe Reek::Smells::LongParameterList do
4
+ RSpec.describe Reek::SmellDetectors::LongParameterList do
5
5
  it 'reports the right values' do
6
6
  src = <<-EOS
7
7
  class Alfa
@@ -1,7 +1,7 @@
1
1
  require_relative '../../spec_helper'
2
- require_lib 'reek/smells/long_yield_list'
2
+ require_lib 'reek/smell_detectors/long_yield_list'
3
3
 
4
- RSpec.describe Reek::Smells::LongYieldList do
4
+ RSpec.describe Reek::SmellDetectors::LongYieldList do
5
5
  it 'reports the right values' do
6
6
  src = <<-EOS
7
7
  class Alfa