reek 5.6.0 → 6.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.github/workflows/ruby.yml +52 -0
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +3 -1
  6. data/.rubocop_todo.yml +27 -20
  7. data/.simplecov +1 -0
  8. data/CHANGELOG.md +29 -0
  9. data/CONTRIBUTING.md +3 -0
  10. data/Dockerfile +2 -1
  11. data/Gemfile +14 -17
  12. data/README.md +11 -11
  13. data/bin/code_climate_reek +12 -2
  14. data/lib/reek.rb +1 -0
  15. data/lib/reek/ast/ast_node_class_map.rb +1 -1
  16. data/lib/reek/ast/node.rb +1 -1
  17. data/lib/reek/ast/sexp_extensions/arguments.rb +11 -0
  18. data/lib/reek/cli/options.rb +3 -3
  19. data/lib/reek/code_comment.rb +36 -29
  20. data/lib/reek/configuration/app_configuration.rb +4 -3
  21. data/lib/reek/configuration/configuration_converter.rb +2 -2
  22. data/lib/reek/configuration/directory_directives.rb +9 -3
  23. data/lib/reek/configuration/excluded_paths.rb +2 -1
  24. data/lib/reek/context/code_context.rb +1 -1
  25. data/lib/reek/context/module_context.rb +3 -1
  26. data/lib/reek/context/refinement_context.rb +16 -0
  27. data/lib/reek/context_builder.rb +16 -2
  28. data/lib/reek/errors/legacy_comment_separator_error.rb +36 -0
  29. data/lib/reek/report.rb +5 -7
  30. data/lib/reek/report/code_climate/code_climate_configuration.yml +1 -1
  31. data/lib/reek/report/code_climate/code_climate_formatter.rb +1 -3
  32. data/lib/reek/report/code_climate/code_climate_report.rb +2 -1
  33. data/lib/reek/report/simple_warning_formatter.rb +0 -7
  34. data/lib/reek/smell_detectors/base_detector.rb +2 -10
  35. data/lib/reek/smell_detectors/boolean_parameter.rb +3 -1
  36. data/lib/reek/smell_detectors/data_clump.rb +23 -56
  37. data/lib/reek/smell_detectors/nil_check.rb +1 -12
  38. data/lib/reek/smell_detectors/uncommunicative_variable_name.rb +1 -1
  39. data/lib/reek/smell_warning.rb +2 -3
  40. data/lib/reek/source/source_locator.rb +14 -13
  41. data/lib/reek/spec/smell_matcher.rb +2 -1
  42. data/lib/reek/version.rb +1 -1
  43. data/reek.gemspec +17 -7
  44. metadata +23 -246
  45. data/.travis.yml +0 -35
  46. data/docs/API.md +0 -174
  47. data/docs/Attribute.md +0 -39
  48. data/docs/Basic-Smell-Options.md +0 -85
  49. data/docs/Boolean-Parameter.md +0 -54
  50. data/docs/Class-Variable.md +0 -40
  51. data/docs/Code-Smells.md +0 -39
  52. data/docs/Command-Line-Options.md +0 -119
  53. data/docs/Control-Couple.md +0 -26
  54. data/docs/Control-Parameter.md +0 -32
  55. data/docs/Data-Clump.md +0 -46
  56. data/docs/Duplicate-Method-Call.md +0 -264
  57. data/docs/Feature-Envy.md +0 -93
  58. data/docs/How-To-Write-New-Detectors.md +0 -132
  59. data/docs/How-reek-works-internally.md +0 -114
  60. data/docs/Instance-Variable-Assumption.md +0 -163
  61. data/docs/Irresponsible-Module.md +0 -47
  62. data/docs/Large-Class.md +0 -16
  63. data/docs/Long-Parameter-List.md +0 -39
  64. data/docs/Long-Yield-List.md +0 -37
  65. data/docs/Manual-Dispatch.md +0 -30
  66. data/docs/Missing-Safe-Method.md +0 -92
  67. data/docs/Module-Initialize.md +0 -62
  68. data/docs/Nested-Iterators.md +0 -59
  69. data/docs/Nil-Check.md +0 -44
  70. data/docs/RSpec-matchers.md +0 -129
  71. data/docs/Rake-Task.md +0 -66
  72. data/docs/Reek-4-to-Reek-5-migration.md +0 -188
  73. data/docs/Reek-Driven-Development.md +0 -46
  74. data/docs/Repeated-Conditional.md +0 -47
  75. data/docs/Simulated-Polymorphism.md +0 -16
  76. data/docs/Smell-Suppression.md +0 -96
  77. data/docs/Style-Guide.md +0 -19
  78. data/docs/Subclassed-From-Core-Class.md +0 -79
  79. data/docs/Too-Many-Constants.md +0 -37
  80. data/docs/Too-Many-Instance-Variables.md +0 -43
  81. data/docs/Too-Many-Methods.md +0 -56
  82. data/docs/Too-Many-Statements.md +0 -54
  83. data/docs/Uncommunicative-Method-Name.md +0 -94
  84. data/docs/Uncommunicative-Module-Name.md +0 -92
  85. data/docs/Uncommunicative-Name.md +0 -18
  86. data/docs/Uncommunicative-Parameter-Name.md +0 -90
  87. data/docs/Uncommunicative-Variable-Name.md +0 -96
  88. data/docs/Unused-Parameters.md +0 -28
  89. data/docs/Unused-Private-Method.md +0 -101
  90. data/docs/Utility-Function.md +0 -56
  91. data/docs/Versioning-Policy.md +0 -7
  92. data/docs/YAML-Reports.md +0 -93
  93. data/docs/defaults.reek.yml +0 -129
  94. data/docs/templates/default/docstring/html/public_api_marker.erb +0 -3
  95. data/docs/templates/default/docstring/setup.rb +0 -37
  96. data/docs/templates/default/fulldoc/html/css/common.css +0 -1
  97. data/docs/yard_plugin.rb +0 -17
  98. data/features/command_line_interface/basic_usage.feature +0 -15
  99. data/features/command_line_interface/options.feature +0 -124
  100. data/features/command_line_interface/show_progress.feature +0 -33
  101. data/features/command_line_interface/smell_selection.feature +0 -15
  102. data/features/command_line_interface/smells_count.feature +0 -38
  103. data/features/command_line_interface/stdin.feature +0 -65
  104. data/features/configuration_files/accept_setting.feature +0 -87
  105. data/features/configuration_files/directory_specific_directives.feature +0 -274
  106. data/features/configuration_files/exclude_directives.feature +0 -35
  107. data/features/configuration_files/exclude_paths_directives.feature +0 -42
  108. data/features/configuration_files/masking_smells.feature +0 -94
  109. data/features/configuration_files/mix_accept_reject_setting.feature +0 -84
  110. data/features/configuration_files/reject_setting.feature +0 -89
  111. data/features/configuration_files/schema_validation.feature +0 -59
  112. data/features/configuration_files/show_configuration_file.feature +0 -44
  113. data/features/configuration_files/unused_private_method.feature +0 -68
  114. data/features/configuration_loading.feature +0 -91
  115. data/features/configuration_via_source_comments/erroneous_source_comments.feature +0 -68
  116. data/features/configuration_via_source_comments/well_formed_source_comments.feature +0 -116
  117. data/features/locales.feature +0 -32
  118. data/features/programmatic_access.feature +0 -41
  119. data/features/rake_task/rake_task.feature +0 -138
  120. data/features/reports/codeclimate.feature +0 -59
  121. data/features/reports/json.feature +0 -59
  122. data/features/reports/reports.feature +0 -219
  123. data/features/reports/yaml.feature +0 -52
  124. data/features/rspec_matcher.feature +0 -41
  125. data/features/samples.feature +0 -305
  126. data/features/step_definitions/.rubocop.yml +0 -5
  127. data/features/step_definitions/reek_steps.rb +0 -98
  128. data/features/step_definitions/sample_file_steps.rb +0 -63
  129. data/features/support/env.rb +0 -34
  130. data/features/todo_list.feature +0 -108
  131. data/samples/checkstyle.xml +0 -7
  132. data/samples/clean_source/clean.rb +0 -6
  133. data/samples/configuration/accepts_rejects_and_excludes_for_detectors.reek.yml +0 -29
  134. data/samples/configuration/accepts_rejects_and_excludes_for_directory_directives.reek.yml +0 -30
  135. data/samples/configuration/corrupt.reek +0 -1
  136. data/samples/configuration/empty.reek +0 -0
  137. data/samples/configuration/full_configuration.reek +0 -13
  138. data/samples/configuration/full_mask.reek +0 -6
  139. data/samples/configuration/home/home.reek.yml +0 -4
  140. data/samples/configuration/partial_mask.reek +0 -4
  141. data/samples/configuration/regular_configuration/.reek.yml +0 -4
  142. data/samples/configuration/regular_configuration/empty_sub_directory/.gitignore +0 -0
  143. data/samples/configuration/with_excluded_paths.reek +0 -5
  144. data/samples/no_config_file/.keep +0 -0
  145. data/samples/paths.rb +0 -5
  146. data/samples/smelly_source/inline.rb +0 -704
  147. data/samples/smelly_source/optparse.rb +0 -1788
  148. data/samples/smelly_source/redcloth.rb +0 -1130
  149. data/samples/smelly_source/ruby.rb +0 -368
  150. data/samples/smelly_source/smelly.rb +0 -7
  151. data/samples/source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb +0 -5
  152. data/samples/source_with_exclude_paths/nested/ignore_me_as_well/irresponsible_module.rb +0 -2
  153. data/samples/source_with_exclude_paths/nested/uncommunicative_parameter_name.rb +0 -6
  154. data/samples/source_with_exclude_paths/nested/uncommunicative_variable_name.rb +0 -6
  155. data/samples/source_with_hidden_directories/.hidden/hidden.rb +0 -1
  156. data/samples/source_with_hidden_directories/not_hidden.rb +0 -1
  157. data/samples/source_with_non_ruby_files/gibberish +0 -1
  158. data/samples/source_with_non_ruby_files/python_source.py +0 -1
  159. data/samples/source_with_non_ruby_files/ruby.rb +0 -6
  160. data/spec/factories/factories.rb +0 -37
  161. data/spec/performance/reek/smell_detectors/runtime_speed_spec.rb +0 -17
  162. data/spec/quality/documentation_spec.rb +0 -40
  163. data/spec/quality/reek_source_spec.rb +0 -11
  164. data/spec/reek/ast/node_spec.rb +0 -211
  165. data/spec/reek/ast/object_refs_spec.rb +0 -83
  166. data/spec/reek/ast/reference_collector_spec.rb +0 -47
  167. data/spec/reek/ast/sexp_extensions_spec.rb +0 -516
  168. data/spec/reek/cli/application_spec.rb +0 -168
  169. data/spec/reek/cli/command/report_command_spec.rb +0 -44
  170. data/spec/reek/cli/command/todo_list_command_spec.rb +0 -86
  171. data/spec/reek/cli/options_spec.rb +0 -51
  172. data/spec/reek/cli/silencer_spec.rb +0 -28
  173. data/spec/reek/code_comment_spec.rb +0 -185
  174. data/spec/reek/configuration/app_configuration_spec.rb +0 -195
  175. data/spec/reek/configuration/configuration_file_finder_spec.rb +0 -230
  176. data/spec/reek/configuration/default_directive_spec.rb +0 -13
  177. data/spec/reek/configuration/directory_directives_spec.rb +0 -116
  178. data/spec/reek/configuration/excluded_paths_spec.rb +0 -16
  179. data/spec/reek/configuration/rake_task_converter_spec.rb +0 -33
  180. data/spec/reek/configuration/schema_validator_spec.rb +0 -165
  181. data/spec/reek/context/code_context_spec.rb +0 -192
  182. data/spec/reek/context/ghost_context_spec.rb +0 -60
  183. data/spec/reek/context/method_context_spec.rb +0 -72
  184. data/spec/reek/context/module_context_spec.rb +0 -55
  185. data/spec/reek/context/root_context_spec.rb +0 -12
  186. data/spec/reek/context/statement_counter_spec.rb +0 -24
  187. data/spec/reek/context_builder_spec.rb +0 -460
  188. data/spec/reek/detector_repository_spec.rb +0 -22
  189. data/spec/reek/documentation_link_spec.rb +0 -20
  190. data/spec/reek/errors/base_error_spec.rb +0 -13
  191. data/spec/reek/examiner_spec.rb +0 -309
  192. data/spec/reek/logging_error_handler_spec.rb +0 -24
  193. data/spec/reek/rake/task_spec.rb +0 -56
  194. data/spec/reek/report/code_climate/code_climate_configuration_spec.rb +0 -24
  195. data/spec/reek/report/code_climate/code_climate_fingerprint_spec.rb +0 -126
  196. data/spec/reek/report/code_climate/code_climate_formatter_spec.rb +0 -51
  197. data/spec/reek/report/code_climate/code_climate_report_spec.rb +0 -56
  198. data/spec/reek/report/html_report_spec.rb +0 -19
  199. data/spec/reek/report/json_report_spec.rb +0 -58
  200. data/spec/reek/report/location_formatter_spec.rb +0 -32
  201. data/spec/reek/report/progress_formatter_spec.rb +0 -68
  202. data/spec/reek/report/text_report_spec.rb +0 -89
  203. data/spec/reek/report/xml_report_spec.rb +0 -24
  204. data/spec/reek/report/yaml_report_spec.rb +0 -55
  205. data/spec/reek/report_spec.rb +0 -28
  206. data/spec/reek/smell_configuration_spec.rb +0 -56
  207. data/spec/reek/smell_detectors/attribute_spec.rb +0 -197
  208. data/spec/reek/smell_detectors/base_detector_spec.rb +0 -60
  209. data/spec/reek/smell_detectors/boolean_parameter_spec.rb +0 -93
  210. data/spec/reek/smell_detectors/class_variable_spec.rb +0 -106
  211. data/spec/reek/smell_detectors/control_parameter_spec.rb +0 -300
  212. data/spec/reek/smell_detectors/data_clump_spec.rb +0 -120
  213. data/spec/reek/smell_detectors/duplicate_method_call_spec.rb +0 -211
  214. data/spec/reek/smell_detectors/feature_envy_spec.rb +0 -295
  215. data/spec/reek/smell_detectors/instance_variable_assumption_spec.rb +0 -96
  216. data/spec/reek/smell_detectors/irresponsible_module_spec.rb +0 -226
  217. data/spec/reek/smell_detectors/long_parameter_list_spec.rb +0 -61
  218. data/spec/reek/smell_detectors/long_yield_list_spec.rb +0 -49
  219. data/spec/reek/smell_detectors/manual_dispatch_spec.rb +0 -75
  220. data/spec/reek/smell_detectors/missing_safe_method_spec.rb +0 -62
  221. data/spec/reek/smell_detectors/module_initialize_spec.rb +0 -77
  222. data/spec/reek/smell_detectors/nested_iterators_spec.rb +0 -333
  223. data/spec/reek/smell_detectors/nil_check_spec.rb +0 -100
  224. data/spec/reek/smell_detectors/repeated_conditional_spec.rb +0 -100
  225. data/spec/reek/smell_detectors/subclassed_from_core_class_spec.rb +0 -77
  226. data/spec/reek/smell_detectors/too_many_constants_spec.rb +0 -144
  227. data/spec/reek/smell_detectors/too_many_instance_variables_spec.rb +0 -132
  228. data/spec/reek/smell_detectors/too_many_methods_spec.rb +0 -54
  229. data/spec/reek/smell_detectors/too_many_statements_spec.rb +0 -90
  230. data/spec/reek/smell_detectors/uncommunicative_method_name_spec.rb +0 -78
  231. data/spec/reek/smell_detectors/uncommunicative_module_name_spec.rb +0 -78
  232. data/spec/reek/smell_detectors/uncommunicative_parameter_name_spec.rb +0 -147
  233. data/spec/reek/smell_detectors/uncommunicative_variable_name_spec.rb +0 -201
  234. data/spec/reek/smell_detectors/unused_parameters_spec.rb +0 -114
  235. data/spec/reek/smell_detectors/unused_private_method_spec.rb +0 -205
  236. data/spec/reek/smell_detectors/utility_function_spec.rb +0 -293
  237. data/spec/reek/smell_warning_spec.rb +0 -137
  238. data/spec/reek/source/source_code_spec.rb +0 -66
  239. data/spec/reek/source/source_locator_spec.rb +0 -166
  240. data/spec/reek/spec/should_reek_of_spec.rb +0 -154
  241. data/spec/reek/spec/should_reek_only_of_spec.rb +0 -91
  242. data/spec/reek/spec/should_reek_spec.rb +0 -52
  243. data/spec/reek/spec/smell_matcher_spec.rb +0 -87
  244. data/spec/reek/tree_dresser_spec.rb +0 -46
  245. data/spec/spec_helper.rb +0 -96
  246. data/tasks/configuration.rake +0 -19
  247. data/tasks/console.rake +0 -5
  248. data/tasks/reek.rake +0 -6
  249. data/tasks/rubocop.rake +0 -11
  250. data/tasks/test.rake +0 -32
@@ -19,6 +19,7 @@ module Reek
19
19
  # @quality :reek:TooManyMethods { max_methods: 18 }
20
20
  class BaseDetector
21
21
  attr_reader :config
22
+
22
23
  # The name of the config field that lists the names of code contexts
23
24
  # that should not be checked. Add this field to the config for each
24
25
  # smell that should ignore this code element.
@@ -89,7 +90,7 @@ module Reek
89
90
 
90
91
  class << self
91
92
  def smell_type
92
- @smell_type ||= name.split(/::/).last
93
+ @smell_type ||= name.split('::').last
93
94
  end
94
95
 
95
96
  def contexts
@@ -121,15 +122,6 @@ module Reek
121
122
  @descendants ||= []
122
123
  end
123
124
 
124
- #
125
- # @param detector [String] the detector in question, e.g. 'DuplicateMethodCall'
126
- # @return [Boolean]
127
- #
128
- def valid_detector?(detector)
129
- descendants.map { |descendant| descendant.to_s.split('::').last }.
130
- include?(detector)
131
- end
132
-
133
125
  #
134
126
  # Transform a detector name to the corresponding constant.
135
127
  # Note that we assume a valid name - exceptions are not handled here.
@@ -14,6 +14,8 @@ module Reek
14
14
  #
15
15
  # See {file:docs/Boolean-Parameter.md} for details.
16
16
  class BooleanParameter < BaseDetector
17
+ BOOLEAN_VALUES = [:true, :false].freeze
18
+
17
19
  #
18
20
  # Checks whether the given method has any Boolean parameters.
19
21
  #
@@ -21,7 +23,7 @@ module Reek
21
23
  #
22
24
  def sniff
23
25
  context.default_assignments.select do |_parameter, value|
24
- [:true, :false].include?(value.type)
26
+ BOOLEAN_VALUES.include?(value.type)
25
27
  end.map do |parameter, _value|
26
28
  smell_warning(
27
29
  lines: [source_line],
@@ -51,7 +51,7 @@ module Reek
51
51
  # @return [Array<SmellWarning>]
52
52
  #
53
53
  def sniff
54
- MethodGroup.new(context, min_clump_size, max_copies).clumps.map do |clump, methods|
54
+ clumps.map do |clump, methods|
55
55
  methods_length = methods.length
56
56
  smell_warning(
57
57
  lines: methods.map(&:line),
@@ -72,72 +72,39 @@ module Reek
72
72
  private
73
73
 
74
74
  def max_copies
75
- value(MAX_COPIES_KEY, context)
75
+ @max_copies ||= value(MAX_COPIES_KEY, context)
76
76
  end
77
77
 
78
78
  def min_clump_size
79
- value(MIN_CLUMP_SIZE_KEY, context)
79
+ @min_clump_size ||= value(MIN_CLUMP_SIZE_KEY, context)
80
80
  end
81
- end
82
- end
83
81
 
84
- # Represents a group of methods
85
- # @private
86
- class MethodGroup
87
- def initialize(ctx, min_clump_size, max_copies)
88
- @min_clump_size = min_clump_size
89
- @max_copies = max_copies
90
- @candidate_methods = ctx.node_instance_methods.map do |defn_node|
91
- CandidateMethod.new(defn_node)
82
+ def candidate_methods
83
+ @candidate_methods ||= context.node_instance_methods
92
84
  end
93
- end
94
85
 
95
- def candidate_clumps
96
- candidate_methods.each_cons(max_copies + 1).map do |methods|
97
- common_argument_names_for(methods)
98
- end.select do |clump|
99
- clump.length >= min_clump_size
100
- end.uniq
101
- end
102
-
103
- # @quality :reek:UtilityFunction
104
- def common_argument_names_for(methods)
105
- methods.map(&:arg_names).inject(:&)
106
- end
107
-
108
- def methods_containing_clump(clump)
109
- candidate_methods.select { |method| clump & method.arg_names == clump }
110
- end
111
-
112
- def clumps
113
- candidate_clumps.map do |clump|
114
- [clump, methods_containing_clump(clump)]
86
+ def candidate_clumps
87
+ candidate_methods.each_cons(max_copies + 1).map do |methods|
88
+ common_argument_names_for(methods)
89
+ end.select do |clump|
90
+ clump.length >= min_clump_size
91
+ end.uniq
115
92
  end
116
- end
117
-
118
- private
119
93
 
120
- attr_reader :candidate_methods, :max_copies, :min_clump_size
121
- end
122
-
123
- # A method definition and a copy of its parameters
124
- # @private
125
- class CandidateMethod
126
- extend Forwardable
127
-
128
- def_delegators :defn, :line, :name
94
+ # @quality :reek:UtilityFunction
95
+ def common_argument_names_for(methods)
96
+ methods.map(&:arg_names).inject(:&).compact.sort
97
+ end
129
98
 
130
- def initialize(defn_node)
131
- @defn = defn_node
132
- end
99
+ def methods_containing_clump(clump)
100
+ candidate_methods.select { |method| clump & method.arg_names == clump }
101
+ end
133
102
 
134
- def arg_names
135
- # TODO: Is all this sorting still needed?
136
- @arg_names ||= defn.arg_names.compact.sort
103
+ def clumps
104
+ candidate_clumps.map do |clump|
105
+ [clump, methods_containing_clump(clump)]
106
+ end
107
+ end
137
108
  end
138
-
139
- private
140
-
141
- attr_reader :defn
142
109
  end
143
110
  end
@@ -24,8 +24,7 @@ module Reek
24
24
 
25
25
  def detect_nodes
26
26
  finders = [NodeFinder.new(context, :send, NilCallNodeDetector),
27
- NodeFinder.new(context, :when, NilWhenNodeDetector),
28
- NodeFinder.new(context, :csend, SafeNavigationNodeDetector)]
27
+ NodeFinder.new(context, :when, NilWhenNodeDetector)]
29
28
  finders.flat_map(&:smelly_nodes)
30
29
  end
31
30
 
@@ -88,16 +87,6 @@ module Reek
88
87
  node.condition_list.any? { |it| it.type == :nil }
89
88
  end
90
89
  end
91
-
92
- # Detect safe navigation. Returns true for all nodes, since all :csend
93
- # nodes are considered smelly.
94
- module SafeNavigationNodeDetector
95
- module_function
96
-
97
- def detect(_node)
98
- true
99
- end
100
- end
101
90
  end
102
91
  end
103
92
  end
@@ -74,7 +74,7 @@ module Reek
74
74
  end
75
75
 
76
76
  def uncommunicative_variable_name?(name)
77
- sanitized_name = name.to_s.gsub(/^[@\*\&]*/, '')
77
+ sanitized_name = name.to_s.gsub(/^[@*&]*/, '')
78
78
  !acceptable_name?(sanitized_name)
79
79
  end
80
80
 
@@ -31,8 +31,7 @@ module Reek
31
31
  # public API.
32
32
  #
33
33
  # @quality :reek:LongParameterList { max_params: 6 }
34
- def initialize(smell_type, context: '', lines:, message:,
35
- source:, parameters: {})
34
+ def initialize(smell_type, lines:, message:, source:, context: '', parameters: {})
36
35
  @smell_type = smell_type
37
36
  @source = source
38
37
  @context = context.to_s
@@ -60,7 +59,7 @@ module Reek
60
59
 
61
60
  # @public
62
61
  def to_hash
63
- stringified_params = Hash[parameters.map { |key, val| [key.to_s, val] }]
62
+ stringified_params = parameters.map { |key, val| [key.to_s, val] }.to_h
64
63
  base_hash.merge(stringified_params)
65
64
  end
66
65
 
@@ -33,23 +33,26 @@ module Reek
33
33
 
34
34
  attr_reader :configuration, :paths, :options
35
35
 
36
- # @quality :reek:TooManyStatements { max_statements: 7 }
37
- # @quality :reek:NestedIterators { max_allowed_nesting: 2 }
38
36
  def source_paths
39
37
  paths.each_with_object([]) do |given_path, relevant_paths|
40
- unless given_path.exist?
38
+ if given_path.exist?
39
+ relevant_paths.concat source_files_from_path(given_path)
40
+ else
41
41
  print_no_such_file_error(given_path)
42
- next
43
42
  end
43
+ end
44
+ end
44
45
 
45
- given_path.find do |path|
46
- if path.directory?
47
- ignore_path?(path) ? Find.prune : next
48
- elsif ruby_file?(path)
49
- relevant_paths << path unless ignore_file?(path)
50
- end
46
+ def source_files_from_path(given_path)
47
+ relevant_paths = []
48
+ given_path.find do |path|
49
+ if path.directory?
50
+ Find.prune if ignore_path?(path)
51
+ elsif ruby_file?(path)
52
+ relevant_paths << path unless ignore_file?(path)
51
53
  end
52
54
  end
55
+ relevant_paths
53
56
  end
54
57
 
55
58
  def ignore_file?(path)
@@ -59,10 +62,8 @@ module Reek
59
62
 
60
63
  false
61
64
  end
62
- elsif path_excluded?(path)
63
- true
64
65
  else
65
- false
66
+ path_excluded?(path)
66
67
  end
67
68
  end
68
69
 
@@ -43,8 +43,9 @@ module Reek
43
43
  raise ArgumentError, "The attribute '#{extra_keys.first}' is not available for comparison"
44
44
  end
45
45
 
46
+ # :reek:FeatureEnvy
46
47
  def common_parameters_equal?(other_parameters)
47
- smell_warning.parameters.slice(*other_parameters.keys) == other_parameters
48
+ smell_warning.parameters.values_at(*other_parameters.keys) == other_parameters.values
48
49
  end
49
50
 
50
51
  def common_attributes_equal?(attributes)
data/lib/reek/version.rb CHANGED
@@ -8,6 +8,6 @@ module Reek
8
8
  # @public
9
9
  module Version
10
10
  # @public
11
- STRING = '5.6.0'
11
+ STRING = '6.0.4'
12
12
  end
13
13
  end
data/reek.gemspec CHANGED
@@ -12,16 +12,26 @@ Gem::Specification.new do |s|
12
12
  s.license = 'MIT'
13
13
  s.email = ['timo.roessner@googlemail.com']
14
14
  s.extra_rdoc_files = ['CHANGELOG.md', 'License.txt']
15
- s.files = `git ls-files -z`.split("\0")
15
+ s.files = Dir.chdir(File.expand_path(__dir__)) do
16
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|samples|docs|tasks)/}) }
17
+ end
18
+
16
19
  s.executables = s.files.grep(%r{^bin/}).map { |path| File.basename(path) }
17
20
  s.homepage = 'https://github.com/troessner/reek'
18
21
  s.rdoc_options = %w(--main README.md -x assets/|bin/|config/|features/|spec/|tasks/)
19
- s.required_ruby_version = '>= 2.3.0'
22
+ s.required_ruby_version = '>= 2.4.0'
20
23
  s.summary = 'Code smell detector for Ruby'
21
24
 
22
- s.add_runtime_dependency 'codeclimate-engine-rb', '~> 0.4.0'
23
- s.add_runtime_dependency 'kwalify', '~> 0.7.0'
24
- s.add_runtime_dependency 'parser', '< 2.8', '>= 2.5.0.0', '!= 2.5.1.1'
25
- s.add_runtime_dependency 'psych', '~> 3.1.0'
26
- s.add_runtime_dependency 'rainbow', '>= 2.0', '< 4.0'
25
+ s.metadata = {
26
+ 'homepage_uri' => 'https://github.com/troessner/reek',
27
+ 'source_code_uri' => 'https://github.com/troessner/reek',
28
+ 'bug_tracker_uri' => 'https://github.com/troessner/reek/issues',
29
+ 'changelog_uri' => 'https://github.com/troessner/reek/CHANGELOG.md',
30
+ 'documentation_uri' => 'https://www.rubydoc.info/gems/reek'
31
+ }
32
+
33
+ s.add_runtime_dependency 'kwalify', '~> 0.7.0'
34
+ s.add_runtime_dependency 'parser', '~> 3.0.0'
35
+ s.add_runtime_dependency 'psych', '~> 3.1'
36
+ s.add_runtime_dependency 'rainbow', '>= 2.0', '< 4.0'
27
37
  end
metadata CHANGED
@@ -1,32 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reek
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.0
4
+ version: 6.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Rutherford
8
8
  - Timo Roessner
9
9
  - Matijs van Zuijlen
10
10
  - Piotr Szotkowski
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-01-20 00:00:00.000000000 Z
14
+ date: 2021-04-27 00:00:00.000000000 Z
15
15
  dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: codeclimate-engine-rb
18
- requirement: !ruby/object:Gem::Requirement
19
- requirements:
20
- - - "~>"
21
- - !ruby/object:Gem::Version
22
- version: 0.4.0
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: 0.4.0
30
16
  - !ruby/object:Gem::Dependency
31
17
  name: kwalify
32
18
  requirement: !ruby/object:Gem::Requirement
@@ -45,42 +31,30 @@ dependencies:
45
31
  name: parser
46
32
  requirement: !ruby/object:Gem::Requirement
47
33
  requirements:
48
- - - "<"
49
- - !ruby/object:Gem::Version
50
- version: '2.8'
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: 2.5.0.0
54
- - - "!="
34
+ - - "~>"
55
35
  - !ruby/object:Gem::Version
56
- version: 2.5.1.1
36
+ version: 3.0.0
57
37
  type: :runtime
58
38
  prerelease: false
59
39
  version_requirements: !ruby/object:Gem::Requirement
60
40
  requirements:
61
- - - "<"
62
- - !ruby/object:Gem::Version
63
- version: '2.8'
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 2.5.0.0
67
- - - "!="
41
+ - - "~>"
68
42
  - !ruby/object:Gem::Version
69
- version: 2.5.1.1
43
+ version: 3.0.0
70
44
  - !ruby/object:Gem::Dependency
71
45
  name: psych
72
46
  requirement: !ruby/object:Gem::Requirement
73
47
  requirements:
74
48
  - - "~>"
75
49
  - !ruby/object:Gem::Version
76
- version: 3.1.0
50
+ version: '3.1'
77
51
  type: :runtime
78
52
  prerelease: false
79
53
  version_requirements: !ruby/object:Gem::Requirement
80
54
  requirements:
81
55
  - - "~>"
82
56
  - !ruby/object:Gem::Version
83
- version: 3.1.0
57
+ version: '3.1'
84
58
  - !ruby/object:Gem::Dependency
85
59
  name: rainbow
86
60
  requirement: !ruby/object:Gem::Requirement
@@ -114,12 +88,13 @@ extra_rdoc_files:
114
88
  - License.txt
115
89
  files:
116
90
  - ".dockerignore"
91
+ - ".github/dependabot.yml"
92
+ - ".github/workflows/ruby.yml"
117
93
  - ".gitignore"
118
94
  - ".reek.yml"
119
95
  - ".rubocop.yml"
120
96
  - ".rubocop_todo.yml"
121
97
  - ".simplecov"
122
- - ".travis.yml"
123
98
  - ".yardopts"
124
99
  - CHANGELOG.md
125
100
  - CONTRIBUTING.md
@@ -130,92 +105,7 @@ files:
130
105
  - Rakefile
131
106
  - bin/code_climate_reek
132
107
  - bin/reek
133
- - docs/API.md
134
- - docs/Attribute.md
135
- - docs/Basic-Smell-Options.md
136
- - docs/Boolean-Parameter.md
137
- - docs/Class-Variable.md
138
- - docs/Code-Smells.md
139
- - docs/Command-Line-Options.md
140
- - docs/Control-Couple.md
141
- - docs/Control-Parameter.md
142
- - docs/Data-Clump.md
143
- - docs/Duplicate-Method-Call.md
144
- - docs/Feature-Envy.md
145
- - docs/How-To-Write-New-Detectors.md
146
- - docs/How-reek-works-internally.md
147
- - docs/Instance-Variable-Assumption.md
148
- - docs/Irresponsible-Module.md
149
- - docs/Large-Class.md
150
- - docs/Long-Parameter-List.md
151
- - docs/Long-Yield-List.md
152
- - docs/Manual-Dispatch.md
153
- - docs/Missing-Safe-Method.md
154
- - docs/Module-Initialize.md
155
- - docs/Nested-Iterators.md
156
- - docs/Nil-Check.md
157
- - docs/RSpec-matchers.md
158
- - docs/Rake-Task.md
159
- - docs/Reek-4-to-Reek-5-migration.md
160
- - docs/Reek-Driven-Development.md
161
- - docs/Repeated-Conditional.md
162
- - docs/Simulated-Polymorphism.md
163
- - docs/Smell-Suppression.md
164
- - docs/Style-Guide.md
165
- - docs/Subclassed-From-Core-Class.md
166
- - docs/Too-Many-Constants.md
167
- - docs/Too-Many-Instance-Variables.md
168
- - docs/Too-Many-Methods.md
169
- - docs/Too-Many-Statements.md
170
- - docs/Uncommunicative-Method-Name.md
171
- - docs/Uncommunicative-Module-Name.md
172
- - docs/Uncommunicative-Name.md
173
- - docs/Uncommunicative-Parameter-Name.md
174
- - docs/Uncommunicative-Variable-Name.md
175
- - docs/Unused-Parameters.md
176
- - docs/Unused-Private-Method.md
177
- - docs/Utility-Function.md
178
- - docs/Versioning-Policy.md
179
- - docs/YAML-Reports.md
180
- - docs/defaults.reek.yml
181
- - docs/templates/default/docstring/html/public_api_marker.erb
182
- - docs/templates/default/docstring/setup.rb
183
- - docs/templates/default/fulldoc/html/css/common.css
184
- - docs/yard_plugin.rb
185
108
  - engine.json
186
- - features/command_line_interface/basic_usage.feature
187
- - features/command_line_interface/options.feature
188
- - features/command_line_interface/show_progress.feature
189
- - features/command_line_interface/smell_selection.feature
190
- - features/command_line_interface/smells_count.feature
191
- - features/command_line_interface/stdin.feature
192
- - features/configuration_files/accept_setting.feature
193
- - features/configuration_files/directory_specific_directives.feature
194
- - features/configuration_files/exclude_directives.feature
195
- - features/configuration_files/exclude_paths_directives.feature
196
- - features/configuration_files/masking_smells.feature
197
- - features/configuration_files/mix_accept_reject_setting.feature
198
- - features/configuration_files/reject_setting.feature
199
- - features/configuration_files/schema_validation.feature
200
- - features/configuration_files/show_configuration_file.feature
201
- - features/configuration_files/unused_private_method.feature
202
- - features/configuration_loading.feature
203
- - features/configuration_via_source_comments/erroneous_source_comments.feature
204
- - features/configuration_via_source_comments/well_formed_source_comments.feature
205
- - features/locales.feature
206
- - features/programmatic_access.feature
207
- - features/rake_task/rake_task.feature
208
- - features/reports/codeclimate.feature
209
- - features/reports/json.feature
210
- - features/reports/reports.feature
211
- - features/reports/yaml.feature
212
- - features/rspec_matcher.feature
213
- - features/samples.feature
214
- - features/step_definitions/.rubocop.yml
215
- - features/step_definitions/reek_steps.rb
216
- - features/step_definitions/sample_file_steps.rb
217
- - features/support/env.rb
218
- - features/todo_list.feature
219
109
  - lib/reek.rb
220
110
  - lib/reek/ast/ast_node_class_map.rb
221
111
  - lib/reek/ast/builder.rb
@@ -265,6 +155,7 @@ files:
265
155
  - lib/reek/context/ghost_context.rb
266
156
  - lib/reek/context/method_context.rb
267
157
  - lib/reek/context/module_context.rb
158
+ - lib/reek/context/refinement_context.rb
268
159
  - lib/reek/context/root_context.rb
269
160
  - lib/reek/context/send_context.rb
270
161
  - lib/reek/context/singleton_attribute_context.rb
@@ -281,6 +172,7 @@ files:
281
172
  - lib/reek/errors/encoding_error.rb
282
173
  - lib/reek/errors/garbage_detector_configuration_in_comment_error.rb
283
174
  - lib/reek/errors/incomprehensible_source_error.rb
175
+ - lib/reek/errors/legacy_comment_separator_error.rb
284
176
  - lib/reek/errors/syntax_error.rb
285
177
  - lib/reek/examiner.rb
286
178
  - lib/reek/logging_error_handler.rb
@@ -356,131 +248,16 @@ files:
356
248
  - logo/reek.text.png
357
249
  - logo/reek.text.svg
358
250
  - reek.gemspec
359
- - samples/checkstyle.xml
360
- - samples/clean_source/clean.rb
361
- - samples/configuration/accepts_rejects_and_excludes_for_detectors.reek.yml
362
- - samples/configuration/accepts_rejects_and_excludes_for_directory_directives.reek.yml
363
- - samples/configuration/corrupt.reek
364
- - samples/configuration/empty.reek
365
- - samples/configuration/full_configuration.reek
366
- - samples/configuration/full_mask.reek
367
- - samples/configuration/home/home.reek.yml
368
- - samples/configuration/partial_mask.reek
369
- - samples/configuration/regular_configuration/.reek.yml
370
- - samples/configuration/regular_configuration/empty_sub_directory/.gitignore
371
- - samples/configuration/with_excluded_paths.reek
372
- - samples/no_config_file/.keep
373
- - samples/paths.rb
374
- - samples/smelly_source/inline.rb
375
- - samples/smelly_source/optparse.rb
376
- - samples/smelly_source/redcloth.rb
377
- - samples/smelly_source/ruby.rb
378
- - samples/smelly_source/smelly.rb
379
- - samples/source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb
380
- - samples/source_with_exclude_paths/nested/ignore_me_as_well/irresponsible_module.rb
381
- - samples/source_with_exclude_paths/nested/uncommunicative_parameter_name.rb
382
- - samples/source_with_exclude_paths/nested/uncommunicative_variable_name.rb
383
- - samples/source_with_hidden_directories/.hidden/hidden.rb
384
- - samples/source_with_hidden_directories/not_hidden.rb
385
- - samples/source_with_non_ruby_files/gibberish
386
- - samples/source_with_non_ruby_files/python_source.py
387
- - samples/source_with_non_ruby_files/ruby.rb
388
- - spec/factories/factories.rb
389
- - spec/performance/reek/smell_detectors/runtime_speed_spec.rb
390
- - spec/quality/documentation_spec.rb
391
- - spec/quality/reek_source_spec.rb
392
- - spec/reek/ast/node_spec.rb
393
- - spec/reek/ast/object_refs_spec.rb
394
- - spec/reek/ast/reference_collector_spec.rb
395
- - spec/reek/ast/sexp_extensions_spec.rb
396
- - spec/reek/cli/application_spec.rb
397
- - spec/reek/cli/command/report_command_spec.rb
398
- - spec/reek/cli/command/todo_list_command_spec.rb
399
- - spec/reek/cli/options_spec.rb
400
- - spec/reek/cli/silencer_spec.rb
401
- - spec/reek/code_comment_spec.rb
402
- - spec/reek/configuration/app_configuration_spec.rb
403
- - spec/reek/configuration/configuration_file_finder_spec.rb
404
- - spec/reek/configuration/default_directive_spec.rb
405
- - spec/reek/configuration/directory_directives_spec.rb
406
- - spec/reek/configuration/excluded_paths_spec.rb
407
- - spec/reek/configuration/rake_task_converter_spec.rb
408
- - spec/reek/configuration/schema_validator_spec.rb
409
- - spec/reek/context/code_context_spec.rb
410
- - spec/reek/context/ghost_context_spec.rb
411
- - spec/reek/context/method_context_spec.rb
412
- - spec/reek/context/module_context_spec.rb
413
- - spec/reek/context/root_context_spec.rb
414
- - spec/reek/context/statement_counter_spec.rb
415
- - spec/reek/context_builder_spec.rb
416
- - spec/reek/detector_repository_spec.rb
417
- - spec/reek/documentation_link_spec.rb
418
- - spec/reek/errors/base_error_spec.rb
419
- - spec/reek/examiner_spec.rb
420
- - spec/reek/logging_error_handler_spec.rb
421
- - spec/reek/rake/task_spec.rb
422
- - spec/reek/report/code_climate/code_climate_configuration_spec.rb
423
- - spec/reek/report/code_climate/code_climate_fingerprint_spec.rb
424
- - spec/reek/report/code_climate/code_climate_formatter_spec.rb
425
- - spec/reek/report/code_climate/code_climate_report_spec.rb
426
- - spec/reek/report/html_report_spec.rb
427
- - spec/reek/report/json_report_spec.rb
428
- - spec/reek/report/location_formatter_spec.rb
429
- - spec/reek/report/progress_formatter_spec.rb
430
- - spec/reek/report/text_report_spec.rb
431
- - spec/reek/report/xml_report_spec.rb
432
- - spec/reek/report/yaml_report_spec.rb
433
- - spec/reek/report_spec.rb
434
- - spec/reek/smell_configuration_spec.rb
435
- - spec/reek/smell_detectors/attribute_spec.rb
436
- - spec/reek/smell_detectors/base_detector_spec.rb
437
- - spec/reek/smell_detectors/boolean_parameter_spec.rb
438
- - spec/reek/smell_detectors/class_variable_spec.rb
439
- - spec/reek/smell_detectors/control_parameter_spec.rb
440
- - spec/reek/smell_detectors/data_clump_spec.rb
441
- - spec/reek/smell_detectors/duplicate_method_call_spec.rb
442
- - spec/reek/smell_detectors/feature_envy_spec.rb
443
- - spec/reek/smell_detectors/instance_variable_assumption_spec.rb
444
- - spec/reek/smell_detectors/irresponsible_module_spec.rb
445
- - spec/reek/smell_detectors/long_parameter_list_spec.rb
446
- - spec/reek/smell_detectors/long_yield_list_spec.rb
447
- - spec/reek/smell_detectors/manual_dispatch_spec.rb
448
- - spec/reek/smell_detectors/missing_safe_method_spec.rb
449
- - spec/reek/smell_detectors/module_initialize_spec.rb
450
- - spec/reek/smell_detectors/nested_iterators_spec.rb
451
- - spec/reek/smell_detectors/nil_check_spec.rb
452
- - spec/reek/smell_detectors/repeated_conditional_spec.rb
453
- - spec/reek/smell_detectors/subclassed_from_core_class_spec.rb
454
- - spec/reek/smell_detectors/too_many_constants_spec.rb
455
- - spec/reek/smell_detectors/too_many_instance_variables_spec.rb
456
- - spec/reek/smell_detectors/too_many_methods_spec.rb
457
- - spec/reek/smell_detectors/too_many_statements_spec.rb
458
- - spec/reek/smell_detectors/uncommunicative_method_name_spec.rb
459
- - spec/reek/smell_detectors/uncommunicative_module_name_spec.rb
460
- - spec/reek/smell_detectors/uncommunicative_parameter_name_spec.rb
461
- - spec/reek/smell_detectors/uncommunicative_variable_name_spec.rb
462
- - spec/reek/smell_detectors/unused_parameters_spec.rb
463
- - spec/reek/smell_detectors/unused_private_method_spec.rb
464
- - spec/reek/smell_detectors/utility_function_spec.rb
465
- - spec/reek/smell_warning_spec.rb
466
- - spec/reek/source/source_code_spec.rb
467
- - spec/reek/source/source_locator_spec.rb
468
- - spec/reek/spec/should_reek_of_spec.rb
469
- - spec/reek/spec/should_reek_only_of_spec.rb
470
- - spec/reek/spec/should_reek_spec.rb
471
- - spec/reek/spec/smell_matcher_spec.rb
472
- - spec/reek/tree_dresser_spec.rb
473
- - spec/spec_helper.rb
474
- - tasks/configuration.rake
475
- - tasks/console.rake
476
- - tasks/reek.rake
477
- - tasks/rubocop.rake
478
- - tasks/test.rake
479
251
  homepage: https://github.com/troessner/reek
480
252
  licenses:
481
253
  - MIT
482
- metadata: {}
483
- post_install_message:
254
+ metadata:
255
+ homepage_uri: https://github.com/troessner/reek
256
+ source_code_uri: https://github.com/troessner/reek
257
+ bug_tracker_uri: https://github.com/troessner/reek/issues
258
+ changelog_uri: https://github.com/troessner/reek/CHANGELOG.md
259
+ documentation_uri: https://www.rubydoc.info/gems/reek
260
+ post_install_message:
484
261
  rdoc_options:
485
262
  - "--main"
486
263
  - README.md
@@ -492,15 +269,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
492
269
  requirements:
493
270
  - - ">="
494
271
  - !ruby/object:Gem::Version
495
- version: 2.3.0
272
+ version: 2.4.0
496
273
  required_rubygems_version: !ruby/object:Gem::Requirement
497
274
  requirements:
498
275
  - - ">="
499
276
  - !ruby/object:Gem::Version
500
277
  version: '0'
501
278
  requirements: []
502
- rubygems_version: 3.1.2
503
- signing_key:
279
+ rubygems_version: 3.2.3
280
+ signing_key:
504
281
  specification_version: 4
505
282
  summary: Code smell detector for Ruby
506
283
  test_files: []