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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reek
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.8
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Rutherford
@@ -10,36 +10,42 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-07-07 00:00:00.000000000 Z
13
+ date: 2014-11-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ruby_parser
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 3.5.0
22
+ - - "<"
20
23
  - !ruby/object:Gem::Version
21
- version: '3.3'
24
+ version: '4.0'
22
25
  type: :runtime
23
26
  prerelease: false
24
27
  version_requirements: !ruby/object:Gem::Requirement
25
28
  requirements:
26
- - - "~>"
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 3.5.0
32
+ - - "<"
27
33
  - !ruby/object:Gem::Version
28
- version: '3.3'
34
+ version: '4.0'
29
35
  - !ruby/object:Gem::Dependency
30
36
  name: sexp_processor
31
37
  requirement: !ruby/object:Gem::Requirement
32
38
  requirements:
33
- - - ">="
39
+ - - "~>"
34
40
  - !ruby/object:Gem::Version
35
- version: '0'
41
+ version: '4.4'
36
42
  type: :runtime
37
43
  prerelease: false
38
44
  version_requirements: !ruby/object:Gem::Requirement
39
45
  requirements:
40
- - - ">="
46
+ - - "~>"
41
47
  - !ruby/object:Gem::Version
42
- version: '0'
48
+ version: '4.4'
43
49
  - !ruby/object:Gem::Dependency
44
50
  name: ruby2ruby
45
51
  requirement: !ruby/object:Gem::Requirement
@@ -98,75 +104,81 @@ dependencies:
98
104
  name: rake
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
- - - ">="
107
+ - - "~>"
102
108
  - !ruby/object:Gem::Version
103
- version: '0'
109
+ version: '10.0'
104
110
  type: :development
105
111
  prerelease: false
106
112
  version_requirements: !ruby/object:Gem::Requirement
107
113
  requirements:
108
- - - ">="
114
+ - - "~>"
109
115
  - !ruby/object:Gem::Version
110
- version: '0'
116
+ version: '10.0'
111
117
  - !ruby/object:Gem::Dependency
112
118
  name: cucumber
113
119
  requirement: !ruby/object:Gem::Requirement
114
120
  requirements:
115
- - - ">="
121
+ - - "~>"
116
122
  - !ruby/object:Gem::Version
117
- version: '0'
123
+ version: '1.3'
118
124
  type: :development
119
125
  prerelease: false
120
126
  version_requirements: !ruby/object:Gem::Requirement
121
127
  requirements:
122
- - - ">="
128
+ - - "~>"
123
129
  - !ruby/object:Gem::Version
124
- version: '0'
130
+ version: '1.3'
125
131
  - !ruby/object:Gem::Dependency
126
132
  name: rspec
127
133
  requirement: !ruby/object:Gem::Requirement
128
134
  requirements:
129
135
  - - "~>"
130
136
  - !ruby/object:Gem::Version
131
- version: '2.12'
137
+ version: '3.0'
132
138
  type: :development
133
139
  prerelease: false
134
140
  version_requirements: !ruby/object:Gem::Requirement
135
141
  requirements:
136
142
  - - "~>"
137
143
  - !ruby/object:Gem::Version
138
- version: '2.12'
144
+ version: '3.0'
139
145
  - !ruby/object:Gem::Dependency
140
146
  name: flay
141
147
  requirement: !ruby/object:Gem::Requirement
142
148
  requirements:
143
- - - ">="
149
+ - - "~>"
144
150
  - !ruby/object:Gem::Version
145
- version: '0'
151
+ version: '2.4'
146
152
  type: :development
147
153
  prerelease: false
148
154
  version_requirements: !ruby/object:Gem::Requirement
149
155
  requirements:
150
- - - ">="
156
+ - - "~>"
151
157
  - !ruby/object:Gem::Version
152
- version: '0'
158
+ version: '2.4'
153
159
  - !ruby/object:Gem::Dependency
154
160
  name: yard
155
161
  requirement: !ruby/object:Gem::Requirement
156
162
  requirements:
157
163
  - - ">="
158
164
  - !ruby/object:Gem::Version
159
- version: '0'
165
+ version: 0.8.7
166
+ - - "<"
167
+ - !ruby/object:Gem::Version
168
+ version: '0.9'
160
169
  type: :development
161
170
  prerelease: false
162
171
  version_requirements: !ruby/object:Gem::Requirement
163
172
  requirements:
164
173
  - - ">="
165
174
  - !ruby/object:Gem::Version
166
- version: '0'
167
- description: |
168
- Reek is a tool that examines Ruby classes, modules and methods
169
- and reports any code smells it finds.
175
+ version: 0.8.7
176
+ - - "<"
177
+ - !ruby/object:Gem::Version
178
+ version: '0.9'
179
+ description: |2
180
+ Reek is a tool that examines Ruby classes, modules and methods and reports
181
+ any code smells it finds.
170
182
  email:
171
183
  - timo.roessner@googlemail.com
172
184
  executables:
@@ -181,9 +193,11 @@ files:
181
193
  - License.txt
182
194
  - README.md
183
195
  - Rakefile
196
+ - assets/html_output.html.erb
184
197
  - bin/reek
185
198
  - config/defaults.reek
186
199
  - features/command_line_interface/options.feature
200
+ - features/command_line_interface/smell_selection.feature
187
201
  - features/command_line_interface/smells_count.feature
188
202
  - features/command_line_interface/stdin.feature
189
203
  - features/configuration_files/masking_smells.feature
@@ -197,10 +211,13 @@ files:
197
211
  - features/support/env.rb
198
212
  - lib/reek.rb
199
213
  - lib/reek/cli/application.rb
200
- - lib/reek/cli/command_line.rb
214
+ - lib/reek/cli/command.rb
201
215
  - lib/reek/cli/help_command.rb
216
+ - lib/reek/cli/options.rb
202
217
  - lib/reek/cli/reek_command.rb
203
- - lib/reek/cli/report.rb
218
+ - lib/reek/cli/report/formatter.rb
219
+ - lib/reek/cli/report/report.rb
220
+ - lib/reek/cli/report/strategy.rb
204
221
  - lib/reek/cli/version_command.rb
205
222
  - lib/reek/config_file_exception.rb
206
223
  - lib/reek/core/code_context.rb
@@ -264,6 +281,7 @@ files:
264
281
  - spec/gem/updates_spec.rb
265
282
  - spec/gem/yard_spec.rb
266
283
  - spec/matchers/smell_of_matcher.rb
284
+ - spec/quality/reek_source_spec.rb
267
285
  - spec/reek/cli/help_command_spec.rb
268
286
  - spec/reek/cli/report_spec.rb
269
287
  - spec/reek/cli/version_command_spec.rb
@@ -348,6 +366,7 @@ files:
348
366
  - spec/samples/not_quite_masked/dirty.rb
349
367
  - spec/samples/not_quite_masked/masked.reek
350
368
  - spec/samples/not_quite_masked/smelly.rb
369
+ - spec/samples/one_smelly_file/dirty.rb
351
370
  - spec/samples/optparse.rb
352
371
  - spec/samples/overrides/masked/dirty.rb
353
372
  - spec/samples/overrides/masked/lower.reek
@@ -369,19 +388,22 @@ files:
369
388
  - tasks/reek.rake
370
389
  - tasks/test.rake
371
390
  homepage: http://wiki.github.com/troessner/reek
372
- licenses: []
391
+ licenses:
392
+ - MIT
373
393
  metadata: {}
374
- post_install_message: Thank you for downloading Reek. For info see the reek wiki http://wiki.github.com/troessner/reek
394
+ post_install_message:
375
395
  rdoc_options:
376
396
  - "--main"
377
397
  - README.md
398
+ - "-x"
399
+ - assets/|bin/|config/|features/|spec/|tasks/
378
400
  require_paths:
379
401
  - lib
380
402
  required_ruby_version: !ruby/object:Gem::Requirement
381
403
  requirements:
382
404
  - - ">="
383
405
  - !ruby/object:Gem::Version
384
- version: '0'
406
+ version: 1.9.2
385
407
  required_rubygems_version: !ruby/object:Gem::Requirement
386
408
  requirements:
387
409
  - - ">="
@@ -1,126 +0,0 @@
1
- require 'optparse'
2
- require 'rainbow'
3
- require 'reek/cli/report'
4
- require 'reek/cli/reek_command'
5
- require 'reek/cli/help_command'
6
- require 'reek/cli/version_command'
7
- require 'reek/source'
8
-
9
- module Reek
10
- module Cli
11
-
12
- #
13
- # Parses the command line
14
- #
15
- class Options
16
-
17
- def initialize(argv)
18
- @argv = argv
19
- @parser = OptionParser.new
20
- @colored = true
21
- @report_class = QuietReport
22
- @warning_formatter = WarningFormatterWithLineNumbers
23
- @command_class = ReekCommand
24
- @format = Report::DefaultFormat
25
- @config_files = []
26
- @sort_by_issue_count = false
27
- set_options
28
- end
29
-
30
- def banner
31
- progname = @parser.program_name
32
- # SMELL:
33
- # The following banner isn't really correct. Help, Version and Reek
34
- # are really sub-commands (in the git/svn sense) and so the usage
35
- # banner should show three different command-lines. The other
36
- # options are all flags for the Reek sub-command.
37
- #
38
- # reek -h|--help Display a help message
39
- #
40
- # reek -v|--version Output the tool's version number
41
- #
42
- # reek [options] files List the smells in the given files
43
- # -c|--config file Specify file(s) with config options
44
- # -n|--line-number Prefix smelly lines with line numbers
45
- # -q|-[no-]quiet Only list files that have smells
46
- # files Names of files or dirs to be checked
47
- #
48
- return <<EOB
49
- Usage: #{progname} [options] [files]
50
-
51
- Examples:
52
-
53
- #{progname} lib/*.rb
54
- #{progname} -q lib
55
- cat my_class.rb | #{progname}
56
-
57
- See http://wiki.github.com/troessner/reek for detailed help.
58
-
59
- EOB
60
- end
61
-
62
- def set_options
63
- @parser.banner = banner
64
- @parser.separator "Common options:"
65
- @parser.on("-h", "--help", "Show this message") do
66
- @command_class = HelpCommand
67
- end
68
- @parser.on("-v", "--version", "Show version") do
69
- @command_class = VersionCommand
70
- end
71
-
72
- @parser.separator "\nConfiguration:"
73
- @parser.on("-c", "--config FILE", "Read configuration options from FILE") do |file|
74
- @config_files << file
75
- end
76
-
77
- @parser.separator "\nReport formatting:"
78
- @parser.on("-o", "--[no-]color", "Use colors for the output (this is the default)") do |opt|
79
- @colored = opt
80
- end
81
- @parser.on("-q", "--quiet", "Suppress headings for smell-free source files (this is the default)") do |opt|
82
- @report_class = QuietReport
83
- end
84
- @parser.on("-V", "--no-quiet", "--verbose", "Show headings for smell-free source files") do |opt|
85
- @report_class = VerboseReport
86
- end
87
- @parser.on("-n", "--no-line-numbers", "Suppress line numbers from the output") do
88
- @warning_formatter = SimpleWarningFormatter
89
- end
90
- @parser.on("--line-numbers", "Show line numbers in the output (this is the default)") do
91
- @warning_formatter = WarningFormatterWithLineNumbers
92
- end
93
- @parser.on("-s", "--single-line", "Show IDE-compatible single-line-per-warning") do
94
- @warning_formatter = SingleLineWarningFormatter
95
- end
96
- @parser.on("-S", "--sort-by-issue-count", 'Sort by "issue-count", listing the "smelliest" files first') do
97
- @sort_by_issue_count = true
98
- end
99
- @parser.on("-y", "--yaml", "Report smells in YAML format") do
100
- @format = :yaml
101
- end
102
- end
103
-
104
- def parse
105
- @parser.parse!(@argv)
106
- if @command_class == HelpCommand
107
- HelpCommand.new(@parser)
108
- elsif @command_class == VersionCommand
109
- VersionCommand.new(@parser.program_name)
110
- else
111
- Rainbow.enabled = @colored
112
- reporter = @report_class.new(@warning_formatter, ReportFormatter, @sort_by_issue_count, @format)
113
- ReekCommand.create(get_sources, reporter, @config_files)
114
- end
115
- end
116
-
117
- def get_sources
118
- if @argv.empty?
119
- return [$stdin.to_reek_source('$stdin')]
120
- else
121
- return Source::SourceLocator.new(@argv).all_sources
122
- end
123
- end
124
- end
125
- end
126
- end
@@ -1,138 +0,0 @@
1
- require 'rainbow'
2
-
3
- module Reek
4
- module Cli
5
- module ReportFormatter
6
- def self.format_list(warnings, formatter = SimpleWarningFormatter)
7
- warnings.map do |warning|
8
- " #{formatter.format warning}"
9
- end.join("\n")
10
- end
11
-
12
- def self.header(examiner)
13
- count = examiner.smells_count
14
- result = Rainbow("#{examiner.description} -- ").cyan + Rainbow("#{count} warning").yellow
15
- result += Rainbow('s').yellow unless count == 1
16
- result
17
- end
18
- end
19
-
20
- module SimpleWarningFormatter
21
- def self.format(warning)
22
- "#{warning.context} #{warning.message} (#{warning.subclass})"
23
- end
24
- end
25
-
26
- module WarningFormatterWithLineNumbers
27
- def self.format(warning)
28
- "#{warning.lines.inspect}:#{SimpleWarningFormatter.format(warning)}"
29
- end
30
- end
31
-
32
- module SingleLineWarningFormatter
33
- def self.format(warning)
34
- "#{warning.source}:#{warning.lines.first}: #{SimpleWarningFormatter.format(warning)}"
35
- end
36
- end
37
-
38
- #
39
- # A report that contains the smells and smell counts following source code analysis.
40
- #
41
- class Report
42
- DefaultFormat = :text
43
-
44
- def initialize(warning_formatter = SimpleWarningFormatter, report_formatter = ReportFormatter, sort_by_issue_count = false, format = DefaultFormat)
45
- @warning_formatter = warning_formatter
46
- @report_formatter = report_formatter
47
- @examiners = []
48
- @total_smell_count = 0
49
- @sort_by_issue_count = sort_by_issue_count
50
- @format = format
51
- end
52
-
53
- def add_examiner(examiner)
54
- @total_smell_count += examiner.smells_count
55
- @examiners << examiner
56
- self
57
- end
58
-
59
- def show
60
- case @format
61
- when DefaultFormat
62
- sort_examiners
63
- display_summary
64
- display_total_smell_count
65
- when :yaml
66
- if all_smells.size > 0
67
- print(all_smells.to_yaml)
68
- else
69
- print ''
70
- end
71
- end
72
- end
73
-
74
- def has_smells?
75
- @total_smell_count > 0
76
- end
77
-
78
- private
79
-
80
- def all_smells
81
- @all_smells ||= @examiners.each_with_object([]) { |examiner, smells| smells << examiner.smells }
82
- .flatten
83
- end
84
-
85
- def sort_examiners
86
- @examiners.sort! {|first, second| second.smells_count <=> first.smells_count } if @sort_by_issue_count
87
- end
88
-
89
- def display_summary
90
- print gather_results.reject(&:empty?).join("\n")
91
- end
92
-
93
- def display_total_smell_count
94
- if @examiners.size > 1
95
- print "\n"
96
- print total_smell_count_message
97
- end
98
- end
99
-
100
- def total_smell_count_message
101
- Rainbow("#{@total_smell_count} total warning#{'s' unless @total_smell_count == 1 }\n").red
102
- end
103
-
104
- def summarize_single_examiner(examiner)
105
- result = @report_formatter.header examiner
106
- if examiner.smelly?
107
- formatted_list = @report_formatter.format_list examiner.smells, @warning_formatter
108
- result += ":\n#{formatted_list}"
109
- end
110
- result
111
- end
112
- end
113
-
114
- #
115
- # A report that lists smell-free source files.
116
- #
117
- class VerboseReport < Report
118
- def gather_results
119
- @examiners.each_with_object([]) do |examiner, result|
120
- result << summarize_single_examiner(examiner)
121
- end
122
- end
123
- end
124
-
125
- #
126
- # A report that does not list smell-free source files.
127
- #
128
- class QuietReport < Report
129
- def gather_results
130
- @examiners.each_with_object([]) do |examiner, result|
131
- if examiner.smelly?
132
- result << summarize_single_examiner(examiner)
133
- end
134
- end
135
- end
136
- end
137
- end
138
- end