reek 6.0.1 → 6.0.5

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 (237) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.github/workflows/ruby.yml +52 -0
  4. data/.rubocop.yml +2 -20
  5. data/.rubocop_todo.yml +27 -20
  6. data/CHANGELOG.md +22 -0
  7. data/CONTRIBUTING.md +3 -0
  8. data/Dockerfile +1 -1
  9. data/Gemfile +6 -6
  10. data/README.md +1 -1
  11. data/bin/code_climate_reek +2 -3
  12. data/lib/reek.rb +1 -0
  13. data/lib/reek/ast/ast_node_class_map.rb +1 -1
  14. data/lib/reek/ast/node.rb +1 -1
  15. data/lib/reek/cli/options.rb +1 -1
  16. data/lib/reek/configuration/app_configuration.rb +4 -3
  17. data/lib/reek/configuration/directory_directives.rb +2 -2
  18. data/lib/reek/configuration/excluded_paths.rb +2 -1
  19. data/lib/reek/context/code_context.rb +1 -1
  20. data/lib/reek/context/module_context.rb +3 -1
  21. data/lib/reek/context/refinement_context.rb +16 -0
  22. data/lib/reek/context_builder.rb +16 -2
  23. data/lib/reek/report/code_climate/code_climate_configuration.yml +1 -1
  24. data/lib/reek/report/code_climate/code_climate_formatter.rb +1 -3
  25. data/lib/reek/smell_detectors/base_detector.rb +1 -1
  26. data/lib/reek/smell_detectors/boolean_parameter.rb +3 -1
  27. data/lib/reek/smell_detectors/uncommunicative_variable_name.rb +1 -1
  28. data/lib/reek/smell_warning.rb +2 -3
  29. data/lib/reek/source/source_locator.rb +14 -13
  30. data/lib/reek/version.rb +1 -1
  31. data/reek.gemspec +14 -3
  32. metadata +29 -232
  33. data/.travis.yml +0 -36
  34. data/docs/API.md +0 -174
  35. data/docs/Attribute.md +0 -39
  36. data/docs/Basic-Smell-Options.md +0 -85
  37. data/docs/Boolean-Parameter.md +0 -54
  38. data/docs/Class-Variable.md +0 -40
  39. data/docs/Code-Smells.md +0 -39
  40. data/docs/Command-Line-Options.md +0 -119
  41. data/docs/Control-Couple.md +0 -26
  42. data/docs/Control-Parameter.md +0 -32
  43. data/docs/Data-Clump.md +0 -46
  44. data/docs/Duplicate-Method-Call.md +0 -264
  45. data/docs/Feature-Envy.md +0 -93
  46. data/docs/How-To-Write-New-Detectors.md +0 -132
  47. data/docs/How-reek-works-internally.md +0 -114
  48. data/docs/Instance-Variable-Assumption.md +0 -163
  49. data/docs/Irresponsible-Module.md +0 -47
  50. data/docs/Large-Class.md +0 -16
  51. data/docs/Long-Parameter-List.md +0 -39
  52. data/docs/Long-Yield-List.md +0 -37
  53. data/docs/Manual-Dispatch.md +0 -30
  54. data/docs/Missing-Safe-Method.md +0 -92
  55. data/docs/Module-Initialize.md +0 -62
  56. data/docs/Nested-Iterators.md +0 -59
  57. data/docs/Nil-Check.md +0 -47
  58. data/docs/RSpec-matchers.md +0 -129
  59. data/docs/Rake-Task.md +0 -66
  60. data/docs/Reek-4-to-Reek-5-migration.md +0 -188
  61. data/docs/Reek-Driven-Development.md +0 -46
  62. data/docs/Repeated-Conditional.md +0 -47
  63. data/docs/Simulated-Polymorphism.md +0 -16
  64. data/docs/Smell-Suppression.md +0 -96
  65. data/docs/Style-Guide.md +0 -19
  66. data/docs/Subclassed-From-Core-Class.md +0 -79
  67. data/docs/Too-Many-Constants.md +0 -37
  68. data/docs/Too-Many-Instance-Variables.md +0 -43
  69. data/docs/Too-Many-Methods.md +0 -56
  70. data/docs/Too-Many-Statements.md +0 -54
  71. data/docs/Uncommunicative-Method-Name.md +0 -94
  72. data/docs/Uncommunicative-Module-Name.md +0 -92
  73. data/docs/Uncommunicative-Name.md +0 -18
  74. data/docs/Uncommunicative-Parameter-Name.md +0 -90
  75. data/docs/Uncommunicative-Variable-Name.md +0 -96
  76. data/docs/Unused-Parameters.md +0 -28
  77. data/docs/Unused-Private-Method.md +0 -101
  78. data/docs/Utility-Function.md +0 -56
  79. data/docs/Versioning-Policy.md +0 -7
  80. data/docs/YAML-Reports.md +0 -93
  81. data/docs/defaults.reek.yml +0 -129
  82. data/docs/templates/default/docstring/html/public_api_marker.erb +0 -3
  83. data/docs/templates/default/docstring/setup.rb +0 -37
  84. data/docs/templates/default/fulldoc/html/css/common.css +0 -1
  85. data/docs/yard_plugin.rb +0 -17
  86. data/features/command_line_interface/basic_usage.feature +0 -15
  87. data/features/command_line_interface/options.feature +0 -123
  88. data/features/command_line_interface/show_progress.feature +0 -33
  89. data/features/command_line_interface/smell_selection.feature +0 -15
  90. data/features/command_line_interface/smells_count.feature +0 -38
  91. data/features/command_line_interface/stdin.feature +0 -65
  92. data/features/configuration_files/accept_setting.feature +0 -87
  93. data/features/configuration_files/directory_specific_directives.feature +0 -274
  94. data/features/configuration_files/exclude_directives.feature +0 -35
  95. data/features/configuration_files/exclude_paths_directives.feature +0 -42
  96. data/features/configuration_files/masking_smells.feature +0 -94
  97. data/features/configuration_files/mix_accept_reject_setting.feature +0 -84
  98. data/features/configuration_files/reject_setting.feature +0 -89
  99. data/features/configuration_files/schema_validation.feature +0 -59
  100. data/features/configuration_files/show_configuration_file.feature +0 -44
  101. data/features/configuration_files/unused_private_method.feature +0 -68
  102. data/features/configuration_loading.feature +0 -91
  103. data/features/configuration_via_source_comments/erroneous_source_comments.feature +0 -68
  104. data/features/configuration_via_source_comments/well_formed_source_comments.feature +0 -116
  105. data/features/locales.feature +0 -32
  106. data/features/programmatic_access.feature +0 -41
  107. data/features/rake_task/rake_task.feature +0 -138
  108. data/features/reports/codeclimate.feature +0 -59
  109. data/features/reports/json.feature +0 -59
  110. data/features/reports/reports.feature +0 -219
  111. data/features/reports/yaml.feature +0 -52
  112. data/features/rspec_matcher.feature +0 -41
  113. data/features/samples.feature +0 -305
  114. data/features/step_definitions/.rubocop.yml +0 -5
  115. data/features/step_definitions/reek_steps.rb +0 -102
  116. data/features/step_definitions/sample_file_steps.rb +0 -63
  117. data/features/support/env.rb +0 -33
  118. data/features/todo_list.feature +0 -108
  119. data/samples/checkstyle.xml +0 -7
  120. data/samples/clean_source/clean.rb +0 -6
  121. data/samples/configuration/accepts_rejects_and_excludes_for_detectors.reek.yml +0 -29
  122. data/samples/configuration/accepts_rejects_and_excludes_for_directory_directives.reek.yml +0 -30
  123. data/samples/configuration/corrupt.reek +0 -1
  124. data/samples/configuration/empty.reek +0 -0
  125. data/samples/configuration/full_configuration.reek +0 -13
  126. data/samples/configuration/full_mask.reek +0 -6
  127. data/samples/configuration/home/home.reek.yml +0 -4
  128. data/samples/configuration/partial_mask.reek +0 -4
  129. data/samples/configuration/regular_configuration/.reek.yml +0 -4
  130. data/samples/configuration/regular_configuration/empty_sub_directory/.gitignore +0 -0
  131. data/samples/configuration/with_excluded_paths.reek +0 -5
  132. data/samples/no_config_file/.keep +0 -0
  133. data/samples/paths.rb +0 -5
  134. data/samples/smelly_source/inline.rb +0 -704
  135. data/samples/smelly_source/optparse.rb +0 -1788
  136. data/samples/smelly_source/redcloth.rb +0 -1130
  137. data/samples/smelly_source/ruby.rb +0 -368
  138. data/samples/smelly_source/smelly.rb +0 -7
  139. data/samples/source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb +0 -5
  140. data/samples/source_with_exclude_paths/nested/ignore_me_as_well/irresponsible_module.rb +0 -2
  141. data/samples/source_with_exclude_paths/nested/uncommunicative_parameter_name.rb +0 -6
  142. data/samples/source_with_exclude_paths/nested/uncommunicative_variable_name.rb +0 -6
  143. data/samples/source_with_hidden_directories/.hidden/hidden.rb +0 -1
  144. data/samples/source_with_hidden_directories/not_hidden.rb +0 -1
  145. data/samples/source_with_non_ruby_files/gibberish +0 -1
  146. data/samples/source_with_non_ruby_files/python_source.py +0 -1
  147. data/samples/source_with_non_ruby_files/ruby.rb +0 -6
  148. data/spec/performance/reek/smell_detectors/runtime_speed_spec.rb +0 -17
  149. data/spec/quality/documentation_spec.rb +0 -40
  150. data/spec/quality/reek_source_spec.rb +0 -11
  151. data/spec/reek/ast/node_spec.rb +0 -211
  152. data/spec/reek/ast/object_refs_spec.rb +0 -83
  153. data/spec/reek/ast/reference_collector_spec.rb +0 -47
  154. data/spec/reek/ast/sexp_extensions_spec.rb +0 -498
  155. data/spec/reek/cli/application_spec.rb +0 -168
  156. data/spec/reek/cli/command/report_command_spec.rb +0 -44
  157. data/spec/reek/cli/command/todo_list_command_spec.rb +0 -86
  158. data/spec/reek/cli/options_spec.rb +0 -51
  159. data/spec/reek/cli/silencer_spec.rb +0 -28
  160. data/spec/reek/code_comment_spec.rb +0 -184
  161. data/spec/reek/configuration/app_configuration_spec.rb +0 -195
  162. data/spec/reek/configuration/configuration_file_finder_spec.rb +0 -230
  163. data/spec/reek/configuration/default_directive_spec.rb +0 -13
  164. data/spec/reek/configuration/directory_directives_spec.rb +0 -122
  165. data/spec/reek/configuration/excluded_paths_spec.rb +0 -16
  166. data/spec/reek/configuration/rake_task_converter_spec.rb +0 -33
  167. data/spec/reek/configuration/schema_validator_spec.rb +0 -165
  168. data/spec/reek/context/code_context_spec.rb +0 -192
  169. data/spec/reek/context/ghost_context_spec.rb +0 -60
  170. data/spec/reek/context/method_context_spec.rb +0 -72
  171. data/spec/reek/context/module_context_spec.rb +0 -55
  172. data/spec/reek/context/root_context_spec.rb +0 -12
  173. data/spec/reek/context/statement_counter_spec.rb +0 -24
  174. data/spec/reek/context_builder_spec.rb +0 -457
  175. data/spec/reek/detector_repository_spec.rb +0 -22
  176. data/spec/reek/documentation_link_spec.rb +0 -20
  177. data/spec/reek/errors/base_error_spec.rb +0 -13
  178. data/spec/reek/examiner_spec.rb +0 -309
  179. data/spec/reek/logging_error_handler_spec.rb +0 -24
  180. data/spec/reek/rake/task_spec.rb +0 -56
  181. data/spec/reek/report/code_climate/code_climate_configuration_spec.rb +0 -22
  182. data/spec/reek/report/code_climate/code_climate_fingerprint_spec.rb +0 -126
  183. data/spec/reek/report/code_climate/code_climate_formatter_spec.rb +0 -51
  184. data/spec/reek/report/code_climate/code_climate_report_spec.rb +0 -56
  185. data/spec/reek/report/html_report_spec.rb +0 -19
  186. data/spec/reek/report/json_report_spec.rb +0 -58
  187. data/spec/reek/report/location_formatter_spec.rb +0 -32
  188. data/spec/reek/report/progress_formatter_spec.rb +0 -68
  189. data/spec/reek/report/text_report_spec.rb +0 -89
  190. data/spec/reek/report/xml_report_spec.rb +0 -24
  191. data/spec/reek/report/yaml_report_spec.rb +0 -55
  192. data/spec/reek/report_spec.rb +0 -28
  193. data/spec/reek/smell_configuration_spec.rb +0 -56
  194. data/spec/reek/smell_detectors/attribute_spec.rb +0 -197
  195. data/spec/reek/smell_detectors/base_detector_spec.rb +0 -50
  196. data/spec/reek/smell_detectors/boolean_parameter_spec.rb +0 -93
  197. data/spec/reek/smell_detectors/class_variable_spec.rb +0 -106
  198. data/spec/reek/smell_detectors/control_parameter_spec.rb +0 -300
  199. data/spec/reek/smell_detectors/data_clump_spec.rb +0 -134
  200. data/spec/reek/smell_detectors/duplicate_method_call_spec.rb +0 -211
  201. data/spec/reek/smell_detectors/feature_envy_spec.rb +0 -295
  202. data/spec/reek/smell_detectors/instance_variable_assumption_spec.rb +0 -96
  203. data/spec/reek/smell_detectors/irresponsible_module_spec.rb +0 -226
  204. data/spec/reek/smell_detectors/long_parameter_list_spec.rb +0 -61
  205. data/spec/reek/smell_detectors/long_yield_list_spec.rb +0 -49
  206. data/spec/reek/smell_detectors/manual_dispatch_spec.rb +0 -75
  207. data/spec/reek/smell_detectors/missing_safe_method_spec.rb +0 -68
  208. data/spec/reek/smell_detectors/module_initialize_spec.rb +0 -77
  209. data/spec/reek/smell_detectors/nested_iterators_spec.rb +0 -333
  210. data/spec/reek/smell_detectors/nil_check_spec.rb +0 -100
  211. data/spec/reek/smell_detectors/repeated_conditional_spec.rb +0 -100
  212. data/spec/reek/smell_detectors/subclassed_from_core_class_spec.rb +0 -77
  213. data/spec/reek/smell_detectors/too_many_constants_spec.rb +0 -144
  214. data/spec/reek/smell_detectors/too_many_instance_variables_spec.rb +0 -132
  215. data/spec/reek/smell_detectors/too_many_methods_spec.rb +0 -54
  216. data/spec/reek/smell_detectors/too_many_statements_spec.rb +0 -90
  217. data/spec/reek/smell_detectors/uncommunicative_method_name_spec.rb +0 -78
  218. data/spec/reek/smell_detectors/uncommunicative_module_name_spec.rb +0 -78
  219. data/spec/reek/smell_detectors/uncommunicative_parameter_name_spec.rb +0 -147
  220. data/spec/reek/smell_detectors/uncommunicative_variable_name_spec.rb +0 -201
  221. data/spec/reek/smell_detectors/unused_parameters_spec.rb +0 -114
  222. data/spec/reek/smell_detectors/unused_private_method_spec.rb +0 -205
  223. data/spec/reek/smell_detectors/utility_function_spec.rb +0 -293
  224. data/spec/reek/smell_warning_spec.rb +0 -137
  225. data/spec/reek/source/source_code_spec.rb +0 -79
  226. data/spec/reek/source/source_locator_spec.rb +0 -166
  227. data/spec/reek/spec/should_reek_of_spec.rb +0 -153
  228. data/spec/reek/spec/should_reek_only_of_spec.rb +0 -91
  229. data/spec/reek/spec/should_reek_spec.rb +0 -52
  230. data/spec/reek/spec/smell_matcher_spec.rb +0 -87
  231. data/spec/reek/tree_dresser_spec.rb +0 -46
  232. data/spec/spec_helper.rb +0 -110
  233. data/tasks/configuration.rake +0 -19
  234. data/tasks/console.rake +0 -5
  235. data/tasks/reek.rake +0 -6
  236. data/tasks/rubocop.rake +0 -11
  237. data/tasks/test.rake +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 107593e309020bb2745d630599f8bf33bde2c9f708877895465cd12360267f82
4
- data.tar.gz: 61290a2608c069e4c5977720e5a1d99fe8d4e716dfaa8503c0491b226790a8a7
3
+ metadata.gz: 23929fdfa24a401c782d5390e43941b9a3829ed51083e2f1b7d6bcfe1280cd4e
4
+ data.tar.gz: 24ce8ccc73f1db8f7f2571d80d14ae95ba52060efd37f2d76af39a8bdaf0f177
5
5
  SHA512:
6
- metadata.gz: '09025ee922070bcb0c415f82fd5591e6658610a661ae4fc24abb472f16df6c3ed222fcfd84f81500a1951cadfabfb33b5c9414e26164f67cc140699774a9d2e7'
7
- data.tar.gz: 7b9af8e1a09c5722fbedd946389411dee5aa7a5b98f03f48330a9d7f76d4c126bf170fff94955af6abe7a3a6c2e4b1b046c1fd1b8e304ee678a0fbecb52919f1
6
+ metadata.gz: 147a1013216674c7ead0cea2299ccaa37ccd89d2f409f11f65cf64706f747b96bbe06364059391a8f252c05fba3c2a9f7b4f314f424e92af5673ecc8eae20b74
7
+ data.tar.gz: 2255554dbf2f7c1b3bb11daa8da1b7956c2ce1bb4a9c02da420f0db24fd285c8857dbbdf4b04616029ff1b0ed30bdd857012435d8557e6e1a7237d9c38887710
@@ -0,0 +1,9 @@
1
+ # Documentation for all configuration options:
2
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
3
+
4
+ version: 2
5
+ updates:
6
+ - package-ecosystem: "bundler"
7
+ directory: "/"
8
+ schedule:
9
+ interval: "daily"
@@ -0,0 +1,52 @@
1
+ # This workflow will download a prebuilt Ruby version, install dependencies and
2
+ # run tests with Rake
3
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
4
+
5
+ name: Ruby
6
+
7
+ on:
8
+ push:
9
+ branches: [ master ]
10
+ pull_request:
11
+ branches: [ master ]
12
+
13
+ jobs:
14
+ test:
15
+
16
+ runs-on: ubuntu-latest
17
+
18
+ strategy:
19
+ matrix:
20
+ ruby: [2.4, 2.5, 2.6, 2.7, jruby-9.2]
21
+
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+ - name: Set up Ruby
25
+ uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: ${{ matrix.ruby }}
28
+ bundler-cache: true
29
+ - name: Run specs
30
+ run: bundle exec rake test:spec
31
+ - name: Run performance tests
32
+ run: bundle exec rake test:performance
33
+ - name: Update default configuration
34
+ run: bundle exec rake configuration:update_default_configuration
35
+ - name: Run cucumber features
36
+ run: bundle exec rake test:features
37
+ - name: Run code quality specs
38
+ run: bundle exec rake test:quality
39
+
40
+ rubocop:
41
+
42
+ runs-on: ubuntu-latest
43
+
44
+ steps:
45
+ - uses: actions/checkout@v2
46
+ - name: Set up Ruby
47
+ uses: ruby/setup-ruby@v1
48
+ with:
49
+ ruby-version: 2.7
50
+ bundler-cache: true
51
+ - name: Run RuboCop
52
+ run: bundle exec rubocop -P
data/.rubocop.yml CHANGED
@@ -9,6 +9,7 @@ AllCops:
9
9
  - 'samples/**/*'
10
10
  - 'tmp/**/*'
11
11
  - 'vendor/**/*'
12
+ NewCops: enable
12
13
  TargetRubyVersion: 2.4
13
14
 
14
15
  # Tables are nice
@@ -57,6 +58,7 @@ Lint/BooleanSymbol:
57
58
  # Spec blocks can be any size
58
59
  Metrics/BlockLength:
59
60
  Exclude:
61
+ - '**/*.gemspec'
60
62
  - 'spec/**/*'
61
63
 
62
64
  # Keyword arguments make long parameter lists readable
@@ -130,23 +132,3 @@ Style/WordArray:
130
132
  Metrics/ClassLength:
131
133
  Exclude:
132
134
  - 'lib/reek/cli/options.rb'
133
-
134
- # Activate new cops from RuboCop 0.80 - 0.83
135
- Lint/RaiseException:
136
- Enabled: true
137
- Lint/StructNewOverride:
138
- Enabled: true
139
- Layout/EmptyLinesAroundAttributeAccessor:
140
- Enabled: true
141
- Layout/SpaceAroundMethodCallOperator:
142
- Enabled: true
143
- Style/ExponentialNotation:
144
- Enabled: true
145
- Style/HashEachMethods:
146
- Enabled: true
147
- Style/HashTransformKeys:
148
- Enabled: true
149
- Style/HashTransformValues:
150
- Enabled: true
151
- Style/SlicingWithRange:
152
- Enabled: true
data/.rubocop_todo.yml CHANGED
@@ -1,22 +1,36 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-12-22 13:19:30 +0100 using RuboCop version 0.78.0.
3
+ # on 2021-01-03 18:17:11 UTC using RuboCop version 1.7.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 3
9
+ # Offense count: 2
10
+ Lint/MissingSuper:
11
+ Exclude:
12
+ - 'lib/reek/rake/task.rb'
13
+ - 'lib/reek/smell_detectors/base_detector.rb'
14
+
15
+ # Offense count: 2
16
+ # Configuration parameters: IgnoredPatterns.
17
+ # IgnoredPatterns: (?-mix:(exactly|at_least|at_most)\(\d+\)\.times)
18
+ Lint/UnreachableLoop:
19
+ Exclude:
20
+ - 'spec/reek/ast/node_spec.rb'
21
+
22
+ # Offense count: 2
23
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
10
24
  Metrics/AbcSize:
11
25
  Max: 21
12
26
 
13
27
  # Offense count: 1
14
- # Configuration parameters: CountComments.
28
+ # Configuration parameters: CountComments, CountAsOne.
15
29
  Metrics/ClassLength:
16
- Max: 161
30
+ Max: 170
17
31
 
18
- # Offense count: 14
19
- # Configuration parameters: CountComments, ExcludedMethods.
32
+ # Offense count: 13
33
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
20
34
  Metrics/MethodLength:
21
35
  Max: 16
22
36
 
@@ -25,17 +39,6 @@ RSpec/AnyInstance:
25
39
  Exclude:
26
40
  - 'spec/reek/cli/application_spec.rb'
27
41
 
28
- # Offense count: 1
29
- # Configuration parameters: CustomIncludeMethods.
30
- RSpec/EmptyExampleGroup:
31
- Exclude:
32
- - 'spec/factories/factories.rb'
33
-
34
- # Offense count: 1
35
- RSpec/MissingExampleGroupArgument:
36
- Exclude:
37
- - 'spec/factories/factories.rb'
38
-
39
42
  # Offense count: 4
40
43
  RSpec/MultipleDescribes:
41
44
  Exclude:
@@ -44,12 +47,16 @@ RSpec/MultipleDescribes:
44
47
  - 'spec/reek/report/location_formatter_spec.rb'
45
48
  - 'spec/reek/report/progress_formatter_spec.rb'
46
49
 
47
- # Offense count: 32
48
- # Configuration parameters: AggregateFailuresByDefault.
50
+ # Offense count: 30
49
51
  RSpec/MultipleExpectations:
50
52
  Max: 5
51
53
 
52
- # Offense count: 25
54
+ # Offense count: 16
55
+ # Configuration parameters: AllowSubject.
56
+ RSpec/MultipleMemoizedHelpers:
57
+ Max: 9
58
+
59
+ # Offense count: 27
53
60
  RSpec/NestedGroups:
54
61
  Max: 5
55
62
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Change log
2
2
 
3
+ ## 6.0.5 (2021-08-01)
4
+
5
+ * (dependabot) Loosen dependency on psych
6
+ * (Nicolás Ferrari) Fix bugs when used by codeclimate
7
+
8
+ ## 6.0.4 (2021-04-27)
9
+
10
+ * (Nicolás Ferrari) Add build-base to Dockerfile
11
+ * (Masataka Pocke Kuwabara and Daniel Santos Dantas) Reduce gem package size
12
+
13
+ ## 6.0.3 (2021-01-11)
14
+
15
+ * (mvz) Require parser 3.0
16
+ * (mvz) In a refinement, assign smells to the refined module or class
17
+
18
+ ## 6.0.2 (2020-10-17)
19
+
20
+ * (mvz) Loosen dependency on psych. This should resolve installation problems on
21
+ mingw32
22
+ * (Cesario Uy) Fix typo in docs for "Boolean Parameter" smell
23
+ * (mvz) Set link metadata in gemspec
24
+
3
25
  ## 6.0.1 (2020-05-26)
4
26
 
5
27
  * (Maxim Pertsov) Handle absolute paths for directories correctly
data/CONTRIBUTING.md CHANGED
@@ -27,6 +27,9 @@ version, Ruby platform (MRI, JRuby, etc.), operating system.
27
27
  Try to provide a minimal example that reproduces the issue.
28
28
  Extra kudos if you can write it as a failing test. :)
29
29
 
30
+ Make sure any code examples and output are properly formatted
31
+ using [code blocks](https://github.github.com/gfm/#fenced-code-blocks).
32
+
30
33
  ## Contributing features, bugfixes, documentation
31
34
 
32
35
  ### Getting started
data/Dockerfile CHANGED
@@ -11,7 +11,7 @@ ENV code_dir /code
11
11
  ENV app_dir /usr/src/app
12
12
  ENV user app
13
13
 
14
- RUN apk --update add git
14
+ RUN apk --update add git build-base
15
15
  ADD . ${app_dir}
16
16
 
17
17
  RUN adduser -u 9000 -D ${user}
data/Gemfile CHANGED
@@ -7,16 +7,16 @@ ruby RUBY_VERSION
7
7
  group :development do
8
8
  gem 'aruba', '~> 1.0'
9
9
  gem 'codeclimate-engine-rb', '~> 0.4.0'
10
- gem 'cucumber', '~> 3.0'
10
+ gem 'cucumber', ['>= 4.0', '< 7.0']
11
11
  gem 'kramdown', '~> 2.1'
12
12
  gem 'kramdown-parser-gfm', '~> 1.0'
13
13
  gem 'rake', '~> 13.0'
14
14
  gem 'rspec', '~> 3.0'
15
15
  gem 'rspec-benchmark', '~> 0.6.0'
16
- gem 'rubocop', '~> 0.83.0'
17
- gem 'rubocop-performance', '~> 1.5.0'
18
- gem 'rubocop-rspec', '~> 1.39.0'
19
- gem 'simplecov', '~> 0.18.1'
16
+ gem 'rubocop', '~> 1.12.0'
17
+ gem 'rubocop-performance', '~> 1.10.1'
18
+ gem 'rubocop-rspec', '~> 2.2.0'
19
+ gem 'simplecov', ['>= 0.18.0', '< 0.22.0']
20
20
  gem 'yard', '~> 0.9.5'
21
21
 
22
22
  platforms :mri do
@@ -25,5 +25,5 @@ group :development do
25
25
  end
26
26
 
27
27
  group :debugging do
28
- gem 'pry', '~> 0.13.0'
28
+ gem 'pry', '~> 0.14.0'
29
29
  end
data/README.md CHANGED
@@ -373,7 +373,7 @@ are documented in the corresponding smell type /docs page (if you want to get a
373
373
  configurations you can also check out [the `defaults.reek.yml` file in this repository](docs/defaults.reek.yml).
374
374
 
375
375
  Note that you do not need a configuration file at all.
376
- If you're fine with all the [defaults.reek.yml](docs/defaults.reek.yml) we set you can skip this completely.
376
+ If you're fine with all the [defaults](docs/defaults.reek.yml) we set you can skip this completely.
377
377
 
378
378
  Don't worry about introducing a mistake in your configuration file that might go unnoticed - Reek uses a
379
379
  schema to validate your configuration against on start up and will faily loudly in case you
@@ -14,15 +14,14 @@ class CodeClimateToReek
14
14
  # we have to exit with a zero for both failure and success.
15
15
  ENGINE_CONFIGURATION = [
16
16
  '--failure-exit-code', '0',
17
- '--success-exit-code', '0',
18
- '.'
17
+ '--success-exit-code', '0'
19
18
  ].freeze
20
19
 
21
20
  attr_reader :configuration_file_path, :include_paths_key, :include_paths_default
22
21
 
23
22
  def initialize(configuration_file_path: '/config.json',
24
23
  include_paths_key: 'include_paths',
25
- include_paths_default: [])
24
+ include_paths_default: ['.'])
26
25
  @configuration_file_path = configuration_file_path
27
26
  @include_paths_key = include_paths_key
28
27
  @include_paths_default = include_paths_default
data/lib/reek.rb CHANGED
@@ -8,6 +8,7 @@ require_relative 'reek/examiner'
8
8
  require_relative 'reek/report'
9
9
 
10
10
  module Reek
11
+ DEFAULT_SMELL_CONFIGURATION = File.join(__dir__, '../docs/defaults.reek.yml').freeze
11
12
  DEFAULT_CONFIGURATION_FILE_NAME = '.reek.yml'
12
13
  DETECTORS_KEY = 'detectors'
13
14
  EXCLUDE_PATHS_KEY = 'exclude_paths'
@@ -30,7 +30,7 @@ module Reek
30
30
  SexpExtensions.const_get(const)
31
31
  ]
32
32
  end
33
- Hash[assoc]
33
+ assoc.to_h
34
34
  end
35
35
  end
36
36
 
data/lib/reek/ast/node.rb CHANGED
@@ -60,7 +60,7 @@ module Reek
60
60
  #
61
61
  # Returns an array with all matching nodes.
62
62
  def each_node(target_types, ignoring = [], &blk)
63
- return enum_for(:each_node, target_types, ignoring) unless block_given?
63
+ return enum_for(:each_node, target_types, ignoring) unless blk
64
64
 
65
65
  look_for(Array(target_types), ignoring, &blk)
66
66
  end
@@ -87,7 +87,7 @@ module Reek
87
87
 
88
88
  def set_banner
89
89
  program_name = parser.program_name
90
- parser.banner = <<-BANNER.gsub(/^[ ]+/, '')
90
+ parser.banner = <<-BANNER.gsub(/^ +/, '')
91
91
  Usage: #{program_name} [options] [files]
92
92
 
93
93
  Examples:
@@ -72,11 +72,12 @@ module Reek
72
72
 
73
73
  def load_values(values)
74
74
  values.each do |key, value|
75
- if key == EXCLUDE_PATHS_KEY
75
+ case key
76
+ when EXCLUDE_PATHS_KEY
76
77
  excluded_paths.add value
77
- elsif key == DIRECTORIES_KEY
78
+ when DIRECTORIES_KEY
78
79
  directory_directives.add value
79
- elsif key == DETECTORS_KEY
80
+ when DETECTORS_KEY
80
81
  default_directive.add value
81
82
  end
82
83
  end
@@ -84,7 +84,7 @@ module Reek
84
84
  gsub('<<to_eol_wildcards>>', '.*').
85
85
  gsub('<<to_wildcards>>', '.*')
86
86
  else
87
- glob + '.*'
87
+ "#{glob}.*"
88
88
  end
89
89
 
90
90
  Regexp.new("^#{regexp}$", Regexp::IGNORECASE)
@@ -92,7 +92,7 @@ module Reek
92
92
 
93
93
  def error_message_for_invalid_smell_type(klass)
94
94
  "You are trying to configure smell type #{klass} but we can't find one with that name.\n" \
95
- "Please make sure you spelled it right. (See 'docs/defaults.reek' in the Reek\n" \
95
+ "Please make sure you spelled it right. (See 'docs/defaults.reek.yml' in the Reek\n" \
96
96
  'repository for a list of all available smell types.)'
97
97
  end
98
98
  end
@@ -14,7 +14,8 @@ module Reek
14
14
  # @param paths [String]
15
15
  # @return [undefined]
16
16
  def add(paths)
17
- paths.each { |path| self << Pathname(path) }
17
+ paths.flat_map { |path| Dir[path] }.
18
+ each { |path| self << Pathname(path) }
18
19
  end
19
20
  end
20
21
  end
@@ -51,7 +51,7 @@ module Reek
51
51
  # @return [Enumerator]
52
52
  #
53
53
  def each(&block)
54
- return enum_for(:each) unless block_given?
54
+ return enum_for(:each) unless block
55
55
 
56
56
  yield self
57
57
  children.each do |child|
@@ -66,6 +66,8 @@ module Reek
66
66
  CodeComment.new(comment: exp.leading_comment).descriptive?
67
67
  end
68
68
 
69
+ CONSTANT_SEXP_TYPES = [:casgn, :class, :module].freeze
70
+
69
71
  # A namespace module is a module (or class) that is only there for namespacing
70
72
  # purposes, and thus contains only nested constants, modules or classes.
71
73
  #
@@ -78,7 +80,7 @@ module Reek
78
80
  return false if exp.type == :casgn
79
81
 
80
82
  children = exp.direct_children
81
- children.any? && children.all? { |child| [:casgn, :class, :module].include? child.type }
83
+ children.any? && children.all? { |child| CONSTANT_SEXP_TYPES.include? child.type }
82
84
  end
83
85
 
84
86
  def track_visibility(visibility, names)
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'module_context'
4
+
5
+ module Reek
6
+ module Context
7
+ #
8
+ # A context wrapper for any refinement blocks found in a syntax tree.
9
+ #
10
+ class RefinementContext < ModuleContext
11
+ def full_name
12
+ exp.call.args.first.name
13
+ end
14
+ end
15
+ end
16
+ end
@@ -5,6 +5,7 @@ require_relative 'context/class_context'
5
5
  require_relative 'context/ghost_context'
6
6
  require_relative 'context/method_context'
7
7
  require_relative 'context/module_context'
8
+ require_relative 'context/refinement_context'
8
9
  require_relative 'context/root_context'
9
10
  require_relative 'context/send_context'
10
11
  require_relative 'context/singleton_attribute_context'
@@ -20,7 +21,7 @@ module Reek
20
21
  # counting. Ideally `ContextBuilder` would only build up the context tree and leave the
21
22
  # statement and reference counting to the contexts.
22
23
  #
23
- # @quality :reek:TooManyMethods { max_methods: 31 }
24
+ # @quality :reek:TooManyMethods { max_methods: 32 }
24
25
  # @quality :reek:UnusedPrivateMethod { exclude: [ !ruby/regexp /process_/ ] }
25
26
  # @quality :reek:DataClump
26
27
  class ContextBuilder
@@ -263,9 +264,16 @@ module Reek
263
264
  #
264
265
  # Counts non-empty blocks as one statement.
265
266
  #
267
+ # A refinement block is handled differently and causes a RefinementContext
268
+ # to be opened.
269
+ #
266
270
  def process_block(exp, _parent)
267
271
  increase_statement_count_by(exp.block)
268
- process(exp)
272
+ if exp.call.name == :refine
273
+ handle_refinement_block(exp)
274
+ else
275
+ process(exp)
276
+ end
269
277
  end
270
278
 
271
279
  # Handles `begin` and `kwbegin` nodes. `begin` nodes are created implicitly
@@ -508,6 +516,12 @@ module Reek
508
516
  end
509
517
  end
510
518
 
519
+ def handle_refinement_block(exp)
520
+ inside_new_context(Context::RefinementContext, exp) do
521
+ process(exp)
522
+ end
523
+ end
524
+
511
525
  def handle_send_for_modules(exp)
512
526
  arg_names = exp.args.map { |arg| arg.children.first }
513
527
  current_context.track_visibility(exp.name, arg_names)