reek 4.7.1 → 5.0.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 (260) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +17 -12
  3. data/.rubocop.yml +36 -7
  4. data/.simplecov +1 -0
  5. data/.travis.yml +3 -9
  6. data/.yardopts +1 -1
  7. data/CHANGELOG.md +59 -0
  8. data/CONTRIBUTING.md +1 -1
  9. data/Gemfile +5 -5
  10. data/README.md +134 -104
  11. data/Rakefile +16 -3
  12. data/bin/reek +1 -3
  13. data/docs/API.md +2 -9
  14. data/docs/Basic-Smell-Options.md +51 -11
  15. data/docs/Code-Smells.md +1 -1
  16. data/docs/Command-Line-Options.md +14 -4
  17. data/docs/Duplicate-Method-Call.md +49 -1
  18. data/docs/Feature-Envy.md +44 -0
  19. data/docs/How-To-Write-New-Detectors.md +7 -7
  20. data/docs/Instance-Variable-Assumption.md +1 -1
  21. data/docs/{Prima-Donna-Method.md → Missing-Safe-Method.md} +11 -9
  22. data/docs/Rake-Task.md +1 -1
  23. data/docs/Reek-4-to-Reek-5-migration.md +193 -0
  24. data/docs/Reek-Driven-Development.md +1 -1
  25. data/docs/Uncommunicative-Method-Name.md +45 -6
  26. data/docs/Uncommunicative-Module-Name.md +49 -7
  27. data/docs/Uncommunicative-Parameter-Name.md +43 -5
  28. data/docs/Uncommunicative-Variable-Name.md +73 -2
  29. data/docs/Unused-Private-Method.md +3 -3
  30. data/docs/defaults.reek.yml +129 -0
  31. data/docs/yard_plugin.rb +1 -0
  32. data/features/command_line_interface/basic_usage.feature +2 -2
  33. data/features/command_line_interface/options.feature +46 -4
  34. data/features/command_line_interface/show_progress.feature +4 -4
  35. data/features/command_line_interface/smell_selection.feature +1 -1
  36. data/features/command_line_interface/smells_count.feature +6 -6
  37. data/features/command_line_interface/stdin.feature +30 -8
  38. data/features/configuration_files/accept_setting.feature +45 -28
  39. data/features/configuration_files/directory_specific_directives.feature +80 -75
  40. data/features/configuration_files/exclude_directives.feature +11 -10
  41. data/features/configuration_files/exclude_paths_directives.feature +4 -4
  42. data/features/configuration_files/masking_smells.feature +38 -9
  43. data/features/configuration_files/mix_accept_reject_setting.feature +31 -28
  44. data/features/configuration_files/reject_setting.feature +52 -41
  45. data/features/configuration_files/schema_validation.feature +59 -0
  46. data/features/configuration_files/unused_private_method.feature +18 -16
  47. data/features/configuration_loading.feature +53 -10
  48. data/features/configuration_via_source_comments/erroneous_source_comments.feature +3 -3
  49. data/features/configuration_via_source_comments/well_formed_source_comments.feature +2 -2
  50. data/features/locales.feature +32 -0
  51. data/features/rake_task/rake_task.feature +58 -18
  52. data/features/reports/json.feature +3 -3
  53. data/features/reports/reports.feature +34 -34
  54. data/features/reports/yaml.feature +3 -3
  55. data/features/rspec_matcher.feature +40 -0
  56. data/features/samples.feature +287 -287
  57. data/features/step_definitions/reek_steps.rb +2 -2
  58. data/features/step_definitions/sample_file_steps.rb +9 -4
  59. data/features/support/env.rb +2 -11
  60. data/features/todo_list.feature +26 -23
  61. data/lib/reek/ast/builder.rb +1 -1
  62. data/lib/reek/ast/node.rb +40 -58
  63. data/lib/reek/ast/object_refs.rb +1 -1
  64. data/lib/reek/ast/reference_collector.rb +2 -4
  65. data/lib/reek/ast/sexp_extensions/case.rb +1 -1
  66. data/lib/reek/ast/sexp_extensions/if.rb +8 -1
  67. data/lib/reek/ast/sexp_extensions/logical_operators.rb +1 -1
  68. data/lib/reek/ast/sexp_extensions/methods.rb +4 -6
  69. data/lib/reek/ast/sexp_extensions/send.rb +0 -4
  70. data/lib/reek/cli/application.rb +4 -3
  71. data/lib/reek/cli/command/report_command.rb +1 -2
  72. data/lib/reek/cli/command/todo_list_command.rb +8 -8
  73. data/lib/reek/cli/options.rb +31 -16
  74. data/lib/reek/cli/silencer.rb +14 -3
  75. data/lib/reek/code_comment.rb +14 -16
  76. data/lib/reek/configuration/app_configuration.rb +32 -27
  77. data/lib/reek/configuration/configuration_converter.rb +110 -0
  78. data/lib/reek/configuration/configuration_file_finder.rb +16 -41
  79. data/lib/reek/configuration/configuration_validator.rb +12 -23
  80. data/lib/reek/configuration/default_directive.rb +17 -3
  81. data/lib/reek/configuration/directory_directives.rb +17 -11
  82. data/lib/reek/configuration/excluded_paths.rb +1 -1
  83. data/lib/reek/configuration/rake_task_converter.rb +29 -0
  84. data/lib/reek/configuration/schema.yml +210 -0
  85. data/lib/reek/configuration/schema_validator.rb +38 -0
  86. data/lib/reek/context/attribute_context.rb +3 -3
  87. data/lib/reek/context/code_context.rb +47 -43
  88. data/lib/reek/context/ghost_context.rb +0 -2
  89. data/lib/reek/context/method_context.rb +22 -15
  90. data/lib/reek/context/module_context.rb +5 -9
  91. data/lib/reek/context/root_context.rb +0 -4
  92. data/lib/reek/context/send_context.rb +2 -2
  93. data/lib/reek/context_builder.rb +43 -44
  94. data/lib/reek/detector_repository.rb +11 -11
  95. data/lib/reek/documentation_link.rb +28 -0
  96. data/lib/reek/errors/bad_detector_configuration_key_in_comment_error.rb +14 -13
  97. data/lib/reek/errors/bad_detector_in_comment_error.rb +12 -11
  98. data/lib/reek/errors/base_error.rb +3 -0
  99. data/lib/reek/errors/config_file_error.rb +11 -0
  100. data/lib/reek/errors/encoding_error.rb +43 -0
  101. data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +13 -12
  102. data/lib/reek/errors/incomprehensible_source_error.rb +22 -24
  103. data/lib/reek/errors/syntax_error.rb +41 -0
  104. data/lib/reek/examiner.rb +24 -26
  105. data/lib/reek/logging_error_handler.rb +7 -5
  106. data/lib/reek/rake/task.rb +8 -4
  107. data/lib/reek/report/base_report.rb +8 -12
  108. data/lib/reek/report/code_climate/code_climate_configuration.rb +1 -1
  109. data/lib/reek/report/code_climate/code_climate_configuration.yml +6 -10
  110. data/lib/reek/report/documentation_link_warning_formatter.rb +17 -0
  111. data/lib/reek/report/heading_formatter.rb +54 -0
  112. data/lib/reek/report/json_report.rb +1 -1
  113. data/lib/reek/report/location_formatter.rb +40 -0
  114. data/lib/reek/report/progress_formatter.rb +79 -0
  115. data/lib/reek/report/simple_warning_formatter.rb +34 -0
  116. data/lib/reek/report/text_report.rb +1 -2
  117. data/lib/reek/report/xml_report.rb +3 -3
  118. data/lib/reek/report/yaml_report.rb +1 -1
  119. data/lib/reek/report.rb +15 -10
  120. data/lib/reek/smell_configuration.rb +2 -2
  121. data/lib/reek/smell_detectors/attribute.rb +5 -11
  122. data/lib/reek/smell_detectors/base_detector.rb +30 -26
  123. data/lib/reek/smell_detectors/boolean_parameter.rb +3 -5
  124. data/lib/reek/smell_detectors/class_variable.rb +5 -14
  125. data/lib/reek/smell_detectors/control_parameter.rb +18 -33
  126. data/lib/reek/smell_detectors/data_clump.rb +15 -9
  127. data/lib/reek/smell_detectors/duplicate_method_call.rb +23 -17
  128. data/lib/reek/smell_detectors/feature_envy.rb +9 -7
  129. data/lib/reek/smell_detectors/instance_variable_assumption.rb +14 -23
  130. data/lib/reek/smell_detectors/irresponsible_module.rb +5 -12
  131. data/lib/reek/smell_detectors/long_parameter_list.rb +10 -7
  132. data/lib/reek/smell_detectors/long_yield_list.rb +10 -7
  133. data/lib/reek/smell_detectors/manual_dispatch.rb +4 -5
  134. data/lib/reek/smell_detectors/{prima_donna_method.rb → missing_safe_method.rb} +20 -20
  135. data/lib/reek/smell_detectors/module_initialize.rb +3 -5
  136. data/lib/reek/smell_detectors/nested_iterators.rb +16 -24
  137. data/lib/reek/smell_detectors/nil_check.rb +8 -15
  138. data/lib/reek/smell_detectors/repeated_conditional.rb +13 -11
  139. data/lib/reek/smell_detectors/subclassed_from_core_class.rb +7 -8
  140. data/lib/reek/smell_detectors/too_many_constants.rb +10 -9
  141. data/lib/reek/smell_detectors/too_many_instance_variables.rb +10 -6
  142. data/lib/reek/smell_detectors/too_many_methods.rb +11 -7
  143. data/lib/reek/smell_detectors/too_many_statements.rb +10 -6
  144. data/lib/reek/smell_detectors/uncommunicative_method_name.rb +10 -11
  145. data/lib/reek/smell_detectors/uncommunicative_module_name.rb +14 -18
  146. data/lib/reek/smell_detectors/uncommunicative_parameter_name.rb +17 -22
  147. data/lib/reek/smell_detectors/uncommunicative_variable_name.rb +26 -27
  148. data/lib/reek/smell_detectors/unused_parameters.rb +4 -6
  149. data/lib/reek/smell_detectors/unused_private_method.rb +11 -18
  150. data/lib/reek/smell_detectors/utility_function.rb +12 -16
  151. data/lib/reek/smell_detectors.rb +1 -2
  152. data/lib/reek/smell_warning.rb +15 -8
  153. data/lib/reek/source/source_code.rb +57 -58
  154. data/lib/reek/source/source_locator.rb +8 -8
  155. data/lib/reek/spec/should_reek.rb +2 -2
  156. data/lib/reek/spec/should_reek_of.rb +9 -16
  157. data/lib/reek/spec/should_reek_only_of.rb +4 -4
  158. data/lib/reek/spec.rb +6 -6
  159. data/lib/reek/tree_dresser.rb +8 -8
  160. data/lib/reek/version.rb +1 -1
  161. data/reek.gemspec +5 -7
  162. data/samples/checkstyle.xml +1 -1
  163. data/samples/configuration/accepts_rejects_and_excludes_for_detectors.reek.yml +29 -0
  164. data/samples/configuration/accepts_rejects_and_excludes_for_directory_directives.reek.yml +30 -0
  165. data/samples/configuration/full_configuration.reek +8 -4
  166. data/samples/configuration/full_mask.reek +5 -4
  167. data/samples/configuration/partial_mask.reek +3 -2
  168. data/samples/configuration/regular_configuration/.reek.yml +4 -0
  169. data/samples/paths.rb +5 -4
  170. data/samples/source_with_hidden_directories/.hidden/hidden.rb +1 -0
  171. data/samples/source_with_hidden_directories/not_hidden.rb +1 -0
  172. data/spec/factories/factories.rb +2 -13
  173. data/spec/reek/ast/node_spec.rb +103 -10
  174. data/spec/reek/ast/reference_collector_spec.rb +1 -1
  175. data/spec/reek/ast/sexp_extensions_spec.rb +14 -34
  176. data/spec/reek/cli/application_spec.rb +52 -42
  177. data/spec/reek/cli/command/todo_list_command_spec.rb +6 -4
  178. data/spec/reek/cli/silencer_spec.rb +28 -0
  179. data/spec/reek/code_comment_spec.rb +31 -38
  180. data/spec/reek/configuration/app_configuration_spec.rb +46 -33
  181. data/spec/reek/configuration/configuration_file_finder_spec.rb +133 -51
  182. data/spec/reek/configuration/default_directive_spec.rb +1 -1
  183. data/spec/reek/configuration/directory_directives_spec.rb +6 -7
  184. data/spec/reek/configuration/excluded_paths_spec.rb +6 -6
  185. data/spec/reek/configuration/rake_task_converter_spec.rb +33 -0
  186. data/spec/reek/configuration/schema_validator_spec.rb +165 -0
  187. data/spec/reek/context/code_context_spec.rb +70 -106
  188. data/spec/reek/context/ghost_context_spec.rb +9 -9
  189. data/spec/reek/context/method_context_spec.rb +2 -2
  190. data/spec/reek/context/module_context_spec.rb +3 -3
  191. data/spec/reek/context/root_context_spec.rb +1 -1
  192. data/spec/reek/context_builder_spec.rb +20 -0
  193. data/spec/reek/documentation_link_spec.rb +20 -0
  194. data/spec/reek/errors/base_error_spec.rb +13 -0
  195. data/spec/reek/examiner_spec.rb +136 -29
  196. data/spec/reek/rake/task_spec.rb +25 -2
  197. data/spec/reek/report/code_climate/code_climate_fingerprint_spec.rb +82 -80
  198. data/spec/reek/report/code_climate/code_climate_formatter_spec.rb +6 -6
  199. data/spec/reek/report/json_report_spec.rb +13 -46
  200. data/spec/reek/report/{formatter/location_formatter_spec.rb → location_formatter_spec.rb} +5 -5
  201. data/spec/reek/report/{formatter/progress_formatter_spec.rb → progress_formatter_spec.rb} +4 -4
  202. data/spec/reek/report/text_report_spec.rb +4 -4
  203. data/spec/reek/report/xml_report_spec.rb +3 -3
  204. data/spec/reek/report/yaml_report_spec.rb +9 -38
  205. data/spec/reek/report_spec.rb +3 -3
  206. data/spec/reek/smell_detectors/base_detector_spec.rb +4 -5
  207. data/spec/reek/smell_detectors/boolean_parameter_spec.rb +2 -2
  208. data/spec/reek/smell_detectors/class_variable_spec.rb +26 -32
  209. data/spec/reek/smell_detectors/control_parameter_spec.rb +34 -4
  210. data/spec/reek/smell_detectors/duplicate_method_call_spec.rb +3 -3
  211. data/spec/reek/smell_detectors/feature_envy_spec.rb +47 -2
  212. data/spec/reek/smell_detectors/irresponsible_module_spec.rb +0 -11
  213. data/spec/reek/smell_detectors/{prima_donna_method_spec.rb → missing_safe_method_spec.rb} +10 -10
  214. data/spec/reek/smell_detectors/module_initialize_spec.rb +14 -0
  215. data/spec/reek/smell_detectors/nested_iterators_spec.rb +1 -1
  216. data/spec/reek/smell_detectors/too_many_constants_spec.rb +3 -3
  217. data/spec/reek/smell_detectors/too_many_instance_variables_spec.rb +1 -1
  218. data/spec/reek/smell_detectors/uncommunicative_method_name_spec.rb +6 -6
  219. data/spec/reek/smell_detectors/uncommunicative_module_name_spec.rb +6 -4
  220. data/spec/reek/smell_detectors/uncommunicative_parameter_name_spec.rb +36 -15
  221. data/spec/reek/smell_detectors/uncommunicative_variable_name_spec.rb +9 -9
  222. data/spec/reek/smell_detectors/unused_parameters_spec.rb +3 -3
  223. data/spec/reek/smell_detectors/unused_private_method_spec.rb +21 -10
  224. data/spec/reek/smell_detectors/utility_function_spec.rb +57 -5
  225. data/spec/reek/smell_warning_spec.rb +12 -8
  226. data/spec/reek/source/source_code_spec.rb +22 -21
  227. data/spec/reek/source/source_locator_spec.rb +17 -17
  228. data/spec/reek/spec/should_reek_of_spec.rb +25 -29
  229. data/spec/reek/spec/should_reek_only_of_spec.rb +2 -2
  230. data/spec/reek/spec/should_reek_spec.rb +8 -8
  231. data/spec/reek/spec/smell_matcher_spec.rb +23 -23
  232. data/spec/reek/tree_dresser_spec.rb +12 -17
  233. data/spec/spec_helper.rb +6 -17
  234. data/tasks/configuration.rake +8 -5
  235. metadata +74 -41
  236. data/defaults.reek +0 -131
  237. data/features/configuration_files/warn_about_multiple_configuration_files.feature +0 -44
  238. data/lib/reek/report/formatter/heading_formatter.rb +0 -52
  239. data/lib/reek/report/formatter/location_formatter.rb +0 -42
  240. data/lib/reek/report/formatter/progress_formatter.rb +0 -81
  241. data/lib/reek/report/formatter/simple_warning_formatter.rb +0 -35
  242. data/lib/reek/report/formatter/wiki_link_warning_formatter.rb +0 -36
  243. data/lib/reek/report/formatter.rb +0 -33
  244. data/lib/reek/smell_detectors/syntax.rb +0 -37
  245. data/samples/configuration/non_public_modifiers_mask.reek +0 -3
  246. data/samples/smelly_with_inline_mask.rb +0 -8
  247. data/samples/smelly_with_modifiers.rb +0 -12
  248. data/samples/source_with_hidden_directories/.hidden/uncommunicative_method_name.rb +0 -5
  249. data/samples/source_with_non_ruby_files/uncommunicative_parameter_name.rb +0 -6
  250. data/spec/reek/smell_detectors/syntax_spec.rb +0 -17
  251. /data/{samples/configuration/more_than_one_configuration_file/regular.reek → .reek.yml} +0 -0
  252. /data/samples/{clean.rb → clean_source/clean.rb} +0 -0
  253. /data/samples/{exceptions.reek → configuration/home/home.reek.yml} +0 -0
  254. /data/samples/configuration/{more_than_one_configuration_file/todo.reek → regular_configuration/empty_sub_directory/.gitignore} +0 -0
  255. /data/samples/{configuration/single_configuration_file/.reek → no_config_file/.keep} +0 -0
  256. /data/samples/{inline.rb → smelly_source/inline.rb} +0 -0
  257. /data/samples/{optparse.rb → smelly_source/optparse.rb} +0 -0
  258. /data/samples/{redcloth.rb → smelly_source/redcloth.rb} +0 -0
  259. /data/samples/{smelly.rb → smelly_source/smelly.rb} +0 -0
  260. /data/samples/{source_with_hidden_directories/uncommunicative_parameter_name.rb → source_with_non_ruby_files/ruby.rb} +0 -0
@@ -1,17 +1,15 @@
1
- require_lib 'reek/cli/silencer'
2
- Reek::CLI::Silencer.silently do
3
- require 'parser/ruby22'
4
- end
5
-
6
1
  require_relative '../spec_helper'
2
+ Reek::CLI::Silencer.without_warnings { require 'parser/ruby25' }
7
3
  require_lib 'reek/tree_dresser'
8
4
 
9
5
  RSpec.describe Reek::TreeDresser do
10
- let(:dresser) { described_class.new }
11
- let(:sexp) do
12
- Parser::Ruby22.parse('class Klazz; def meth(argument); argument.call_me; end; end')
13
- end
14
- let(:dressed_ast) do
6
+ describe '#dress' do
7
+ let(:dresser) { described_class.new }
8
+ let(:sexp) do
9
+ Parser::Ruby25.parse('class Klazz; def meth(argument); argument.call_me; end; end')
10
+ end
11
+ let(:dressed_ast) { dresser.dress(sexp, {}) }
12
+
15
13
  # The dressed AST looks like this:
16
14
  # (class
17
15
  # (const nil :Klazz) nil
@@ -20,14 +18,11 @@ RSpec.describe Reek::TreeDresser do
20
18
  # (arg :argument))
21
19
  # (send
22
20
  # (lvar :argument) :call_me)))
23
- dresser.dress(sexp, {})
24
- end
25
- let(:const_node) { dressed_ast.children.first }
26
- let(:def_node) { dressed_ast.children.last }
27
- let(:args_node) { def_node.children[1] }
28
- let(:send_node) { def_node.children[2] }
21
+ let(:const_node) { dressed_ast.children.first }
22
+ let(:def_node) { dressed_ast.children.last }
23
+ let(:args_node) { def_node.children[1] }
24
+ let(:send_node) { def_node.children[2] }
29
25
 
30
- context 'dresses the given sexp' do
31
26
  it 'dresses `const` nodes properly' do
32
27
  expect(const_node).to be_a Reek::AST::SexpExtensions::ConstNode
33
28
  end
data/spec/spec_helper.rb CHANGED
@@ -8,15 +8,13 @@ require_relative '../lib/reek/configuration/app_configuration'
8
8
 
9
9
  require_relative '../samples/paths'
10
10
 
11
- Reek::CLI::Silencer.silently do
12
- begin
13
- require 'pry-byebug'
14
- rescue LoadError # rubocop:disable Lint/HandleExceptions
15
- end
11
+ begin
12
+ Reek::CLI::Silencer.without_warnings { require 'pry-byebug' }
13
+ rescue LoadError # rubocop:disable Lint/HandleExceptions
16
14
  end
17
15
 
18
- require 'factory_girl'
19
- FactoryGirl.find_definitions
16
+ require 'factory_bot'
17
+ FactoryBot.find_definitions
20
18
 
21
19
  # Simple helpers for our specs.
22
20
  module Helpers
@@ -76,7 +74,7 @@ end
76
74
  RSpec.configure do |config|
77
75
  config.filter_run :focus
78
76
  config.run_all_when_everything_filtered = true
79
- config.include FactoryGirl::Syntax::Methods
77
+ config.include FactoryBot::Syntax::Methods
80
78
  config.include Helpers
81
79
 
82
80
  config.disable_monkey_patching!
@@ -85,15 +83,6 @@ RSpec.configure do |config|
85
83
  mocks.verify_partial_doubles = true
86
84
  mocks.verify_doubled_constant_names = true
87
85
  end
88
-
89
- # Avoid infinitely running tests. This is mainly useful when running a
90
- # mutation tester. Set the DEBUG environment variable to something truthy
91
- # like '1' to disable this and allow using pry without specs failing.
92
- unless ENV['DEBUG']
93
- config.around(:each) do |example|
94
- Timeout.timeout(5, &example)
95
- end
96
- end
97
86
  end
98
87
 
99
88
  RSpec::Matchers.define_negated_matcher :not_reek_of, :reek_of
@@ -1,15 +1,18 @@
1
1
  require_relative '../lib/reek/detector_repository'
2
+ require_relative '../lib/reek/configuration/rake_task_converter'
3
+ require_relative '../lib/reek/configuration/app_configuration'
4
+
2
5
  require 'yaml'
3
6
 
4
7
  namespace :configuration do
5
8
  desc 'Updates the default configuration file when smell defaults change'
6
9
  task :update_default_configuration do
7
- DEFAULT_SMELL_CONFIGURATION = 'defaults.reek'.freeze
10
+ DEFAULT_SMELL_CONFIGURATION = 'docs/defaults.reek.yml'.freeze
8
11
  content = Reek::DetectorRepository.smell_types.each_with_object({}) do |klass, hash|
9
- hash[klass.smell_type] = klass.default_config
12
+ hash[klass.smell_type] = Reek::Configuration::RakeTaskConverter.convert klass.default_config
13
+ end
14
+ File.open(DEFAULT_SMELL_CONFIGURATION, 'w') do |file|
15
+ YAML.dump({ Reek::Configuration::AppConfiguration::DETECTORS_KEY => content }, file)
10
16
  end
11
- File.open(DEFAULT_SMELL_CONFIGURATION, 'w') { |file| YAML.dump(content, file) }
12
17
  end
13
18
  end
14
-
15
- task 'test:spec' => 'configuration:update_default_configuration'
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.7.1
4
+ version: 5.0.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: 2017-06-12 00:00:00.000000000 Z
14
+ date: 2018-06-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: codeclimate-engine-rb
@@ -27,40 +27,60 @@ dependencies:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.4.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: kwalify
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: 0.7.0
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: 0.7.0
30
44
  - !ruby/object:Gem::Dependency
31
45
  name: parser
32
46
  requirement: !ruby/object:Gem::Requirement
33
47
  requirements:
34
48
  - - "<"
35
49
  - !ruby/object:Gem::Version
36
- version: '2.5'
50
+ version: '2.6'
37
51
  - - ">="
38
52
  - !ruby/object:Gem::Version
39
- version: 2.4.0.0
53
+ version: 2.5.0.0
40
54
  type: :runtime
41
55
  prerelease: false
42
56
  version_requirements: !ruby/object:Gem::Requirement
43
57
  requirements:
44
58
  - - "<"
45
59
  - !ruby/object:Gem::Version
46
- version: '2.5'
60
+ version: '2.6'
47
61
  - - ">="
48
62
  - !ruby/object:Gem::Version
49
- version: 2.4.0.0
63
+ version: 2.5.0.0
50
64
  - !ruby/object:Gem::Dependency
51
65
  name: rainbow
52
66
  requirement: !ruby/object:Gem::Requirement
53
67
  requirements:
54
- - - "~>"
68
+ - - ">="
55
69
  - !ruby/object:Gem::Version
56
70
  version: '2.0'
71
+ - - "<"
72
+ - !ruby/object:Gem::Version
73
+ version: '4.0'
57
74
  type: :runtime
58
75
  prerelease: false
59
76
  version_requirements: !ruby/object:Gem::Requirement
60
77
  requirements:
61
- - - "~>"
78
+ - - ">="
62
79
  - !ruby/object:Gem::Version
63
80
  version: '2.0'
81
+ - - "<"
82
+ - !ruby/object:Gem::Version
83
+ version: '4.0'
64
84
  description: Reek is a tool that examines Ruby classes, modules and methods and reports
65
85
  any code smells it finds.
66
86
  email:
@@ -76,6 +96,7 @@ files:
76
96
  - ".codeclimate.yml"
77
97
  - ".dockerignore"
78
98
  - ".gitignore"
99
+ - ".reek.yml"
79
100
  - ".rubocop.yml"
80
101
  - ".simplecov"
81
102
  - ".travis.yml"
@@ -90,7 +111,6 @@ files:
90
111
  - ataru_setup.rb
91
112
  - bin/code_climate_reek
92
113
  - bin/reek
93
- - defaults.reek
94
114
  - docs/API.md
95
115
  - docs/Attribute.md
96
116
  - docs/Basic-Smell-Options.md
@@ -111,12 +131,13 @@ files:
111
131
  - docs/Long-Parameter-List.md
112
132
  - docs/Long-Yield-List.md
113
133
  - docs/Manual-Dispatch.md
134
+ - docs/Missing-Safe-Method.md
114
135
  - docs/Module-Initialize.md
115
136
  - docs/Nested-Iterators.md
116
137
  - docs/Nil-Check.md
117
- - docs/Prima-Donna-Method.md
118
138
  - docs/RSpec-matchers.md
119
139
  - docs/Rake-Task.md
140
+ - docs/Reek-4-to-Reek-5-migration.md
120
141
  - docs/Reek-Driven-Development.md
121
142
  - docs/Repeated-Conditional.md
122
143
  - docs/Simulated-Polymorphism.md
@@ -137,6 +158,7 @@ files:
137
158
  - docs/Utility-Function.md
138
159
  - docs/Versioning-Policy.md
139
160
  - docs/YAML-Reports.md
161
+ - docs/defaults.reek.yml
140
162
  - docs/templates/default/docstring/html/public_api_marker.erb
141
163
  - docs/templates/default/docstring/setup.rb
142
164
  - docs/templates/default/fulldoc/html/css/common.css
@@ -155,17 +177,19 @@ files:
155
177
  - features/configuration_files/masking_smells.feature
156
178
  - features/configuration_files/mix_accept_reject_setting.feature
157
179
  - features/configuration_files/reject_setting.feature
180
+ - features/configuration_files/schema_validation.feature
158
181
  - features/configuration_files/unused_private_method.feature
159
- - features/configuration_files/warn_about_multiple_configuration_files.feature
160
182
  - features/configuration_loading.feature
161
183
  - features/configuration_via_source_comments/erroneous_source_comments.feature
162
184
  - features/configuration_via_source_comments/well_formed_source_comments.feature
185
+ - features/locales.feature
163
186
  - features/programmatic_access.feature
164
187
  - features/rake_task/rake_task.feature
165
188
  - features/reports/codeclimate.feature
166
189
  - features/reports/json.feature
167
190
  - features/reports/reports.feature
168
191
  - features/reports/yaml.feature
192
+ - features/rspec_matcher.feature
169
193
  - features/samples.feature
170
194
  - features/step_definitions/.rubocop.yml
171
195
  - features/step_definitions/reek_steps.rb
@@ -208,11 +232,15 @@ files:
208
232
  - lib/reek/cli/status.rb
209
233
  - lib/reek/code_comment.rb
210
234
  - lib/reek/configuration/app_configuration.rb
235
+ - lib/reek/configuration/configuration_converter.rb
211
236
  - lib/reek/configuration/configuration_file_finder.rb
212
237
  - lib/reek/configuration/configuration_validator.rb
213
238
  - lib/reek/configuration/default_directive.rb
214
239
  - lib/reek/configuration/directory_directives.rb
215
240
  - lib/reek/configuration/excluded_paths.rb
241
+ - lib/reek/configuration/rake_task_converter.rb
242
+ - lib/reek/configuration/schema.yml
243
+ - lib/reek/configuration/schema_validator.rb
216
244
  - lib/reek/context/attribute_context.rb
217
245
  - lib/reek/context/class_context.rb
218
246
  - lib/reek/context/code_context.rb
@@ -227,11 +255,15 @@ files:
227
255
  - lib/reek/context/visibility_tracker.rb
228
256
  - lib/reek/context_builder.rb
229
257
  - lib/reek/detector_repository.rb
258
+ - lib/reek/documentation_link.rb
230
259
  - lib/reek/errors/bad_detector_configuration_key_in_comment_error.rb
231
260
  - lib/reek/errors/bad_detector_in_comment_error.rb
232
261
  - lib/reek/errors/base_error.rb
262
+ - lib/reek/errors/config_file_error.rb
263
+ - lib/reek/errors/encoding_error.rb
233
264
  - lib/reek/errors/garbage_detector_configuration_in_comment_error.rb
234
265
  - lib/reek/errors/incomprehensible_source_error.rb
266
+ - lib/reek/errors/syntax_error.rb
235
267
  - lib/reek/examiner.rb
236
268
  - lib/reek/logging_error_handler.rb
237
269
  - lib/reek/rake/task.rb
@@ -243,15 +275,14 @@ files:
243
275
  - lib/reek/report/code_climate/code_climate_fingerprint.rb
244
276
  - lib/reek/report/code_climate/code_climate_formatter.rb
245
277
  - lib/reek/report/code_climate/code_climate_report.rb
246
- - lib/reek/report/formatter.rb
247
- - lib/reek/report/formatter/heading_formatter.rb
248
- - lib/reek/report/formatter/location_formatter.rb
249
- - lib/reek/report/formatter/progress_formatter.rb
250
- - lib/reek/report/formatter/simple_warning_formatter.rb
251
- - lib/reek/report/formatter/wiki_link_warning_formatter.rb
278
+ - lib/reek/report/documentation_link_warning_formatter.rb
279
+ - lib/reek/report/heading_formatter.rb
252
280
  - lib/reek/report/html_report.rb
253
281
  - lib/reek/report/html_report/html_report.html.erb
254
282
  - lib/reek/report/json_report.rb
283
+ - lib/reek/report/location_formatter.rb
284
+ - lib/reek/report/progress_formatter.rb
285
+ - lib/reek/report/simple_warning_formatter.rb
255
286
  - lib/reek/report/text_report.rb
256
287
  - lib/reek/report/xml_report.rb
257
288
  - lib/reek/report/yaml_report.rb
@@ -270,13 +301,12 @@ files:
270
301
  - lib/reek/smell_detectors/long_parameter_list.rb
271
302
  - lib/reek/smell_detectors/long_yield_list.rb
272
303
  - lib/reek/smell_detectors/manual_dispatch.rb
304
+ - lib/reek/smell_detectors/missing_safe_method.rb
273
305
  - lib/reek/smell_detectors/module_initialize.rb
274
306
  - lib/reek/smell_detectors/nested_iterators.rb
275
307
  - lib/reek/smell_detectors/nil_check.rb
276
- - lib/reek/smell_detectors/prima_donna_method.rb
277
308
  - lib/reek/smell_detectors/repeated_conditional.rb
278
309
  - lib/reek/smell_detectors/subclassed_from_core_class.rb
279
- - lib/reek/smell_detectors/syntax.rb
280
310
  - lib/reek/smell_detectors/too_many_constants.rb
281
311
  - lib/reek/smell_detectors/too_many_instance_variables.rb
282
312
  - lib/reek/smell_detectors/too_many_methods.rb
@@ -306,33 +336,32 @@ files:
306
336
  - logo/reek.text.svg
307
337
  - reek.gemspec
308
338
  - samples/checkstyle.xml
309
- - samples/clean.rb
339
+ - samples/clean_source/clean.rb
340
+ - samples/configuration/accepts_rejects_and_excludes_for_detectors.reek.yml
341
+ - samples/configuration/accepts_rejects_and_excludes_for_directory_directives.reek.yml
310
342
  - samples/configuration/corrupt.reek
311
343
  - samples/configuration/empty.reek
312
344
  - samples/configuration/full_configuration.reek
313
345
  - samples/configuration/full_mask.reek
314
- - samples/configuration/more_than_one_configuration_file/regular.reek
315
- - samples/configuration/more_than_one_configuration_file/todo.reek
316
- - samples/configuration/non_public_modifiers_mask.reek
346
+ - samples/configuration/home/home.reek.yml
317
347
  - samples/configuration/partial_mask.reek
318
- - samples/configuration/single_configuration_file/.reek
348
+ - samples/configuration/regular_configuration/.reek.yml
349
+ - samples/configuration/regular_configuration/empty_sub_directory/.gitignore
319
350
  - samples/configuration/with_excluded_paths.reek
320
- - samples/exceptions.reek
321
- - samples/inline.rb
322
- - samples/optparse.rb
351
+ - samples/no_config_file/.keep
323
352
  - samples/paths.rb
324
- - samples/redcloth.rb
325
- - samples/smelly.rb
326
- - samples/smelly_with_inline_mask.rb
327
- - samples/smelly_with_modifiers.rb
353
+ - samples/smelly_source/inline.rb
354
+ - samples/smelly_source/optparse.rb
355
+ - samples/smelly_source/redcloth.rb
356
+ - samples/smelly_source/smelly.rb
328
357
  - samples/source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb
329
358
  - samples/source_with_exclude_paths/nested/ignore_me_as_well/irresponsible_module.rb
330
359
  - samples/source_with_exclude_paths/nested/uncommunicative_parameter_name.rb
331
- - samples/source_with_hidden_directories/.hidden/uncommunicative_method_name.rb
332
- - samples/source_with_hidden_directories/uncommunicative_parameter_name.rb
360
+ - samples/source_with_hidden_directories/.hidden/hidden.rb
361
+ - samples/source_with_hidden_directories/not_hidden.rb
333
362
  - samples/source_with_non_ruby_files/gibberish
334
363
  - samples/source_with_non_ruby_files/python_source.py
335
- - samples/source_with_non_ruby_files/uncommunicative_parameter_name.rb
364
+ - samples/source_with_non_ruby_files/ruby.rb
336
365
  - spec/factories/factories.rb
337
366
  - spec/quality/reek_source_spec.rb
338
367
  - spec/reek/ast/node_spec.rb
@@ -343,12 +372,15 @@ files:
343
372
  - spec/reek/cli/command/report_command_spec.rb
344
373
  - spec/reek/cli/command/todo_list_command_spec.rb
345
374
  - spec/reek/cli/options_spec.rb
375
+ - spec/reek/cli/silencer_spec.rb
346
376
  - spec/reek/code_comment_spec.rb
347
377
  - spec/reek/configuration/app_configuration_spec.rb
348
378
  - spec/reek/configuration/configuration_file_finder_spec.rb
349
379
  - spec/reek/configuration/default_directive_spec.rb
350
380
  - spec/reek/configuration/directory_directives_spec.rb
351
381
  - spec/reek/configuration/excluded_paths_spec.rb
382
+ - spec/reek/configuration/rake_task_converter_spec.rb
383
+ - spec/reek/configuration/schema_validator_spec.rb
352
384
  - spec/reek/context/code_context_spec.rb
353
385
  - spec/reek/context/ghost_context_spec.rb
354
386
  - spec/reek/context/method_context_spec.rb
@@ -357,6 +389,8 @@ files:
357
389
  - spec/reek/context/statement_counter_spec.rb
358
390
  - spec/reek/context_builder_spec.rb
359
391
  - spec/reek/detector_repository_spec.rb
392
+ - spec/reek/documentation_link_spec.rb
393
+ - spec/reek/errors/base_error_spec.rb
360
394
  - spec/reek/examiner_spec.rb
361
395
  - spec/reek/logging_error_handler_spec.rb
362
396
  - spec/reek/rake/task_spec.rb
@@ -364,10 +398,10 @@ files:
364
398
  - spec/reek/report/code_climate/code_climate_fingerprint_spec.rb
365
399
  - spec/reek/report/code_climate/code_climate_formatter_spec.rb
366
400
  - spec/reek/report/code_climate/code_climate_report_spec.rb
367
- - spec/reek/report/formatter/location_formatter_spec.rb
368
- - spec/reek/report/formatter/progress_formatter_spec.rb
369
401
  - spec/reek/report/html_report_spec.rb
370
402
  - spec/reek/report/json_report_spec.rb
403
+ - spec/reek/report/location_formatter_spec.rb
404
+ - spec/reek/report/progress_formatter_spec.rb
371
405
  - spec/reek/report/text_report_spec.rb
372
406
  - spec/reek/report/xml_report_spec.rb
373
407
  - spec/reek/report/yaml_report_spec.rb
@@ -386,13 +420,12 @@ files:
386
420
  - spec/reek/smell_detectors/long_parameter_list_spec.rb
387
421
  - spec/reek/smell_detectors/long_yield_list_spec.rb
388
422
  - spec/reek/smell_detectors/manual_dispatch_spec.rb
423
+ - spec/reek/smell_detectors/missing_safe_method_spec.rb
389
424
  - spec/reek/smell_detectors/module_initialize_spec.rb
390
425
  - spec/reek/smell_detectors/nested_iterators_spec.rb
391
426
  - spec/reek/smell_detectors/nil_check_spec.rb
392
- - spec/reek/smell_detectors/prima_donna_method_spec.rb
393
427
  - spec/reek/smell_detectors/repeated_conditional_spec.rb
394
428
  - spec/reek/smell_detectors/subclassed_from_core_class_spec.rb
395
- - spec/reek/smell_detectors/syntax_spec.rb
396
429
  - spec/reek/smell_detectors/too_many_constants_spec.rb
397
430
  - spec/reek/smell_detectors/too_many_instance_variables_spec.rb
398
431
  - spec/reek/smell_detectors/too_many_methods_spec.rb
@@ -419,7 +452,7 @@ files:
419
452
  - tasks/reek.rake
420
453
  - tasks/rubocop.rake
421
454
  - tasks/test.rake
422
- homepage: https://github.com/troessner/reek/wiki
455
+ homepage: https://github.com/troessner/reek
423
456
  licenses:
424
457
  - MIT
425
458
  metadata: {}
@@ -435,7 +468,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
435
468
  requirements:
436
469
  - - ">="
437
470
  - !ruby/object:Gem::Version
438
- version: 2.1.0
471
+ version: 2.3.0
439
472
  required_rubygems_version: !ruby/object:Gem::Requirement
440
473
  requirements:
441
474
  - - ">="
@@ -443,7 +476,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
443
476
  version: '0'
444
477
  requirements: []
445
478
  rubyforge_project:
446
- rubygems_version: 2.5.1
479
+ rubygems_version: 2.5.2.2
447
480
  signing_key:
448
481
  specification_version: 4
449
482
  summary: Code smell detector for Ruby
data/defaults.reek DELETED
@@ -1,131 +0,0 @@
1
- ---
2
- Attribute:
3
- enabled: true
4
- exclude: []
5
- BooleanParameter:
6
- enabled: true
7
- exclude: []
8
- ClassVariable:
9
- enabled: true
10
- exclude: []
11
- ControlParameter:
12
- enabled: true
13
- exclude: []
14
- DataClump:
15
- enabled: true
16
- exclude: []
17
- max_copies: 2
18
- min_clump_size: 2
19
- DuplicateMethodCall:
20
- enabled: true
21
- exclude: []
22
- max_calls: 1
23
- allow_calls: []
24
- FeatureEnvy:
25
- enabled: true
26
- exclude: []
27
- InstanceVariableAssumption:
28
- enabled: true
29
- exclude: []
30
- IrresponsibleModule:
31
- enabled: true
32
- exclude: []
33
- LongParameterList:
34
- enabled: true
35
- exclude: []
36
- max_params: 3
37
- overrides:
38
- initialize:
39
- max_params: 5
40
- LongYieldList:
41
- enabled: true
42
- exclude: []
43
- max_params: 3
44
- ManualDispatch:
45
- enabled: true
46
- exclude: []
47
- ModuleInitialize:
48
- enabled: true
49
- exclude: []
50
- NestedIterators:
51
- enabled: true
52
- exclude: []
53
- max_allowed_nesting: 1
54
- ignore_iterators:
55
- - tap
56
- NilCheck:
57
- enabled: true
58
- exclude: []
59
- PrimaDonnaMethod:
60
- enabled: true
61
- exclude: []
62
- RepeatedConditional:
63
- enabled: true
64
- exclude: []
65
- max_ifs: 2
66
- SubclassedFromCoreClass:
67
- enabled: true
68
- exclude: []
69
- Syntax:
70
- enabled: true
71
- exclude: []
72
- TooManyConstants:
73
- enabled: true
74
- exclude: []
75
- max_constants: 5
76
- TooManyInstanceVariables:
77
- enabled: true
78
- exclude: []
79
- max_instance_variables: 4
80
- TooManyMethods:
81
- enabled: true
82
- exclude: []
83
- max_methods: 15
84
- TooManyStatements:
85
- enabled: true
86
- exclude:
87
- - initialize
88
- max_statements: 5
89
- UncommunicativeMethodName:
90
- enabled: true
91
- exclude: []
92
- reject:
93
- - !ruby/regexp /^[a-z]$/
94
- - !ruby/regexp /[0-9]$/
95
- - !ruby/regexp /[A-Z]/
96
- accept: []
97
- UncommunicativeModuleName:
98
- enabled: true
99
- exclude: []
100
- reject:
101
- - !ruby/regexp /^.$/
102
- - !ruby/regexp /[0-9]$/
103
- accept: []
104
- UncommunicativeParameterName:
105
- enabled: true
106
- exclude: []
107
- reject:
108
- - !ruby/regexp /^.$/
109
- - !ruby/regexp /[0-9]$/
110
- - !ruby/regexp /[A-Z]/
111
- - !ruby/regexp /^_/
112
- accept: []
113
- UncommunicativeVariableName:
114
- enabled: true
115
- exclude: []
116
- reject:
117
- - !ruby/regexp /^.$/
118
- - !ruby/regexp /[0-9]$/
119
- - !ruby/regexp /[A-Z]/
120
- accept:
121
- - !ruby/regexp /^_$/
122
- UnusedParameters:
123
- enabled: true
124
- exclude: []
125
- UnusedPrivateMethod:
126
- enabled: false
127
- exclude: []
128
- UtilityFunction:
129
- enabled: true
130
- exclude: []
131
- public_methods_only: false
@@ -1,44 +0,0 @@
1
- Feature: Warn on multiple configuration files
2
- Reek is designed for one configuration file and for one configuration file only.
3
- We should make this clear to the user by warning him when we detect multiple
4
- configuration files and then exiting the program.
5
-
6
- Scenario: Warn on more than one configuration file
7
- Given the smelly file 'smelly.rb'
8
- And a file named "config.reek" with:
9
- """
10
- ---
11
- UncommunicativeMethodName:
12
- enabled: false
13
- """
14
- And a file named ".todo.reek" with:
15
- """
16
- ---
17
- UtilityFunction:
18
- enabled: false
19
- """
20
- When I run reek smelly.rb
21
- Then it reports the error "Error: Found multiple configuration files '.todo.reek', 'config.reek'"
22
- And it reports the error "Reek supports only one configuration file. You have 2 options now:"
23
- And it reports the error "1) Remove all offending files"
24
- And it reports the error "2) Be specific about which one you want to load via the -c switch"
25
- And the exit status indicates an error
26
-
27
- Scenario: Do not warn on more than one when we explicitly specify one configuration file
28
- Given the smelly file 'smelly.rb'
29
- And a file named "config.reek" with:
30
- """
31
- ---
32
- UncommunicativeMethodName:
33
- enabled: false
34
- """
35
- And a file named ".todo.reek" with:
36
- """
37
- ---
38
- UtilityFunction:
39
- enabled: false
40
- """
41
- When I run reek -c config.reek smelly.rb
42
- Then the exit status indicates smells
43
- And it reports no errors
44
-
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Reek
4
- module Report
5
- module Formatter
6
- #
7
- # Base class for heading formatters.
8
- # Is responsible for formatting the heading emitted for each examiner
9
- #
10
- # @abstract Override {#show_header?} to implement a heading formatter.
11
- class HeadingFormatterBase
12
- attr_reader :report_formatter
13
-
14
- def initialize(report_formatter)
15
- @report_formatter = report_formatter
16
- end
17
-
18
- # :reek:UtilityFunction
19
- def show_header?(_examiner)
20
- raise NotImplementedError
21
- end
22
-
23
- def header(examiner)
24
- if show_header?(examiner)
25
- report_formatter.header examiner
26
- else
27
- ''
28
- end
29
- end
30
- end
31
-
32
- #
33
- # Lists out each examiner, even if it has no smell
34
- #
35
- class VerboseHeadingFormatter < HeadingFormatterBase
36
- def show_header?(_examiner)
37
- true
38
- end
39
- end
40
-
41
- #
42
- # Lists only smelly examiners
43
- #
44
- class QuietHeadingFormatter < HeadingFormatterBase
45
- # :reek:UtilityFunction
46
- def show_header?(examiner)
47
- examiner.smelly?
48
- end
49
- end
50
- end
51
- end
52
- end