reek 4.5.0 → 4.6.0

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 (128) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +10 -7
  3. data/.travis.yml +13 -9
  4. data/CHANGELOG.md +36 -3
  5. data/Dockerfile +6 -5
  6. data/Gemfile +8 -7
  7. data/README.md +45 -27
  8. data/docs/How-To-Write-New-Detectors.md +6 -6
  9. data/docs/Irresponsible-Module.md +8 -1
  10. data/docs/Nil-Check.md +1 -1
  11. data/docs/Prima-Donna-Method.md +27 -0
  12. data/docs/RSpec-matchers.md +5 -10
  13. data/docs/Unused-Private-Method.md +27 -0
  14. data/docs/templates/default/docstring/setup.rb +1 -8
  15. data/features/command_line_interface/options.feature +5 -1
  16. data/features/command_line_interface/stdin.feature +1 -1
  17. data/features/configuration_files/exclude_paths_directives.feature +43 -0
  18. data/features/configuration_files/warn_about_multiple_configuration_files.feature +44 -0
  19. data/features/configuration_via_source_comments/erroneous_source_comments.feature +15 -0
  20. data/features/samples.feature +3 -8
  21. data/features/step_definitions/reek_steps.rb +5 -5
  22. data/features/todo_list.feature +1 -2
  23. data/lib/reek/ast/reference_collector.rb +2 -4
  24. data/lib/reek/ast/sexp_extensions/arguments.rb +0 -5
  25. data/lib/reek/ast/sexp_extensions/constant.rb +1 -0
  26. data/lib/reek/cli/application.rb +7 -8
  27. data/lib/reek/cli/command/report_command.rb +3 -1
  28. data/lib/reek/cli/options.rb +29 -13
  29. data/lib/reek/cli/status.rb +10 -0
  30. data/lib/reek/code_comment.rb +48 -6
  31. data/lib/reek/configuration/configuration_file_finder.rb +87 -27
  32. data/lib/reek/context/ghost_context.rb +1 -2
  33. data/lib/reek/context_builder.rb +26 -1
  34. data/lib/reek/detector_repository.rb +64 -0
  35. data/lib/reek/errors/bad_detector_configuration_key_in_comment_error.rb +37 -0
  36. data/lib/reek/errors/bad_detector_in_comment_error.rb +2 -1
  37. data/lib/reek/errors/base_error.rb +9 -0
  38. data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +2 -1
  39. data/lib/reek/errors/incomprehensible_source_error.rb +47 -0
  40. data/lib/reek/errors/parse_error.rb +19 -0
  41. data/lib/reek/examiner.rb +17 -41
  42. data/lib/reek/logging_error_handler.rb +15 -0
  43. data/lib/reek/report/code_climate/code_climate_configuration.rb +12 -0
  44. data/lib/reek/report/code_climate/code_climate_configuration.yml +156 -0
  45. data/lib/reek/report/code_climate/code_climate_fingerprint.rb +4 -2
  46. data/lib/reek/report/code_climate/code_climate_formatter.rb +2 -2
  47. data/lib/reek/smell_configuration.rb +64 -0
  48. data/lib/reek/smell_detectors/attribute.rb +0 -2
  49. data/lib/reek/smell_detectors/base_detector.rb +24 -4
  50. data/lib/reek/smell_detectors/boolean_parameter.rb +0 -1
  51. data/lib/reek/smell_detectors/class_variable.rb +0 -1
  52. data/lib/reek/smell_detectors/control_parameter.rb +0 -1
  53. data/lib/reek/smell_detectors/data_clump.rb +0 -1
  54. data/lib/reek/smell_detectors/duplicate_method_call.rb +0 -1
  55. data/lib/reek/smell_detectors/feature_envy.rb +0 -1
  56. data/lib/reek/smell_detectors/instance_variable_assumption.rb +0 -1
  57. data/lib/reek/smell_detectors/irresponsible_module.rb +0 -1
  58. data/lib/reek/smell_detectors/long_parameter_list.rb +0 -2
  59. data/lib/reek/smell_detectors/long_yield_list.rb +0 -1
  60. data/lib/reek/smell_detectors/manual_dispatch.rb +4 -6
  61. data/lib/reek/smell_detectors/module_initialize.rb +5 -8
  62. data/lib/reek/smell_detectors/nested_iterators.rb +0 -1
  63. data/lib/reek/smell_detectors/nil_check.rb +0 -1
  64. data/lib/reek/smell_detectors/prima_donna_method.rb +30 -1
  65. data/lib/reek/smell_detectors/repeated_conditional.rb +0 -1
  66. data/lib/reek/smell_detectors/subclassed_from_core_class.rb +0 -1
  67. data/lib/reek/smell_detectors/too_many_constants.rb +0 -1
  68. data/lib/reek/smell_detectors/too_many_instance_variables.rb +0 -1
  69. data/lib/reek/smell_detectors/too_many_methods.rb +0 -1
  70. data/lib/reek/smell_detectors/too_many_statements.rb +0 -1
  71. data/lib/reek/smell_detectors/uncommunicative_method_name.rb +0 -1
  72. data/lib/reek/smell_detectors/uncommunicative_module_name.rb +0 -1
  73. data/lib/reek/smell_detectors/uncommunicative_parameter_name.rb +0 -1
  74. data/lib/reek/smell_detectors/uncommunicative_variable_name.rb +0 -1
  75. data/lib/reek/smell_detectors/unused_parameters.rb +0 -1
  76. data/lib/reek/smell_detectors/unused_private_method.rb +0 -2
  77. data/lib/reek/smell_detectors/utility_function.rb +0 -1
  78. data/lib/reek/smell_warning.rb +85 -0
  79. data/lib/reek/source/source_code.rb +2 -1
  80. data/lib/reek/source/source_locator.rb +15 -3
  81. data/lib/reek/spec/should_reek_of.rb +1 -1
  82. data/lib/reek/spec.rb +6 -4
  83. data/lib/reek/version.rb +1 -1
  84. data/reek.gemspec +1 -1
  85. data/samples/configuration/more_than_one_configuration_file/todo.reek +0 -0
  86. data/samples/configuration/single_configuration_file/.reek +0 -0
  87. data/spec/factories/factories.rb +2 -10
  88. data/spec/quality/reek_source_spec.rb +5 -3
  89. data/spec/reek/ast/reference_collector_spec.rb +0 -17
  90. data/spec/reek/cli/application_spec.rb +25 -1
  91. data/spec/reek/cli/command/report_command_spec.rb +2 -2
  92. data/spec/reek/cli/command/todo_list_command_spec.rb +14 -71
  93. data/spec/reek/cli/options_spec.rb +4 -0
  94. data/spec/reek/code_comment_spec.rb +47 -0
  95. data/spec/reek/configuration/configuration_file_finder_spec.rb +38 -15
  96. data/spec/reek/context/code_context_spec.rb +10 -10
  97. data/spec/reek/context/method_context_spec.rb +1 -1
  98. data/spec/reek/context/module_context_spec.rb +8 -4
  99. data/spec/reek/{smell_detectors/detector_repository_spec.rb → detector_repository_spec.rb} +3 -3
  100. data/spec/reek/examiner_spec.rb +39 -40
  101. data/spec/reek/logging_error_handler_spec.rb +24 -0
  102. data/spec/reek/report/code_climate/code_climate_configuration_spec.rb +24 -0
  103. data/spec/reek/report/code_climate/code_climate_fingerprint_spec.rb +9 -9
  104. data/spec/reek/report/yaml_report_spec.rb +4 -4
  105. data/spec/reek/{smell_detectors/smell_configuration_spec.rb → smell_configuration_spec.rb} +3 -3
  106. data/spec/reek/smell_detectors/base_detector_spec.rb +18 -0
  107. data/spec/reek/smell_detectors/duplicate_method_call_spec.rb +2 -2
  108. data/spec/reek/smell_detectors/feature_envy_spec.rb +18 -8
  109. data/spec/reek/smell_detectors/manual_dispatch_spec.rb +13 -0
  110. data/spec/reek/smell_detectors/module_initialize_spec.rb +23 -2
  111. data/spec/reek/smell_detectors/nested_iterators_spec.rb +1 -1
  112. data/spec/reek/smell_detectors/prima_donna_method_spec.rb +12 -0
  113. data/spec/reek/smell_detectors/subclassed_from_core_class_spec.rb +0 -5
  114. data/spec/reek/smell_detectors/uncommunicative_variable_name_spec.rb +2 -2
  115. data/spec/reek/smell_detectors/unused_parameters_spec.rb +1 -1
  116. data/spec/reek/{smell_detectors/smell_warning_spec.rb → smell_warning_spec.rb} +9 -9
  117. data/spec/reek/source/source_code_spec.rb +6 -29
  118. data/spec/reek/source/source_locator_spec.rb +48 -16
  119. data/spec/reek/spec/should_reek_of_spec.rb +1 -1
  120. data/spec/reek/spec/should_reek_only_of_spec.rb +4 -4
  121. data/spec/spec_helper.rb +4 -3
  122. data/tasks/configuration.rake +2 -2
  123. metadata +26 -14
  124. data/lib/reek/smell_detectors/detector_repository.rb +0 -66
  125. data/lib/reek/smell_detectors/smell_configuration.rb +0 -66
  126. data/lib/reek/smell_detectors/smell_warning.rb +0 -88
  127. data/tasks/mutant.rake +0 -14
  128. /data/samples/configuration/{.reek → more_than_one_configuration_file/regular.reek} +0 -0
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: 4.5.0
4
+ version: 4.6.0
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-10-13 00:00:00.000000000 Z
14
+ date: 2017-04-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: codeclimate-engine-rb
@@ -31,9 +31,9 @@ dependencies:
31
31
  name: parser
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - "~>"
34
+ - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: 2.3.1
36
+ version: '2.5'
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: 2.3.1.2
@@ -41,9 +41,9 @@ dependencies:
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
44
+ - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: 2.3.1
46
+ version: '2.5'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: 2.3.1.2
@@ -151,10 +151,12 @@ files:
151
151
  - features/configuration_files/accept_setting.feature
152
152
  - features/configuration_files/directory_specific_directives.feature
153
153
  - features/configuration_files/exclude_directives.feature
154
+ - features/configuration_files/exclude_paths_directives.feature
154
155
  - features/configuration_files/masking_smells.feature
155
156
  - features/configuration_files/mix_accept_reject_setting.feature
156
157
  - features/configuration_files/reject_setting.feature
157
158
  - features/configuration_files/unused_private_method.feature
159
+ - features/configuration_files/warn_about_multiple_configuration_files.feature
158
160
  - features/configuration_loading.feature
159
161
  - features/configuration_via_source_comments/erroneous_source_comments.feature
160
162
  - features/configuration_via_source_comments/well_formed_source_comments.feature
@@ -200,6 +202,7 @@ files:
200
202
  - lib/reek/cli/command/todo_list_command.rb
201
203
  - lib/reek/cli/options.rb
202
204
  - lib/reek/cli/silencer.rb
205
+ - lib/reek/cli/status.rb
203
206
  - lib/reek/code_comment.rb
204
207
  - lib/reek/configuration/app_configuration.rb
205
208
  - lib/reek/configuration/configuration_file_finder.rb
@@ -220,13 +223,20 @@ files:
220
223
  - lib/reek/context/statement_counter.rb
221
224
  - lib/reek/context/visibility_tracker.rb
222
225
  - lib/reek/context_builder.rb
226
+ - lib/reek/detector_repository.rb
227
+ - lib/reek/errors/bad_detector_configuration_key_in_comment_error.rb
223
228
  - lib/reek/errors/bad_detector_in_comment_error.rb
229
+ - lib/reek/errors/base_error.rb
224
230
  - lib/reek/errors/garbage_detector_configuration_in_comment_error.rb
231
+ - lib/reek/errors/incomprehensible_source_error.rb
232
+ - lib/reek/errors/parse_error.rb
225
233
  - lib/reek/examiner.rb
234
+ - lib/reek/logging_error_handler.rb
226
235
  - lib/reek/rake/task.rb
227
236
  - lib/reek/report.rb
228
237
  - lib/reek/report/base_report.rb
229
238
  - lib/reek/report/code_climate.rb
239
+ - lib/reek/report/code_climate/code_climate_configuration.rb
230
240
  - lib/reek/report/code_climate/code_climate_configuration.yml
231
241
  - lib/reek/report/code_climate/code_climate_fingerprint.rb
232
242
  - lib/reek/report/code_climate/code_climate_formatter.rb
@@ -243,6 +253,7 @@ files:
243
253
  - lib/reek/report/text_report.rb
244
254
  - lib/reek/report/xml_report.rb
245
255
  - lib/reek/report/yaml_report.rb
256
+ - lib/reek/smell_configuration.rb
246
257
  - lib/reek/smell_detectors.rb
247
258
  - lib/reek/smell_detectors/attribute.rb
248
259
  - lib/reek/smell_detectors/base_detector.rb
@@ -250,7 +261,6 @@ files:
250
261
  - lib/reek/smell_detectors/class_variable.rb
251
262
  - lib/reek/smell_detectors/control_parameter.rb
252
263
  - lib/reek/smell_detectors/data_clump.rb
253
- - lib/reek/smell_detectors/detector_repository.rb
254
264
  - lib/reek/smell_detectors/duplicate_method_call.rb
255
265
  - lib/reek/smell_detectors/feature_envy.rb
256
266
  - lib/reek/smell_detectors/instance_variable_assumption.rb
@@ -263,8 +273,6 @@ files:
263
273
  - lib/reek/smell_detectors/nil_check.rb
264
274
  - lib/reek/smell_detectors/prima_donna_method.rb
265
275
  - lib/reek/smell_detectors/repeated_conditional.rb
266
- - lib/reek/smell_detectors/smell_configuration.rb
267
- - lib/reek/smell_detectors/smell_warning.rb
268
276
  - lib/reek/smell_detectors/subclassed_from_core_class.rb
269
277
  - lib/reek/smell_detectors/too_many_constants.rb
270
278
  - lib/reek/smell_detectors/too_many_instance_variables.rb
@@ -277,6 +285,7 @@ files:
277
285
  - lib/reek/smell_detectors/unused_parameters.rb
278
286
  - lib/reek/smell_detectors/unused_private_method.rb
279
287
  - lib/reek/smell_detectors/utility_function.rb
288
+ - lib/reek/smell_warning.rb
280
289
  - lib/reek/source/source_code.rb
281
290
  - lib/reek/source/source_locator.rb
282
291
  - lib/reek/spec.rb
@@ -295,13 +304,15 @@ files:
295
304
  - reek.gemspec
296
305
  - samples/checkstyle.xml
297
306
  - samples/clean.rb
298
- - samples/configuration/.reek
299
307
  - samples/configuration/corrupt.reek
300
308
  - samples/configuration/empty.reek
301
309
  - samples/configuration/full_configuration.reek
302
310
  - samples/configuration/full_mask.reek
311
+ - samples/configuration/more_than_one_configuration_file/regular.reek
312
+ - samples/configuration/more_than_one_configuration_file/todo.reek
303
313
  - samples/configuration/non_public_modifiers_mask.reek
304
314
  - samples/configuration/partial_mask.reek
315
+ - samples/configuration/single_configuration_file/.reek
305
316
  - samples/configuration/with_excluded_paths.reek
306
317
  - samples/exceptions.reek
307
318
  - samples/inline.rb
@@ -342,8 +353,11 @@ files:
342
353
  - spec/reek/context/root_context_spec.rb
343
354
  - spec/reek/context/statement_counter_spec.rb
344
355
  - spec/reek/context_builder_spec.rb
356
+ - spec/reek/detector_repository_spec.rb
345
357
  - spec/reek/examiner_spec.rb
358
+ - spec/reek/logging_error_handler_spec.rb
346
359
  - spec/reek/rake/task_spec.rb
360
+ - spec/reek/report/code_climate/code_climate_configuration_spec.rb
347
361
  - spec/reek/report/code_climate/code_climate_fingerprint_spec.rb
348
362
  - spec/reek/report/code_climate/code_climate_formatter_spec.rb
349
363
  - spec/reek/report/code_climate/code_climate_report_spec.rb
@@ -355,13 +369,13 @@ files:
355
369
  - spec/reek/report/xml_report_spec.rb
356
370
  - spec/reek/report/yaml_report_spec.rb
357
371
  - spec/reek/report_spec.rb
372
+ - spec/reek/smell_configuration_spec.rb
358
373
  - spec/reek/smell_detectors/attribute_spec.rb
359
374
  - spec/reek/smell_detectors/base_detector_spec.rb
360
375
  - spec/reek/smell_detectors/boolean_parameter_spec.rb
361
376
  - spec/reek/smell_detectors/class_variable_spec.rb
362
377
  - spec/reek/smell_detectors/control_parameter_spec.rb
363
378
  - spec/reek/smell_detectors/data_clump_spec.rb
364
- - spec/reek/smell_detectors/detector_repository_spec.rb
365
379
  - spec/reek/smell_detectors/duplicate_method_call_spec.rb
366
380
  - spec/reek/smell_detectors/feature_envy_spec.rb
367
381
  - spec/reek/smell_detectors/instance_variable_assumption_spec.rb
@@ -374,8 +388,6 @@ files:
374
388
  - spec/reek/smell_detectors/nil_check_spec.rb
375
389
  - spec/reek/smell_detectors/prima_donna_method_spec.rb
376
390
  - spec/reek/smell_detectors/repeated_conditional_spec.rb
377
- - spec/reek/smell_detectors/smell_configuration_spec.rb
378
- - spec/reek/smell_detectors/smell_warning_spec.rb
379
391
  - spec/reek/smell_detectors/subclassed_from_core_class_spec.rb
380
392
  - spec/reek/smell_detectors/too_many_constants_spec.rb
381
393
  - spec/reek/smell_detectors/too_many_instance_variables_spec.rb
@@ -388,6 +400,7 @@ files:
388
400
  - spec/reek/smell_detectors/unused_parameters_spec.rb
389
401
  - spec/reek/smell_detectors/unused_private_method_spec.rb
390
402
  - spec/reek/smell_detectors/utility_function_spec.rb
403
+ - spec/reek/smell_warning_spec.rb
391
404
  - spec/reek/source/source_code_spec.rb
392
405
  - spec/reek/source/source_locator_spec.rb
393
406
  - spec/reek/spec/should_reek_of_spec.rb
@@ -399,7 +412,6 @@ files:
399
412
  - tasks/ataru.rake
400
413
  - tasks/configuration.rake
401
414
  - tasks/console.rake
402
- - tasks/mutant.rake
403
415
  - tasks/reek.rake
404
416
  - tasks/rubocop.rake
405
417
  - tasks/test.rake
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
- require_relative '../smell_detectors'
3
- require_relative 'base_detector'
4
- require_relative '../configuration/app_configuration'
5
-
6
- module Reek
7
- module SmellDetectors
8
- #
9
- # Contains all the existing smell detectors and exposes operations on them.
10
- #
11
- class DetectorRepository
12
- # @return [Array<Reek::SmellDetectors::BaseDetector>] All known SmellDetectors
13
- # e.g. [Reek::Smells::BooleanParameter, Reek::Smells::ClassVariable].
14
- def self.smell_types
15
- Reek::SmellDetectors::BaseDetector.descendants.sort_by(&:name)
16
- end
17
-
18
- # @param filter_by_smells [Array<String>]
19
- # List of smell types to filter by, e.g. "DuplicateMethodCall".
20
- # More precisely it should be whatever is returned by `BaseDetector`.smell_type.
21
- # This means that you can write the "DuplicateMethodCall" from above also like this:
22
- # Reek::Smells::DuplicateMethodCall.smell_type
23
- # if you want to make sure you do not fat-finger strings.
24
- #
25
- # @return [Array<Reek::SmellDetectors::BaseDetector>] All SmellDetectors that we want to filter for
26
- # e.g. [Reek::Smells::Attribute].
27
- def self.eligible_smell_types(filter_by_smells = [])
28
- return smell_types if filter_by_smells.empty?
29
- smell_types.select do |klass|
30
- filter_by_smells.include? klass.smell_type
31
- end
32
- end
33
-
34
- def initialize(smell_types: self.class.smell_types,
35
- configuration: {})
36
- @configuration = configuration
37
- @smell_types = smell_types
38
- @detectors = smell_types.map { |klass| klass.new configuration_for(klass) }
39
- end
40
-
41
- def examine(context)
42
- smell_detectors_for(context.type).flat_map do |detector|
43
- detector.run_for(context)
44
- end
45
- end
46
-
47
- private
48
-
49
- attr_reader :configuration, :smell_types, :detectors
50
-
51
- def configuration_for(klass)
52
- configuration.fetch klass, {}
53
- end
54
-
55
- def smell_detectors_for(type)
56
- enabled_detectors.select do |detector|
57
- detector.contexts.include? type
58
- end
59
- end
60
-
61
- def enabled_detectors
62
- detectors.select { |detector| detector.config.enabled? }
63
- end
64
- end
65
- end
66
- end
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
- module Reek
3
- module SmellDetectors
4
- #
5
- # Represents a single set of configuration options for a smell detector
6
- #
7
- class SmellConfiguration
8
- # The name of the config field that specifies whether a smell is
9
- # enabled. Set to +true+ or +false+.
10
- ENABLED_KEY = 'enabled'.freeze
11
-
12
- # The name of the config field that sets scope-specific overrides
13
- # for other values in the current smell detector's configuration.
14
- OVERRIDES_KEY = 'overrides'.freeze
15
-
16
- def initialize(hash)
17
- @options = hash
18
- end
19
-
20
- def merge(new_options)
21
- options.merge!(new_options)
22
- end
23
-
24
- def enabled?
25
- options[ENABLED_KEY]
26
- end
27
-
28
- def overrides_for(context)
29
- Overrides.new(options.fetch(OVERRIDES_KEY, {})).for_context(context)
30
- end
31
-
32
- # Retrieves the value, if any, for the given +key+ in the given +context+.
33
- #
34
- # Raises an error if neither the context nor this config have a value for
35
- # the key.
36
- #
37
- def value(key, context)
38
- overrides_for(context).each { |conf| return conf[key] if conf.key?(key) }
39
- options.fetch(key)
40
- end
41
-
42
- private
43
-
44
- attr_reader :options
45
- end
46
-
47
- #
48
- # A set of context-specific overrides for smell detectors.
49
- #
50
- class Overrides
51
- def initialize(hash)
52
- @hash = hash
53
- end
54
-
55
- # Find any overrides that match the supplied context
56
- def for_context(context)
57
- contexts = hash.keys.select { |ckey| context.matches?([ckey]) }
58
- contexts.map { |exc| hash[exc] }
59
- end
60
-
61
- private
62
-
63
- attr_reader :hash
64
- end
65
- end
66
- end
@@ -1,88 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'forwardable'
3
-
4
- module Reek
5
- # @public
6
- module SmellDetectors
7
- #
8
- # Reports a warning that a smell has been found.
9
- #
10
- # @public
11
- #
12
- # :reek:TooManyInstanceVariables: { max_instance_variables: 6 }
13
- class SmellWarning
14
- include Comparable
15
- extend Forwardable
16
-
17
- # @public
18
- attr_reader :context, :lines, :message, :parameters, :smell_detector, :source
19
- def_delegators :smell_detector, :smell_type
20
-
21
- # @note When using Reek's public API, you should not create SmellWarning
22
- # objects yourself. This is why the initializer is not part of the
23
- # public API.
24
- #
25
- # :reek:LongParameterList: { max_params: 6 }
26
- def initialize(smell_detector, context: '', lines:, message:,
27
- source:, parameters: {})
28
- @smell_detector = smell_detector
29
- @source = source
30
- @context = context.to_s
31
- @lines = lines
32
- @message = message
33
- @parameters = parameters
34
-
35
- freeze
36
- end
37
-
38
- # @public
39
- def hash
40
- identifying_values.hash
41
- end
42
-
43
- # @public
44
- def <=>(other)
45
- identifying_values <=> other.identifying_values
46
- end
47
-
48
- # @public
49
- def eql?(other)
50
- (self <=> other).zero?
51
- end
52
-
53
- # @public
54
- def to_hash
55
- stringified_params = Hash[parameters.map { |key, val| [key.to_s, val] }]
56
- base_hash.merge(stringified_params)
57
- end
58
-
59
- alias yaml_hash to_hash
60
-
61
- def base_message
62
- "#{smell_type}: #{context} #{message}"
63
- end
64
-
65
- def smell_class
66
- smell_detector.class
67
- end
68
-
69
- protected
70
-
71
- def identifying_values
72
- [smell_type, context, message, lines]
73
- end
74
-
75
- private
76
-
77
- def base_hash
78
- {
79
- 'context' => context,
80
- 'lines' => lines,
81
- 'message' => message,
82
- 'smell_type' => smell_type,
83
- 'source' => source
84
- }
85
- end
86
- end
87
- end
88
- end
data/tasks/mutant.rake DELETED
@@ -1,14 +0,0 @@
1
- desc 'Runs mutant'
2
- task :mutant do
3
- command = <<-EOS
4
- RUBY_THREAD_VM_STACK_SIZE=64000\
5
- bundle exec mutant\
6
- --include lib\
7
- --require reek\
8
- --use rspec\
9
- --since master^\
10
- --jobs 4 'Reek*'
11
- EOS
12
- system command
13
- abort unless $CHILD_STATUS.success?
14
- end