reek 1.2.6 → 1.2.8

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 (209) hide show
  1. data/.yardopts +10 -0
  2. data/History.txt +62 -0
  3. data/README.md +74 -0
  4. data/bin/reek +2 -2
  5. data/config/defaults.reek +44 -5
  6. data/features/api.feature +20 -0
  7. data/features/masking_smells.feature +60 -42
  8. data/features/options.feature +7 -2
  9. data/features/rake_task.feature +29 -22
  10. data/features/reports.feature +9 -41
  11. data/features/samples.feature +184 -196
  12. data/features/stdin.feature +5 -8
  13. data/features/step_definitions/reek_steps.rb +8 -4
  14. data/features/support/env.rb +2 -3
  15. data/features/yaml.feature +85 -0
  16. data/lib/reek/cli/application.rb +46 -0
  17. data/lib/reek/cli/command_line.rb +108 -0
  18. data/lib/reek/cli/help_command.rb +18 -0
  19. data/lib/reek/cli/reek_command.rb +37 -0
  20. data/lib/reek/cli/report.rb +58 -0
  21. data/lib/reek/cli/version_command.rb +19 -0
  22. data/lib/reek/cli/yaml_command.rb +32 -0
  23. data/lib/reek/core/code_context.rb +64 -0
  24. data/lib/reek/core/code_parser.rb +166 -0
  25. data/lib/reek/core/method_context.rb +84 -0
  26. data/lib/reek/core/module_context.rb +20 -0
  27. data/lib/reek/core/object_refs.rb +51 -0
  28. data/lib/reek/core/singleton_method_context.rb +20 -0
  29. data/lib/reek/core/smell_configuration.rb +62 -0
  30. data/lib/reek/core/sniffer.rb +105 -0
  31. data/lib/reek/core/stop_context.rb +30 -0
  32. data/lib/reek/core/warning_collector.rb +27 -0
  33. data/lib/reek/examiner.rb +104 -0
  34. data/lib/reek/rake/task.rb +142 -0
  35. data/lib/reek/smell_warning.rb +73 -23
  36. data/lib/reek/smells/attribute.rb +26 -21
  37. data/lib/reek/smells/boolean_parameter.rb +38 -0
  38. data/lib/reek/smells/class_variable.rb +22 -9
  39. data/lib/reek/smells/control_couple.rb +40 -16
  40. data/lib/reek/smells/data_clump.rb +114 -23
  41. data/lib/reek/smells/duplication.rb +55 -15
  42. data/lib/reek/smells/feature_envy.rb +16 -7
  43. data/lib/reek/smells/irresponsible_module.rb +37 -0
  44. data/lib/reek/smells/large_class.rb +37 -19
  45. data/lib/reek/smells/long_method.rb +20 -9
  46. data/lib/reek/smells/long_parameter_list.rb +22 -10
  47. data/lib/reek/smells/long_yield_list.rb +43 -7
  48. data/lib/reek/smells/nested_iterators.rb +68 -8
  49. data/lib/reek/smells/simulated_polymorphism.rb +26 -15
  50. data/lib/reek/smells/smell_detector.rb +29 -51
  51. data/lib/reek/smells/uncommunicative_method_name.rb +74 -0
  52. data/lib/reek/smells/uncommunicative_module_name.rb +74 -0
  53. data/lib/reek/smells/uncommunicative_parameter_name.rb +79 -0
  54. data/lib/reek/smells/uncommunicative_variable_name.rb +89 -0
  55. data/lib/reek/smells/utility_function.rb +51 -12
  56. data/lib/reek/smells.rb +29 -0
  57. data/lib/reek/source/code_comment.rb +37 -0
  58. data/lib/reek/source/config_file.rb +72 -0
  59. data/lib/reek/source/core_extras.rb +46 -0
  60. data/lib/reek/source/reference_collector.rb +28 -0
  61. data/lib/reek/source/sexp_formatter.rb +17 -0
  62. data/lib/reek/source/source_code.rb +44 -0
  63. data/lib/reek/source/source_file.rb +32 -0
  64. data/lib/reek/source/source_locator.rb +42 -0
  65. data/lib/reek/source/tree_dresser.rb +204 -0
  66. data/lib/reek/source.rb +18 -0
  67. data/lib/reek/spec/should_reek.rb +31 -0
  68. data/lib/reek/spec/should_reek_of.rb +37 -0
  69. data/lib/reek/spec/should_reek_only_of.rb +37 -0
  70. data/lib/reek/spec.rb +51 -0
  71. data/lib/reek.rb +8 -4
  72. data/reek.gemspec +9 -7
  73. data/spec/matchers/smell_of_matcher.rb +58 -0
  74. data/spec/reek/{help_command_spec.rb → cli/help_command_spec.rb} +3 -4
  75. data/spec/reek/cli/reek_command_spec.rb +46 -0
  76. data/spec/reek/cli/report_spec.rb +30 -0
  77. data/spec/reek/{version_command_spec.rb → cli/version_command_spec.rb} +3 -3
  78. data/spec/reek/cli/yaml_command_spec.rb +47 -0
  79. data/spec/reek/core/code_context_spec.rb +145 -0
  80. data/spec/reek/{code_parser_spec.rb → core/code_parser_spec.rb} +7 -6
  81. data/spec/reek/{config_spec.rb → core/config_spec.rb} +2 -6
  82. data/spec/reek/{method_context_spec.rb → core/method_context_spec.rb} +16 -36
  83. data/spec/reek/core/module_context_spec.rb +27 -0
  84. data/spec/reek/{object_refs_spec.rb → core/object_refs_spec.rb} +5 -6
  85. data/spec/reek/core/singleton_method_context_spec.rb +9 -0
  86. data/spec/reek/core/smell_configuration_spec.rb +11 -0
  87. data/spec/reek/core/stop_context_spec.rb +17 -0
  88. data/spec/reek/core/warning_collector_spec.rb +27 -0
  89. data/spec/reek/examiner_spec.rb +103 -0
  90. data/spec/reek/smell_warning_spec.rb +74 -82
  91. data/spec/reek/smells/attribute_spec.rb +42 -23
  92. data/spec/reek/smells/behaves_like_variable_detector.rb +2 -2
  93. data/spec/reek/smells/boolean_parameter_spec.rb +66 -0
  94. data/spec/reek/smells/class_variable_spec.rb +60 -75
  95. data/spec/reek/smells/control_couple_spec.rb +37 -32
  96. data/spec/reek/smells/data_clump_spec.rb +63 -24
  97. data/spec/reek/smells/duplication_spec.rb +106 -57
  98. data/spec/reek/smells/feature_envy_spec.rb +113 -92
  99. data/spec/reek/smells/irresponsible_module_spec.rb +58 -0
  100. data/spec/reek/smells/large_class_spec.rb +67 -57
  101. data/spec/reek/smells/long_method_spec.rb +40 -10
  102. data/spec/reek/smells/long_parameter_list_spec.rb +50 -28
  103. data/spec/reek/smells/long_yield_list_spec.rb +57 -0
  104. data/spec/reek/smells/nested_iterators_spec.rb +115 -7
  105. data/spec/reek/smells/simulated_polymorphism_spec.rb +56 -20
  106. data/spec/reek/smells/smell_detector_shared.rb +42 -0
  107. data/spec/reek/smells/uncommunicative_method_name_spec.rb +42 -0
  108. data/spec/reek/smells/uncommunicative_module_name_spec.rb +66 -0
  109. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +71 -0
  110. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +120 -0
  111. data/spec/reek/smells/utility_function_spec.rb +50 -4
  112. data/spec/reek/source/code_comment_spec.rb +82 -0
  113. data/spec/reek/source/object_source_spec.rb +20 -0
  114. data/spec/reek/source/reference_collector_spec.rb +53 -0
  115. data/spec/reek/{adapters/source_spec.rb → source/source_code_spec.rb} +7 -8
  116. data/spec/reek/source/tree_dresser_spec.rb +270 -0
  117. data/spec/reek/spec/should_reek_of_spec.rb +76 -0
  118. data/spec/reek/spec/should_reek_only_of_spec.rb +89 -0
  119. data/spec/reek/{adapters → spec}/should_reek_spec.rb +8 -32
  120. data/spec/samples/all_but_one_masked/clean_one.rb +1 -0
  121. data/spec/samples/all_but_one_masked/dirty.rb +1 -0
  122. data/spec/samples/all_but_one_masked/masked.reek +5 -1
  123. data/spec/samples/clean_due_to_masking/clean_one.rb +1 -0
  124. data/spec/samples/clean_due_to_masking/clean_three.rb +1 -0
  125. data/spec/samples/clean_due_to_masking/clean_two.rb +1 -0
  126. data/spec/samples/clean_due_to_masking/dirty_one.rb +1 -1
  127. data/spec/samples/clean_due_to_masking/dirty_two.rb +1 -1
  128. data/spec/samples/clean_due_to_masking/masked.reek +5 -1
  129. data/spec/samples/config/allow_duplication.reek +3 -0
  130. data/spec/samples/config/deeper_nested_iterators.reek +3 -0
  131. data/spec/samples/corrupt_config_file/dirty.rb +1 -1
  132. data/spec/samples/demo/demo.rb +8 -0
  133. data/spec/samples/empty_config_file/dirty.rb +2 -1
  134. data/spec/samples/exceptions.reek +1 -1
  135. data/spec/samples/inline_config/dirty.rb +16 -0
  136. data/spec/samples/inline_config/masked.reek +7 -0
  137. data/spec/samples/mask_some/dirty.rb +8 -0
  138. data/spec/samples/mask_some/some.reek +8 -0
  139. data/spec/samples/masked/dirty.rb +2 -1
  140. data/spec/samples/masked/masked.reek +3 -1
  141. data/spec/samples/mixed_results/clean_one.rb +1 -0
  142. data/spec/samples/mixed_results/clean_three.rb +1 -0
  143. data/spec/samples/mixed_results/clean_two.rb +1 -0
  144. data/spec/samples/mixed_results/dirty_one.rb +1 -0
  145. data/spec/samples/mixed_results/dirty_two.rb +1 -0
  146. data/spec/samples/not_quite_masked/dirty.rb +2 -1
  147. data/spec/samples/not_quite_masked/masked.reek +1 -1
  148. data/spec/samples/overrides/masked/dirty.rb +2 -1
  149. data/spec/samples/overrides/masked/lower.reek +3 -1
  150. data/spec/samples/three_clean_files/clean_one.rb +1 -0
  151. data/spec/samples/three_clean_files/clean_three.rb +1 -0
  152. data/spec/samples/three_clean_files/clean_two.rb +1 -0
  153. data/spec/samples/two_smelly_files/dirty_one.rb +2 -1
  154. data/spec/samples/two_smelly_files/dirty_two.rb +2 -1
  155. data/spec/spec_helper.rb +10 -2
  156. data/tasks/reek.rake +2 -2
  157. data/tasks/test.rake +12 -3
  158. metadata +121 -79
  159. data/README.rdoc +0 -84
  160. data/features/profile.feature +0 -34
  161. data/lib/reek/adapters/application.rb +0 -46
  162. data/lib/reek/adapters/command_line.rb +0 -77
  163. data/lib/reek/adapters/config_file.rb +0 -31
  164. data/lib/reek/adapters/core_extras.rb +0 -64
  165. data/lib/reek/adapters/rake_task.rb +0 -121
  166. data/lib/reek/adapters/report.rb +0 -86
  167. data/lib/reek/adapters/source.rb +0 -72
  168. data/lib/reek/adapters/spec.rb +0 -133
  169. data/lib/reek/block_context.rb +0 -62
  170. data/lib/reek/class_context.rb +0 -41
  171. data/lib/reek/code_context.rb +0 -68
  172. data/lib/reek/code_parser.rb +0 -203
  173. data/lib/reek/configuration.rb +0 -57
  174. data/lib/reek/detector_stack.rb +0 -37
  175. data/lib/reek/help_command.rb +0 -14
  176. data/lib/reek/if_context.rb +0 -18
  177. data/lib/reek/masking_collection.rb +0 -33
  178. data/lib/reek/method_context.rb +0 -138
  179. data/lib/reek/module_context.rb +0 -49
  180. data/lib/reek/name.rb +0 -57
  181. data/lib/reek/object_refs.rb +0 -49
  182. data/lib/reek/reek_command.rb +0 -28
  183. data/lib/reek/sexp_formatter.rb +0 -10
  184. data/lib/reek/singleton_method_context.rb +0 -26
  185. data/lib/reek/smells/uncommunicative_name.rb +0 -84
  186. data/lib/reek/sniffer.rb +0 -177
  187. data/lib/reek/stop_context.rb +0 -35
  188. data/lib/reek/tree_dresser.rb +0 -82
  189. data/lib/reek/version_command.rb +0 -14
  190. data/lib/reek/yield_call_context.rb +0 -12
  191. data/spec/reek/adapters/report_spec.rb +0 -31
  192. data/spec/reek/adapters/should_reek_of_spec.rb +0 -138
  193. data/spec/reek/adapters/should_reek_only_of_spec.rb +0 -87
  194. data/spec/reek/block_context_spec.rb +0 -65
  195. data/spec/reek/class_context_spec.rb +0 -161
  196. data/spec/reek/code_context_spec.rb +0 -182
  197. data/spec/reek/configuration_spec.rb +0 -12
  198. data/spec/reek/if_context_spec.rb +0 -17
  199. data/spec/reek/masking_collection_spec.rb +0 -236
  200. data/spec/reek/module_context_spec.rb +0 -46
  201. data/spec/reek/name_spec.rb +0 -37
  202. data/spec/reek/object_source_spec.rb +0 -23
  203. data/spec/reek/reek_command_spec.rb +0 -45
  204. data/spec/reek/singleton_method_context_spec.rb +0 -16
  205. data/spec/reek/smells/smell_detector_spec.rb +0 -36
  206. data/spec/reek/smells/uncommunicative_name_spec.rb +0 -146
  207. data/spec/reek/sniffer_spec.rb +0 -11
  208. data/spec/reek/stop_context_spec.rb +0 -33
  209. data/spec/reek/tree_dresser_spec.rb +0 -20
data/.yardopts ADDED
@@ -0,0 +1,10 @@
1
+ --no-private
2
+ --readme README.md
3
+ lib/reek.rb
4
+ lib/reek/*.rb
5
+ lib/reek/smells/*.rb
6
+ lib/reek/source/*.rb
7
+ lib/reek/spec/*.rb
8
+ lib/reek/rake/*.rb
9
+ -
10
+ *.txt
data/History.txt CHANGED
@@ -1,3 +1,65 @@
1
+ == 1.2.8 (2010-04-26)
2
+
3
+ === Major Changes
4
+ * Smell detectors can be configured or disabled in code comments
5
+ ** Comment with :reek:smell_name disables the named smell for a class, module or method
6
+ ** Comment with :reek:smell_name:{...} for more detailed configuration
7
+ * Additional config file(s) can be specified:
8
+ ** on the command-line using -c
9
+ ** via Reek::Rake::Task in the rakefile
10
+
11
+ === Minor Changes
12
+ * Duplication can be configured to ignore specific calls
13
+ * IrresponsibleModule now reports scoped module names correctly (#66)
14
+ * NestedIterators is now more configurable:
15
+ ** Option to specify permitted nesting depth (#14)
16
+ ** Option to ignore certain iterator methods
17
+
18
+ == 1.2.7.3 (2010-03-29)
19
+
20
+ === Minor Changes
21
+ * UtilityFunction no longer reported when local method called in param initializer (#60)
22
+ * Spaces removed from smell class names in report output
23
+ * Masked smells are no longer reported
24
+ ** the -a command-line option has been removed
25
+ ** some methods on Examiner are now deprecated
26
+ * DataClump no longer needs infinite memory for large classes (#57 again)
27
+
28
+ == 1.2.7.2 (2010-03-05)
29
+
30
+ === Minor Changes
31
+ * Number of masked smells is no longer shown in report headers
32
+ * Masked smells are no longer listed in --yaml reports
33
+ * DataClump no longer needs infinite memory for large classes (#57)
34
+ * DataClump reports the names of the offending methods in the YAML report
35
+ * UncommunicativeMethodName now accepts operator names (+, -, ...)
36
+ * Uncommunicative Name now warns about uppercase letters in method & var names
37
+
38
+ == 1.2.7.1 (2010-02-03)
39
+
40
+ === Minor Changes
41
+ * Fixed crash on a case statement with no condition (#58)
42
+
43
+ == 1.2.7 (2010-02-01)
44
+
45
+ === Major Changes
46
+ * New option --yaml reports smells in YAML format
47
+ * Now require 'reek/rake/task' to use the rake task
48
+ * Now require 'reek/spec' to use the Rspec matchers
49
+ * Developer API completely revised and documented
50
+
51
+ === Minor Changes
52
+ * New smell: Irresponsible Module (has no meaningful comment)
53
+ * ControlCouple no longer checks arguments yielded to blocks
54
+ * FeatureEnvy and UtilityFunction are now subclasses of a new smell: LowCohesion
55
+ * NestedIterators now reports the nesting depth
56
+ * Fixed problem checking for UtilityFunctions in Object
57
+ * Improved detection of invalid config files
58
+ * Invalid config files are now ignored
59
+ * Non-existent files are now ignored
60
+
61
+ See http://wiki.github.com/kevinrutherford/reek for further details.
62
+
1
63
  == 1.2.6 (2009-11-28)
2
64
 
3
65
  === Minor Changes
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # Reek -- code smell detection for Ruby
2
+
3
+ Reek is a tool that examines Ruby classes, modules and methods and
4
+ reports any code smells it finds. Install it like this:
5
+
6
+ $ gem install reek
7
+
8
+ and run it like this:
9
+
10
+ $ reek [options] [dir_or_source_file]*
11
+
12
+ For a full list of command-line options see the Reek
13
+ wiki[http://wiki.github.com/kevinrutherford/reek/command-line-options]
14
+ or run
15
+
16
+ $ reek --help
17
+
18
+ ## Example
19
+
20
+ Imagine a source file <tt>demo.rb</tt> containing:
21
+
22
+ class Dirty
23
+ # This method smells of :reek:NestedIterators but ignores them
24
+ def awful(x, y, offset = 0, log = false)
25
+ puts @screen.title
26
+ @screen = widgets.map {|w| w.each {|key| key += 3}}
27
+ puts @screen.contents
28
+ end
29
+ end
30
+
31
+ Reek will report the following code smells in this file:
32
+
33
+ $ reek demo.rb
34
+ spec/samples/demo/demo.rb -- 6 warnings:
35
+ Dirty has no descriptive comment (IrresponsibleModule)
36
+ Dirty#awful has 4 parameters (LongParameterList)
37
+ Dirty#awful has boolean parameter 'log' (ControlCouple)
38
+ Dirty#awful has the parameter name 'x' (UncommunicativeName)
39
+ Dirty#awful has the parameter name 'y' (UncommunicativeName)
40
+ Dirty#awful has the variable name 'w' (UncommunicativeName)
41
+
42
+ ## Features
43
+
44
+ Reek currently includes checks for some aspects of Control Couple,
45
+ Data Clump, Feature Envy, Large Class, Long Method, Long Parameter List,
46
+ Simulated Polymorphism, Uncommunicative Name and more.
47
+ See the [Reek wiki](http://wiki.github.com/kevinrutherford/reek/code-smells)
48
+ for up to date details of exactly what Reek will check in your code.
49
+
50
+ ### Tool Integration
51
+
52
+ Reek integrates with many of your favourite tools:
53
+
54
+ * `require 'reek/rake/task'` to easily add Reek to your Rakefile
55
+ * `require 'reek/spec'` to add the `should_not reek` custom matcher to your Rspec examples
56
+ * Reek is fully compliant with Ruby 1.8.6, 1.8.7 and 1.9.1
57
+
58
+ ### Dependencies
59
+
60
+ Reek makes use of the following other gems:
61
+
62
+ * ruby_parser
63
+ * sexp_processor
64
+ * ruby2ruby
65
+
66
+ Learn More
67
+ ----------
68
+
69
+ Find out more about Reek from any of the following sources:
70
+
71
+ * Browse the Reek documentation at [http://wiki.github.com/kevinrutherford/reek](http://wiki.github.com/kevinrutherford/reek)
72
+ * Browse the code or install the latest development version from [http://github.com/kevinrutherford/reek/tree](http://github.com/kevinrutherford/reek/tree)
73
+ * Read the code API at [http://rdoc.info/projects/kevinrutherford/reek](http://rdoc.info/projects/kevinrutherford/reek)
74
+ * Follow [@rubyreek](http://twitter.com/rubyreek) on twitter!
data/bin/reek CHANGED
@@ -6,6 +6,6 @@
6
6
  # Author: Kevin Rutherford
7
7
  #
8
8
 
9
- require 'reek/adapters/application'
9
+ require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'lib', 'reek', 'cli', 'application')
10
10
 
11
- exit Reek::Application.new(ARGV).execute
11
+ exit Reek::Cli::Application.new(ARGV).execute
data/config/defaults.reek CHANGED
@@ -1,10 +1,30 @@
1
1
  ---
2
+ UncommunicativeParameterName:
3
+ accept: []
4
+
5
+ exclude: []
6
+
7
+ enabled: true
8
+ reject:
9
+ - !ruby/regexp /^.$/
10
+ - !ruby/regexp /[0-9]$/
11
+ - !ruby/regexp /[A-Z]/
2
12
  LargeClass:
3
13
  max_methods: 25
4
14
  exclude: []
5
15
 
6
16
  enabled: true
7
17
  max_instance_variables: 9
18
+ UncommunicativeMethodName:
19
+ accept: []
20
+
21
+ exclude: []
22
+
23
+ enabled: true
24
+ reject:
25
+ - !ruby/regexp /^[a-z]$/
26
+ - !ruby/regexp /[0-9]$/
27
+ - !ruby/regexp /[A-Z]/
8
28
  LongParameterList:
9
29
  max_params: 3
10
30
  exclude: []
@@ -20,7 +40,13 @@ FeatureEnvy:
20
40
  ClassVariable:
21
41
  exclude: *id001
22
42
  enabled: true
23
- UncommunicativeName:
43
+ BooleanParameter:
44
+ exclude: *id001
45
+ enabled: true
46
+ IrresponsibleModule:
47
+ exclude: *id001
48
+ enabled: true
49
+ UncommunicativeModuleName:
24
50
  accept:
25
51
  - Inline::C
26
52
  exclude: []
@@ -30,14 +56,20 @@ UncommunicativeName:
30
56
  - !ruby/regexp /^.$/
31
57
  - !ruby/regexp /[0-9]$/
32
58
  NestedIterators:
33
- exclude: *id001
59
+ ignore_iterators: []
60
+
61
+ exclude: []
62
+
34
63
  enabled: true
64
+ max_allowed_nesting: 1
35
65
  LongMethod:
36
66
  max_statements: 5
37
67
  exclude:
38
68
  - initialize
39
69
  enabled: true
40
70
  Duplication:
71
+ allow_calls: []
72
+
41
73
  exclude: []
42
74
 
43
75
  enabled: true
@@ -51,6 +83,16 @@ Attribute:
51
83
  exclude: []
52
84
 
53
85
  enabled: false
86
+ UncommunicativeVariableName:
87
+ accept: []
88
+
89
+ exclude: []
90
+
91
+ enabled: true
92
+ reject:
93
+ - !ruby/regexp /^.$/
94
+ - !ruby/regexp /[0-9]$/
95
+ - !ruby/regexp /[A-Z]/
54
96
  SimulatedPolymorphism:
55
97
  exclude: []
56
98
 
@@ -70,6 +112,3 @@ LongYieldList:
70
112
  exclude: []
71
113
 
72
114
  enabled: true
73
- overrides:
74
- initialize:
75
- max_params: 5
@@ -0,0 +1,20 @@
1
+ @masking
2
+ Feature: The Reek API maintains backwards compatibility
3
+ In order to use Reek witthout fuss
4
+ As a developer
5
+ I want to mave a stable API
6
+
7
+ Scenario: the demo example reports as expected
8
+ When I run reek spec/samples/demo
9
+ Then the exit status indicates smells
10
+ And it reports:
11
+ """
12
+ spec/samples/demo/demo.rb -- 6 warnings:
13
+ Dirty has no descriptive comment (IrresponsibleModule)
14
+ Dirty#awful has 4 parameters (LongParameterList)
15
+ Dirty#awful has boolean parameter 'log' (ControlCouple)
16
+ Dirty#awful has the parameter name 'x' (UncommunicativeName)
17
+ Dirty#awful has the parameter name 'y' (UncommunicativeName)
18
+ Dirty#awful has the variable name 'w' (UncommunicativeName)
19
+
20
+ """
@@ -10,61 +10,54 @@ Feature: Masking smells using config files
10
10
  And it reports:
11
11
  """
12
12
  spec/samples/empty_config_file/dirty.rb -- 6 warnings:
13
- Dirty has the variable name '@s' (Uncommunicative Name)
13
+ Dirty has the variable name '@s' (UncommunicativeName)
14
14
  Dirty#a calls @s.title twice (Duplication)
15
15
  Dirty#a calls puts(@s.title) twice (Duplication)
16
- Dirty#a has the name 'a' (Uncommunicative Name)
17
- Dirty#a/block has the variable name 'x' (Uncommunicative Name)
18
- Dirty#a/block/block is nested (Nested Iterators)
16
+ Dirty#a contains iterators nested 2 deep (NestedIterators)
17
+ Dirty#a has the name 'a' (UncommunicativeName)
18
+ Dirty#a has the variable name 'x' (UncommunicativeName)
19
19
 
20
20
  """
21
21
 
22
22
  Scenario: corrupt config file prevents normal output
23
- When I run reek spec/samples/corrupt_config_file/dirty.rb
24
- Then the exit status indicates an error
25
- And it reports the error 'Error: Invalid configuration file "corrupt.reek" -- not a Hash'
26
-
27
- Scenario: missing source file is an error
28
- When I run reek no_such_file.rb
29
- Then the exit status indicates an error
30
- And it reports the error "Error: No such file or directory - no_such_file.rb"
31
-
32
- Scenario: switch off one smell
33
- When I run reek spec/samples/masked/dirty.rb
23
+ When I run reek spec/samples/corrupt_config_file
34
24
  Then the exit status indicates smells
35
25
  And it reports:
36
26
  """
37
- spec/samples/masked/dirty.rb -- 3 warnings (+3 masked):
27
+ spec/samples/corrupt_config_file/dirty.rb -- 7 warnings:
28
+ Dirty has no descriptive comment (IrresponsibleModule)
29
+ Dirty has the variable name '@s' (UncommunicativeName)
38
30
  Dirty#a calls @s.title twice (Duplication)
39
31
  Dirty#a calls puts(@s.title) twice (Duplication)
40
- Dirty#a/block/block is nested (Nested Iterators)
32
+ Dirty#a contains iterators nested 2 deep (NestedIterators)
33
+ Dirty#a has the name 'a' (UncommunicativeName)
34
+ Dirty#a has the variable name 'x' (UncommunicativeName)
41
35
 
42
36
  """
37
+ And it reports the error 'Error: Invalid configuration file "corrupt.reek" -- "This is not a config file" is not a code smell'
43
38
 
44
- Scenario: switch off one smell but show all in the report
45
- When I run reek --show-all spec/samples/masked/dirty.rb
39
+ Scenario: missing source file is an error
40
+ When I run reek no_such_file.rb spec/samples/masked/dirty.rb
46
41
  Then the exit status indicates smells
47
42
  And it reports:
48
43
  """
49
- spec/samples/masked/dirty.rb -- 3 warnings (+3 masked):
50
- (masked) Dirty has the variable name '@s' (Uncommunicative Name)
44
+ spec/samples/masked/dirty.rb -- 3 warnings:
51
45
  Dirty#a calls @s.title twice (Duplication)
52
46
  Dirty#a calls puts(@s.title) twice (Duplication)
53
- (masked) Dirty#a has the name 'a' (Uncommunicative Name)
54
- (masked) Dirty#a/block has the variable name 'x' (Uncommunicative Name)
55
- Dirty#a/block/block is nested (Nested Iterators)
47
+ Dirty#a contains iterators nested 2 deep (NestedIterators)
56
48
 
57
49
  """
50
+ And it reports the error "Error: No such file - no_such_file.rb"
58
51
 
59
- Scenario: switch off one smell and hide them in the report
60
- When I run reek --no-show-all spec/samples/masked/dirty.rb
52
+ Scenario: switch off one smell
53
+ When I run reek spec/samples/masked/dirty.rb
61
54
  Then the exit status indicates smells
62
55
  And it reports:
63
56
  """
64
- spec/samples/masked/dirty.rb -- 3 warnings (+3 masked):
57
+ spec/samples/masked/dirty.rb -- 3 warnings:
65
58
  Dirty#a calls @s.title twice (Duplication)
66
59
  Dirty#a calls puts(@s.title) twice (Duplication)
67
- Dirty#a/block/block is nested (Nested Iterators)
60
+ Dirty#a contains iterators nested 2 deep (NestedIterators)
68
61
 
69
62
  """
70
63
 
@@ -73,12 +66,12 @@ Feature: Masking smells using config files
73
66
  Then the exit status indicates smells
74
67
  And it reports:
75
68
  """
76
- spec/samples/not_quite_masked/dirty.rb -- 5 warnings (+1 masked):
77
- Dirty has the variable name '@s' (Uncommunicative Name)
69
+ spec/samples/not_quite_masked/dirty.rb -- 5 warnings:
70
+ Dirty has the variable name '@s' (UncommunicativeName)
78
71
  Dirty#a calls @s.title twice (Duplication)
79
72
  Dirty#a calls puts(@s.title) twice (Duplication)
80
- Dirty#a has the name 'a' (Uncommunicative Name)
81
- Dirty#a/block/block is nested (Nested Iterators)
73
+ Dirty#a contains iterators nested 2 deep (NestedIterators)
74
+ Dirty#a has the name 'a' (UncommunicativeName)
82
75
 
83
76
  """
84
77
 
@@ -88,24 +81,49 @@ Feature: Masking smells using config files
88
81
  Then the exit status indicates smells
89
82
  And it reports:
90
83
  """
91
- spec/samples/overrides/masked/dirty.rb -- 2 warnings (+4 masked):
84
+ spec/samples/overrides/masked/dirty.rb -- 2 warnings:
92
85
  Dirty#a calls @s.title twice (Duplication)
93
86
  Dirty#a calls puts(@s.title) twice (Duplication)
94
87
 
95
88
  """
96
89
 
97
- @overrides
98
- Scenario: all show up masked even when overridden
99
- When I run reek --show-all spec/samples/overrides
90
+ Scenario: allow masking some calls for duplication smell
91
+ When I run reek spec/samples/mask_some/dirty.rb
100
92
  Then the exit status indicates smells
101
93
  And it reports:
102
94
  """
103
- spec/samples/overrides/masked/dirty.rb -- 2 warnings (+4 masked):
104
- (masked) Dirty has the variable name '@s' (Uncommunicative Name)
95
+ spec/samples/mask_some/dirty.rb -- 2 warnings:
105
96
  Dirty#a calls @s.title twice (Duplication)
106
- Dirty#a calls puts(@s.title) twice (Duplication)
107
- (masked) Dirty#a has the name 'a' (Uncommunicative Name)
108
- (masked) Dirty#a/block has the variable name 'x' (Uncommunicative Name)
109
- (masked) Dirty#a/block/block is nested (Nested Iterators)
97
+ Dirty#a contains iterators nested 2 deep (NestedIterators)
98
+
99
+ """
100
+
101
+ @comments
102
+ Scenario: provide extra masking inline in comments
103
+ When I run reek spec/samples/inline_config
104
+ Then the exit status indicates smells
105
+ And it reports:
106
+ """
107
+ spec/samples/inline_config/dirty.rb -- 1 warning:
108
+ Dirty#a calls @s.title twice (Duplication)
109
+
110
+ """
111
+
112
+ Scenario: supports a config file
113
+ When I run reek -c spec/samples/config/allow_duplication.reek spec/samples/masked/dirty.rb
114
+ Then the exit status indicates smells
115
+ And it reports:
116
+ """
117
+ spec/samples/masked/dirty.rb -- 1 warning:
118
+ Dirty#a contains iterators nested 2 deep (NestedIterators)
119
+
120
+ """
121
+
122
+ Scenario: supports multiple config files
123
+ When I run reek -c spec/samples/config/allow_duplication.reek -c spec/samples/config/deeper_nested_iterators.reek spec/samples/masked/dirty.rb
124
+ Then it succeeds
125
+ And it reports:
126
+ """
127
+ spec/samples/masked/dirty.rb -- 0 warnings
110
128
 
111
129
  """
@@ -8,6 +8,7 @@ Feature: Reek can be controlled using command-line options
8
8
  When I run reek --no-such-option
9
9
  Then the exit status indicates an error
10
10
  And it reports the error "Error: invalid option: --no-such-option"
11
+ And stdout equals ""
11
12
 
12
13
  Scenario: display the current version number
13
14
  When I run reek --version
@@ -24,7 +25,7 @@ Feature: Reek can be controlled using command-line options
24
25
  Examples:
25
26
 
26
27
  reek lib/*.rb
27
- reek -q -a lib
28
+ reek -q lib
28
29
  cat my_class.rb | reek
29
30
 
30
31
  See http://wiki.github.com/kevinrutherford/reek for detailed help.
@@ -34,8 +35,12 @@ Feature: Reek can be controlled using command-line options
34
35
  -v, --version Show version
35
36
 
36
37
 
38
+ Configuration:
39
+ -c, --config FILE Read configuration options from FILE
40
+
41
+
37
42
  Report formatting:
38
- -a, --[no-]show-all Show all smells, including those masked by config settings
39
43
  -q, --[no-]quiet Suppress headings for smell-free source files
44
+ -y, --yaml Report smells in YAML format
40
45
 
41
46
  """
@@ -1,62 +1,55 @@
1
1
  @rake
2
- Feature: Reek can be driven through its RakeTask
2
+ Feature: Reek can be driven through its Task
3
3
  Reek provides an easy way to integrate its use into Rakefiles,
4
- via the RakeTask class. These scenarios test its various options.
4
+ via the Task class. These scenarios test its various options.
5
5
 
6
6
  Scenario: source_files points at the desired files
7
7
  When I run rake reek with:
8
8
  """
9
- Reek::RakeTask.new do |t|
9
+ Reek::Rake::Task.new do |t|
10
10
  t.source_files = 'spec/samples/masked/dirty.rb'
11
11
  end
12
12
  """
13
13
  Then the exit status indicates an error
14
14
  And it reports:
15
15
  """
16
- spec/samples/masked/dirty.rb -- 3 warnings (+3 masked):
16
+ spec/samples/masked/dirty.rb -- 3 warnings:
17
17
  Dirty#a calls @s.title twice (Duplication)
18
18
  Dirty#a calls puts(@s.title) twice (Duplication)
19
- Dirty#a/block/block is nested (Nested Iterators)
19
+ Dirty#a contains iterators nested 2 deep (NestedIterators)
20
20
  """
21
21
 
22
22
  Scenario: name changes the task name
23
23
  When I run rake silky with:
24
24
  """
25
- Reek::RakeTask.new('silky') do |t|
25
+ Reek::Rake::Task.new('silky') do |t|
26
26
  t.source_files = 'spec/samples/masked/dirty.rb'
27
27
  end
28
28
  """
29
29
  Then the exit status indicates an error
30
30
  And it reports:
31
31
  """
32
- spec/samples/masked/dirty.rb -- 3 warnings (+3 masked):
32
+ spec/samples/masked/dirty.rb -- 3 warnings:
33
33
  Dirty#a calls @s.title twice (Duplication)
34
34
  Dirty#a calls puts(@s.title) twice (Duplication)
35
- Dirty#a/block/block is nested (Nested Iterators)
35
+ Dirty#a contains iterators nested 2 deep (NestedIterators)
36
36
  """
37
37
 
38
38
  Scenario: verbose prints the reek command
39
39
  When I run rake reek with:
40
40
  """
41
- Reek::RakeTask.new do |t|
41
+ Reek::Rake::Task.new do |t|
42
42
  t.source_files = 'spec/samples/masked/dirty.rb'
43
43
  t.verbose = true
44
44
  end
45
45
  """
46
46
  Then the exit status indicates an error
47
- And it reports:
48
- """
49
- /usr/bin/ruby1.8 -I"/home/kevin/Working/git/reek/lib" "/home/kevin/Working/git/reek/bin/reek" "spec/samples/masked/dirty.rb"
50
- spec/samples/masked/dirty.rb -- 3 warnings (+3 masked):
51
- Dirty#a calls @s.title twice (Duplication)
52
- Dirty#a calls puts(@s.title) twice (Duplication)
53
- Dirty#a/block/block is nested (Nested Iterators)
54
- """
47
+ And stdout includes /spec\/samples\/masked\/dirty\.rb/
55
48
 
56
49
  Scenario: fail_on_error can hide the error status
57
50
  When I run rake reek with:
58
51
  """
59
- Reek::RakeTask.new do |t|
52
+ Reek::Rake::Task.new do |t|
60
53
  t.fail_on_error = false
61
54
  t.source_files = 'spec/samples/empty_config_file/dirty.rb'
62
55
  end
@@ -65,10 +58,24 @@ Feature: Reek can be driven through its RakeTask
65
58
  And it reports:
66
59
  """
67
60
  spec/samples/empty_config_file/dirty.rb -- 6 warnings:
68
- Dirty has the variable name '@s' (Uncommunicative Name)
61
+ Dirty has the variable name '@s' (UncommunicativeName)
69
62
  Dirty#a calls @s.title twice (Duplication)
70
63
  Dirty#a calls puts(@s.title) twice (Duplication)
71
- Dirty#a has the name 'a' (Uncommunicative Name)
72
- Dirty#a/block has the variable name 'x' (Uncommunicative Name)
73
- Dirty#a/block/block is nested (Nested Iterators)
64
+ Dirty#a contains iterators nested 2 deep (NestedIterators)
65
+ Dirty#a has the name 'a' (UncommunicativeName)
66
+ Dirty#a has the variable name 'x' (UncommunicativeName)
67
+ """
68
+
69
+ Scenario: can be configured with config_files
70
+ When I run rake reek with:
71
+ """
72
+ Reek::Rake::Task.new do |t|
73
+ t.config_files = 'spec/samples/config/**/*.reek'
74
+ t.source_files = 'spec/samples/masked/dirty.rb'
75
+ end
76
+ """
77
+ Then it succeeds
78
+ And it reports:
79
+ """
80
+ spec/samples/masked/dirty.rb -- 0 warnings
74
81
  """
@@ -10,19 +10,19 @@ Feature: Correctly formatted reports
10
10
  And it reports:
11
11
  """
12
12
  spec/samples/two_smelly_files/dirty_one.rb -- 6 warnings:
13
- Dirty has the variable name '@s' (Uncommunicative Name)
13
+ Dirty has the variable name '@s' (UncommunicativeName)
14
14
  Dirty#a calls @s.title twice (Duplication)
15
15
  Dirty#a calls puts(@s.title) twice (Duplication)
16
- Dirty#a has the name 'a' (Uncommunicative Name)
17
- Dirty#a/block has the variable name 'x' (Uncommunicative Name)
18
- Dirty#a/block/block is nested (Nested Iterators)
16
+ Dirty#a contains iterators nested 2 deep (NestedIterators)
17
+ Dirty#a has the name 'a' (UncommunicativeName)
18
+ Dirty#a has the variable name 'x' (UncommunicativeName)
19
19
  spec/samples/two_smelly_files/dirty_two.rb -- 6 warnings:
20
- Dirty has the variable name '@s' (Uncommunicative Name)
20
+ Dirty has the variable name '@s' (UncommunicativeName)
21
21
  Dirty#a calls @s.title twice (Duplication)
22
22
  Dirty#a calls puts(@s.title) twice (Duplication)
23
- Dirty#a has the name 'a' (Uncommunicative Name)
24
- Dirty#a/block has the variable name 'x' (Uncommunicative Name)
25
- Dirty#a/block/block is nested (Nested Iterators)
23
+ Dirty#a contains iterators nested 2 deep (NestedIterators)
24
+ Dirty#a has the name 'a' (UncommunicativeName)
25
+ Dirty#a has the variable name 'x' (UncommunicativeName)
26
26
 
27
27
  """
28
28
 
@@ -50,41 +50,9 @@ Feature: Correctly formatted reports
50
50
  Scenario Outline: --quiet turns off headers for fragrant files
51
51
  When I run reek <option> spec/samples/three_clean_files/*.rb
52
52
  Then it succeeds
53
- And it reports:
54
- """
55
-
56
-
57
- """
53
+ And stdout equals ""
58
54
 
59
55
  Examples:
60
56
  | option |
61
57
  | -q |
62
58
  | --quiet |
63
-
64
-
65
- Scenario Outline: -a turns on details in presence of -q
66
- When I run reek <options> spec/samples/clean_due_to_masking/*.rb
67
- Then it succeeds
68
- And it reports:
69
- """
70
- spec/samples/clean_due_to_masking/dirty_one.rb -- 0 warnings (+6 masked):
71
- (masked) Dirty has the variable name '@s' (Uncommunicative Name)
72
- (masked) Dirty#a calls @s.title twice (Duplication)
73
- (masked) Dirty#a calls puts(@s.title) twice (Duplication)
74
- (masked) Dirty#a has the name 'a' (Uncommunicative Name)
75
- (masked) Dirty#a/block has the variable name 'x' (Uncommunicative Name)
76
- (masked) Dirty#a/block/block is nested (Nested Iterators)
77
- spec/samples/clean_due_to_masking/dirty_two.rb -- 0 warnings (+6 masked):
78
- (masked) Dirty has the variable name '@s' (Uncommunicative Name)
79
- (masked) Dirty#a calls @s.title twice (Duplication)
80
- (masked) Dirty#a calls puts(@s.title) twice (Duplication)
81
- (masked) Dirty#a has the name 'a' (Uncommunicative Name)
82
- (masked) Dirty#a/block has the variable name 'x' (Uncommunicative Name)
83
- (masked) Dirty#a/block/block is nested (Nested Iterators)
84
-
85
- """
86
-
87
- Examples:
88
- | options |
89
- | -q -a |
90
- | -a -q |