reek 1.3.8 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +11 -0
  3. data/README.md +22 -14
  4. data/Rakefile +2 -15
  5. data/assets/html_output.html.erb +103 -0
  6. data/features/command_line_interface/options.feature +3 -0
  7. data/features/command_line_interface/smell_selection.feature +19 -0
  8. data/features/rake_task/rake_task.feature +1 -1
  9. data/features/reports/reports.feature +16 -0
  10. data/features/reports/yaml.feature +26 -23
  11. data/features/samples.feature +2 -1
  12. data/features/step_definitions/reek_steps.rb +15 -15
  13. data/features/support/env.rb +7 -9
  14. data/lib/reek/cli/application.rb +2 -4
  15. data/lib/reek/cli/command.rb +12 -0
  16. data/lib/reek/cli/help_command.rb +3 -6
  17. data/lib/reek/cli/options.rb +147 -0
  18. data/lib/reek/cli/reek_command.rb +18 -14
  19. data/lib/reek/cli/report/formatter.rb +56 -0
  20. data/lib/reek/cli/report/report.rb +106 -0
  21. data/lib/reek/cli/report/strategy.rb +63 -0
  22. data/lib/reek/cli/version_command.rb +3 -6
  23. data/lib/reek/config_file_exception.rb +0 -1
  24. data/lib/reek/core/code_context.rb +1 -3
  25. data/lib/reek/core/code_parser.rb +13 -12
  26. data/lib/reek/core/method_context.rb +13 -2
  27. data/lib/reek/core/module_context.rb +0 -4
  28. data/lib/reek/core/object_refs.rb +2 -3
  29. data/lib/reek/core/singleton_method_context.rb +0 -2
  30. data/lib/reek/core/smell_configuration.rb +3 -5
  31. data/lib/reek/core/smell_repository.rb +7 -8
  32. data/lib/reek/core/sniffer.rb +4 -10
  33. data/lib/reek/core/stop_context.rb +2 -4
  34. data/lib/reek/core/warning_collector.rb +0 -1
  35. data/lib/reek/examiner.rb +19 -17
  36. data/lib/reek/rake/task.rb +7 -10
  37. data/lib/reek/smell_warning.rb +4 -8
  38. data/lib/reek/smells.rb +0 -1
  39. data/lib/reek/smells/attribute.rb +8 -11
  40. data/lib/reek/smells/boolean_parameter.rb +5 -7
  41. data/lib/reek/smells/class_variable.rb +6 -7
  42. data/lib/reek/smells/control_parameter.rb +78 -45
  43. data/lib/reek/smells/data_clump.rb +13 -16
  44. data/lib/reek/smells/duplicate_method_call.rb +13 -11
  45. data/lib/reek/smells/feature_envy.rb +6 -7
  46. data/lib/reek/smells/irresponsible_module.rb +4 -6
  47. data/lib/reek/smells/long_parameter_list.rb +5 -7
  48. data/lib/reek/smells/long_yield_list.rb +2 -4
  49. data/lib/reek/smells/nested_iterators.rb +12 -22
  50. data/lib/reek/smells/nil_check.rb +35 -46
  51. data/lib/reek/smells/prima_donna_method.rb +24 -16
  52. data/lib/reek/smells/repeated_conditional.rb +8 -10
  53. data/lib/reek/smells/smell_detector.rb +9 -7
  54. data/lib/reek/smells/too_many_instance_variables.rb +7 -9
  55. data/lib/reek/smells/too_many_methods.rb +6 -8
  56. data/lib/reek/smells/too_many_statements.rb +4 -6
  57. data/lib/reek/smells/uncommunicative_method_name.rb +5 -7
  58. data/lib/reek/smells/uncommunicative_module_name.rb +5 -7
  59. data/lib/reek/smells/uncommunicative_parameter_name.rb +7 -9
  60. data/lib/reek/smells/uncommunicative_variable_name.rb +15 -18
  61. data/lib/reek/smells/unused_parameters.rb +5 -45
  62. data/lib/reek/smells/utility_function.rb +9 -10
  63. data/lib/reek/source.rb +0 -1
  64. data/lib/reek/source/code_comment.rb +7 -8
  65. data/lib/reek/source/config_file.rb +2 -4
  66. data/lib/reek/source/core_extras.rb +1 -1
  67. data/lib/reek/source/reference_collector.rb +1 -2
  68. data/lib/reek/source/sexp_extensions.rb +93 -10
  69. data/lib/reek/source/sexp_formatter.rb +2 -3
  70. data/lib/reek/source/sexp_node.rb +19 -15
  71. data/lib/reek/source/source_code.rb +4 -14
  72. data/lib/reek/source/source_file.rb +3 -5
  73. data/lib/reek/source/source_locator.rb +5 -6
  74. data/lib/reek/source/source_repository.rb +3 -3
  75. data/lib/reek/source/tree_dresser.rb +2 -2
  76. data/lib/reek/spec.rb +1 -2
  77. data/lib/reek/spec/should_reek.rb +8 -5
  78. data/lib/reek/spec/should_reek_of.rb +6 -4
  79. data/lib/reek/spec/should_reek_only_of.rb +10 -6
  80. data/lib/reek/version.rb +1 -1
  81. data/reek.gemspec +34 -30
  82. data/spec/gem/updates_spec.rb +3 -4
  83. data/spec/gem/yard_spec.rb +1 -2
  84. data/spec/matchers/smell_of_matcher.rb +12 -14
  85. data/spec/quality/reek_source_spec.rb +42 -0
  86. data/spec/reek/cli/help_command_spec.rb +7 -5
  87. data/spec/reek/cli/report_spec.rb +89 -22
  88. data/spec/reek/cli/version_command_spec.rb +8 -6
  89. data/spec/reek/core/code_context_spec.rb +25 -26
  90. data/spec/reek/core/code_parser_spec.rb +6 -6
  91. data/spec/reek/core/method_context_spec.rb +18 -18
  92. data/spec/reek/core/module_context_spec.rb +5 -5
  93. data/spec/reek/core/object_refs_spec.rb +21 -22
  94. data/spec/reek/core/smell_configuration_spec.rb +22 -21
  95. data/spec/reek/core/stop_context_spec.rb +2 -2
  96. data/spec/reek/core/warning_collector_spec.rb +3 -3
  97. data/spec/reek/examiner_spec.rb +9 -9
  98. data/spec/reek/smell_warning_spec.rb +29 -29
  99. data/spec/reek/smells/attribute_spec.rb +6 -6
  100. data/spec/reek/smells/behaves_like_variable_detector.rb +6 -6
  101. data/spec/reek/smells/boolean_parameter_spec.rb +17 -17
  102. data/spec/reek/smells/class_variable_spec.rb +9 -9
  103. data/spec/reek/smells/control_parameter_spec.rb +161 -137
  104. data/spec/reek/smells/data_clump_spec.rb +22 -19
  105. data/spec/reek/smells/duplicate_method_call_spec.rb +71 -27
  106. data/spec/reek/smells/feature_envy_spec.rb +32 -32
  107. data/spec/reek/smells/irresponsible_module_spec.rb +21 -21
  108. data/spec/reek/smells/long_parameter_list_spec.rb +14 -14
  109. data/spec/reek/smells/long_yield_list_spec.rb +6 -6
  110. data/spec/reek/smells/nested_iterators_spec.rb +21 -21
  111. data/spec/reek/smells/nil_check_spec.rb +23 -15
  112. data/spec/reek/smells/prima_donna_method_spec.rb +5 -5
  113. data/spec/reek/smells/repeated_conditional_spec.rb +14 -14
  114. data/spec/reek/smells/smell_detector_shared.rb +9 -9
  115. data/spec/reek/smells/too_many_instance_variables_spec.rb +12 -12
  116. data/spec/reek/smells/too_many_methods_spec.rb +10 -10
  117. data/spec/reek/smells/too_many_statements_spec.rb +41 -41
  118. data/spec/reek/smells/uncommunicative_method_name_spec.rb +4 -4
  119. data/spec/reek/smells/uncommunicative_module_name_spec.rb +12 -12
  120. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +21 -21
  121. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +49 -49
  122. data/spec/reek/smells/unused_parameters_spec.rb +26 -16
  123. data/spec/reek/smells/utility_function_spec.rb +20 -20
  124. data/spec/reek/source/code_comment_spec.rb +37 -37
  125. data/spec/reek/source/object_source_spec.rb +5 -5
  126. data/spec/reek/source/reference_collector_spec.rb +9 -9
  127. data/spec/reek/source/sexp_extensions_spec.rb +73 -52
  128. data/spec/reek/source/sexp_formatter_spec.rb +3 -4
  129. data/spec/reek/source/sexp_node_spec.rb +3 -3
  130. data/spec/reek/source/source_code_spec.rb +16 -15
  131. data/spec/reek/source/tree_dresser_spec.rb +2 -2
  132. data/spec/reek/spec/should_reek_of_spec.rb +11 -11
  133. data/spec/reek/spec/should_reek_only_of_spec.rb +11 -11
  134. data/spec/reek/spec/should_reek_spec.rb +11 -11
  135. data/spec/samples/one_smelly_file/dirty.rb +3 -0
  136. data/spec/spec_helper.rb +0 -6
  137. data/tasks/develop.rake +8 -16
  138. data/tasks/reek.rake +5 -13
  139. data/tasks/test.rake +5 -22
  140. metadata +56 -34
  141. data/lib/reek/cli/command_line.rb +0 -126
  142. data/lib/reek/cli/report.rb +0 -138
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e5b741864981fffaab8d15e77e27ade44e67355
4
- data.tar.gz: 0196170433478c772cd616523401c3c58dd4c40f
3
+ metadata.gz: 6002373fce680e5b27b465fef2e8809c9cc0301a
4
+ data.tar.gz: abf6a5e6e1ab36e4d940bcea6f83893df1c230a5
5
5
  SHA512:
6
- metadata.gz: 224dfa2013aad084aaff389f7aca99883f0d7153f7086fa6c860dde323753da85aec0809c9b5a47f410cd84c69754aba47d5887a9cb782b9128619ebca198663
7
- data.tar.gz: 32a0e0f15be5a1deecdd60a61d06f894917d979f24a7e8942c3bd22cba336ced0103fa1f3090b442388d54c2be5c947ac97beb12f4f28ca0a5b106c6f1c9b3ad
6
+ metadata.gz: 3b6d532b9a3e596ce386b1edd8e389dffb31a4b9276cbc584d3c216d9a21d67b5cf84dc69f9cf99ec7f27abc4ea0e2fb1fd63153bd9772ba2d8a47a86e7444d5
7
+ data.tar.gz: 9db171e0f2a6096d8d5f0093feb9d7a42a119d300d19403e689caaef6444287ca1401a4e0df0338e38caf8b7ddcdd0d72908baeb1446ec499bb15b382ca2fb6a
data/CHANGELOG CHANGED
@@ -1,3 +1,14 @@
1
+ == 1.4.0
2
+
3
+ * (Gilles Leblanc) Corrects UnusedParameter with keyword arguments with splat
4
+ * (mvz) Consider block parameter for DuplicateMethodCall
5
+ * (mvz) Add support for detecting specific smells
6
+ * (troessner) Add ultra verbose warning formatter.
7
+
8
+ == 1.3.8
9
+
10
+ * Internal improvements
11
+
1
12
  == 1.3.7
2
13
 
3
14
  * (gilles-leblanc) Add color to reek's output
data/README.md CHANGED
@@ -95,11 +95,13 @@ for up to date details of exactly what Reek will check in your code.
95
95
 
96
96
  ### Integration
97
97
 
98
- Basically there are two ways to use reek in your project except for the obvious static code analysis:
98
+ Basically there are two ways to use reek in your project except for the obvious
99
+ static code analysis:
99
100
 
100
- (1) Use Reek's [Rake Task](https://github.com/troessner/reek/wiki/Rake-Task) to easily add Reek to your Rakefile
101
+ 1. Use Reek's [Rake Task](https://github.com/troessner/reek/wiki/Rake-Task) to
102
+ easily add Reek to your Rakefile
101
103
 
102
- (2) Add Reek's custom matcher to your Rspec examples like this:
104
+ 2. Add Reek's custom matcher to your Rspec examples like this:
103
105
 
104
106
  ```Ruby
105
107
  require 'rubygems'
@@ -122,23 +124,27 @@ my_precious_code.should_not reek # Well, it does.
122
124
 
123
125
  ### Running the tests
124
126
 
125
- Either just `rake` to run all or, if you want to be specific:
127
+ Either just `bundle exec rake` to run all or, if you want to be specific:
126
128
 
127
129
  ```bash
128
- spec spec/your/file # Runs all tests
129
- spec spec/your/file -l 23 # Runs test in line 23
130
- spec spec/your/file -u # Runs all tests stopping at the breakpoints you have set before with `debugger`
130
+ bundle exec rspec spec/your/file_spec.rb # Runs all tests in spec/your/file_spec.rb
131
+ bundle exec rspec spec/your/file_spec.rb:23 # Runs test in line 23
132
+ bundle exec cucumber features/your_file.feature # Runs all scenarios in your_file.feature
133
+ bundle exec cucumber features/your_file.feature:23 # Runs scenario at line 23
131
134
  ```
132
135
 
133
136
  ## Miscellaneous
134
137
 
135
138
  ### Tools
136
139
 
137
- There's a vim plugin for `reek`: [https://github.com/rainerborene/vim-reek](https://github.com/rainerborene/vim-reek)
140
+ There's a vim plugin for `reek`:
141
+ [https://github.com/rainerborene/vim-reek](https://github.com/rainerborene/vim-reek)
138
142
 
139
- TextMate Bundle for `reek`: [https://github.com/peeyush1234/reek.tmbundle](https://github.com/peeyush1234/reek.tmbundle)
143
+ TextMate Bundle for `reek`:
144
+ [https://github.com/peeyush1234/reek.tmbundle](https://github.com/peeyush1234/reek.tmbundle)
140
145
 
141
- Colorful output for `reek`: [Preek](https://github.com/joenas/preek) (also with [Guard::Preek](https://github.com/joenas/guard-preek))
146
+ Colorful output for `reek`: [Preek](https://github.com/joenas/preek) (also with
147
+ [Guard::Preek](https://github.com/joenas/guard-preek))
142
148
 
143
149
  ### Dependencies
144
150
 
@@ -153,7 +159,9 @@ Reek makes use of the following other gems:
153
159
 
154
160
  Find out more about Reek from any of the following sources:
155
161
 
156
- * Browse the Reek documentation at [https://github.com/troessner/reek/wiki](https://github.com/troessner/reek/wiki)
157
- * Browse the code or install the latest development version from [https://github.com/troessner/reek/tree](https://github.com/troessner/reek/tree)
158
- * Read the code API at [http://rdoc.info/projects/troessner/reek](http://rdoc.info/projects/troessner/reek)
159
-
162
+ * Browse the Reek documentation at
163
+ [https://github.com/troessner/reek/wiki](https://github.com/troessner/reek/wiki)
164
+ * Browse the code or install the latest development version from
165
+ [https://github.com/troessner/reek/tree](https://github.com/troessner/reek/tree)
166
+ * Read the code API at
167
+ [http://rdoc.info/projects/troessner/reek](http://rdoc.info/projects/troessner/reek)
data/Rakefile CHANGED
@@ -1,19 +1,6 @@
1
1
  require 'rake/clean'
2
- require "bundler/gem_tasks"
3
-
4
- $:.unshift File.dirname(__FILE__) + '/lib'
5
-
6
- PROJECT_NAME = 'reek'
7
-
8
- BUILD_DIR = 'build'; directory BUILD_DIR
9
- PKG_DIR = "#{BUILD_DIR}/pkg"; directory PKG_DIR
10
-
11
- GEM_MANIFEST = "Manifest.txt"
12
- VERSION_FILE = 'lib/reek.rb'
13
-
14
- CLOBBER.include("#{BUILD_DIR}/*")
2
+ require 'bundler/gem_tasks'
15
3
 
16
4
  Dir['tasks/**/*.rake'].each { |t| load t }
17
5
 
18
- task :default => [:test]
19
-
6
+ task default: [:test]
@@ -0,0 +1,103 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='UTF-8' />
5
+ <title>Reek Output</title>
6
+ <style>
7
+ * {
8
+ -webkit-box-sizing: border-box;
9
+ -moz-box-sizing: border-box;
10
+ box-sizing: border-box;
11
+ }
12
+ body {
13
+ background-color: #e8eef2;
14
+ font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
15
+ margin: 0;
16
+ }
17
+ #header {
18
+ background-color: #fafbfc;
19
+ border-bottom: 1px solid #cfdbe2;
20
+ margin-bottom: 20px;
21
+ padding: 20px;
22
+ color: #444444;
23
+ }
24
+ h1 {
25
+ margin: 0;
26
+ }
27
+ .total-warnings {
28
+ color: #f47f7f;
29
+ }
30
+ #reek-smells {
31
+ padding: 20px;
32
+ width: 100%;
33
+ }
34
+ .box {
35
+ margin-bottom: 20px;
36
+ background-color: #ffffff;
37
+ border: 1px solid transparent;
38
+ border-radius: 4px;
39
+ border-color: #cfdbe2;
40
+ -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
41
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
42
+ border-top-width: 3px;
43
+ }
44
+ .smell-list {
45
+ margin-bottom: 0px;
46
+ padding-left: 0px;
47
+ }
48
+ .list-item:first-child {
49
+ border-top-width: 0;
50
+ }
51
+ .list-item {
52
+ border-width: 1px 0;
53
+ border-radius: 0;
54
+ position: relative;
55
+ display: block;
56
+ padding: 10px 15px;
57
+ margin-bottom: -1px;
58
+ background-color: #ffffff;
59
+ border: 1px solid #f1f2f3;
60
+ }
61
+ .list-item > .content:first-child {
62
+ margin-top: 0px;
63
+ }
64
+ .list-item > .content {
65
+ overflow: hidden;
66
+ }
67
+ .list-item > .content > .heading {
68
+ margin: 0 0 5px 0;
69
+ }
70
+ .list-item > .content > small {
71
+ float: right;
72
+ color: #909fa7;
73
+ font-size: 0.8rem;
74
+ }
75
+ .list-item > .content > p {
76
+ margin: 0;
77
+ color: #656565;
78
+ }
79
+ </style>
80
+ </head>
81
+ <body>
82
+ <div id="header">
83
+ <h1>Reek Output - <span class="total-warnings"><%= smells.size %> total warnings</span></h1>
84
+ </div>
85
+ <div id="reek-smells">
86
+ <div class="box">
87
+ <div class="smell-list">
88
+ <% smells.each do |smell| %>
89
+ <div class="list-item">
90
+ <div class="content">
91
+ <div class="heading"><strong><%= smell.context%></strong> <%= smell.message%> (<%= smell.subclass%>)</div>
92
+ <small class="text-muted pull-right">Line <%= smell.lines %></small>
93
+ <p>
94
+ <small><%= smell.source %></small>
95
+ </p>
96
+ </div>
97
+ </div>
98
+ <% end %>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ </body>
103
+ </html>
@@ -36,15 +36,18 @@ Feature: Reek can be controlled using command-line options
36
36
 
37
37
  Configuration:
38
38
  -c, --config FILE Read configuration options from FILE
39
+ --smell SMELL Detect smell SMELL (default is all enabled smells)
39
40
 
40
41
  Report formatting:
41
42
  -o, --[no-]color Use colors for the output (this is the default)
42
43
  -q, --quiet Suppress headings for smell-free source files (this is the default)
43
44
  -V, --no-quiet, --verbose Show headings for smell-free source files
45
+ -U, --ultra-verbose Be as explanatory as possible
44
46
  -n, --no-line-numbers Suppress line numbers from the output
45
47
  --line-numbers Show line numbers in the output (this is the default)
46
48
  -s, --single-line Show IDE-compatible single-line-per-warning
47
49
  -S, --sort-by-issue-count Sort by "issue-count", listing the "smelliest" files first
48
50
  -y, --yaml Report smells in YAML format
51
+ -H, --html Report smells in HTML format
49
52
 
50
53
  """
@@ -0,0 +1,19 @@
1
+ Feature: Smell selection
2
+ In order to focus on particular code smells
3
+ As a developer
4
+ I want to be able to selectively activate smell detectors
5
+
6
+ Scenario: --smell selects a smell to detect
7
+ When I run reek --no-line-numbers --smell DuplicateMethodCall spec/samples/two_smelly_files
8
+ Then the exit status indicates smells
9
+ And it reports:
10
+ """
11
+ spec/samples/two_smelly_files/dirty_one.rb -- 2 warnings:
12
+ Dirty#a calls @s.title twice (DuplicateMethodCall)
13
+ Dirty#a calls puts(@s.title) twice (DuplicateMethodCall)
14
+ spec/samples/two_smelly_files/dirty_two.rb -- 2 warnings:
15
+ Dirty#a calls @s.title twice (DuplicateMethodCall)
16
+ Dirty#a calls puts(@s.title) twice (DuplicateMethodCall)
17
+ 4 total warnings
18
+
19
+ """
@@ -46,7 +46,7 @@ Feature: Reek can be driven through its Task
46
46
  end
47
47
  """
48
48
  Then the exit status indicates an error
49
- And stdout includes /spec\/samples\/masked\/dirty\.rb/
49
+ And stdout includes "spec/samples/masked/dirty.rb"
50
50
 
51
51
  Scenario: fail_on_error can hide the error status
52
52
  When I run rake reek with:
@@ -187,3 +187,19 @@ Feature: Correctly formatted reports
187
187
  | args |
188
188
  | spec/samples/two_smelly_files/ |
189
189
  | spec/samples/two_smelly_files |
190
+
191
+ Scenario Outline: -U or --ultra-verbose adds helpful links to smell warnings
192
+ When I run reek <option> spec/samples/one_smelly_file/dirty.rb
193
+ Then the exit status indicates smells
194
+ And it reports:
195
+ """
196
+ spec/samples/one_smelly_file/dirty.rb -- 3 warnings:
197
+ [1]:D has no descriptive comment (IrresponsibleModule) [https://github.com/troessner/reek/wiki/Irresponsible-Module]
198
+ [1]:D has the name 'D' (UncommunicativeModuleName) [https://github.com/troessner/reek/wiki/Uncommunicative-Module-Name]
199
+ [2]:D#a has the name 'a' (UncommunicativeMethodName) [https://github.com/troessner/reek/wiki/Uncommunicative-Method-Name]
200
+ """
201
+
202
+ Examples:
203
+ | option |
204
+ | -U |
205
+ | --ultra-verbose |
@@ -6,7 +6,10 @@ Feature: Report smells using simple YAML layout
6
6
  Scenario: output is empty when there are no smells
7
7
  When I run reek --yaml spec/samples/three_clean_files
8
8
  Then it succeeds
9
- And stdout equals ""
9
+ And it reports this yaml:
10
+ """
11
+ --- []
12
+ """
10
13
 
11
14
  @masking
12
15
  Scenario: masked smells always appear
@@ -14,49 +17,49 @@ Feature: Report smells using simple YAML layout
14
17
  Then the exit status indicates smells
15
18
  And it reports this yaml:
16
19
  """
17
- ---
18
- - !ruby/object:Reek::SmellWarning
19
- location:
20
- lines:
20
+ ---
21
+ - !ruby/object:Reek::SmellWarning
22
+ location:
23
+ lines:
21
24
  - 4
22
25
  - 6
23
26
  context: Dirty#a
24
27
  source: spec/samples/masked/dirty.rb
25
- smell:
28
+ smell:
26
29
  class: Duplication
27
30
  occurrences: 2
28
31
  subclass: DuplicateMethodCall
29
32
  call: "@s.title"
30
33
  message: calls @s.title twice
31
- status:
34
+ status:
32
35
  is_active: true
33
- - !ruby/object:Reek::SmellWarning
34
- location:
35
- lines:
36
+ - !ruby/object:Reek::SmellWarning
37
+ location:
38
+ lines:
36
39
  - 5
37
40
  - 7
38
41
  context: Dirty#a
39
42
  source: spec/samples/masked/dirty.rb
40
- smell:
43
+ smell:
41
44
  class: Duplication
42
45
  occurrences: 2
43
46
  subclass: DuplicateMethodCall
44
47
  call: puts(@s.title)
45
48
  message: calls puts(@s.title) twice
46
- status:
49
+ status:
47
50
  is_active: true
48
- - !ruby/object:Reek::SmellWarning
49
- location:
50
- lines:
51
+ - !ruby/object:Reek::SmellWarning
52
+ location:
53
+ lines:
51
54
  - 5
52
55
  context: Dirty#a
53
56
  source: spec/samples/masked/dirty.rb
54
- smell:
57
+ smell:
55
58
  class: NestedIterators
56
59
  depth: 2
57
60
  subclass: NestedIterators
58
61
  message: contains iterators nested 2 deep
59
- status:
62
+ status:
60
63
  is_active: true
61
64
 
62
65
  """
@@ -67,19 +70,19 @@ Feature: Report smells using simple YAML layout
67
70
  Then the exit status indicates smells
68
71
  And it reports this yaml:
69
72
  """
70
- ---
71
- - !ruby/object:Reek::SmellWarning
72
- location:
73
- lines:
73
+ ---
74
+ - !ruby/object:Reek::SmellWarning
75
+ location:
76
+ lines:
74
77
  - 1
75
78
  context: Turn
76
79
  source: $stdin
77
- smell:
80
+ smell:
78
81
  class: IrresponsibleModule
79
82
  subclass: IrresponsibleModule
80
83
  module_name: Turn
81
84
  message: has no descriptive comment
82
- status:
85
+ status:
83
86
  is_active: true
84
87
 
85
88
  """
@@ -59,7 +59,7 @@ Feature: Basic smell detection
59
59
  Then the exit status indicates smells
60
60
  And it reports:
61
61
  """
62
- spec/samples/optparse.rb -- 108 warnings:
62
+ spec/samples/optparse.rb -- 109 warnings:
63
63
  OptionParser has at least 42 methods (TooManyMethods)
64
64
  OptionParser has the variable name 'f' (UncommunicativeVariableName)
65
65
  OptionParser has the variable name 'k' (UncommunicativeVariableName)
@@ -154,6 +154,7 @@ Feature: Basic smell detection
154
154
  OptionParser::Switch#self.incompatible_argument_styles has the parameter name 't' (UncommunicativeParameterName)
155
155
  OptionParser::Switch#summarize calls (indent + l) twice (DuplicateMethodCall)
156
156
  OptionParser::Switch#summarize calls left.collect twice (DuplicateMethodCall)
157
+ OptionParser::Switch#summarize calls left.collect { |s| s.length } twice (DuplicateMethodCall)
157
158
  OptionParser::Switch#summarize calls left.collect { |s| s.length }.max twice (DuplicateMethodCall)
158
159
  OptionParser::Switch#summarize calls left.collect { |s| s.length }.max.to_i twice (DuplicateMethodCall)
159
160
  OptionParser::Switch#summarize calls left.shift twice (DuplicateMethodCall)
@@ -11,59 +11,59 @@ When /^I run rake (\w*) with:$/ do |name, task_def|
11
11
  end
12
12
 
13
13
  Then /^stdout equals "([^\"]*)"$/ do |report|
14
- @last_stdout.should == report
14
+ expect(@last_stdout).to eq report
15
15
  end
16
16
 
17
- Then /^stdout includes \/([^\"]*)\/$/ do |report|
18
- @last_stdout.should match(report)
17
+ Then /^stdout includes "(.*)"$/ do |text|
18
+ expect(@last_stdout).to include text
19
19
  end
20
20
 
21
21
  Then /^it succeeds$/ do
22
- @last_exit_status.should == Reek::Cli::Application::STATUS_SUCCESS
22
+ expect(@last_exit_status).to eq Reek::Cli::Application::STATUS_SUCCESS
23
23
  end
24
24
 
25
25
  Then /^the exit status indicates an error$/ do
26
- @last_exit_status.should == Reek::Cli::Application::STATUS_ERROR
26
+ expect(@last_exit_status).to eq Reek::Cli::Application::STATUS_ERROR
27
27
  end
28
28
 
29
29
  Then /^the exit status indicates smells$/ do
30
- @last_exit_status.should == Reek::Cli::Application::STATUS_SMELLS
30
+ expect(@last_exit_status).to eq Reek::Cli::Application::STATUS_SMELLS
31
31
  end
32
32
 
33
33
  Then /^it reports:$/ do |report|
34
- @last_stdout.chomp.should == report.chomp
34
+ expect(@last_stdout.chomp).to eq report.chomp
35
35
  end
36
36
 
37
37
  Then /^it reports this yaml:$/ do |expected_yaml|
38
38
  expected_warnings = YAML.load(expected_yaml.chomp)
39
39
  actual_warnings = YAML.load(@last_stdout)
40
- actual_warnings.should == expected_warnings
40
+ expect(actual_warnings).to eq expected_warnings
41
41
  end
42
42
 
43
43
  Then /^stderr reports:$/ do |report|
44
- @last_stderr.should == report
44
+ expect(@last_stderr).to eq report
45
45
  end
46
46
 
47
47
  Then /^it reports no errors$/ do
48
- @last_stderr.chomp.should eq ""
48
+ expect(@last_stderr.chomp).to eq ''
49
49
  end
50
50
 
51
51
  Then /^it reports an error$/ do
52
- @last_stderr.chomp.should_not be_empty
52
+ expect(@last_stderr.chomp).to_not be_empty
53
53
  end
54
54
 
55
55
  Then /^it reports the error ['"](.*)['"]$/ do |string|
56
- @last_stderr.chomp.should == string
56
+ expect(@last_stderr.chomp).to eq string
57
57
  end
58
58
 
59
59
  Then /^it reports a parsing error$/ do
60
- @last_stderr.chomp.should match(/Racc::ParseError/)
60
+ expect(@last_stderr.chomp).to match(/Racc::ParseError/)
61
61
  end
62
62
 
63
63
  Then /^it should indicate the line numbers of those smells$/ do
64
- @last_stdout.chomp.should match(/\[.*\]:/)
64
+ expect(@last_stdout.chomp).to match(/\[.*\]:/)
65
65
  end
66
66
 
67
67
  Then /^it reports the current version$/ do
68
- @last_stdout.should == "reek #{Reek::VERSION}\n"
68
+ expect(@last_stdout).to eq "reek #{Reek::VERSION}\n"
69
69
  end