reek 3.11 → 4.0.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -0
  3. data/.travis.yml +0 -1
  4. data/CHANGELOG.md +13 -1
  5. data/README.md +0 -1
  6. data/bin/code_climate_reek +1 -0
  7. data/bin/reek +1 -0
  8. data/docs/API.md +2 -2
  9. data/docs/RSpec-matchers.md +4 -7
  10. data/features/reports/json.feature +0 -4
  11. data/features/reports/yaml.feature +4 -8
  12. data/lib/reek.rb +1 -0
  13. data/lib/reek/ast/ast_node_class_map.rb +1 -0
  14. data/lib/reek/ast/node.rb +1 -0
  15. data/lib/reek/ast/object_refs.rb +2 -1
  16. data/lib/reek/ast/reference_collector.rb +1 -0
  17. data/lib/reek/ast/sexp_extensions.rb +1 -0
  18. data/lib/reek/ast/sexp_extensions/arguments.rb +1 -0
  19. data/lib/reek/ast/sexp_extensions/attribute_assignments.rb +1 -0
  20. data/lib/reek/ast/sexp_extensions/block.rb +1 -0
  21. data/lib/reek/ast/sexp_extensions/case.rb +1 -0
  22. data/lib/reek/ast/sexp_extensions/constant.rb +1 -0
  23. data/lib/reek/ast/sexp_extensions/if.rb +1 -0
  24. data/lib/reek/ast/sexp_extensions/literal.rb +1 -0
  25. data/lib/reek/ast/sexp_extensions/logical_operators.rb +1 -0
  26. data/lib/reek/ast/sexp_extensions/methods.rb +1 -0
  27. data/lib/reek/ast/sexp_extensions/module.rb +1 -0
  28. data/lib/reek/ast/sexp_extensions/nested_assignables.rb +1 -0
  29. data/lib/reek/ast/sexp_extensions/self.rb +1 -0
  30. data/lib/reek/ast/sexp_extensions/send.rb +1 -0
  31. data/lib/reek/ast/sexp_extensions/super.rb +1 -0
  32. data/lib/reek/ast/sexp_extensions/symbols.rb +1 -0
  33. data/lib/reek/ast/sexp_extensions/variables.rb +1 -0
  34. data/lib/reek/ast/sexp_extensions/when.rb +1 -0
  35. data/lib/reek/ast/sexp_extensions/yield.rb +1 -0
  36. data/lib/reek/cli/application.rb +1 -0
  37. data/lib/reek/cli/command/base_command.rb +1 -0
  38. data/lib/reek/cli/command/report_command.rb +2 -1
  39. data/lib/reek/cli/command/todo_list_command.rb +2 -1
  40. data/lib/reek/cli/input.rb +1 -0
  41. data/lib/reek/cli/option_interpreter.rb +1 -0
  42. data/lib/reek/cli/options.rb +1 -0
  43. data/lib/reek/cli/silencer.rb +1 -0
  44. data/lib/reek/cli/warning_collector.rb +1 -0
  45. data/lib/reek/code_comment.rb +1 -0
  46. data/lib/reek/configuration/app_configuration.rb +1 -0
  47. data/lib/reek/configuration/configuration_file_finder.rb +1 -0
  48. data/lib/reek/configuration/configuration_validator.rb +1 -0
  49. data/lib/reek/configuration/default_directive.rb +1 -0
  50. data/lib/reek/configuration/directory_directives.rb +1 -0
  51. data/lib/reek/configuration/excluded_paths.rb +1 -0
  52. data/lib/reek/context/attribute_context.rb +1 -0
  53. data/lib/reek/context/class_context.rb +1 -0
  54. data/lib/reek/context/code_context.rb +1 -0
  55. data/lib/reek/context/ghost_context.rb +1 -0
  56. data/lib/reek/context/method_context.rb +1 -0
  57. data/lib/reek/context/module_context.rb +1 -0
  58. data/lib/reek/context/root_context.rb +1 -0
  59. data/lib/reek/context/send_context.rb +1 -0
  60. data/lib/reek/context/singleton_attribute_context.rb +1 -0
  61. data/lib/reek/context/singleton_method_context.rb +1 -0
  62. data/lib/reek/context/statement_counter.rb +1 -0
  63. data/lib/reek/context/visibility_tracker.rb +3 -2
  64. data/lib/reek/context_builder.rb +1 -0
  65. data/lib/reek/examiner.rb +2 -1
  66. data/lib/reek/rake/task.rb +1 -0
  67. data/lib/reek/report.rb +1 -0
  68. data/lib/reek/report/code_climate/code_climate_formatter.rb +2 -2
  69. data/lib/reek/report/formatter.rb +1 -0
  70. data/lib/reek/report/heading_formatter.rb +1 -0
  71. data/lib/reek/report/location_formatter.rb +1 -0
  72. data/lib/reek/report/report.rb +3 -3
  73. data/lib/reek/smells.rb +1 -0
  74. data/lib/reek/smells/attribute.rb +1 -0
  75. data/lib/reek/smells/boolean_parameter.rb +1 -4
  76. data/lib/reek/smells/class_variable.rb +1 -0
  77. data/lib/reek/smells/control_parameter.rb +7 -4
  78. data/lib/reek/smells/data_clump.rb +1 -0
  79. data/lib/reek/smells/duplicate_method_call.rb +5 -4
  80. data/lib/reek/smells/feature_envy.rb +1 -4
  81. data/lib/reek/smells/irresponsible_module.rb +1 -0
  82. data/lib/reek/smells/long_parameter_list.rb +1 -0
  83. data/lib/reek/smells/long_yield_list.rb +1 -4
  84. data/lib/reek/smells/module_initialize.rb +1 -0
  85. data/lib/reek/smells/nested_iterators.rb +2 -1
  86. data/lib/reek/smells/nil_check.rb +3 -4
  87. data/lib/reek/smells/prima_donna_method.rb +1 -0
  88. data/lib/reek/smells/repeated_conditional.rb +1 -4
  89. data/lib/reek/smells/smell_configuration.rb +1 -0
  90. data/lib/reek/smells/smell_detector.rb +2 -13
  91. data/lib/reek/smells/smell_repository.rb +1 -0
  92. data/lib/reek/smells/smell_warning.rb +4 -6
  93. data/lib/reek/smells/too_many_instance_variables.rb +1 -4
  94. data/lib/reek/smells/too_many_methods.rb +1 -4
  95. data/lib/reek/smells/too_many_statements.rb +1 -4
  96. data/lib/reek/smells/uncommunicative_method_name.rb +2 -5
  97. data/lib/reek/smells/uncommunicative_module_name.rb +2 -6
  98. data/lib/reek/smells/uncommunicative_parameter_name.rb +3 -6
  99. data/lib/reek/smells/uncommunicative_variable_name.rb +1 -4
  100. data/lib/reek/smells/unused_parameters.rb +1 -4
  101. data/lib/reek/smells/unused_private_method.rb +1 -0
  102. data/lib/reek/smells/utility_function.rb +1 -4
  103. data/lib/reek/source/source_code.rb +2 -1
  104. data/lib/reek/source/source_locator.rb +1 -0
  105. data/lib/reek/spec.rb +16 -23
  106. data/lib/reek/spec/should_reek.rb +3 -2
  107. data/lib/reek/spec/should_reek_of.rb +18 -15
  108. data/lib/reek/spec/should_reek_only_of.rb +6 -5
  109. data/lib/reek/spec/smell_matcher.rb +3 -7
  110. data/lib/reek/tree_dresser.rb +1 -0
  111. data/lib/reek/version.rb +2 -1
  112. data/reek.gemspec +1 -1
  113. data/spec/reek/examiner_spec.rb +8 -4
  114. data/spec/reek/report/code_climate_formatter_spec.rb +1 -1
  115. data/spec/reek/report/code_climate_report_spec.rb +2 -2
  116. data/spec/reek/report/html_report_spec.rb +1 -6
  117. data/spec/reek/report/json_report_spec.rb +0 -4
  118. data/spec/reek/report/yaml_report_spec.rb +0 -4
  119. data/spec/reek/smells/data_clump_spec.rb +2 -2
  120. data/spec/reek/smells/feature_envy_spec.rb +3 -3
  121. data/spec/reek/smells/nested_iterators_spec.rb +0 -1
  122. data/spec/reek/smells/prima_donna_method_spec.rb +0 -1
  123. data/spec/reek/smells/smell_detector_shared.rb +1 -5
  124. data/spec/reek/smells/too_many_methods_spec.rb +0 -1
  125. data/spec/reek/smells/uncommunicative_module_name_spec.rb +0 -1
  126. data/spec/reek/smells/unused_private_method_spec.rb +6 -4
  127. data/spec/reek/smells/utility_function_spec.rb +1 -1
  128. data/spec/reek/spec/should_reek_of_spec.rb +7 -3
  129. data/spec/reek/spec/smell_matcher_spec.rb +0 -4
  130. metadata +6 -6
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative '../examiner'
2
3
  require_relative '../report/formatter'
3
4
  require_relative 'should_reek_of'
@@ -10,24 +11,24 @@ module Reek
10
11
  # code smell and no others.
11
12
  #
12
13
  class ShouldReekOnlyOf < ShouldReekOf
13
- def matches?(actual)
14
- matches_examiner?(Examiner.new(actual, configuration: configuration))
14
+ def matches?(source)
15
+ matches_examiner?(Examiner.new(source, configuration: configuration))
15
16
  end
16
17
 
17
18
  def matches_examiner?(examiner)
18
19
  self.examiner = examiner
19
20
  self.warnings = examiner.smells
20
21
  return false if warnings.empty?
21
- warnings.all? { |warning| SmellMatcher.new(warning).matches?(smell_category) }
22
+ warnings.all? { |warning| SmellMatcher.new(warning).matches?(smell_type) }
22
23
  end
23
24
 
24
25
  def failure_message
25
26
  rpt = Report::Formatter.format_list(warnings)
26
- "Expected #{examiner.description} to reek only of #{smell_category}, but got:\n#{rpt}"
27
+ "Expected #{examiner.description} to reek only of #{smell_type}, but got:\n#{rpt}"
27
28
  end
28
29
 
29
30
  def failure_message_when_negated
30
- "Expected #{examiner.description} not to reek only of #{smell_category}, but it did"
31
+ "Expected #{examiner.description} not to reek only of #{smell_type}, but it did"
31
32
  end
32
33
 
33
34
  private
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Reek
2
3
  module Spec
3
4
  #
@@ -17,16 +18,15 @@ module Reek
17
18
  end
18
19
 
19
20
  def matches_smell_type?(klass)
20
- smell_classes.include?(klass.to_s)
21
+ smell_warning.smell_type == klass.to_s
21
22
  end
22
23
 
23
24
  def matches_attributes?(attributes)
24
25
  check_attributes_comparability(attributes)
25
26
 
26
- # FIXME: Use Array#to_h when dropping Ruby 2.0 compatibility.
27
27
  fields, params = attributes.
28
28
  partition { |key, _| COMPARABLE_ATTRIBUTES.include? key }.
29
- map { |arr| Hash[arr] }
29
+ map(&:to_h)
30
30
 
31
31
  common_parameters_equal?(params) &&
32
32
  common_attributes_equal?(fields)
@@ -34,10 +34,6 @@ module Reek
34
34
 
35
35
  private
36
36
 
37
- def smell_classes
38
- [smell_warning.smell_category, smell_warning.smell_type]
39
- end
40
-
41
37
  def check_attributes_comparability(other_attributes)
42
38
  parameter_keys = other_attributes.keys - COMPARABLE_ATTRIBUTES
43
39
  extra_keys = parameter_keys - smell_warning.parameters.keys
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative 'ast/ast_node_class_map'
2
3
 
3
4
  module Reek
data/lib/reek/version.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # @public
2
3
  module Reek
3
4
  #
@@ -6,6 +7,6 @@ module Reek
6
7
  # @public
7
8
  module Version
8
9
  # @public
9
- STRING = '3.11'.freeze
10
+ STRING = '4.0.0.pre1'.freeze
10
11
  end
11
12
  end
data/reek.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.executables = s.files.grep(%r{^bin/}).map { |path| File.basename(path) }
20
20
  s.homepage = 'https://github.com/troessner/reek/wiki'
21
21
  s.rdoc_options = %w(--main README.md -x assets/|bin/|config/|features/|spec/|tasks/)
22
- s.required_ruby_version = '>= 2.0.0'
22
+ s.required_ruby_version = '>= 2.1.0'
23
23
  s.summary = 'Code smell detector for Ruby'
24
24
 
25
25
  s.add_runtime_dependency 'codeclimate-engine-rb', '~> 0.3.1'
@@ -20,7 +20,7 @@ RSpec.shared_examples_for 'one smell found' do
20
20
  end
21
21
 
22
22
  it 'reports the correct smell' do
23
- expect(examiner.smells[0].smell_category).to eq(expected_first_smell)
23
+ expect(examiner.smells[0].smell_type).to eq(expected_first_smell)
24
24
  end
25
25
  end
26
26
 
@@ -35,14 +35,18 @@ RSpec.describe Reek::Examiner do
35
35
 
36
36
  context 'with a smelly String' do
37
37
  let(:examiner) { described_class.new('def fine() y = 4; end') }
38
- let(:expected_first_smell) { 'UncommunicativeName' }
38
+ let(:expected_first_smell) { 'UncommunicativeVariableName' }
39
39
 
40
40
  it_should_behave_like 'one smell found'
41
41
  end
42
42
 
43
43
  context 'with a partially masked smelly File' do
44
44
  let(:configuration) { test_configuration_for(path) }
45
- let(:examiner) { described_class.new(smelly_file, [], configuration: configuration) }
45
+ let(:examiner) do
46
+ described_class.new(smelly_file,
47
+ filter_by_smells: [],
48
+ configuration: configuration)
49
+ end
46
50
  let(:path) { SAMPLES_PATH.join('all_but_one_masked/masked.reek') }
47
51
  let(:smelly_file) { Pathname.glob(SAMPLES_PATH.join('all_but_one_masked/d*.rb')).first }
48
52
 
@@ -59,7 +63,7 @@ RSpec.describe Reek::Examiner do
59
63
  describe '#smells' do
60
64
  it 'returns the detected smell warnings' do
61
65
  code = 'def foo; bar.call_me(); bar.call_me(); end'
62
- examiner = described_class.new code, ['DuplicateMethodCall']
66
+ examiner = described_class.new code, filter_by_smells: ['DuplicateMethodCall']
63
67
 
64
68
  smell = examiner.smells.first
65
69
  expect(smell).to be_a(Reek::Smells::SmellWarning)
@@ -25,7 +25,7 @@ RSpec.describe Reek::Report::CodeClimateFormatter, '#render' do
25
25
  end
26
26
 
27
27
  it 'sets a check name based on the smell detector' do
28
- expect(rendered).to match(%r{\"check_name\":\"LowCohesion\/UtilityFunction\"})
28
+ expect(rendered).to match(/\"check_name\":\"UtilityFunction\"/)
29
29
  end
30
30
 
31
31
  it 'sets the location' do
@@ -29,7 +29,7 @@ RSpec.describe Reek::Report::CodeClimateReport do
29
29
  it 'prints smells as json' do
30
30
  expected = <<-EOS.delete("\n")
31
31
  {\"type\":\"issue\",
32
- \"check_name\":\"UncommunicativeName/UncommunicativeParameterName\",
32
+ \"check_name\":\"UncommunicativeParameterName\",
33
33
  \"description\":\"simple has the parameter name 'a'\",
34
34
  \"categories\":[\"Complexity\"],
35
35
  \"location\":{\"path\":\"string\",\"lines\":{\"begin\":1,\"end\":1}},
@@ -40,7 +40,7 @@ RSpec.describe Reek::Report::CodeClimateReport do
40
40
  mis-interpreted; and they hurt the flow of reading, because the reader must slow down
41
41
  to interpret the names.\\n\"}}\u0000
42
42
  {\"type\":\"issue\",
43
- \"check_name\":\"LowCohesion/UtilityFunction\",
43
+ \"check_name\":\"UtilityFunction\",
44
44
  \"description\":\"simple doesn't depend on instance state (maybe move it to another class?)\",
45
45
  \"categories\":[\"Complexity\"],
46
46
  \"location\":{\"path\":\"string\",\"lines\":{\"begin\":1,\"end\":1}},
@@ -1,4 +1,3 @@
1
- require 'tempfile'
2
1
  require_relative '../../spec_helper'
3
2
  require_lib 'reek/examiner'
4
3
  require_lib 'reek/report/report'
@@ -14,11 +13,7 @@ RSpec.describe Reek::Report::HTMLReport do
14
13
  end
15
14
 
16
15
  it 'has the text 0 total warnings' do
17
- tempfile = Tempfile.new(['Reek::Report::HTMLReport.', '.html'])
18
- response = "HTML file saved\n"
19
- expect { instance.show(target_path: tempfile.path) }.
20
- to output(response).to_stdout
21
- expect(tempfile.read).to include('0 total warnings')
16
+ expect { instance.show }.to output(/0 total warnings/).to_stdout
22
17
  end
23
18
  end
24
19
  end
@@ -37,7 +37,6 @@ RSpec.describe Reek::Report::JSONReport do
37
37
  "context": "simple",
38
38
  "lines": [1],
39
39
  "message": "has the parameter name 'a'",
40
- "smell_category": "UncommunicativeName",
41
40
  "smell_type": "UncommunicativeParameterName",
42
41
  "source": "string",
43
42
  "name": "a"
@@ -46,7 +45,6 @@ RSpec.describe Reek::Report::JSONReport do
46
45
  "context": "simple",
47
46
  "lines": [1],
48
47
  "message": "doesn't depend on instance state (maybe move it to another class?)",
49
- "smell_category": "LowCohesion",
50
48
  "smell_type": "UtilityFunction",
51
49
  "source": "string",
52
50
  "name": "simple"
@@ -71,7 +69,6 @@ RSpec.describe Reek::Report::JSONReport do
71
69
  "context": "simple",
72
70
  "lines": [1],
73
71
  "message": "has the parameter name 'a'",
74
- "smell_category": "UncommunicativeName",
75
72
  "smell_type": "UncommunicativeParameterName",
76
73
  "source": "string",
77
74
  "name": "a",
@@ -81,7 +78,6 @@ RSpec.describe Reek::Report::JSONReport do
81
78
  "context": "simple",
82
79
  "lines": [1],
83
80
  "message": "doesn't depend on instance state (maybe move it to another class?)",
84
- "smell_category": "LowCohesion",
85
81
  "smell_type": "UtilityFunction",
86
82
  "source": "string",
87
83
  "name": "simple",
@@ -37,7 +37,6 @@ RSpec.describe Reek::Report::YAMLReport do
37
37
  lines:
38
38
  - 1
39
39
  message: "has the parameter name 'a'"
40
- smell_category: "UncommunicativeName"
41
40
  smell_type: "UncommunicativeParameterName"
42
41
  source: "string"
43
42
  name: "a"
@@ -45,7 +44,6 @@ RSpec.describe Reek::Report::YAMLReport do
45
44
  lines:
46
45
  - 1
47
46
  message: "doesn't depend on instance state (maybe move it to another class?)"
48
- smell_category: "LowCohesion"
49
47
  smell_type: "UtilityFunction"
50
48
  source: "string"
51
49
  name: "simple"
@@ -67,7 +65,6 @@ RSpec.describe Reek::Report::YAMLReport do
67
65
  lines:
68
66
  - 1
69
67
  message: "has the parameter name 'a'"
70
- smell_category: "UncommunicativeName"
71
68
  smell_type: "UncommunicativeParameterName"
72
69
  source: "string"
73
70
  name: "a"
@@ -76,7 +73,6 @@ RSpec.describe Reek::Report::YAMLReport do
76
73
  lines:
77
74
  - 1
78
75
  message: "doesn't depend on instance state (maybe move it to another class?)"
79
- smell_category: "LowCohesion"
80
76
  smell_type: "UtilityFunction"
81
77
  source: "string"
82
78
  name: "simple"
@@ -49,8 +49,8 @@ RSpec.shared_examples_for 'a data clump detector' do
49
49
  expect(smells[0].lines).to eq([2, 3, 4])
50
50
  end
51
51
 
52
- it 'reports the correct smell class' do
53
- expect(smells[0].smell_category).to eq(Reek::Smells::DataClump.smell_category)
52
+ it 'reports the correct smell type' do
53
+ expect(smells[0].smell_type).to eq(Reek::Smells::DataClump.smell_type)
54
54
  end
55
55
 
56
56
  it 'reports the context fq name' do
@@ -113,7 +113,7 @@ RSpec.describe Reek::Smells::FeatureEnvy do
113
113
  @cow.feed_to(thing.pig)
114
114
  @duck.feed_to(thing.pig)
115
115
  end
116
- ').to reek_only_of(:Duplication)
116
+ ').to reek_only_of(:DuplicateMethodCall)
117
117
  end
118
118
 
119
119
  it 'should count local calls' do
@@ -122,7 +122,7 @@ RSpec.describe Reek::Smells::FeatureEnvy do
122
122
  cow.feed_to(thing.pig)
123
123
  duck.feed_to(thing.pig)
124
124
  end
125
- ').to reek_only_of(:Duplication)
125
+ ').to reek_only_of(:DuplicateMethodCall)
126
126
  end
127
127
 
128
128
  it 'should report many calls to lvar' do
@@ -230,7 +230,7 @@ RSpec.describe Reek::Smells::FeatureEnvy do
230
230
  #{receiver}.fred
231
231
  end
232
232
  EOS
233
- Reek::Examiner.new(src, ['FeatureEnvy']).smells.first
233
+ Reek::Examiner.new(src, filter_by_smells: ['FeatureEnvy']).smells.first
234
234
  end
235
235
 
236
236
  it_should_behave_like 'common fields set correctly'
@@ -123,7 +123,6 @@ RSpec.describe Reek::Smells::NestedIterators do
123
123
  warnings = detector.inspect(build(:method_context, source: source))
124
124
  warning = warnings.first
125
125
 
126
- expect(warning.smell_category).to eq(Reek::Smells::NestedIterators.smell_category)
127
126
  expect(warning.smell_type).to eq(Reek::Smells::NestedIterators.smell_type)
128
127
  expect(warning.parameters[:name]).to eq('foo')
129
128
  expect(warning.lines).to eq([3])
@@ -23,7 +23,6 @@ RSpec.describe Reek::Smells::PrimaDonnaMethod do
23
23
  smells = detector.inspect(ctx)
24
24
  warning = smells[0]
25
25
 
26
- expect(warning.smell_category).to eq('PrimaDonnaMethod')
27
26
  expect(warning.smell_type).to eq('PrimaDonnaMethod')
28
27
  expect(warning.lines).to eq([1])
29
28
  end
@@ -23,11 +23,7 @@ RSpec.shared_examples_for 'common fields set correctly' do
23
23
  expect(warning.source).to eq('string')
24
24
  end
25
25
 
26
- it 'reports the smell class' do
27
- expect(warning.smell_category).to eq(detector.smell_category)
28
- end
29
-
30
- it 'reports the smell sub class' do
26
+ it 'reports the smell type' do
31
27
  expect(warning.smell_type).to eq(detector.smell_type)
32
28
  end
33
29
  end
@@ -71,7 +71,6 @@ RSpec.describe Reek::Smells::TooManyMethods do
71
71
  ctx = Reek::Context::ModuleContext.new(nil, syntax_tree)
72
72
  warning = detector.inspect(ctx)[0]
73
73
  expect(warning.source).to eq(source_name)
74
- expect(warning.smell_category).to eq(described_class.smell_category)
75
74
  expect(warning.smell_type).to eq(described_class.smell_type)
76
75
  expect(warning.parameters[:count]).to eq(3)
77
76
  expect(warning.lines).to eq([1])
@@ -30,7 +30,6 @@ RSpec.describe Reek::Smells::UncommunicativeModuleName do
30
30
  ctx = Reek::Context::CodeContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
31
31
  smells = detector.inspect(ctx)
32
32
  expect(smells.length).to eq(1)
33
- expect(smells[0].smell_category).to eq(Reek::Smells::UncommunicativeModuleName.smell_category)
34
33
  expect(smells[0].smell_type).to eq(Reek::Smells::UncommunicativeModuleName.smell_type)
35
34
  expect(smells[0].parameters[:name]).to eq('X')
36
35
  expect(smells[0].context).to match(/#{smells[0].parameters[:name]}/)
@@ -37,16 +37,16 @@ RSpec.describe Reek::Smells::UnusedPrivateMethod do
37
37
  end
38
38
  EOF
39
39
 
40
- examiner = Reek::Examiner.new(source, 'UnusedPrivateMethod', configuration: configuration)
40
+ examiner = Reek::Examiner.new(source,
41
+ filter_by_smells: 'UnusedPrivateMethod',
42
+ configuration: configuration)
41
43
 
42
44
  first_warning = examiner.smells.first
43
- expect(first_warning.smell_category).to eq(Reek::Smells::UnusedPrivateMethod.smell_category)
44
45
  expect(first_warning.smell_type).to eq(Reek::Smells::UnusedPrivateMethod.smell_type)
45
46
  expect(first_warning.parameters[:name]).to eq(:drive)
46
47
  expect(first_warning.lines).to eq([4])
47
48
 
48
49
  second_warning = examiner.smells.last
49
- expect(second_warning.smell_category).to eq(Reek::Smells::UnusedPrivateMethod.smell_category)
50
50
  expect(second_warning.smell_type).to eq(Reek::Smells::UnusedPrivateMethod.smell_type)
51
51
  expect(second_warning.parameters[:name]).to eq(:start)
52
52
  expect(second_warning.lines).to eq([3])
@@ -64,7 +64,9 @@ RSpec.describe Reek::Smells::UnusedPrivateMethod do
64
64
  end
65
65
  EOF
66
66
 
67
- examiner = Reek::Examiner.new(source, 'UnusedPrivateMethod', configuration: configuration)
67
+ examiner = Reek::Examiner.new(source,
68
+ filter_by_smells: 'UnusedPrivateMethod',
69
+ configuration: configuration)
68
70
 
69
71
  expect(examiner.smells.size).to eq(1)
70
72
  warning_for_drive = examiner.smells.first
@@ -16,7 +16,7 @@ RSpec.describe Reek::Smells::UtilityFunction do
16
16
  arga.b.c
17
17
  end
18
18
  EOS
19
- Reek::Examiner.new(src, ['UtilityFunction']).smells[0]
19
+ Reek::Examiner.new(src, filter_by_smells: ['UtilityFunction']).smells[0]
20
20
  end
21
21
 
22
22
  it_should_behave_like 'common fields set correctly'
@@ -3,11 +3,15 @@ require_relative '../../spec_helper'
3
3
  require_lib 'reek/spec'
4
4
 
5
5
  RSpec.describe Reek::Spec::ShouldReekOf do
6
- describe 'smell type check' do
6
+ describe 'smell type selection' do
7
7
  let(:ruby) { 'def double_thing() @other.thing.foo + @other.thing.foo end' }
8
8
 
9
- it 'reports duplicate calls' do
10
- expect(ruby).to reek_of(:Duplication)
9
+ it 'reports duplicate calls by smell type' do
10
+ expect(ruby).to reek_of(:DuplicateMethodCall)
11
+ end
12
+
13
+ it 'reports duplicate calls by smell detector class' do
14
+ expect(ruby).to reek_of(Reek::Smells::DuplicateMethodCall)
11
15
  end
12
16
 
13
17
  it 'does not report any feature envy' do
@@ -55,10 +55,6 @@ RSpec.describe Reek::Spec::SmellMatcher do
55
55
  expect(matcher.matches_smell_type?(:UncommunicativeVariableName)).to be_truthy
56
56
  end
57
57
 
58
- it 'matches on category symbol' do
59
- expect(matcher.matches_smell_type?(:UncommunicativeName)).to be_truthy
60
- end
61
-
62
58
  it 'does not match on different class symbol' do
63
59
  expect(matcher.matches_smell_type?(:FeatureEnvy)).to be_falsy
64
60
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reek
3
3
  version: !ruby/object:Gem::Version
4
- version: '3.11'
4
+ version: 4.0.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Rutherford
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-02-18 00:00:00.000000000 Z
14
+ date: 2016-03-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: codeclimate-engine-rb
@@ -393,15 +393,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
393
393
  requirements:
394
394
  - - ">="
395
395
  - !ruby/object:Gem::Version
396
- version: 2.0.0
396
+ version: 2.1.0
397
397
  required_rubygems_version: !ruby/object:Gem::Requirement
398
398
  requirements:
399
- - - ">="
399
+ - - ">"
400
400
  - !ruby/object:Gem::Version
401
- version: '0'
401
+ version: 1.3.1
402
402
  requirements: []
403
403
  rubyforge_project:
404
- rubygems_version: 2.4.5.1
404
+ rubygems_version: 2.5.1
405
405
  signing_key:
406
406
  specification_version: 4
407
407
  summary: Code smell detector for Ruby