reek 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -21
  3. data/.travis.yml +1 -0
  4. data/.yardopts +3 -6
  5. data/CHANGELOG +6 -0
  6. data/CONTRIBUTING.md +8 -3
  7. data/README.md +94 -42
  8. data/config/defaults.reek +0 -1
  9. data/docs/API.md +50 -0
  10. data/docs/Attribute.md +43 -0
  11. data/docs/Basic-Smell-Options.md +44 -0
  12. data/docs/Boolean-Parameter.md +52 -0
  13. data/docs/Class-Variable.md +40 -0
  14. data/docs/Code-Smells.md +34 -0
  15. data/docs/Command-Line-Options.md +84 -0
  16. data/docs/Configuration-Files.md +38 -0
  17. data/docs/Control-Couple.md +22 -0
  18. data/docs/Control-Parameter.md +29 -0
  19. data/docs/Data-Clump.md +44 -0
  20. data/docs/Duplicate-Method-Call.md +49 -0
  21. data/docs/Feature-Envy.md +29 -0
  22. data/docs/How-reek-works-internally.md +44 -0
  23. data/docs/Irresponsible-Module.md +39 -0
  24. data/docs/Large-Class.md +20 -0
  25. data/docs/Long-Parameter-List.md +38 -0
  26. data/docs/Long-Yield-List.md +36 -0
  27. data/docs/Module-Initialize.md +62 -0
  28. data/docs/Nested-Iterators.md +38 -0
  29. data/docs/Nil-Check.md +39 -0
  30. data/docs/Prima-Donna-Method.md +53 -0
  31. data/docs/RSpec-matchers.md +133 -0
  32. data/docs/Rake-Task.md +58 -0
  33. data/docs/Reek-Driven-Development.md +45 -0
  34. data/docs/Repeated-Conditional.md +44 -0
  35. data/docs/Simulated-Polymorphism.md +16 -0
  36. data/docs/Smell-Suppression.md +32 -0
  37. data/docs/Too-Many-Instance-Variables.md +43 -0
  38. data/docs/Too-Many-Methods.md +55 -0
  39. data/docs/Too-Many-Statements.md +50 -0
  40. data/docs/Uncommunicative-Method-Name.md +24 -0
  41. data/docs/Uncommunicative-Module-Name.md +23 -0
  42. data/docs/Uncommunicative-Name.md +16 -0
  43. data/docs/Uncommunicative-Parameter-Name.md +24 -0
  44. data/docs/Uncommunicative-Variable-Name.md +24 -0
  45. data/docs/Unused-Parameters.md +27 -0
  46. data/docs/Utility-Function.md +46 -0
  47. data/docs/Versioning-Policy.md +7 -0
  48. data/docs/YAML-Reports.md +111 -0
  49. data/docs/yard_plugin.rb +14 -0
  50. data/features/command_line_interface/options.feature +1 -0
  51. data/features/programmatic_access.feature +1 -1
  52. data/features/samples.feature +3 -3
  53. data/lib/reek.rb +2 -2
  54. data/lib/reek/cli/input.rb +2 -2
  55. data/lib/reek/cli/option_interpreter.rb +2 -0
  56. data/lib/reek/cli/options.rb +10 -4
  57. data/lib/reek/cli/reek_command.rb +2 -2
  58. data/lib/reek/cli/report/report.rb +60 -0
  59. data/lib/reek/cli/silencer.rb +13 -0
  60. data/lib/reek/{source → core}/ast_node.rb +1 -1
  61. data/lib/reek/{source → core}/ast_node_class_map.rb +10 -11
  62. data/lib/reek/{source → core}/code_comment.rb +1 -1
  63. data/lib/reek/core/code_context.rb +1 -1
  64. data/lib/reek/core/examiner.rb +85 -0
  65. data/lib/reek/core/method_context.rb +1 -1
  66. data/lib/reek/core/module_context.rb +2 -2
  67. data/lib/reek/core/reference_collector.rb +31 -0
  68. data/lib/reek/core/singleton_method_context.rb +0 -4
  69. data/lib/reek/core/smell_repository.rb +4 -2
  70. data/lib/reek/{source → core}/tree_dresser.rb +1 -1
  71. data/lib/reek/{source → sexp}/sexp_extensions.rb +5 -5
  72. data/lib/reek/sexp/sexp_formatter.rb +29 -0
  73. data/lib/reek/sexp/sexp_node.rb +91 -0
  74. data/lib/reek/smells.rb +4 -2
  75. data/lib/reek/smells/attribute.rb +35 -7
  76. data/lib/reek/smells/boolean_parameter.rb +1 -1
  77. data/lib/reek/smells/class_variable.rb +1 -1
  78. data/lib/reek/smells/control_parameter.rb +1 -1
  79. data/lib/reek/smells/data_clump.rb +1 -1
  80. data/lib/reek/smells/duplicate_method_call.rb +12 -4
  81. data/lib/reek/smells/feature_envy.rb +1 -1
  82. data/lib/reek/smells/irresponsible_module.rb +3 -3
  83. data/lib/reek/smells/long_parameter_list.rb +1 -1
  84. data/lib/reek/smells/long_yield_list.rb +1 -1
  85. data/lib/reek/smells/module_initialize.rb +1 -1
  86. data/lib/reek/smells/nested_iterators.rb +1 -1
  87. data/lib/reek/smells/nil_check.rb +3 -2
  88. data/lib/reek/smells/prima_donna_method.rb +18 -11
  89. data/lib/reek/smells/repeated_conditional.rb +3 -3
  90. data/lib/reek/smells/smell_detector.rb +5 -1
  91. data/lib/reek/smells/smell_warning.rb +99 -0
  92. data/lib/reek/smells/too_many_instance_variables.rb +1 -1
  93. data/lib/reek/smells/too_many_methods.rb +1 -1
  94. data/lib/reek/smells/too_many_statements.rb +1 -1
  95. data/lib/reek/smells/uncommunicative_method_name.rb +1 -1
  96. data/lib/reek/smells/uncommunicative_module_name.rb +1 -1
  97. data/lib/reek/smells/uncommunicative_parameter_name.rb +1 -1
  98. data/lib/reek/smells/uncommunicative_variable_name.rb +1 -1
  99. data/lib/reek/smells/unused_parameters.rb +1 -1
  100. data/lib/reek/smells/utility_function.rb +3 -16
  101. data/lib/reek/source/source_code.rb +31 -13
  102. data/lib/reek/source/source_locator.rb +16 -17
  103. data/lib/reek/source/source_repository.rb +10 -11
  104. data/lib/reek/spec/should_reek.rb +2 -2
  105. data/lib/reek/spec/should_reek_of.rb +2 -2
  106. data/lib/reek/spec/should_reek_only_of.rb +2 -2
  107. data/lib/reek/version.rb +1 -1
  108. data/reek.gemspec +3 -4
  109. data/spec/factories/factories.rb +1 -1
  110. data/spec/gem/yard_spec.rb +1 -1
  111. data/spec/quality/reek_source_spec.rb +2 -2
  112. data/spec/reek/cli/html_report_spec.rb +3 -3
  113. data/spec/reek/cli/json_report_spec.rb +3 -3
  114. data/spec/reek/cli/{option_interperter_spec.rb → option_interpreter_spec.rb} +1 -1
  115. data/spec/reek/cli/options_spec.rb +19 -0
  116. data/spec/reek/cli/text_report_spec.rb +7 -7
  117. data/spec/reek/cli/xml_report_spec.rb +34 -0
  118. data/spec/reek/cli/yaml_report_spec.rb +3 -3
  119. data/spec/reek/configuration/app_configuration_spec.rb +1 -1
  120. data/spec/reek/configuration/configuration_file_finder_spec.rb +22 -1
  121. data/spec/reek/{source → core}/code_comment_spec.rb +14 -14
  122. data/spec/reek/core/code_context_spec.rb +1 -1
  123. data/spec/reek/{examiner_spec.rb → core/examiner_spec.rb} +12 -12
  124. data/spec/reek/core/method_context_spec.rb +27 -22
  125. data/spec/reek/core/module_context_spec.rb +2 -2
  126. data/spec/reek/core/object_refs_spec.rb +1 -1
  127. data/spec/reek/{source → core}/object_source_spec.rb +1 -1
  128. data/spec/reek/{source → core}/reference_collector_spec.rb +25 -16
  129. data/spec/reek/core/singleton_method_context_spec.rb +12 -2
  130. data/spec/reek/core/smell_configuration_spec.rb +1 -1
  131. data/spec/reek/core/smell_repository_spec.rb +12 -1
  132. data/spec/reek/core/stop_context_spec.rb +1 -1
  133. data/spec/reek/core/tree_dresser_spec.rb +16 -0
  134. data/spec/reek/core/tree_walker_spec.rb +3 -3
  135. data/spec/reek/core/warning_collector_spec.rb +6 -6
  136. data/spec/reek/{source → sexp}/sexp_extensions_spec.rb +8 -8
  137. data/spec/reek/{source → sexp}/sexp_formatter_spec.rb +11 -5
  138. data/spec/reek/{source → sexp}/sexp_node_spec.rb +3 -3
  139. data/spec/reek/smells/attribute_spec.rb +89 -85
  140. data/spec/reek/smells/behaves_like_variable_detector.rb +1 -1
  141. data/spec/reek/smells/boolean_parameter_spec.rb +1 -1
  142. data/spec/reek/smells/class_variable_spec.rb +1 -1
  143. data/spec/reek/smells/control_parameter_spec.rb +1 -1
  144. data/spec/reek/smells/data_clump_spec.rb +2 -2
  145. data/spec/reek/smells/duplicate_method_call_spec.rb +1 -1
  146. data/spec/reek/smells/feature_envy_spec.rb +2 -2
  147. data/spec/reek/smells/irresponsible_module_spec.rb +1 -1
  148. data/spec/reek/smells/long_parameter_list_spec.rb +2 -2
  149. data/spec/reek/smells/long_yield_list_spec.rb +1 -1
  150. data/spec/reek/smells/module_initialize_spec.rb +1 -1
  151. data/spec/reek/smells/nested_iterators_spec.rb +2 -2
  152. data/spec/reek/smells/nil_check_spec.rb +1 -1
  153. data/spec/reek/smells/prima_donna_method_spec.rb +1 -1
  154. data/spec/reek/smells/repeated_conditional_spec.rb +1 -1
  155. data/spec/reek/smells/smell_detector_shared.rb +2 -2
  156. data/spec/reek/{smell_warning_spec.rb → smells/smell_warning_spec.rb} +7 -7
  157. data/spec/reek/smells/too_many_instance_variables_spec.rb +1 -1
  158. data/spec/reek/smells/too_many_methods_spec.rb +1 -1
  159. data/spec/reek/smells/too_many_statements_spec.rb +4 -4
  160. data/spec/reek/smells/uncommunicative_method_name_spec.rb +1 -1
  161. data/spec/reek/smells/uncommunicative_module_name_spec.rb +1 -1
  162. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +1 -1
  163. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +1 -1
  164. data/spec/reek/smells/unused_parameters_spec.rb +1 -1
  165. data/spec/reek/smells/utility_function_spec.rb +1 -1
  166. data/spec/reek/source/source_code_spec.rb +1 -1
  167. data/spec/reek/spec/should_reek_of_spec.rb +1 -1
  168. data/spec/reek/spec/should_reek_only_of_spec.rb +1 -1
  169. data/spec/reek/spec/should_reek_spec.rb +1 -1
  170. data/spec/samples/checkstyle.xml +2 -0
  171. data/spec/spec_helper.rb +15 -3
  172. metadata +68 -38
  173. data/.ruby-gemset +0 -1
  174. data/lib/reek/examiner.rb +0 -79
  175. data/lib/reek/smell_warning.rb +0 -87
  176. data/lib/reek/source/reference_collector.rb +0 -27
  177. data/lib/reek/source/sexp_formatter.rb +0 -22
  178. data/lib/reek/source/sexp_node.rb +0 -79
  179. data/spec/reek/source/tree_dresser_spec.rb +0 -16
@@ -1,4 +1,4 @@
1
- shared_examples_for 'a variable detector' do
1
+ RSpec.shared_examples_for 'a variable detector' do
2
2
  context 'with no variables' do
3
3
  it "doesn't record a smell" do
4
4
  @detector.examine_context(@ctx)
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/smells/boolean_parameter'
3
3
  require_relative 'smell_detector_shared'
4
4
 
5
- describe Reek::Smells::BooleanParameter do
5
+ RSpec.describe Reek::Smells::BooleanParameter do
6
6
  context 'parameter defaulted with boolean' do
7
7
  context 'in a method' do
8
8
  it 'reports a parameter defaulted to true' do
@@ -3,7 +3,7 @@ require_relative '../../../lib/reek/smells/class_variable'
3
3
  require_relative '../../../lib/reek/core/module_context'
4
4
  require_relative 'smell_detector_shared'
5
5
 
6
- describe Reek::Smells::ClassVariable do
6
+ RSpec.describe Reek::Smells::ClassVariable do
7
7
  before :each do
8
8
  @source_name = 'dummy_source'
9
9
  @detector = build(:smell_detector, smell_type: :ClassVariable, source: @source_name)
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/smells/control_parameter'
3
3
  require_relative 'smell_detector_shared'
4
4
 
5
- describe Reek::Smells::ControlParameter do
5
+ RSpec.describe Reek::Smells::ControlParameter do
6
6
  before(:each) do
7
7
  @source_name = 'dummy_source'
8
8
  @detector = build(:smell_detector, smell_type: :ControlParameter, source: @source_name)
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/smells/data_clump'
3
3
  require_relative 'smell_detector_shared'
4
4
 
5
- shared_examples_for 'a data clump detector' do
5
+ RSpec.shared_examples_for 'a data clump detector' do
6
6
  it 'does not report small parameter sets' do
7
7
  src = <<-EOS
8
8
  # test module
@@ -160,7 +160,7 @@ shared_examples_for 'a data clump detector' do
160
160
  end
161
161
  end
162
162
 
163
- describe Reek::Smells::DataClump do
163
+ RSpec.describe Reek::Smells::DataClump do
164
164
  before(:each) do
165
165
  @detector = build(:smell_detector, smell_type: :DataClump)
166
166
  end
@@ -4,7 +4,7 @@ require_relative '../../../lib/reek/core/code_context'
4
4
  require_relative '../../../lib/reek/core/tree_walker'
5
5
  require_relative 'smell_detector_shared'
6
6
 
7
- describe Reek::Smells::DuplicateMethodCall do
7
+ RSpec.describe Reek::Smells::DuplicateMethodCall do
8
8
  context 'when a smell is reported' do
9
9
  before :each do
10
10
  @source_name = 'dummy_source'
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/smells/feature_envy'
3
3
  require_relative 'smell_detector_shared'
4
4
 
5
- describe Reek::Smells::FeatureEnvy do
5
+ RSpec.describe Reek::Smells::FeatureEnvy do
6
6
  context 'with no smell' do
7
7
  it 'should not report use of self' do
8
8
  expect('def simple() self.to_s + self.to_i end').not_to reek_of(:FeatureEnvy)
@@ -211,7 +211,7 @@ describe Reek::Smells::FeatureEnvy do
211
211
  end
212
212
  end
213
213
 
214
- describe Reek::Smells::FeatureEnvy do
214
+ RSpec.describe Reek::Smells::FeatureEnvy do
215
215
  before(:each) do
216
216
  @source_name = 'dummy_source'
217
217
  @detector = build(:smell_detector, smell_type: :FeatureEnvy, source: @source_name)
@@ -3,7 +3,7 @@ require_relative '../../../lib/reek/core/code_context'
3
3
  require_relative '../../../lib/reek/smells/irresponsible_module'
4
4
  require_relative 'smell_detector_shared'
5
5
 
6
- describe Reek::Smells::IrresponsibleModule do
6
+ RSpec.describe Reek::Smells::IrresponsibleModule do
7
7
  before(:each) do
8
8
  @bad_module_name = 'WrongUn'
9
9
  @source_name = 'dummy_source'
@@ -3,7 +3,7 @@ require_relative '../../../lib/reek/core/code_context'
3
3
  require_relative '../../../lib/reek/smells/long_parameter_list'
4
4
  require_relative 'smell_detector_shared'
5
5
 
6
- describe Reek::Smells::LongParameterList do
6
+ RSpec.describe Reek::Smells::LongParameterList do
7
7
  context 'for methods with few parameters' do
8
8
  it 'should report nothing for no parameters' do
9
9
  expect('def simple; f(3);true; end').not_to reek_of(:LongParameterList)
@@ -73,7 +73,7 @@ describe Reek::Smells::LongParameterList do
73
73
  end
74
74
  end
75
75
 
76
- describe Reek::Smells::LongParameterList do
76
+ RSpec.describe Reek::Smells::LongParameterList do
77
77
  before(:each) do
78
78
  @source_name = 'dummy_source'
79
79
  @detector = build(:smell_detector, smell_type: :LongParameterList, source: @source_name)
@@ -3,7 +3,7 @@ require_relative '../../../lib/reek/core/code_context'
3
3
  require_relative '../../../lib/reek/smells/long_yield_list'
4
4
  require_relative 'smell_detector_shared'
5
5
 
6
- describe Reek::Smells::LongYieldList do
6
+ RSpec.describe Reek::Smells::LongYieldList do
7
7
  before(:each) do
8
8
  @source_name = 'dummy_source'
9
9
  @detector = build(:smell_detector, smell_type: :LongYieldList, source: @source_name)
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/smells/module_initialize'
3
3
  require_relative 'smell_detector_shared'
4
4
 
5
- describe Reek::Smells::ModuleInitialize do
5
+ RSpec.describe Reek::Smells::ModuleInitialize do
6
6
  context 'module' do
7
7
  context 'with method named initialize' do
8
8
  it 'smells' do
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/smells/nested_iterators'
3
3
  require_relative 'smell_detector_shared'
4
4
 
5
- describe Reek::Smells::NestedIterators do
5
+ RSpec.describe Reek::Smells::NestedIterators do
6
6
  context 'with no iterators' do
7
7
  it 'reports no smells' do
8
8
  src = 'def fred() nothing = true; end'
@@ -220,7 +220,7 @@ describe Reek::Smells::NestedIterators do
220
220
  end
221
221
  end
222
222
 
223
- describe Reek::Smells::NestedIterators do
223
+ RSpec.describe Reek::Smells::NestedIterators do
224
224
  before(:each) do
225
225
  @source_name = 'dummy_source'
226
226
  @detector = build(:smell_detector, smell_type: :NestedIterators, source: @source_name)
@@ -3,7 +3,7 @@ require_relative '../../../lib/reek/core/code_context'
3
3
  require_relative '../../../lib/reek/smells/nil_check'
4
4
  require_relative 'smell_detector_shared'
5
5
 
6
- describe Reek::Smells::NilCheck do
6
+ RSpec.describe Reek::Smells::NilCheck do
7
7
  context 'for methods' do
8
8
  it 'reports the correct line number' do
9
9
  src = <<-EOS
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/core/module_context'
3
3
  require_relative 'smell_detector_shared'
4
4
 
5
- describe Reek::Smells::PrimaDonnaMethod do
5
+ RSpec.describe Reek::Smells::PrimaDonnaMethod do
6
6
  it 'should report nothing when method and bang counterpart exist' do
7
7
  expect('class C; def m; end; def m!; end; end').not_to reek_of(:PrimaDonnaMethod)
8
8
  end
@@ -4,7 +4,7 @@ require_relative '../../../lib/reek/core/code_context'
4
4
  require_relative 'smell_detector_shared'
5
5
  require_relative '../../../lib/reek/source/source_code'
6
6
 
7
- describe Reek::Smells::RepeatedConditional do
7
+ RSpec.describe Reek::Smells::RepeatedConditional do
8
8
  before(:each) do
9
9
  @source_name = 'dummy_source'
10
10
  @detector = build(:smell_detector, smell_type: :RepeatedConditional, source: @source_name)
@@ -1,7 +1,7 @@
1
1
  require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/core/smell_configuration'
3
3
 
4
- shared_examples_for 'SmellDetector' do
4
+ RSpec.shared_examples_for 'SmellDetector' do
5
5
  context 'exception matching follows the context' do
6
6
  before :each do
7
7
  @ctx = double('context')
@@ -28,7 +28,7 @@ shared_examples_for 'SmellDetector' do
28
28
  end
29
29
  end
30
30
 
31
- shared_examples_for 'common fields set correctly' do
31
+ RSpec.shared_examples_for 'common fields set correctly' do
32
32
  it 'reports the source' do
33
33
  expect(@warning.source).to eq(@source_name)
34
34
  end
@@ -1,7 +1,7 @@
1
- require_relative '../spec_helper'
2
- require_relative '../../lib/reek/smell_warning'
1
+ require_relative '../../spec_helper'
2
+ require_relative '../../../lib/reek/smells/smell_warning'
3
3
 
4
- describe Reek::SmellWarning do
4
+ RSpec.describe Reek::Smells::SmellWarning do
5
5
  let(:duplication_detector) { build(:smell_detector, smell_type: 'DuplicateMethodCall') }
6
6
  let(:feature_envy_detector) { build(:smell_detector, smell_type: 'FeatureEnvy') }
7
7
  let(:utility_function_detector) { build(:smell_detector, smell_type: 'UtilityFunction') }
@@ -117,10 +117,10 @@ describe Reek::SmellWarning do
117
117
  @smell_type = 'FeatureEnvy'
118
118
  @parameters = { 'one' => 34, 'two' => 'second' }
119
119
  @detector = Reek::Smells::FeatureEnvy.new @source
120
- @warning = Reek::SmellWarning.new(@detector, context: @context_name,
121
- lines: @lines,
122
- message: @message,
123
- parameters: @parameters)
120
+ @warning = Reek::Smells::SmellWarning.new(@detector, context: @context_name,
121
+ lines: @lines,
122
+ message: @message,
123
+ parameters: @parameters)
124
124
  @yaml = @warning.yaml_hash
125
125
  end
126
126
 
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/smells/too_many_instance_variables'
3
3
  require_relative 'smell_detector_shared'
4
4
 
5
- describe Reek::Smells::TooManyInstanceVariables do
5
+ RSpec.describe Reek::Smells::TooManyInstanceVariables do
6
6
  before(:each) do
7
7
  @source_name = 'dummy_source'
8
8
  @detector = build(:smell_detector, smell_type: :TooManyInstanceVariables, source: @source_name)
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/smells/too_many_methods'
3
3
  require_relative 'smell_detector_shared'
4
4
 
5
- describe Reek::Smells::TooManyMethods do
5
+ RSpec.describe Reek::Smells::TooManyMethods do
6
6
  before(:each) do
7
7
  @source_name = 'dummy_source'
8
8
  @detector = described_class.new(@source_name)
@@ -11,7 +11,7 @@ def process_singleton_method(source)
11
11
  Reek::Core::TreeWalker.new.process_defs(Reek::Source::SourceCode.from(source).syntax_tree)
12
12
  end
13
13
 
14
- describe Reek::Smells::TooManyStatements do
14
+ RSpec.describe Reek::Smells::TooManyStatements do
15
15
  it 'should not report short methods' do
16
16
  src = 'def short(arga) alf = f(1);@bet = 2;@cut = 3;@dit = 4; @emp = 5;end'
17
17
  expect(src).not_to reek_of(:TooManyStatements)
@@ -49,7 +49,7 @@ describe Reek::Smells::TooManyStatements do
49
49
  end
50
50
  end
51
51
 
52
- describe Reek::Smells::TooManyStatements do
52
+ RSpec.describe Reek::Smells::TooManyStatements do
53
53
  it 'counts 1 assignment' do
54
54
  method = process_method('def one() val = 4; end')
55
55
  expect(method.num_statements).to eq(1)
@@ -91,7 +91,7 @@ describe Reek::Smells::TooManyStatements do
91
91
  end
92
92
  end
93
93
 
94
- describe Reek::Smells::TooManyStatements, 'does not count control statements' do
94
+ RSpec.describe Reek::Smells::TooManyStatements, 'does not count control statements' do
95
95
  it 'counts 1 statement in a conditional expression' do
96
96
  method = process_method('def one() if val == 4; callee(); end; end')
97
97
  expect(method.num_statements).to eq(1)
@@ -248,7 +248,7 @@ describe Reek::Smells::TooManyStatements, 'does not count control statements' do
248
248
  end
249
249
  end
250
250
 
251
- describe Reek::Smells::TooManyStatements do
251
+ RSpec.describe Reek::Smells::TooManyStatements do
252
252
  before(:each) do
253
253
  @detector = build(:smell_detector, smell_type: :TooManyStatements, source: 'source_name')
254
254
  end
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/smells/uncommunicative_method_name'
3
3
  require_relative 'smell_detector_shared'
4
4
 
5
- describe Reek::Smells::UncommunicativeMethodName do
5
+ RSpec.describe Reek::Smells::UncommunicativeMethodName do
6
6
  before do
7
7
  @source_name = 'dummy_source'
8
8
  @detector = build(:smell_detector, smell_type: :UncommunicativeMethodName, source: @source_name)
@@ -3,7 +3,7 @@ require_relative '../../../lib/reek/smells/uncommunicative_module_name'
3
3
  require_relative 'smell_detector_shared'
4
4
  require_relative '../../../lib/reek/core/code_context'
5
5
 
6
- describe Reek::Smells::UncommunicativeModuleName do
6
+ RSpec.describe Reek::Smells::UncommunicativeModuleName do
7
7
  before do
8
8
  @source_name = 'dummy_source'
9
9
  @detector = build(:smell_detector, smell_type: :UncommunicativeModuleName, source: @source_name)
@@ -3,7 +3,7 @@ require_relative '../../../lib/reek/smells/uncommunicative_parameter_name'
3
3
  require_relative 'smell_detector_shared'
4
4
  require_relative '../../../lib/reek/core/method_context'
5
5
 
6
- describe Reek::Smells::UncommunicativeParameterName do
6
+ RSpec.describe Reek::Smells::UncommunicativeParameterName do
7
7
  before :each do
8
8
  @source_name = 'dummy_source'
9
9
  @detector = build(:smell_detector,
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/smells/uncommunicative_variable_name'
3
3
  require_relative 'smell_detector_shared'
4
4
 
5
- describe Reek::Smells::UncommunicativeVariableName do
5
+ RSpec.describe Reek::Smells::UncommunicativeVariableName do
6
6
  before :each do
7
7
  @source_name = 'dummy_source'
8
8
  @detector = build(:smell_detector,
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/smells/unused_parameters'
3
3
  require_relative 'smell_detector_shared'
4
4
 
5
- describe Reek::Smells::UnusedParameters do
5
+ RSpec.describe Reek::Smells::UnusedParameters do
6
6
  context 'for methods' do
7
7
  it 'reports nothing for no parameters' do
8
8
  expect('def simple; true end').not_to reek_of(:UnusedParameters)
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/smells/utility_function'
3
3
  require_relative 'smell_detector_shared'
4
4
 
5
- describe Reek::Smells::UtilityFunction do
5
+ RSpec.describe Reek::Smells::UtilityFunction do
6
6
  describe 'a detector' do
7
7
  before(:each) do
8
8
  @source_name = 'dummy_source'
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require 'stringio'
3
3
  require_relative '../../../lib/reek/source/source_code'
4
4
 
5
- describe Reek::Source::SourceCode do
5
+ RSpec.describe Reek::Source::SourceCode do
6
6
  describe '#syntax_tree' do
7
7
  it 'associates comments with the AST' do
8
8
  source = "# this is\n# a comment\ndef foo; end"
@@ -1,7 +1,7 @@
1
1
  require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/spec'
3
3
 
4
- describe Reek::Spec::ShouldReekOf do
4
+ RSpec.describe Reek::Spec::ShouldReekOf do
5
5
  context 'rdoc demo example' do
6
6
  before :each do
7
7
  @ruby = 'def double_thing() @other.thing.foo + @other.thing.foo end'
@@ -1,7 +1,7 @@
1
1
  require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/spec'
3
3
 
4
- describe Reek::Spec::ShouldReekOnlyOf do
4
+ RSpec.describe Reek::Spec::ShouldReekOnlyOf do
5
5
  before :each do
6
6
  @expected_smell_type = :NestedIterators
7
7
  @expected_context_name = 'SmellyClass#big_method'
@@ -1,7 +1,7 @@
1
1
  require_relative '../../spec_helper'
2
2
  require_relative '../../../lib/reek/spec'
3
3
 
4
- describe Reek::Spec::ShouldReek do
4
+ RSpec.describe Reek::Spec::ShouldReek do
5
5
  let(:matcher) { Reek::Spec::ShouldReek.new }
6
6
 
7
7
  describe 'checking code in a string' do
@@ -0,0 +1,2 @@
1
+ <?xml version='1.0'?>
2
+ <checkstyle><file name='/some/path'><error column='0' line='1' message='doesn&apos;t depend on instance state' severity='warning' source='UtilityFunction'/><error column='0' line='1' message='has the parameter name &apos;a&apos;' severity='warning' source='UncommunicativeParameterName'/></file></checkstyle>
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,14 @@
1
1
  require_relative '../lib/reek/spec'
2
- require_relative '../lib/reek/source/ast_node_class_map'
2
+ require_relative '../lib/reek/core/ast_node_class_map'
3
3
  require_relative '../lib/reek/configuration/app_configuration'
4
4
 
5
- require 'factory_girl'
5
+ Reek::CLI::Silencer.silently do
6
+ require 'factory_girl'
7
+ end
8
+ if Gem.loaded_specs['factory_girl'].version > Gem::Version.create('4.5.0')
9
+ raise 'Remove the above silencer as well as this check now that ' \
10
+ '`factory_girl` gem is updated to version greater than 4.5.0!'
11
+ end
6
12
 
7
13
  begin
8
14
  require 'pry-byebug'
@@ -31,7 +37,7 @@ module Helpers
31
37
 
32
38
  # :reek:UncommunicativeMethodName
33
39
  def s(type, *children)
34
- @klass_map ||= Reek::Source::ASTNodeClassMap.new
40
+ @klass_map ||= Reek::Core::ASTNodeClassMap.new
35
41
  @klass_map.klass_for(type).new(type, children)
36
42
  end
37
43
 
@@ -46,4 +52,10 @@ RSpec.configure do |config|
46
52
  config.run_all_when_everything_filtered = true
47
53
  config.include FactoryGirl::Syntax::Methods
48
54
  config.include Helpers
55
+
56
+ config.disable_monkey_patching!
57
+
58
+ config.mock_with :rspec do |mocks|
59
+ mocks.verify_partial_doubles = true
60
+ end
49
61
  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: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Rutherford
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-04-17 00:00:00.000000000 Z
13
+ date: 2015-05-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parser
@@ -40,20 +40,6 @@ dependencies:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '2.0'
43
- - !ruby/object:Gem::Dependency
44
- name: require_all
45
- requirement: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: '1.3'
50
- type: :runtime
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - "~>"
55
- - !ruby/object:Gem::Version
56
- version: '1.3'
57
43
  - !ruby/object:Gem::Dependency
58
44
  name: unparser
59
45
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +194,6 @@ extra_rdoc_files:
208
194
  files:
209
195
  - ".gitignore"
210
196
  - ".rubocop.yml"
211
- - ".ruby-gemset"
212
197
  - ".travis.yml"
213
198
  - ".yardopts"
214
199
  - CHANGELOG
@@ -221,6 +206,47 @@ files:
221
206
  - bin/reek
222
207
  - config/cucumber.yml
223
208
  - config/defaults.reek
209
+ - docs/API.md
210
+ - docs/Attribute.md
211
+ - docs/Basic-Smell-Options.md
212
+ - docs/Boolean-Parameter.md
213
+ - docs/Class-Variable.md
214
+ - docs/Code-Smells.md
215
+ - docs/Command-Line-Options.md
216
+ - docs/Configuration-Files.md
217
+ - docs/Control-Couple.md
218
+ - docs/Control-Parameter.md
219
+ - docs/Data-Clump.md
220
+ - docs/Duplicate-Method-Call.md
221
+ - docs/Feature-Envy.md
222
+ - docs/How-reek-works-internally.md
223
+ - docs/Irresponsible-Module.md
224
+ - docs/Large-Class.md
225
+ - docs/Long-Parameter-List.md
226
+ - docs/Long-Yield-List.md
227
+ - docs/Module-Initialize.md
228
+ - docs/Nested-Iterators.md
229
+ - docs/Nil-Check.md
230
+ - docs/Prima-Donna-Method.md
231
+ - docs/RSpec-matchers.md
232
+ - docs/Rake-Task.md
233
+ - docs/Reek-Driven-Development.md
234
+ - docs/Repeated-Conditional.md
235
+ - docs/Simulated-Polymorphism.md
236
+ - docs/Smell-Suppression.md
237
+ - docs/Too-Many-Instance-Variables.md
238
+ - docs/Too-Many-Methods.md
239
+ - docs/Too-Many-Statements.md
240
+ - docs/Uncommunicative-Method-Name.md
241
+ - docs/Uncommunicative-Module-Name.md
242
+ - docs/Uncommunicative-Name.md
243
+ - docs/Uncommunicative-Parameter-Name.md
244
+ - docs/Uncommunicative-Variable-Name.md
245
+ - docs/Unused-Parameters.md
246
+ - docs/Utility-Function.md
247
+ - docs/Versioning-Policy.md
248
+ - docs/YAML-Reports.md
249
+ - docs/yard_plugin.rb
224
250
  - features/command_line_interface/options.feature
225
251
  - features/command_line_interface/smell_selection.feature
226
252
  - features/command_line_interface/smells_count.feature
@@ -250,21 +276,29 @@ files:
250
276
  - lib/reek/cli/report/heading_formatter.rb
251
277
  - lib/reek/cli/report/location_formatter.rb
252
278
  - lib/reek/cli/report/report.rb
279
+ - lib/reek/cli/silencer.rb
253
280
  - lib/reek/configuration/app_configuration.rb
254
281
  - lib/reek/configuration/configuration_file_finder.rb
282
+ - lib/reek/core/ast_node.rb
283
+ - lib/reek/core/ast_node_class_map.rb
284
+ - lib/reek/core/code_comment.rb
255
285
  - lib/reek/core/code_context.rb
286
+ - lib/reek/core/examiner.rb
256
287
  - lib/reek/core/method_context.rb
257
288
  - lib/reek/core/module_context.rb
258
289
  - lib/reek/core/object_refs.rb
290
+ - lib/reek/core/reference_collector.rb
259
291
  - lib/reek/core/singleton_method_context.rb
260
292
  - lib/reek/core/smell_configuration.rb
261
293
  - lib/reek/core/smell_repository.rb
262
294
  - lib/reek/core/stop_context.rb
295
+ - lib/reek/core/tree_dresser.rb
263
296
  - lib/reek/core/tree_walker.rb
264
297
  - lib/reek/core/warning_collector.rb
265
- - lib/reek/examiner.rb
266
298
  - lib/reek/rake/task.rb
267
- - lib/reek/smell_warning.rb
299
+ - lib/reek/sexp/sexp_extensions.rb
300
+ - lib/reek/sexp/sexp_formatter.rb
301
+ - lib/reek/sexp/sexp_node.rb
268
302
  - lib/reek/smells.rb
269
303
  - lib/reek/smells/attribute.rb
270
304
  - lib/reek/smells/boolean_parameter.rb
@@ -282,6 +316,7 @@ files:
282
316
  - lib/reek/smells/prima_donna_method.rb
283
317
  - lib/reek/smells/repeated_conditional.rb
284
318
  - lib/reek/smells/smell_detector.rb
319
+ - lib/reek/smells/smell_warning.rb
285
320
  - lib/reek/smells/too_many_instance_variables.rb
286
321
  - lib/reek/smells/too_many_methods.rb
287
322
  - lib/reek/smells/too_many_statements.rb
@@ -291,17 +326,9 @@ files:
291
326
  - lib/reek/smells/uncommunicative_variable_name.rb
292
327
  - lib/reek/smells/unused_parameters.rb
293
328
  - lib/reek/smells/utility_function.rb
294
- - lib/reek/source/ast_node.rb
295
- - lib/reek/source/ast_node_class_map.rb
296
- - lib/reek/source/code_comment.rb
297
- - lib/reek/source/reference_collector.rb
298
- - lib/reek/source/sexp_extensions.rb
299
- - lib/reek/source/sexp_formatter.rb
300
- - lib/reek/source/sexp_node.rb
301
329
  - lib/reek/source/source_code.rb
302
330
  - lib/reek/source/source_locator.rb
303
331
  - lib/reek/source/source_repository.rb
304
- - lib/reek/source/tree_dresser.rb
305
332
  - lib/reek/spec.rb
306
333
  - lib/reek/spec/should_reek.rb
307
334
  - lib/reek/spec/should_reek_of.rb
@@ -314,23 +341,31 @@ files:
314
341
  - spec/quality/reek_source_spec.rb
315
342
  - spec/reek/cli/html_report_spec.rb
316
343
  - spec/reek/cli/json_report_spec.rb
317
- - spec/reek/cli/option_interperter_spec.rb
344
+ - spec/reek/cli/option_interpreter_spec.rb
345
+ - spec/reek/cli/options_spec.rb
318
346
  - spec/reek/cli/text_report_spec.rb
347
+ - spec/reek/cli/xml_report_spec.rb
319
348
  - spec/reek/cli/yaml_report_spec.rb
320
349
  - spec/reek/configuration/app_configuration_spec.rb
321
350
  - spec/reek/configuration/configuration_file_finder_spec.rb
351
+ - spec/reek/core/code_comment_spec.rb
322
352
  - spec/reek/core/code_context_spec.rb
353
+ - spec/reek/core/examiner_spec.rb
323
354
  - spec/reek/core/method_context_spec.rb
324
355
  - spec/reek/core/module_context_spec.rb
325
356
  - spec/reek/core/object_refs_spec.rb
357
+ - spec/reek/core/object_source_spec.rb
358
+ - spec/reek/core/reference_collector_spec.rb
326
359
  - spec/reek/core/singleton_method_context_spec.rb
327
360
  - spec/reek/core/smell_configuration_spec.rb
328
361
  - spec/reek/core/smell_repository_spec.rb
329
362
  - spec/reek/core/stop_context_spec.rb
363
+ - spec/reek/core/tree_dresser_spec.rb
330
364
  - spec/reek/core/tree_walker_spec.rb
331
365
  - spec/reek/core/warning_collector_spec.rb
332
- - spec/reek/examiner_spec.rb
333
- - spec/reek/smell_warning_spec.rb
366
+ - spec/reek/sexp/sexp_extensions_spec.rb
367
+ - spec/reek/sexp/sexp_formatter_spec.rb
368
+ - spec/reek/sexp/sexp_node_spec.rb
334
369
  - spec/reek/smells/attribute_spec.rb
335
370
  - spec/reek/smells/behaves_like_variable_detector.rb
336
371
  - spec/reek/smells/boolean_parameter_spec.rb
@@ -348,6 +383,7 @@ files:
348
383
  - spec/reek/smells/prima_donna_method_spec.rb
349
384
  - spec/reek/smells/repeated_conditional_spec.rb
350
385
  - spec/reek/smells/smell_detector_shared.rb
386
+ - spec/reek/smells/smell_warning_spec.rb
351
387
  - spec/reek/smells/too_many_instance_variables_spec.rb
352
388
  - spec/reek/smells/too_many_methods_spec.rb
353
389
  - spec/reek/smells/too_many_statements_spec.rb
@@ -357,20 +393,14 @@ files:
357
393
  - spec/reek/smells/uncommunicative_variable_name_spec.rb
358
394
  - spec/reek/smells/unused_parameters_spec.rb
359
395
  - spec/reek/smells/utility_function_spec.rb
360
- - spec/reek/source/code_comment_spec.rb
361
- - spec/reek/source/object_source_spec.rb
362
- - spec/reek/source/reference_collector_spec.rb
363
- - spec/reek/source/sexp_extensions_spec.rb
364
- - spec/reek/source/sexp_formatter_spec.rb
365
- - spec/reek/source/sexp_node_spec.rb
366
396
  - spec/reek/source/source_code_spec.rb
367
- - spec/reek/source/tree_dresser_spec.rb
368
397
  - spec/reek/spec/should_reek_of_spec.rb
369
398
  - spec/reek/spec/should_reek_only_of_spec.rb
370
399
  - spec/reek/spec/should_reek_spec.rb
371
400
  - spec/samples/all_but_one_masked/clean_one.rb
372
401
  - spec/samples/all_but_one_masked/dirty.rb
373
402
  - spec/samples/all_but_one_masked/masked.reek
403
+ - spec/samples/checkstyle.xml
374
404
  - spec/samples/clean_due_to_masking/clean_one.rb
375
405
  - spec/samples/clean_due_to_masking/clean_three.rb
376
406
  - spec/samples/clean_due_to_masking/clean_two.rb
@@ -421,7 +451,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
421
451
  version: '0'
422
452
  requirements: []
423
453
  rubyforge_project:
424
- rubygems_version: 2.2.2
454
+ rubygems_version: 2.4.5
425
455
  signing_key:
426
456
  specification_version: 4
427
457
  summary: Code smell detector for Ruby