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
@@ -4,50 +4,40 @@ Feature: Correctly formatted reports
4
4
  I want to be able to parse reek's output simply and consistently
5
5
 
6
6
  Scenario Outline: two reports run together with indented smells
7
+ Given a directory called 'smelly' containing two smelly files
7
8
  When I run reek <args>
8
9
  Then the exit status indicates smells
9
10
  And it reports:
10
11
  """
11
- spec/samples/two_smelly_files/dirty_one.rb -- 6 warnings:
12
- [5]:Dirty has the variable name '@s' (UncommunicativeVariableName)
13
- [4, 6]:Dirty#a calls @s.title 2 times (DuplicateMethodCall)
14
- [4, 6]:Dirty#a calls puts(@s.title) 2 times (DuplicateMethodCall)
15
- [5]:Dirty#a contains iterators nested 2 deep (NestedIterators)
16
- [3]:Dirty#a has the name 'a' (UncommunicativeMethodName)
17
- [5]:Dirty#a has the variable name 'x' (UncommunicativeVariableName)
18
- spec/samples/two_smelly_files/dirty_two.rb -- 6 warnings:
19
- [5]:Dirty has the variable name '@s' (UncommunicativeVariableName)
20
- [4, 6]:Dirty#a calls @s.title 2 times (DuplicateMethodCall)
21
- [4, 6]:Dirty#a calls puts(@s.title) 2 times (DuplicateMethodCall)
22
- [5]:Dirty#a contains iterators nested 2 deep (NestedIterators)
23
- [3]:Dirty#a has the name 'a' (UncommunicativeMethodName)
24
- [5]:Dirty#a has the variable name 'x' (UncommunicativeVariableName)
25
- 12 total warnings
12
+ smelly/dirty_one.rb -- 2 warnings:
13
+ [1]:Dirty has no descriptive comment (IrresponsibleModule)
14
+ [2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
15
+ smelly/dirty_two.rb -- 3 warnings:
16
+ [1]:Dirty has no descriptive comment (IrresponsibleModule)
17
+ [2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
18
+ [3]:Dirty#b has the name 'b' (UncommunicativeMethodName)
19
+ 5 total warnings
26
20
  """
27
21
 
28
22
  Examples:
29
- | args |
30
- | spec/samples/two_smelly_files/*.rb |
31
- | spec/samples/two_smelly_files |
23
+ | args |
24
+ | smelly/dirty_one.rb smelly/dirty_two.rb |
25
+ | smelly |
32
26
 
33
27
  Scenario Outline: No sorting (which means report each file as it is read in)
34
- When I run reek <option> spec/samples/three_smelly_files/*.rb
28
+ Given a directory called 'smelly' containing two smelly files
29
+ When I run reek <option> smelly
35
30
  Then the exit status indicates smells
36
31
  And it reports:
37
32
  """
38
- spec/samples/three_smelly_files/dirty_one.rb -- 2 warnings:
33
+ smelly/dirty_one.rb -- 2 warnings:
39
34
  [1]:Dirty has no descriptive comment (IrresponsibleModule)
40
35
  [2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
41
- spec/samples/three_smelly_files/dirty_three.rb -- 4 warnings:
36
+ smelly/dirty_two.rb -- 3 warnings:
42
37
  [1]:Dirty has no descriptive comment (IrresponsibleModule)
43
38
  [2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
44
39
  [3]:Dirty#b has the name 'b' (UncommunicativeMethodName)
45
- [4]:Dirty#c has the name 'c' (UncommunicativeMethodName)
46
- spec/samples/three_smelly_files/dirty_two.rb -- 3 warnings:
47
- [1]:Dirty has no descriptive comment (IrresponsibleModule)
48
- [2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
49
- [3]:Dirty#b has the name 'b' (UncommunicativeMethodName)
50
- 9 total warnings
40
+ 5 total warnings
51
41
  """
52
42
 
53
43
  Examples:
@@ -57,23 +47,19 @@ Feature: Correctly formatted reports
57
47
  | --sort-by n |
58
48
 
59
49
  Scenario Outline: Sort by issue count
60
- When I run reek <option> spec/samples/three_smelly_files/*.rb
50
+ Given a directory called 'smelly' containing two smelly files
51
+ When I run reek <option> smelly
61
52
  Then the exit status indicates smells
62
53
  And it reports:
63
54
  """
64
- spec/samples/three_smelly_files/dirty_three.rb -- 4 warnings:
65
- [1]:Dirty has no descriptive comment (IrresponsibleModule)
66
- [2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
67
- [3]:Dirty#b has the name 'b' (UncommunicativeMethodName)
68
- [4]:Dirty#c has the name 'c' (UncommunicativeMethodName)
69
- spec/samples/three_smelly_files/dirty_two.rb -- 3 warnings:
55
+ smelly/dirty_two.rb -- 3 warnings:
70
56
  [1]:Dirty has no descriptive comment (IrresponsibleModule)
71
57
  [2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
72
58
  [3]:Dirty#b has the name 'b' (UncommunicativeMethodName)
73
- spec/samples/three_smelly_files/dirty_one.rb -- 2 warnings:
59
+ smelly/dirty_one.rb -- 2 warnings:
74
60
  [1]:Dirty has no descriptive comment (IrresponsibleModule)
75
61
  [2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
76
- 9 total warnings
62
+ 5 total warnings
77
63
  """
78
64
 
79
65
  Examples:
@@ -81,27 +67,24 @@ Feature: Correctly formatted reports
81
67
  | --sort-by smelliness |
82
68
  | --sort-by s |
83
69
 
84
- Scenario Outline: good files show no headings by default
85
- When I run reek <args>
70
+ Scenario: good files show no headings by default
71
+ Given a directory called 'clean_files' containing some clean files
72
+ When I run reek clean_files
86
73
  Then it succeeds
87
74
  And it reports:
88
75
  """
89
76
  0 total warnings
90
77
  """
91
78
 
92
- Examples:
93
- | args |
94
- | spec/samples/three_clean_files/*.rb |
95
- | spec/samples/three_clean_files |
96
-
97
79
  Scenario Outline: --empty-headings turns on headings for fragrant files
98
- When I run reek <option> spec/samples/three_clean_files/*.rb
80
+ Given a directory called 'clean_files' containing some clean files
81
+ When I run reek <option> clean_files
99
82
  Then it succeeds
100
83
  And it reports:
101
84
  """
102
- spec/samples/three_clean_files/clean_one.rb -- 0 warnings
103
- spec/samples/three_clean_files/clean_three.rb -- 0 warnings
104
- spec/samples/three_clean_files/clean_two.rb -- 0 warnings
85
+ clean_files/clean_one.rb -- 0 warnings
86
+ clean_files/clean_three.rb -- 0 warnings
87
+ clean_files/clean_two.rb -- 0 warnings
105
88
  0 total warnings
106
89
  """
107
90
 
@@ -111,12 +94,13 @@ Feature: Correctly formatted reports
111
94
  | -V |
112
95
 
113
96
  Scenario Outline: --no-empty-headings turns off headings for fragrant files
114
- When I run reek <option> spec/samples/three_clean_files/*.rb
97
+ Given a directory called 'clean_files' containing some clean files
98
+ When I run reek <option> clean_files
115
99
  Then it succeeds
116
100
  And it reports:
117
- """
118
- 0 total warnings
119
- """
101
+ """
102
+ 0 total warnings
103
+ """
120
104
 
121
105
  Examples:
122
106
  | option |
@@ -124,17 +108,15 @@ Feature: Correctly formatted reports
124
108
  | -V --no-empty-headings |
125
109
 
126
110
  Scenario Outline: --no-line-numbers turns off line numbers
127
- When I run reek <option> spec/samples/standard_smelly/dirty.rb
111
+ Given a smelly file called 'smelly.rb'
112
+ When I run reek <option> smelly.rb
128
113
  Then the exit status indicates smells
129
114
  And it reports:
130
115
  """
131
- spec/samples/standard_smelly/dirty.rb -- 6 warnings:
132
- Dirty has the variable name '@s' (UncommunicativeVariableName)
133
- Dirty#a calls @s.title 2 times (DuplicateMethodCall)
134
- Dirty#a calls puts(@s.title) 2 times (DuplicateMethodCall)
135
- Dirty#a contains iterators nested 2 deep (NestedIterators)
136
- Dirty#a has the name 'a' (UncommunicativeMethodName)
137
- Dirty#a has the variable name 'x' (UncommunicativeVariableName)
116
+ smelly.rb -- 3 warnings:
117
+ Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
118
+ Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall)
119
+ Smelly#m has the name 'm' (UncommunicativeMethodName)
138
120
  """
139
121
 
140
122
  Examples:
@@ -144,17 +126,15 @@ Feature: Correctly formatted reports
144
126
  | -V --no-line-numbers |
145
127
 
146
128
  Scenario Outline: --line-numbers turns on line numbers
147
- When I run reek <option> spec/samples/standard_smelly/dirty.rb
129
+ Given a smelly file called 'smelly.rb'
130
+ When I run reek <option> smelly.rb
148
131
  Then the exit status indicates smells
149
132
  And it reports:
150
133
  """
151
- spec/samples/standard_smelly/dirty.rb -- 6 warnings:
152
- [5]:Dirty has the variable name '@s' (UncommunicativeVariableName)
153
- [4, 6]:Dirty#a calls @s.title 2 times (DuplicateMethodCall)
154
- [4, 6]:Dirty#a calls puts(@s.title) 2 times (DuplicateMethodCall)
155
- [5]:Dirty#a contains iterators nested 2 deep (NestedIterators)
156
- [3]:Dirty#a has the name 'a' (UncommunicativeMethodName)
157
- [5]:Dirty#a has the variable name 'x' (UncommunicativeVariableName)
134
+ smelly.rb -- 3 warnings:
135
+ [4, 5]:Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
136
+ [4, 5]:Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall)
137
+ [3]:Smelly#m has the name 'm' (UncommunicativeMethodName)
158
138
  """
159
139
 
160
140
  Examples:
@@ -164,17 +144,15 @@ Feature: Correctly formatted reports
164
144
  | --no-line-numbers -n |
165
145
 
166
146
  Scenario Outline: --single-line shows filename and one line number
167
- When I run reek <option> spec/samples/standard_smelly/dirty.rb
147
+ Given a smelly file called 'smelly.rb'
148
+ When I run reek <option> smelly.rb
168
149
  Then the exit status indicates smells
169
150
  And it reports:
170
151
  """
171
- spec/samples/standard_smelly/dirty.rb -- 6 warnings:
172
- spec/samples/standard_smelly/dirty.rb:5: Dirty has the variable name '@s' (UncommunicativeVariableName)
173
- spec/samples/standard_smelly/dirty.rb:4: Dirty#a calls @s.title 2 times (DuplicateMethodCall)
174
- spec/samples/standard_smelly/dirty.rb:4: Dirty#a calls puts(@s.title) 2 times (DuplicateMethodCall)
175
- spec/samples/standard_smelly/dirty.rb:5: Dirty#a contains iterators nested 2 deep (NestedIterators)
176
- spec/samples/standard_smelly/dirty.rb:3: Dirty#a has the name 'a' (UncommunicativeMethodName)
177
- spec/samples/standard_smelly/dirty.rb:5: Dirty#a has the variable name 'x' (UncommunicativeVariableName)
152
+ smelly.rb -- 3 warnings:
153
+ smelly.rb:4: Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
154
+ smelly.rb:4: Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall)
155
+ smelly.rb:3: Smelly#m has the name 'm' (UncommunicativeMethodName)
178
156
  """
179
157
 
180
158
  Examples:
@@ -185,41 +163,36 @@ Feature: Correctly formatted reports
185
163
  | -V -s |
186
164
 
187
165
  Scenario Outline: Extra slashes aren't added to directory names
166
+ Given a directory called 'smelly' containing two smelly files
188
167
  When I run reek <args>
189
168
  Then the exit status indicates smells
190
169
  And it reports:
191
170
  """
192
- spec/samples/two_smelly_files/dirty_one.rb -- 6 warnings:
193
- [5]:Dirty has the variable name '@s' (UncommunicativeVariableName)
194
- [4, 6]:Dirty#a calls @s.title 2 times (DuplicateMethodCall)
195
- [4, 6]:Dirty#a calls puts(@s.title) 2 times (DuplicateMethodCall)
196
- [5]:Dirty#a contains iterators nested 2 deep (NestedIterators)
197
- [3]:Dirty#a has the name 'a' (UncommunicativeMethodName)
198
- [5]:Dirty#a has the variable name 'x' (UncommunicativeVariableName)
199
- spec/samples/two_smelly_files/dirty_two.rb -- 6 warnings:
200
- [5]:Dirty has the variable name '@s' (UncommunicativeVariableName)
201
- [4, 6]:Dirty#a calls @s.title 2 times (DuplicateMethodCall)
202
- [4, 6]:Dirty#a calls puts(@s.title) 2 times (DuplicateMethodCall)
203
- [5]:Dirty#a contains iterators nested 2 deep (NestedIterators)
204
- [3]:Dirty#a has the name 'a' (UncommunicativeMethodName)
205
- [5]:Dirty#a has the variable name 'x' (UncommunicativeVariableName)
206
- 12 total warnings
171
+ smelly/dirty_one.rb -- 2 warnings:
172
+ [1]:Dirty has no descriptive comment (IrresponsibleModule)
173
+ [2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
174
+ smelly/dirty_two.rb -- 3 warnings:
175
+ [1]:Dirty has no descriptive comment (IrresponsibleModule)
176
+ [2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
177
+ [3]:Dirty#b has the name 'b' (UncommunicativeMethodName)
178
+ 5 total warnings
207
179
  """
208
180
 
209
181
  Examples:
210
- | args |
211
- | spec/samples/two_smelly_files/ |
212
- | spec/samples/two_smelly_files |
182
+ | args |
183
+ | smelly/ |
184
+ | smelly |
213
185
 
214
186
  Scenario Outline: -U or --wiki-links adds helpful links to smell warnings
215
- When I run reek <option> spec/samples/one_smelly_file/dirty.rb
187
+ Given a smelly file called 'smelly.rb'
188
+ When I run reek <option> smelly.rb
216
189
  Then the exit status indicates smells
217
190
  And it reports:
218
191
  """
219
- spec/samples/one_smelly_file/dirty.rb -- 3 warnings:
220
- [1]:D has no descriptive comment (IrresponsibleModule) [https://github.com/troessner/reek/wiki/Irresponsible-Module]
221
- [1]:D has the name 'D' (UncommunicativeModuleName) [https://github.com/troessner/reek/wiki/Uncommunicative-Module-Name]
222
- [2]:D#a has the name 'a' (UncommunicativeMethodName) [https://github.com/troessner/reek/wiki/Uncommunicative-Method-Name]
192
+ smelly.rb -- 3 warnings:
193
+ [4, 5]:Smelly#m calls @foo.bar 2 times (DuplicateMethodCall) [https://github.com/troessner/reek/wiki/Duplicate-Method-Call]
194
+ [4, 5]:Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall) [https://github.com/troessner/reek/wiki/Duplicate-Method-Call]
195
+ [3]:Smelly#m has the name 'm' (UncommunicativeMethodName) [https://github.com/troessner/reek/wiki/Uncommunicative-Method-Name]
223
196
  """
224
197
 
225
198
  Examples:
@@ -228,14 +201,15 @@ Feature: Correctly formatted reports
228
201
  | --wiki-links |
229
202
 
230
203
  Scenario Outline: --wiki-links is independent of --line-numbers
231
- When I run reek <option> spec/samples/one_smelly_file/dirty.rb
204
+ Given a smelly file called 'smelly.rb'
205
+ When I run reek <option> smelly.rb
232
206
  Then the exit status indicates smells
233
207
  And it reports:
234
208
  """
235
- spec/samples/one_smelly_file/dirty.rb -- 3 warnings:
236
- D has no descriptive comment (IrresponsibleModule) [https://github.com/troessner/reek/wiki/Irresponsible-Module]
237
- D has the name 'D' (UncommunicativeModuleName) [https://github.com/troessner/reek/wiki/Uncommunicative-Module-Name]
238
- D#a has the name 'a' (UncommunicativeMethodName) [https://github.com/troessner/reek/wiki/Uncommunicative-Method-Name]
209
+ smelly.rb -- 3 warnings:
210
+ Smelly#m calls @foo.bar 2 times (DuplicateMethodCall) [https://github.com/troessner/reek/wiki/Duplicate-Method-Call]
211
+ Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall) [https://github.com/troessner/reek/wiki/Duplicate-Method-Call]
212
+ Smelly#m has the name 'm' (UncommunicativeMethodName) [https://github.com/troessner/reek/wiki/Uncommunicative-Method-Name]
239
213
  """
240
214
 
241
215
  Examples:
@@ -3,7 +3,8 @@ Feature: Report smells using simple YAML layout
3
3
  output a list of smells in Yaml.
4
4
 
5
5
  Scenario: output is empty when there are no smells
6
- When I run reek --format yaml spec/samples/three_clean_files
6
+ Given a directory called 'clean_files' containing some clean files
7
+ When I run reek --format yaml clean_files
7
8
  Then it succeeds
8
9
  And it reports this yaml:
9
10
  """
@@ -11,33 +12,38 @@ Feature: Report smells using simple YAML layout
11
12
  """
12
13
 
13
14
  Scenario: Indicate smells and print them as yaml when using files
14
- When I run reek --format yaml spec/samples/standard_smelly/minimal_dirty.rb
15
+ Given a smelly file called 'smelly.rb'
16
+ When I run reek --format yaml smelly.rb
15
17
  Then the exit status indicates smells
16
18
  And it reports this yaml:
17
19
  """
18
20
  ---
19
- - smell_category: IrresponsibleModule
20
- smell_type: IrresponsibleModule
21
- source: spec/samples/standard_smelly/minimal_dirty.rb
22
- context: C
21
+ - smell_category: Duplication
22
+ smell_type: DuplicateMethodCall
23
+ source: smelly.rb
24
+ context: Smelly#m
23
25
  lines:
24
- - 1
25
- message: has no descriptive comment
26
- name: C
27
- - smell_category: UncommunicativeName
28
- smell_type: UncommunicativeModuleName
29
- source: spec/samples/standard_smelly/minimal_dirty.rb
30
- context: C
26
+ - 4
27
+ - 5
28
+ message: calls @foo.bar 2 times
29
+ name: "@foo.bar"
30
+ count: 2
31
+ - smell_category: Duplication
32
+ smell_type: DuplicateMethodCall
33
+ source: smelly.rb
34
+ context: Smelly#m
31
35
  lines:
32
- - 1
33
- message: has the name 'C'
34
- name: C
36
+ - 4
37
+ - 5
38
+ message: calls puts(@foo.bar) 2 times
39
+ name: puts(@foo.bar)
40
+ count: 2
35
41
  - smell_category: UncommunicativeName
36
42
  smell_type: UncommunicativeMethodName
37
- source: spec/samples/standard_smelly/minimal_dirty.rb
38
- context: C#m
43
+ source: smelly.rb
44
+ context: Smelly#m
39
45
  lines:
40
- - 2
46
+ - 3
41
47
  message: has the name 'm'
42
48
  name: m
43
49
  """
@@ -50,7 +56,7 @@ Feature: Report smells using simple YAML layout
50
56
  ---
51
57
  - smell_category: IrresponsibleModule
52
58
  smell_type: IrresponsibleModule
53
- source: "$stdin"
59
+ source: "STDIN"
54
60
  context: Turn
55
61
  lines:
56
62
  - 1
@@ -4,19 +4,21 @@ Feature: Basic smell detection
4
4
  I want to detect the smells in my Ruby code
5
5
 
6
6
  Scenario: Correct smells from inline.rb
7
- When I run reek --no-line-numbers spec/samples/inline.rb
7
+ Given the "inline.rb" sample file exists
8
+ When I run reek --no-line-numbers inline.rb
8
9
  Then the exit status indicates smells
9
10
  And it reports:
10
11
  """
11
- spec/samples/inline.rb -- 44 warnings:
12
+ inline.rb -- 45 warnings:
12
13
  CompilationError has no descriptive comment (IrresponsibleModule)
14
+ Dir has no descriptive comment (IrresponsibleModule)
13
15
  File has no descriptive comment (IrresponsibleModule)
14
16
  File#self.write_with_backup has approx 6 statements (TooManyStatements)
15
17
  Inline declares the class variable @@directory (ClassVariable)
16
18
  Inline declares the class variable @@rootdir (ClassVariable)
17
19
  Inline#self.rootdir calls env.nil? 2 times (DuplicateMethodCall)
18
20
  Inline#self.rootdir has approx 8 statements (TooManyStatements)
19
- Inline#self.rootdir performs a nil-check. (NilCheck)
21
+ Inline#self.rootdir performs a nil-check (NilCheck)
20
22
  Inline::C declares the class variable @@type_map (ClassVariable)
21
23
  Inline::C has at least 13 instance variables (TooManyInstanceVariables)
22
24
  Inline::C takes parameters [options, src] to 5 methods (DataClump)
@@ -49,18 +51,19 @@ Feature: Basic smell detection
49
51
  Inline::C#parse_signature has the variable name 'x' (UncommunicativeVariableName)
50
52
  Inline::C#parse_signature is controlled by argument raw (ControlParameter)
51
53
  Inline::C#strip_comments doesn't depend on instance state (UtilityFunction)
52
- Inline::C#strip_comments refers to src more than self (FeatureEnvy)
54
+ Module has no descriptive comment (IrresponsibleModule)
53
55
  Module#inline calls Inline.const_get(lang) 2 times (DuplicateMethodCall)
54
56
  Module#inline calls options[:testing] 2 times (DuplicateMethodCall)
55
57
  Module#inline has approx 12 statements (TooManyStatements)
56
58
  """
57
59
 
58
60
  Scenario: Correct smells from optparse.rb
59
- When I run reek --no-line-numbers spec/samples/optparse.rb
61
+ Given the "optparse.rb" sample file exists
62
+ When I run reek --no-line-numbers optparse.rb
60
63
  Then the exit status indicates smells
61
64
  And it reports:
62
65
  """
63
- spec/samples/optparse.rb -- 111 warnings:
66
+ optparse.rb -- 111 warnings:
64
67
  OptionParser has at least 42 methods (TooManyMethods)
65
68
  OptionParser has the variable name 'f' (UncommunicativeVariableName)
66
69
  OptionParser has the variable name 'k' (UncommunicativeVariableName)
@@ -100,7 +103,7 @@ Feature: Basic smell detection
100
103
  OptionParser#make_switch has the variable name 'q' (UncommunicativeVariableName)
101
104
  OptionParser#make_switch has the variable name 's' (UncommunicativeVariableName)
102
105
  OptionParser#make_switch has the variable name 'v' (UncommunicativeVariableName)
103
- OptionParser#make_switch performs a nil-check. (NilCheck)
106
+ OptionParser#make_switch performs a nil-check (NilCheck)
104
107
  OptionParser#order calls argv[0] 2 times (DuplicateMethodCall)
105
108
  OptionParser#order refers to argv more than self (FeatureEnvy)
106
109
  OptionParser#parse calls argv[0] 2 times (DuplicateMethodCall)
@@ -118,7 +121,7 @@ Feature: Basic smell detection
118
121
  OptionParser#permute refers to argv more than self (FeatureEnvy)
119
122
  OptionParser#permute! has approx 6 statements (TooManyStatements)
120
123
  OptionParser#search has the variable name 'k' (UncommunicativeVariableName)
121
- OptionParser#self.inc performs a nil-check. (NilCheck)
124
+ OptionParser#self.inc performs a nil-check (NilCheck)
122
125
  OptionParser#summarize has 4 parameters (LongParameterList)
123
126
  OptionParser#summarize has the variable name 'l' (UncommunicativeVariableName)
124
127
  OptionParser#summarize is controlled by argument blk (ControlParameter)
@@ -175,11 +178,12 @@ Feature: Basic smell detection
175
178
  """
176
179
 
177
180
  Scenario: Correct smells from redcloth.rb
178
- When I run reek --no-line-numbers spec/samples/redcloth.rb
181
+ Given the "redcloth.rb" sample file exists
182
+ When I run reek --no-line-numbers redcloth.rb
179
183
  Then the exit status indicates smells
180
184
  And it reports:
181
185
  """
182
- spec/samples/redcloth.rb -- 98 warnings:
186
+ redcloth.rb -- 95 warnings:
183
187
  RedCloth has at least 44 methods (TooManyMethods)
184
188
  RedCloth has the variable name 'a' (UncommunicativeVariableName)
185
189
  RedCloth has the variable name 'b' (UncommunicativeVariableName)
@@ -191,7 +195,7 @@ Feature: Basic smell detection
191
195
  RedCloth#block_markdown_atx refers to text more than self (FeatureEnvy)
192
196
  RedCloth#block_markdown_bq has approx 6 statements (TooManyStatements)
193
197
  RedCloth#block_markdown_lists has unused parameter 'text' (UnusedParameters)
194
- RedCloth#block_markdown_rule refers to text more than self (FeatureEnvy)
198
+ RedCloth#block_markdown_rule doesn't depend on instance state (UtilityFunction)
195
199
  RedCloth#block_markdown_setext refers to text more than self (FeatureEnvy)
196
200
  RedCloth#block_textile_lists calls depth.last 5 times (DuplicateMethodCall)
197
201
  RedCloth#block_textile_lists calls depth.last.length 2 times (DuplicateMethodCall)
@@ -218,18 +222,15 @@ Feature: Basic smell detection
218
222
  RedCloth#clean_html has approx 15 statements (TooManyStatements)
219
223
  RedCloth#clean_html has the variable name 'q' (UncommunicativeVariableName)
220
224
  RedCloth#clean_html has the variable name 'q2' (UncommunicativeVariableName)
221
- RedCloth#clean_html refers to raw more than self (FeatureEnvy)
222
- RedCloth#clean_html refers to tags more than self (FeatureEnvy)
223
225
  RedCloth#clean_white_space has approx 7 statements (TooManyStatements)
224
226
  RedCloth#clean_white_space refers to text more than self (FeatureEnvy)
225
227
  RedCloth#flush_left doesn't depend on instance state (UtilityFunction)
226
- RedCloth#flush_left refers to text more than self (FeatureEnvy)
227
- RedCloth#footnote_ref refers to text more than self (FeatureEnvy)
228
+ RedCloth#footnote_ref doesn't depend on instance state (UtilityFunction)
228
229
  RedCloth#glyphs_textile has approx 10 statements (TooManyStatements)
230
+ RedCloth#h_align doesn't depend on instance state (UtilityFunction)
229
231
  RedCloth#htmlesc doesn't depend on instance state (UtilityFunction)
230
232
  RedCloth#htmlesc is controlled by argument mode (ControlParameter)
231
- RedCloth#htmlesc refers to str more than self (FeatureEnvy)
232
- RedCloth#incoming_entities refers to text more than self (FeatureEnvy)
233
+ RedCloth#incoming_entities doesn't depend on instance state (UtilityFunction)
233
234
  RedCloth#initialize has the variable name 'r' (UncommunicativeVariableName)
234
235
  RedCloth#inline contains iterators nested 2 deep (NestedIterators)
235
236
  RedCloth#inline_markdown_link has approx 6 statements (TooManyStatements)
@@ -246,11 +247,10 @@ Feature: Basic smell detection
246
247
  RedCloth#inline_textile_span contains iterators nested 2 deep (NestedIterators)
247
248
  RedCloth#inline_textile_span has approx 9 statements (TooManyStatements)
248
249
  RedCloth#inline_textile_span has the variable name 'm' (UncommunicativeVariableName)
250
+ RedCloth#lT doesn't depend on instance state (UtilityFunction)
249
251
  RedCloth#lT has the name 'lT' (UncommunicativeMethodName)
250
252
  RedCloth#lT is controlled by argument text (ControlParameter)
251
- RedCloth#lT refers to text more than self (FeatureEnvy)
252
253
  RedCloth#no_textile doesn't depend on instance state (UtilityFunction)
253
- RedCloth#no_textile refers to text more than self (FeatureEnvy)
254
254
  RedCloth#pba calls $1.length 2 times (DuplicateMethodCall)
255
255
  RedCloth#pba has approx 21 statements (TooManyStatements)
256
256
  RedCloth#pba is controlled by argument element (ControlParameter)
@@ -278,22 +278,17 @@ Feature: Basic smell detection
278
278
  RedCloth#textile_popup_help has the parameter name 'windowH' (UncommunicativeParameterName)
279
279
  RedCloth#textile_popup_help has the parameter name 'windowW' (UncommunicativeParameterName)
280
280
  RedCloth#to_html has approx 26 statements (TooManyStatements)
281
+ RedCloth#v_align doesn't depend on instance state (UtilityFunction)
281
282
  """
282
283
 
283
- Scenario: Correct smells from a source file with Ruby 2.0 specific syntax
284
- When I run reek spec/samples/ruby20_syntax.rb
284
+ Scenario: Correct smells from a source file with unusual syntax samples
285
+ Given the "unusual_syntax.rb" sample file exists
286
+ When I run reek unusual_syntax.rb
285
287
  Then the exit status indicates smells
286
288
  And it reports:
287
289
  """
288
- spec/samples/ruby20_syntax.rb -- 1 warning:
289
- [1]:SomeClass has no descriptive comment (IrresponsibleModule)
290
- """
291
-
292
- Scenario: Correct smells from a source file with Ruby 2.1 specific syntax
293
- When I run reek spec/samples/ruby21_syntax.rb
294
- Then the exit status indicates smells
295
- And it reports:
296
- """
297
- spec/samples/ruby21_syntax.rb -- 1 warning:
290
+ unusual_syntax.rb -- 3 warnings:
298
291
  [1]:SomeClass has no descriptive comment (IrresponsibleModule)
292
+ [18]:SomeClass#method_with_array_decomposition has the parameter name 'a' (UncommunicativeParameterName)
293
+ [18]:SomeClass#method_with_array_decomposition has the parameter name 'b' (UncommunicativeParameterName)
299
294
  """
@@ -0,0 +1,5 @@
1
+ inherit_from: ../../.rubocop.yml
2
+
3
+ # Allow common When <regexp> syntax
4
+ Lint/AmbiguousRegexpLiteral:
5
+ Enabled: false
@@ -11,81 +11,69 @@ When /^I run rake (\w*) with:$/ do |name, task_def|
11
11
  end
12
12
 
13
13
  Then /^it reports nothing$/ do
14
- expect(@last_stdout).to eq ''
14
+ assert_exact_output '', all_stdout
15
15
  end
16
16
 
17
17
  Then /^there is no output on stdout$/ do
18
- expect(@last_stdout).to eq ''
18
+ assert_exact_output '', all_stdout
19
19
  end
20
20
 
21
21
  Then /^stdout includes "(.*)"$/ do |text|
22
- expect(@last_stdout).to include text
22
+ assert_partial_output(text, all_stdout)
23
23
  end
24
24
 
25
25
  Then /^it succeeds$/ do
26
- expect(@last_exit_status).to eq Reek::Cli::Application::STATUS_SUCCESS
26
+ assert_exit_status Reek::CLI::Application::STATUS_SUCCESS
27
27
  end
28
28
 
29
29
  Then /^the exit status indicates an error$/ do
30
- expect(@last_exit_status).to eq Reek::Cli::Application::STATUS_ERROR
30
+ assert_exit_status Reek::CLI::Application::STATUS_ERROR
31
31
  end
32
32
 
33
33
  Then /^the exit status indicates smells$/ do
34
- expect(@last_exit_status).to eq Reek::Cli::Application::STATUS_SMELLS
34
+ assert_exit_status Reek::CLI::Application::STATUS_SMELLS
35
35
  end
36
36
 
37
37
  Then /^it reports:$/ do |report|
38
- expect(@last_stdout).to eq "#{report}\n"
38
+ assert_exact_output "#{report}\n", all_stdout
39
39
  end
40
40
 
41
41
  Then /^it reports this yaml:$/ do |expected_yaml|
42
42
  expected_warnings = YAML.load(expected_yaml.chomp)
43
- actual_warnings = YAML.load(@last_stdout)
43
+ actual_warnings = YAML.load(all_stdout)
44
44
  expect(actual_warnings).to eq expected_warnings
45
45
  end
46
46
 
47
47
  Then /^it reports this JSON:$/ do |expected_json|
48
48
  expected_warnings = JSON.parse(expected_json.chomp)
49
- actual_warnings = JSON.parse(@last_stdout)
49
+ actual_warnings = JSON.parse(all_stdout)
50
50
  expect(actual_warnings).to eq expected_warnings
51
51
  end
52
52
 
53
53
  Then /^stderr reports:$/ do |report|
54
- expect(@last_stderr).to eq report
54
+ assert_exact_output report, all_stderr
55
55
  end
56
56
 
57
57
  Then /^it reports no errors$/ do
58
- expect(@last_stderr.chomp).to eq ''
58
+ assert_exact_output '', all_stderr
59
59
  end
60
60
 
61
61
  Then /^it reports an error$/ do
62
- expect(@last_stderr.chomp).to_not be_empty
62
+ expect(all_stderr).to_not be_empty
63
63
  end
64
64
 
65
65
  Then /^it reports the error ['"](.*)['"]$/ do |string|
66
- expect(@last_stderr.chomp).to eq string
66
+ assert_partial_output string, all_stderr
67
67
  end
68
68
 
69
69
  Then /^it reports a parsing error$/ do
70
- expect(@last_stderr.chomp).to match(/Parser::SyntaxError/)
70
+ assert_partial_output 'Parser::SyntaxError', all_stderr
71
71
  end
72
72
 
73
73
  Then /^it should indicate the line numbers of those smells$/ do
74
- expect(@last_stdout.chomp).to match(/\[.*\]:/)
74
+ assert_matching_output /\[.*\]:/, all_stdout
75
75
  end
76
76
 
77
77
  Then /^it reports the current version$/ do
78
- expect(@last_stdout).to eq "reek #{Reek::Version::STRING}\n"
79
- end
80
-
81
- Given(/^"(.*?)" exists in the working directory$/) do |path|
82
- FileUtils.cp path, Pathname.pwd
83
- end
84
-
85
- Given(/^"(.*?)" exists in the parent directory of the working directory$/) do |path|
86
- FileUtils.cp path, Pathname.pwd.parent
87
- end
88
-
89
- Given(/^"(.*?)" exists in the HOME directory$/) do |path|
90
- FileUtils.cp path, Pathname.new(Dir.home)
78
+ assert_exact_output "reek #{Reek::Version::STRING}\n", all_stdout
91
79
  end