reek 2.0.4 → 3.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 (275) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +13 -0
  3. data/.rubocop.yml +47 -0
  4. data/.travis.yml +31 -0
  5. data/.yardopts +3 -6
  6. data/CHANGELOG +24 -0
  7. data/CONTRIBUTING.md +111 -0
  8. data/Gemfile +16 -0
  9. data/README.md +112 -59
  10. data/bin/reek +2 -2
  11. data/config/cucumber.yml +3 -0
  12. data/config/defaults.reek +0 -1
  13. data/docs/API.md +79 -0
  14. data/docs/Attribute.md +43 -0
  15. data/docs/Basic-Smell-Options.md +44 -0
  16. data/docs/Boolean-Parameter.md +52 -0
  17. data/docs/Class-Variable.md +40 -0
  18. data/docs/Code-Smells.md +34 -0
  19. data/docs/Command-Line-Options.md +84 -0
  20. data/docs/Configuration-Files.md +49 -0
  21. data/docs/Control-Couple.md +22 -0
  22. data/docs/Control-Parameter.md +29 -0
  23. data/docs/Data-Clump.md +44 -0
  24. data/docs/Duplicate-Method-Call.md +49 -0
  25. data/docs/Feature-Envy.md +49 -0
  26. data/docs/How-reek-works-internally.md +114 -0
  27. data/docs/Irresponsible-Module.md +39 -0
  28. data/docs/Large-Class.md +20 -0
  29. data/docs/Long-Parameter-List.md +38 -0
  30. data/docs/Long-Yield-List.md +36 -0
  31. data/docs/Module-Initialize.md +62 -0
  32. data/docs/Nested-Iterators.md +38 -0
  33. data/docs/Nil-Check.md +39 -0
  34. data/docs/Prima-Donna-Method.md +53 -0
  35. data/docs/RSpec-matchers.md +137 -0
  36. data/docs/Rake-Task.md +58 -0
  37. data/docs/Reek-Driven-Development.md +37 -0
  38. data/docs/Repeated-Conditional.md +44 -0
  39. data/docs/Simulated-Polymorphism.md +16 -0
  40. data/docs/Smell-Suppression.md +32 -0
  41. data/docs/Too-Many-Instance-Variables.md +43 -0
  42. data/docs/Too-Many-Methods.md +55 -0
  43. data/docs/Too-Many-Statements.md +50 -0
  44. data/docs/Uncommunicative-Method-Name.md +24 -0
  45. data/docs/Uncommunicative-Module-Name.md +23 -0
  46. data/docs/Uncommunicative-Name.md +16 -0
  47. data/docs/Uncommunicative-Parameter-Name.md +24 -0
  48. data/docs/Uncommunicative-Variable-Name.md +24 -0
  49. data/docs/Unused-Parameters.md +27 -0
  50. data/docs/Utility-Function.md +44 -0
  51. data/docs/Versioning-Policy.md +7 -0
  52. data/docs/YAML-Reports.md +111 -0
  53. data/docs/yard_plugin.rb +14 -0
  54. data/features/{ruby_api/api.feature → command_line_interface/basic_usage.feature} +6 -5
  55. data/features/command_line_interface/options.feature +1 -0
  56. data/features/command_line_interface/smell_selection.feature +4 -8
  57. data/features/command_line_interface/smells_count.feature +25 -32
  58. data/features/command_line_interface/stdin.feature +2 -2
  59. data/features/configuration_files/masking_smells.feature +30 -41
  60. data/features/configuration_files/overrides_defaults.feature +5 -3
  61. data/features/configuration_loading.feature +26 -23
  62. data/features/programmatic_access.feature +43 -0
  63. data/features/rake_task/rake_task.feature +25 -22
  64. data/features/reports/json.feature +24 -26
  65. data/features/reports/reports.feature +77 -103
  66. data/features/reports/yaml.feature +26 -20
  67. data/features/samples.feature +26 -31
  68. data/features/step_definitions/.rubocop.yml +5 -0
  69. data/features/step_definitions/reek_steps.rb +16 -28
  70. data/features/step_definitions/sample_file_steps.rb +158 -0
  71. data/features/support/env.rb +16 -27
  72. data/lib/reek/{source → ast}/ast_node_class_map.rb +11 -12
  73. data/lib/reek/ast/node.rb +132 -0
  74. data/lib/reek/{core → ast}/object_refs.rb +2 -1
  75. data/lib/reek/ast/reference_collector.rb +32 -0
  76. data/lib/reek/{source → ast}/sexp_extensions.rb +43 -7
  77. data/lib/reek/ast/sexp_formatter.rb +31 -0
  78. data/lib/reek/cli/application.rb +5 -4
  79. data/lib/reek/cli/command.rb +2 -1
  80. data/lib/reek/cli/input.rb +6 -5
  81. data/lib/reek/cli/option_interpreter.rb +13 -9
  82. data/lib/reek/cli/options.rb +16 -8
  83. data/lib/reek/cli/reek_command.rb +4 -3
  84. data/lib/reek/cli/silencer.rb +14 -0
  85. data/lib/reek/{core → cli}/warning_collector.rb +2 -1
  86. data/lib/reek/code_comment.rb +36 -0
  87. data/lib/reek/configuration/app_configuration.rb +18 -3
  88. data/lib/reek/configuration/configuration_file_finder.rb +18 -32
  89. data/lib/reek/{core → context}/code_context.rb +8 -6
  90. data/lib/reek/{core → context}/method_context.rb +11 -5
  91. data/lib/reek/{core → context}/module_context.rb +9 -4
  92. data/lib/reek/{core/stop_context.rb → context/root_context.rb} +4 -2
  93. data/lib/reek/{core → context}/singleton_method_context.rb +3 -6
  94. data/lib/reek/examiner.rb +32 -29
  95. data/lib/reek/report/formatter.rb +70 -0
  96. data/lib/reek/report/heading_formatter.rb +45 -0
  97. data/lib/reek/report/location_formatter.rb +35 -0
  98. data/lib/reek/report/report.rb +198 -0
  99. data/lib/reek/smells/attribute.rb +41 -11
  100. data/lib/reek/smells/boolean_parameter.rb +4 -2
  101. data/lib/reek/smells/class_variable.rb +4 -2
  102. data/lib/reek/smells/control_parameter.rb +4 -2
  103. data/lib/reek/smells/data_clump.rb +4 -3
  104. data/lib/reek/smells/duplicate_method_call.rb +15 -5
  105. data/lib/reek/smells/feature_envy.rb +8 -2
  106. data/lib/reek/smells/irresponsible_module.rb +13 -8
  107. data/lib/reek/smells/long_parameter_list.rb +6 -4
  108. data/lib/reek/smells/long_yield_list.rb +4 -2
  109. data/lib/reek/smells/module_initialize.rb +4 -2
  110. data/lib/reek/smells/nested_iterators.rb +4 -2
  111. data/lib/reek/smells/nil_check.rb +6 -3
  112. data/lib/reek/smells/prima_donna_method.rb +21 -12
  113. data/lib/reek/smells/repeated_conditional.rb +7 -4
  114. data/lib/reek/{core → smells}/smell_configuration.rb +3 -1
  115. data/lib/reek/smells/smell_detector.rb +11 -5
  116. data/lib/reek/{core → smells}/smell_repository.rb +9 -5
  117. data/lib/reek/smells/smell_warning.rb +101 -0
  118. data/lib/reek/smells/too_many_instance_variables.rb +4 -2
  119. data/lib/reek/smells/too_many_methods.rb +4 -2
  120. data/lib/reek/smells/too_many_statements.rb +4 -2
  121. data/lib/reek/smells/uncommunicative_method_name.rb +4 -2
  122. data/lib/reek/smells/uncommunicative_module_name.rb +4 -2
  123. data/lib/reek/smells/uncommunicative_parameter_name.rb +4 -2
  124. data/lib/reek/smells/uncommunicative_variable_name.rb +4 -2
  125. data/lib/reek/smells/unused_parameters.rb +4 -2
  126. data/lib/reek/smells/utility_function.rb +11 -22
  127. data/lib/reek/smells.rb +24 -11
  128. data/lib/reek/source/source_code.rb +69 -12
  129. data/lib/reek/source/source_locator.rb +34 -19
  130. data/lib/reek/spec/should_reek.rb +4 -3
  131. data/lib/reek/spec/should_reek_of.rb +2 -1
  132. data/lib/reek/spec/should_reek_only_of.rb +4 -3
  133. data/lib/reek/spec.rb +3 -3
  134. data/lib/reek/tree_dresser.rb +32 -0
  135. data/lib/reek/tree_walker.rb +182 -0
  136. data/lib/reek/version.rb +1 -1
  137. data/lib/reek.rb +3 -3
  138. data/reek.gemspec +18 -25
  139. data/spec/factories/factories.rb +4 -2
  140. data/spec/gem/updates_spec.rb +1 -1
  141. data/spec/gem/yard_spec.rb +2 -2
  142. data/spec/quality/reek_source_spec.rb +3 -3
  143. data/spec/reek/{source/sexp_node_spec.rb → ast/node_spec.rb} +4 -6
  144. data/spec/reek/{core → ast}/object_refs_spec.rb +4 -6
  145. data/spec/reek/{source → ast}/reference_collector_spec.rb +27 -19
  146. data/spec/reek/{source → ast}/sexp_extensions_spec.rb +7 -19
  147. data/spec/reek/{source → ast}/sexp_formatter_spec.rb +13 -8
  148. data/spec/reek/cli/option_interpreter_spec.rb +15 -0
  149. data/spec/reek/cli/options_spec.rb +19 -0
  150. data/spec/reek/cli/warning_collector_spec.rb +28 -0
  151. data/spec/reek/{source/code_comment_spec.rb → code_comment_spec.rb} +19 -17
  152. data/spec/reek/configuration/app_configuration_spec.rb +37 -26
  153. data/spec/reek/configuration/configuration_file_finder_spec.rb +67 -21
  154. data/spec/reek/{core → context}/code_context_spec.rb +18 -21
  155. data/spec/reek/{core → context}/method_context_spec.rb +33 -27
  156. data/spec/reek/{core → context}/module_context_spec.rb +5 -7
  157. data/spec/reek/context/root_context_spec.rb +14 -0
  158. data/spec/reek/context/singleton_method_context_spec.rb +17 -0
  159. data/spec/reek/examiner_spec.rb +9 -50
  160. data/spec/reek/{cli → report}/html_report_spec.rb +6 -9
  161. data/spec/reek/report/json_report_spec.rb +20 -0
  162. data/spec/reek/{cli → report}/text_report_spec.rb +16 -19
  163. data/spec/reek/report/xml_report_spec.rb +34 -0
  164. data/spec/reek/report/yaml_report_spec.rb +20 -0
  165. data/spec/reek/smells/attribute_spec.rb +93 -88
  166. data/spec/reek/smells/behaves_like_variable_detector.rb +1 -1
  167. data/spec/reek/smells/boolean_parameter_spec.rb +31 -5
  168. data/spec/reek/smells/class_variable_spec.rb +10 -10
  169. data/spec/reek/smells/control_parameter_spec.rb +5 -5
  170. data/spec/reek/smells/data_clump_spec.rb +6 -6
  171. data/spec/reek/smells/duplicate_method_call_spec.rb +7 -7
  172. data/spec/reek/smells/feature_envy_spec.rb +12 -13
  173. data/spec/reek/smells/irresponsible_module_spec.rb +28 -32
  174. data/spec/reek/smells/long_parameter_list_spec.rb +7 -7
  175. data/spec/reek/smells/long_yield_list_spec.rb +6 -6
  176. data/spec/reek/smells/module_initialize_spec.rb +4 -4
  177. data/spec/reek/smells/nested_iterators_spec.rb +6 -6
  178. data/spec/reek/smells/nil_check_spec.rb +6 -6
  179. data/spec/reek/smells/prima_donna_method_spec.rb +8 -5
  180. data/spec/reek/smells/repeated_conditional_spec.rb +18 -17
  181. data/spec/reek/{core → smells}/smell_configuration_spec.rb +5 -7
  182. data/spec/reek/smells/smell_detector_shared.rb +6 -7
  183. data/spec/reek/smells/smell_repository_spec.rb +29 -0
  184. data/spec/reek/{smell_warning_spec.rb → smells/smell_warning_spec.rb} +7 -9
  185. data/spec/reek/smells/too_many_instance_variables_spec.rb +5 -5
  186. data/spec/reek/smells/too_many_methods_spec.rb +12 -8
  187. data/spec/reek/smells/too_many_statements_spec.rb +10 -9
  188. data/spec/reek/smells/uncommunicative_method_name_spec.rb +5 -5
  189. data/spec/reek/smells/uncommunicative_module_name_spec.rb +8 -8
  190. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +18 -6
  191. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +10 -7
  192. data/spec/reek/smells/unused_parameters_spec.rb +4 -4
  193. data/spec/reek/smells/utility_function_spec.rb +65 -39
  194. data/spec/reek/source/source_code_spec.rb +10 -10
  195. data/spec/reek/source/source_locator_spec.rb +30 -0
  196. data/spec/reek/spec/should_reek_of_spec.rb +9 -25
  197. data/spec/reek/spec/should_reek_only_of_spec.rb +4 -7
  198. data/spec/reek/spec/should_reek_spec.rb +4 -32
  199. data/spec/reek/tree_dresser_spec.rb +16 -0
  200. data/spec/reek/{core/tree_walker_spec.rb → tree_walker_spec.rb} +5 -7
  201. data/spec/samples/checkstyle.xml +2 -0
  202. data/spec/samples/configuration/with_excluded_paths.reek +4 -0
  203. data/spec/samples/{overrides/masked/lower.reek → masked_by_dotfile/.reek} +3 -1
  204. data/spec/samples/source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb +5 -0
  205. data/spec/samples/source_with_exclude_paths/nested/ignore_me_as_well/irresponsible_module.rb +2 -0
  206. data/spec/samples/source_with_exclude_paths/nested/uncommunicative_parameter_name.rb +6 -0
  207. data/spec/samples/{ruby20_syntax.rb → unusual_syntax.rb} +8 -0
  208. data/spec/spec_helper.rb +21 -10
  209. data/tasks/develop.rake +2 -2
  210. data/tasks/reek.rake +1 -1
  211. metadata +158 -141
  212. data/features/support/hooks.rb +0 -15
  213. data/lib/reek/cli/report/formatter.rb +0 -69
  214. data/lib/reek/cli/report/heading_formatter.rb +0 -45
  215. data/lib/reek/cli/report/location_formatter.rb +0 -34
  216. data/lib/reek/cli/report/report.rb +0 -131
  217. data/lib/reek/core/tree_walker.rb +0 -180
  218. data/lib/reek/smell_warning.rb +0 -87
  219. data/lib/reek/source/ast_node.rb +0 -38
  220. data/lib/reek/source/code_comment.rb +0 -37
  221. data/lib/reek/source/core_extras.rb +0 -46
  222. data/lib/reek/source/reference_collector.rb +0 -27
  223. data/lib/reek/source/sexp_formatter.rb +0 -22
  224. data/lib/reek/source/sexp_node.rb +0 -79
  225. data/lib/reek/source/source_file.rb +0 -16
  226. data/lib/reek/source/source_repository.rb +0 -45
  227. data/lib/reek/source/tree_dresser.rb +0 -24
  228. data/lib/reek/source.rb +0 -16
  229. data/spec/reek/cli/json_report_spec.rb +0 -20
  230. data/spec/reek/cli/option_interperter_spec.rb +0 -14
  231. data/spec/reek/cli/yaml_report_spec.rb +0 -23
  232. data/spec/reek/core/singleton_method_context_spec.rb +0 -9
  233. data/spec/reek/core/smell_repository_spec.rb +0 -17
  234. data/spec/reek/core/stop_context_spec.rb +0 -17
  235. data/spec/reek/core/warning_collector_spec.rb +0 -30
  236. data/spec/reek/source/object_source_spec.rb +0 -20
  237. data/spec/reek/source/tree_dresser_spec.rb +0 -18
  238. data/spec/samples/config/allow_duplication.reek +0 -3
  239. data/spec/samples/config/deeper_nested_iterators.reek +0 -3
  240. data/spec/samples/configuration_loading/minimal_dirty.rb +0 -4
  241. data/spec/samples/configuration_loading/reek-test-run-disable_smells.reek +0 -7
  242. data/spec/samples/configuration_loading/reek-test-run-enable_smells.reek +0 -7
  243. data/spec/samples/corrupt_config_file/corrupt.reek +0 -1
  244. data/spec/samples/corrupt_config_file/dirty.rb +0 -8
  245. data/spec/samples/demo/demo.rb +0 -8
  246. data/spec/samples/empty_config_file/dirty.rb +0 -8
  247. data/spec/samples/empty_config_file/empty.reek +0 -0
  248. data/spec/samples/inline_config/dirty.rb +0 -16
  249. data/spec/samples/inline_config/masked.reek +0 -7
  250. data/spec/samples/mask_some/dirty.rb +0 -8
  251. data/spec/samples/mask_some/some.reek +0 -8
  252. data/spec/samples/masked/dirty.rb +0 -8
  253. data/spec/samples/masked/masked.reek +0 -5
  254. data/spec/samples/minimal_smelly_and_masked/config.reek +0 -7
  255. data/spec/samples/minimal_smelly_and_masked/minimal_dirty.rb +0 -4
  256. data/spec/samples/mixed_results/clean_one.rb +0 -7
  257. data/spec/samples/mixed_results/clean_three.rb +0 -7
  258. data/spec/samples/mixed_results/clean_two.rb +0 -7
  259. data/spec/samples/mixed_results/dirty_one.rb +0 -8
  260. data/spec/samples/mixed_results/dirty_two.rb +0 -8
  261. data/spec/samples/not_quite_masked/dirty.rb +0 -8
  262. data/spec/samples/not_quite_masked/masked.reek +0 -5
  263. data/spec/samples/not_quite_masked/smelly.rb +0 -3
  264. data/spec/samples/one_smelly_file/dirty.rb +0 -3
  265. data/spec/samples/overrides/masked/dirty.rb +0 -8
  266. data/spec/samples/overrides/upper.reek +0 -5
  267. data/spec/samples/overrides_defaults/camel_case.rb +0 -14
  268. data/spec/samples/overrides_defaults/config.reek +0 -6
  269. data/spec/samples/ruby21_syntax.rb +0 -5
  270. data/spec/samples/standard_smelly/dirty.rb +0 -8
  271. data/spec/samples/standard_smelly/minimal_dirty.rb +0 -4
  272. data/spec/samples/three_smelly_files/dirty_one.rb +0 -3
  273. data/spec/samples/three_smelly_files/dirty_three.rb +0 -5
  274. data/spec/samples/three_smelly_files/dirty_two.rb +0 -4
  275. /data/spec/samples/{simple_configuration.reek → configuration/simple_configuration.reek} +0 -0
@@ -1,22 +0,0 @@
1
- old_verbose, $VERBOSE = $VERBOSE, nil
2
- require 'unparser'
3
- $VERBOSE = old_verbose
4
-
5
- module Reek
6
- module Source
7
- #
8
- # Formats snippets of syntax tree back into Ruby source code.
9
- #
10
- class SexpFormatter
11
- def self.format(sexp)
12
- return sexp.to_s unless sexp.is_a? AST::Node
13
- lines = Unparser.unparse(sexp).split "\n"
14
- if lines.length > 1
15
- "#{lines.first} ... #{lines.last}"
16
- else
17
- lines.first
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,79 +0,0 @@
1
- module Reek
2
- module Source
3
- #
4
- # Extensions to +Sexp+ to allow +TreeWalker+ to navigate the abstract
5
- # syntax tree more easily.
6
- #
7
- module SexpNode
8
- def self.format(expr)
9
- case expr
10
- when AST::Node then expr.format_ruby
11
- else expr.to_s
12
- end
13
- end
14
-
15
- def hash
16
- inspect.hash
17
- end
18
-
19
- def each_node(type, ignoring = [], &blk)
20
- if block_given?
21
- look_for(type, ignoring, &blk)
22
- else
23
- result = []
24
- look_for(type, ignoring) { |exp| result << exp }
25
- result
26
- end
27
- end
28
-
29
- def find_nodes(types, ignoring = [])
30
- result = []
31
- look_for_alt(types, ignoring) { |exp| result << exp }
32
- result
33
- end
34
-
35
- def each_sexp
36
- children.each { |elem| yield elem if elem.is_a? AST::Node }
37
- end
38
-
39
- #
40
- # Carries out a depth-first traversal of this syntax tree, yielding
41
- # every Sexp of type +target_type+. The traversal ignores any node
42
- # whose type is listed in the Array +ignoring+.
43
- #
44
- def look_for(target_type, ignoring = [], &blk)
45
- each_sexp do |elem|
46
- elem.look_for(target_type, ignoring, &blk) unless ignoring.include?(elem.type)
47
- end
48
- blk.call(self) if type == target_type
49
- end
50
-
51
- #
52
- # Carries out a depth-first traversal of this syntax tree, yielding
53
- # every Sexp of type +target_type+. The traversal ignores any node
54
- # whose type is listed in the Array +ignoring+, includeing the top node.
55
- #
56
- # Also, doesn't nest
57
- #
58
- def look_for_alt(target_types, ignoring = [], &blk)
59
- return if ignoring.include?(type)
60
- if target_types.include? type
61
- blk.call(self)
62
- else
63
- each_sexp do |elem|
64
- elem.look_for_alt(target_types, ignoring, &blk)
65
- end
66
- end
67
- end
68
-
69
- def contains_nested_node?(target_type)
70
- look_for(target_type) { |_elem| return true }
71
- false
72
- end
73
-
74
- def format_ruby
75
- SexpFormatter.format(self)
76
- end
77
- end
78
- end
79
- end
@@ -1,16 +0,0 @@
1
- require 'reek/source/source_code'
2
-
3
- module Reek
4
- module Source
5
- #
6
- # Represents a file of Ruby source, whose contents will be examined
7
- # for code smells.
8
- #
9
- class SourceFile < SourceCode
10
- def initialize(path)
11
- @path = path
12
- super(IO.readlines(@path).join, @path)
13
- end
14
- end
15
- end
16
- end
@@ -1,45 +0,0 @@
1
- require 'reek/source/core_extras'
2
- require 'reek/source/source_code'
3
- require 'reek/source/source_locator'
4
-
5
- module Reek
6
- module Source
7
- #
8
- # A collection of source code. If the collection is initialized with an array
9
- # it is assumed to be a list of file paths. Otherwise it is assumed to be a
10
- # single unit of Ruby source code.
11
- #
12
- class SourceRepository
13
- # TODO: This method is a least partially broken.
14
- # Regardless of how you call reek, be it:
15
- # reek lib/
16
- # reek lib/file_one.rb lib/file_two.rb
17
- # echo "def m; end" | reek
18
- # we *always* end up in the "when Source::SourceCode" branch.
19
- # So it seems like 80% of this method is never used.
20
- def self.parse(source)
21
- case source
22
- when Array
23
- new 'dir', Source::SourceLocator.new(source).all_sources
24
- when Source::SourceCode
25
- new source.desc, [source]
26
- else
27
- src = source.to_reek_source
28
- new src.desc, [src]
29
- end
30
- end
31
-
32
- include Enumerable
33
- attr_reader :description
34
-
35
- def initialize(description, sources)
36
- @description = description
37
- @sources = sources
38
- end
39
-
40
- def each(&block)
41
- @sources.each(&block)
42
- end
43
- end
44
- end
45
- end
@@ -1,24 +0,0 @@
1
- require 'reek/source/ast_node_class_map'
2
-
3
- module Reek
4
- module Source
5
- #
6
- # Adorns an abstract syntax tree with mix-in modules to make accessing
7
- # the tree more understandable and less implementation-dependent.
8
- #
9
- class TreeDresser
10
- def initialize(klass_map = AstNodeClassMap.new)
11
- @klass_map = klass_map
12
- end
13
-
14
- def dress(sexp, comment_map)
15
- return sexp unless sexp.is_a? AST::Node
16
- type = sexp.type
17
- children = sexp.children.map { |child| dress(child, comment_map) }
18
- comments = comment_map[sexp]
19
- @klass_map.klass_for(type).new(type, children,
20
- location: sexp.loc, comments: comments)
21
- end
22
- end
23
- end
24
- end
data/lib/reek/source.rb DELETED
@@ -1,16 +0,0 @@
1
- require 'reek/source/code_comment'
2
- require 'reek/source/core_extras'
3
- require 'reek/source/sexp_formatter'
4
- require 'reek/source/source_code'
5
- require 'reek/source/source_file'
6
- require 'reek/source/source_locator'
7
- require 'reek/source/tree_dresser'
8
-
9
- module Reek
10
- #
11
- # This module contains a set of classes for interacting with Ruby
12
- # source code and abstract syntax trees.
13
- #
14
- module Source # :nodoc: all
15
- end
16
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
- require 'reek/examiner'
3
- require 'reek/cli/report/report'
4
- require 'reek/cli/report/formatter'
5
-
6
- describe Reek::Cli::Report::JsonReport do
7
- let(:instance) { Reek::Cli::Report::JsonReport.new }
8
-
9
- context 'empty source' do
10
- let(:examiner) { Reek::Examiner.new('') }
11
-
12
- before do
13
- instance.add_examiner examiner
14
- end
15
-
16
- it 'prints empty json' do
17
- expect { instance.show }.to output(/^\[\]$/).to_stdout
18
- end
19
- end
20
- end
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
-
3
- require 'reek/cli/options'
4
-
5
- describe Reek::Cli::OptionInterpreter do
6
- let(:options) { OpenStruct.new }
7
- let(:instance) { Reek::Cli::OptionInterpreter.new(options) }
8
-
9
- describe '#reporter' do
10
- it 'returns a Report::TextReport instance by default' do
11
- expect(instance.reporter).to be_instance_of Reek::Cli::Report::TextReport
12
- end
13
- end
14
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
- require 'reek/examiner'
3
- require 'reek/cli/report/report'
4
- require 'reek/cli/report/formatter'
5
-
6
- include Reek
7
- include Reek::Cli
8
-
9
- describe Report::YamlReport do
10
- let(:instance) { Report::YamlReport.new }
11
-
12
- context 'empty source' do
13
- let(:examiner) { Examiner.new('') }
14
-
15
- before do
16
- instance.add_examiner examiner
17
- end
18
-
19
- it 'prints empty yaml' do
20
- expect { instance.show }.to output(/^--- \[\]\n.*$/).to_stdout
21
- end
22
- end
23
- end
@@ -1,9 +0,0 @@
1
- require 'spec_helper'
2
- require 'reek/core/module_context'
3
- require 'reek/core/singleton_method_context'
4
- require 'reek/core/stop_context'
5
-
6
- include Reek::Core
7
-
8
- describe SingletonMethodContext do
9
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
- require 'reek/core/smell_repository'
3
-
4
- include Reek::Core
5
-
6
- describe SmellRepository do
7
- describe '.smell_types' do
8
- it 'should include existing smell_types' do
9
- expect(SmellRepository.smell_types).to include(Reek::Smells::IrresponsibleModule)
10
- expect(SmellRepository.smell_types).to include(Reek::Smells::TooManyStatements)
11
- end
12
-
13
- it 'should exclude certain smell_types' do
14
- expect(SmellRepository.smell_types).to_not include(Reek::Smells::SmellDetector)
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
- require 'reek/core/stop_context'
3
-
4
- include Reek
5
- include Reek::Core
6
-
7
- describe StopContext do
8
- before :each do
9
- @stop = StopContext.new
10
- end
11
-
12
- context 'full_name' do
13
- it 'reports full context' do
14
- expect(@stop.full_name).to eq('')
15
- end
16
- end
17
- end
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
- require 'reek/core/warning_collector'
3
- require 'reek/smell_warning'
4
-
5
- include Reek::Core
6
-
7
- describe WarningCollector do
8
- before(:each) do
9
- @collector = WarningCollector.new
10
- end
11
-
12
- context 'when empty' do
13
- it 'reports no warnings' do
14
- expect(@collector.warnings).to eq([])
15
- end
16
- end
17
-
18
- context 'with one warning' do
19
- before :each do
20
- @warning = Reek::SmellWarning.new(Reek::Smells::FeatureEnvy.new(''),
21
- context: 'fred',
22
- lines: [1, 2, 3],
23
- message: 'hello')
24
- @collector.found_smell(@warning)
25
- end
26
- it 'reports that warning' do
27
- expect(@collector.warnings).to eq([@warning])
28
- end
29
- end
30
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include Reek
4
-
5
- describe Dir do
6
- it 'reports correct smells via the Dir matcher' do
7
- files = Dir['spec/samples/two_smelly_files/*.rb']
8
- expect(files).to reek
9
- expect(files).to reek_of(:UncommunicativeVariableName)
10
- expect(files).not_to reek_of(:LargeClass)
11
- end
12
-
13
- it 'copes with daft file specs' do
14
- expect(Dir['spec/samples/two_smelly_files/*/.rb']).not_to reek
15
- end
16
-
17
- it 'copes with empty array' do
18
- expect([]).not_to reek
19
- end
20
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
- require 'reek/source/tree_dresser'
3
-
4
- include Reek::Source
5
-
6
- describe TreeDresser do
7
- let(:ifnode) { Parser::AST::Node.new(:if) }
8
- let(:sendnode) { Parser::AST::Node.new(:send) }
9
- let(:dresser) { TreeDresser.new }
10
-
11
- it 'dresses :if sexp with IfNode' do
12
- expect(dresser.dress(ifnode, {})).to be_a Reek::Source::SexpExtensions::IfNode
13
- end
14
-
15
- it 'dresses :send sexp with SendNode' do
16
- expect(dresser.dress(sendnode, {})).to be_a Reek::Source::SexpExtensions::SendNode
17
- end
18
- end
@@ -1,3 +0,0 @@
1
- ---
2
- DuplicateMethodCall:
3
- enabled: false
@@ -1,3 +0,0 @@
1
- ---
2
- NestedIterators:
3
- max_allowed_nesting: 3
@@ -1,4 +0,0 @@
1
- class C
2
- def m
3
- end
4
- end
@@ -1,7 +0,0 @@
1
- ---
2
- IrresponsibleModule:
3
- enabled: false
4
- UncommunicativeModuleName:
5
- enabled: false
6
- UncommunicativeMethodName:
7
- enabled: false
@@ -1,7 +0,0 @@
1
- ---
2
- IrresponsibleModule:
3
- enabled: true
4
- UncommunicativeModuleName:
5
- enabled: true
6
- UncommunicativeMethodName:
7
- enabled: true
@@ -1 +0,0 @@
1
- This is not a config file
@@ -1,8 +0,0 @@
1
- # smelly class for testing purposes
2
- class Dirty
3
- def a
4
- puts @s.title
5
- @s = fred.map {|x| x.each {|key| key += 3}}
6
- puts @s.title
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- class Dirty
2
- # This method smells of :reek:NestedIterators but ignores them
3
- def awful(x, y, offset = 0, log = false)
4
- puts @screen.title
5
- @screen = widgets.map {|w| w.each {|key| key += 3}}
6
- puts @screen.contents
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- # smelly class for testing purposes
2
- class Dirty
3
- def a
4
- puts @s.title
5
- @s = fred.map {|x| x.each {|key| key += 3}}
6
- puts @s.title
7
- end
8
- end
File without changes
@@ -1,16 +0,0 @@
1
- # :reek:DuplicateMethodCall: { allow_calls: [ puts ] }
2
- # smells of :reek:NestedIterators but ignores them
3
- class Dirty
4
- def a
5
- puts @s.title
6
- @s = fred.map {|x| x.each {|key| key += 3}}
7
- puts @s.title
8
- end
9
-
10
- # :reek:DuplicateMethodCall: { max_calls: 2 }
11
- def b
12
- puts @s.title
13
- @s = fred.map {|x| x.each {|key| key += 3}}
14
- puts @s.title
15
- end
16
- end
@@ -1,7 +0,0 @@
1
- ---
2
- IrresponsibleModule:
3
- enabled: false
4
- UncommunicativeVariableName:
5
- enabled: false
6
- UncommunicativeMethodName:
7
- enabled: false
@@ -1,8 +0,0 @@
1
- # smelly class for testing purposes
2
- class Dirty
3
- def a
4
- puts @s.title
5
- @s = fred.map {|x| x.each {|key| key += 3}}
6
- puts @s.title
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- ---
2
- DuplicateMethodCall:
3
- allow_calls:
4
- - puts\(@s.title\)
5
- UncommunicativeVariableName:
6
- enabled: false
7
- UncommunicativeMethodName:
8
- enabled: false
@@ -1,8 +0,0 @@
1
- # smelly class for testing purposes
2
- class Dirty
3
- def a
4
- puts @s.title
5
- @s = fred.map {|x| x.each {|key| key += 3}}
6
- puts @s.title
7
- end
8
- end
@@ -1,5 +0,0 @@
1
- ---
2
- UncommunicativeVariableName:
3
- enabled: false
4
- UncommunicativeMethodName:
5
- enabled: false
@@ -1,7 +0,0 @@
1
- ---
2
- IrresponsibleModule:
3
- enabled: false
4
- UncommunicativeModuleName:
5
- enabled: false
6
- UncommunicativeMethodName:
7
- enabled: false
@@ -1,4 +0,0 @@
1
- class C
2
- def m
3
- end
4
- end
@@ -1,7 +0,0 @@
1
- # clean class for testing purposes
2
- class Clean
3
- def assign
4
- puts @sub.title
5
- @sub.map {|para| para.name }
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- # clean class for testing purposes
2
- class Clean
3
- def assign
4
- puts @sub.title
5
- @sub.map {|para| para.name }
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- # clean class for testing purposes
2
- class Clean
3
- def assign
4
- puts @sub.title
5
- @sub.map {|para| para.name }
6
- end
7
- end
@@ -1,8 +0,0 @@
1
- # smelly class for testing purposes
2
- class Dirty
3
- def a
4
- puts @s.title
5
- @s.map {|x| x.each {|key| key += 3}}
6
- puts @s.title
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- # smelly class for testing purposes
2
- class Dirty
3
- def a
4
- puts @s.title
5
- @s.map {|x| x.each {|key| key += 3}}
6
- puts @s.title
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- # smelly class for testing purposes
2
- class Dirty
3
- def a
4
- puts @s.title
5
- @s = fred.map {|x| x.each {|key| key += 3}}
6
- puts @s.title
7
- end
8
- end
@@ -1,5 +0,0 @@
1
- ---
2
- UncommunicativeVariableName:
3
- accept:
4
- - x
5
-
@@ -1,3 +0,0 @@
1
- def f(x)
2
- 12.nil?
3
- end
@@ -1,3 +0,0 @@
1
- class D
2
- def a; end
3
- end
@@ -1,8 +0,0 @@
1
- # smelly class for testing purposes
2
- class Dirty
3
- def a
4
- puts @s.title
5
- @s = fred.map {|x| x.each {|key| key += 3}}
6
- puts @s.title
7
- end
8
- end
@@ -1,5 +0,0 @@
1
- ---
2
- DuplicateMethodCall:
3
- enabled: false
4
- NestedIterators:
5
- enabled: false
@@ -1,14 +0,0 @@
1
- # Class containing camelCase variable which would normally smell
2
- class CamelCase
3
- def initialize
4
- # These next two would normally smell if it weren't for overridden config values
5
- camelCaseVariable = []
6
- anotherOne = 1
7
-
8
- # this next one should still smell
9
- x1 = 0
10
-
11
- # this next one should not smell
12
- should_not_smell = true
13
- end
14
- end
@@ -1,6 +0,0 @@
1
- ---
2
- UncommunicativeVariableName:
3
- enabled: true
4
- reject:
5
- - !ruby/regexp /^.$/
6
- - !ruby/regexp /[0-9]$/
@@ -1,5 +0,0 @@
1
- class SomeClass
2
- def method_with_required_keyword_arguments(foo:)
3
- puts foo
4
- end
5
- end
@@ -1,8 +0,0 @@
1
- # smelly class for testing purposes
2
- class Dirty
3
- def a
4
- puts @s.title
5
- @s = fred.map {|x| x.each {|key| key += 3}}
6
- puts @s.title
7
- end
8
- end