reek 2.2.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.travis.yml +9 -4
  4. data/CHANGELOG +8 -0
  5. data/Gemfile +6 -4
  6. data/README.md +6 -0
  7. data/docs/API.md +51 -22
  8. data/docs/Configuration-Files.md +12 -1
  9. data/docs/Feature-Envy.md +30 -10
  10. data/docs/How-reek-works-internally.md +109 -39
  11. data/docs/RSpec-matchers.md +26 -22
  12. data/docs/Reek-Driven-Development.md +0 -8
  13. data/docs/Utility-Function.md +8 -10
  14. data/features/{ruby_api/api.feature → command_line_interface/basic_usage.feature} +2 -2
  15. data/features/programmatic_access.feature +21 -2
  16. data/features/samples.feature +3 -1
  17. data/lib/reek.rb +2 -2
  18. data/lib/reek/{core → ast}/ast_node_class_map.rb +8 -8
  19. data/lib/reek/{sexp/sexp_node.rb → ast/node.rb} +47 -6
  20. data/lib/reek/{core → ast}/object_refs.rb +2 -1
  21. data/lib/reek/{core → ast}/reference_collector.rb +2 -1
  22. data/lib/reek/{sexp → ast}/sexp_extensions.rb +10 -5
  23. data/lib/reek/{sexp → ast}/sexp_formatter.rb +7 -5
  24. data/lib/reek/cli/application.rb +1 -0
  25. data/lib/reek/cli/command.rb +1 -0
  26. data/lib/reek/cli/input.rb +4 -1
  27. data/lib/reek/cli/option_interpreter.rb +6 -4
  28. data/lib/reek/cli/options.rb +2 -1
  29. data/lib/reek/cli/reek_command.rb +3 -2
  30. data/lib/reek/cli/silencer.rb +1 -0
  31. data/lib/reek/{core → cli}/warning_collector.rb +2 -1
  32. data/lib/reek/code_comment.rb +36 -0
  33. data/lib/reek/configuration/app_configuration.rb +17 -2
  34. data/lib/reek/configuration/configuration_file_finder.rb +1 -0
  35. data/lib/reek/{core → context}/code_context.rb +7 -5
  36. data/lib/reek/{core → context}/method_context.rb +5 -3
  37. data/lib/reek/{core → context}/module_context.rb +8 -3
  38. data/lib/reek/{core/stop_context.rb → context/root_context.rb} +4 -2
  39. data/lib/reek/{core → context}/singleton_method_context.rb +2 -1
  40. data/lib/reek/examiner.rb +82 -0
  41. data/lib/reek/report/formatter.rb +70 -0
  42. data/lib/reek/report/heading_formatter.rb +45 -0
  43. data/lib/reek/report/location_formatter.rb +35 -0
  44. data/lib/reek/report/report.rb +198 -0
  45. data/lib/reek/smells.rb +24 -13
  46. data/lib/reek/smells/attribute.rb +6 -4
  47. data/lib/reek/smells/boolean_parameter.rb +3 -1
  48. data/lib/reek/smells/class_variable.rb +3 -1
  49. data/lib/reek/smells/control_parameter.rb +3 -1
  50. data/lib/reek/smells/data_clump.rb +3 -1
  51. data/lib/reek/smells/duplicate_method_call.rb +3 -1
  52. data/lib/reek/smells/feature_envy.rb +3 -1
  53. data/lib/reek/smells/irresponsible_module.rb +12 -7
  54. data/lib/reek/smells/long_parameter_list.rb +5 -3
  55. data/lib/reek/smells/long_yield_list.rb +3 -1
  56. data/lib/reek/smells/module_initialize.rb +3 -1
  57. data/lib/reek/smells/nested_iterators.rb +3 -1
  58. data/lib/reek/smells/nil_check.rb +3 -1
  59. data/lib/reek/smells/prima_donna_method.rb +3 -1
  60. data/lib/reek/smells/repeated_conditional.rb +5 -3
  61. data/lib/reek/{core → smells}/smell_configuration.rb +3 -1
  62. data/lib/reek/smells/smell_detector.rb +9 -7
  63. data/lib/reek/{core → smells}/smell_repository.rb +3 -2
  64. data/lib/reek/smells/smell_warning.rb +6 -4
  65. data/lib/reek/smells/too_many_instance_variables.rb +3 -1
  66. data/lib/reek/smells/too_many_methods.rb +3 -1
  67. data/lib/reek/smells/too_many_statements.rb +3 -1
  68. data/lib/reek/smells/uncommunicative_method_name.rb +3 -1
  69. data/lib/reek/smells/uncommunicative_module_name.rb +3 -1
  70. data/lib/reek/smells/uncommunicative_parameter_name.rb +3 -1
  71. data/lib/reek/smells/uncommunicative_variable_name.rb +3 -1
  72. data/lib/reek/smells/unused_parameters.rb +3 -1
  73. data/lib/reek/smells/utility_function.rb +5 -2
  74. data/lib/reek/source/source_code.rb +40 -9
  75. data/lib/reek/source/source_locator.rb +30 -12
  76. data/lib/reek/spec/should_reek.rb +5 -4
  77. data/lib/reek/spec/should_reek_of.rb +3 -2
  78. data/lib/reek/spec/should_reek_only_of.rb +5 -4
  79. data/lib/reek/tree_dresser.rb +32 -0
  80. data/lib/reek/tree_walker.rb +182 -0
  81. data/lib/reek/version.rb +1 -1
  82. data/reek.gemspec +3 -3
  83. data/spec/factories/factories.rb +2 -0
  84. data/spec/reek/{sexp/sexp_node_spec.rb → ast/node_spec.rb} +2 -2
  85. data/spec/reek/{core → ast}/object_refs_spec.rb +3 -3
  86. data/spec/reek/{core → ast}/reference_collector_spec.rb +2 -2
  87. data/spec/reek/{sexp → ast}/sexp_extensions_spec.rb +6 -16
  88. data/spec/reek/{sexp → ast}/sexp_formatter_spec.rb +2 -2
  89. data/spec/reek/cli/option_interpreter_spec.rb +2 -1
  90. data/spec/reek/{core → cli}/warning_collector_spec.rb +3 -3
  91. data/spec/reek/{core/code_comment_spec.rb → code_comment_spec.rb} +3 -3
  92. data/spec/reek/configuration/app_configuration_spec.rb +31 -18
  93. data/spec/reek/{core → context}/code_context_spec.rb +14 -15
  94. data/spec/reek/{core → context}/method_context_spec.rb +8 -8
  95. data/spec/reek/{core → context}/module_context_spec.rb +4 -4
  96. data/spec/reek/context/root_context_spec.rb +14 -0
  97. data/spec/reek/{core → context}/singleton_method_context_spec.rb +4 -4
  98. data/spec/reek/{core/examiner_spec.rb → examiner_spec.rb} +3 -42
  99. data/spec/reek/{cli → report}/html_report_spec.rb +5 -5
  100. data/spec/reek/report/json_report_spec.rb +20 -0
  101. data/spec/reek/{cli → report}/text_report_spec.rb +14 -14
  102. data/spec/reek/{cli → report}/xml_report_spec.rb +7 -7
  103. data/spec/reek/report/yaml_report_spec.rb +20 -0
  104. data/spec/reek/smells/attribute_spec.rb +2 -1
  105. data/spec/reek/smells/boolean_parameter_spec.rb +1 -1
  106. data/spec/reek/smells/class_variable_spec.rb +5 -5
  107. data/spec/reek/smells/control_parameter_spec.rb +1 -1
  108. data/spec/reek/smells/data_clump_spec.rb +1 -1
  109. data/spec/reek/smells/duplicate_method_call_spec.rb +3 -3
  110. data/spec/reek/smells/feature_envy_spec.rb +1 -1
  111. data/spec/reek/smells/irresponsible_module_spec.rb +24 -28
  112. data/spec/reek/smells/long_parameter_list_spec.rb +2 -2
  113. data/spec/reek/smells/long_yield_list_spec.rb +2 -2
  114. data/spec/reek/smells/nested_iterators_spec.rb +1 -1
  115. data/spec/reek/smells/nil_check_spec.rb +2 -2
  116. data/spec/reek/smells/prima_donna_method_spec.rb +3 -3
  117. data/spec/reek/smells/repeated_conditional_spec.rb +6 -6
  118. data/spec/reek/{core → smells}/smell_configuration_spec.rb +4 -4
  119. data/spec/reek/smells/smell_detector_shared.rb +2 -2
  120. data/spec/reek/{core → smells}/smell_repository_spec.rb +5 -4
  121. data/spec/reek/smells/too_many_instance_variables_spec.rb +1 -1
  122. data/spec/reek/smells/too_many_methods_spec.rb +4 -4
  123. data/spec/reek/smells/too_many_statements_spec.rb +2 -2
  124. data/spec/reek/smells/uncommunicative_method_name_spec.rb +1 -1
  125. data/spec/reek/smells/uncommunicative_module_name_spec.rb +4 -4
  126. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +2 -2
  127. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +3 -3
  128. data/spec/reek/smells/utility_function_spec.rb +23 -1
  129. data/spec/reek/source/source_code_spec.rb +1 -1
  130. data/spec/reek/source/source_locator_spec.rb +30 -0
  131. data/spec/reek/spec/should_reek_of_spec.rb +0 -17
  132. data/spec/reek/spec/should_reek_spec.rb +0 -25
  133. data/spec/reek/tree_dresser_spec.rb +16 -0
  134. data/spec/reek/{core/tree_walker_spec.rb → tree_walker_spec.rb} +5 -5
  135. data/spec/samples/{simple_configuration.reek → configuration/simple_configuration.reek} +0 -0
  136. data/spec/samples/configuration/with_excluded_paths.reek +4 -0
  137. data/spec/samples/source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb +5 -0
  138. data/spec/samples/source_with_exclude_paths/nested/ignore_me_as_well/irresponsible_module.rb +2 -0
  139. data/spec/samples/source_with_exclude_paths/nested/uncommunicative_parameter_name.rb +6 -0
  140. data/spec/spec_helper.rb +6 -7
  141. data/tasks/develop.rake +2 -2
  142. metadata +71 -69
  143. data/lib/reek/cli/report/formatter.rb +0 -69
  144. data/lib/reek/cli/report/heading_formatter.rb +0 -45
  145. data/lib/reek/cli/report/location_formatter.rb +0 -34
  146. data/lib/reek/cli/report/report.rb +0 -191
  147. data/lib/reek/core/ast_node.rb +0 -38
  148. data/lib/reek/core/code_comment.rb +0 -37
  149. data/lib/reek/core/examiner.rb +0 -85
  150. data/lib/reek/core/tree_dresser.rb +0 -24
  151. data/lib/reek/core/tree_walker.rb +0 -180
  152. data/lib/reek/source/source_repository.rb +0 -43
  153. data/spec/reek/cli/json_report_spec.rb +0 -20
  154. data/spec/reek/cli/yaml_report_spec.rb +0 -20
  155. data/spec/reek/core/object_source_spec.rb +0 -18
  156. data/spec/reek/core/stop_context_spec.rb +0 -14
  157. data/spec/reek/core/tree_dresser_spec.rb +0 -16
@@ -28,14 +28,6 @@ end
28
28
 
29
29
  By requiring "reek/spec":http://reek.rubyforge.org/rdoc/classes/Reek/Spec.html you gain access to the `reek` matcher, which returns true if and only if `reek` finds smells in your code. And if the test fails, the matcher produces an error message that includes details of all the smells it found.
30
30
 
31
- Note: if you're on ruby 1.9 and RSpec2 you should include Reek::Spec in the configuration block like so,
32
-
33
- ```Ruby
34
- RSpec.configure do |c|
35
- c.include(Reek::Spec)
36
- end
37
- ```
38
-
39
31
  ## assert
40
32
 
41
33
  If you're not yet into BDD with Rspec, you can still gain the benefits of Reek-driven development using assertions:
@@ -2,11 +2,9 @@
2
2
 
3
3
  ## Introduction
4
4
 
5
- A Utility Function is any instance method that has no dependency on the state of the instance.
5
+ A _Utility Function_ is any instance method that has no dependency on the state of the instance.
6
6
 
7
- A Utility Function reduces the code’s ability to communicate intent: code that “belongs” on one class but which is located in another can be hard to find, and may upset the “System of Names” in the host class. A Utility Function also affects the design’s flexibility: A code fragment that is in the wrong class creates couplings that may not be natural within the application’s domain, and creates a loss of cohesion in the unwilling host class.
8
-
9
- A Utility Function often arises because it must manipulate other objects (usually its arguments) to get them into a useful form, and one force preventing them (the arguments) doing this themselves is that the common knowledge lives outside the arguments, or the arguments are of too basic a type to justify extending that type. Therefore there must be something which 'knows' about the contents or purposes of the arguments. That thing would have to be more than just a basic type, because the basic types are either containers which don't know about their contents, or they are single objects which can't capture their relationship with their fellows of the same type. So, this thing with the extra knowledge should be reified into a class, and the utility method will most likely belong there.
7
+ _Utility Function_ is heavily related to _[Feature Envy](Feature-Envy.md)_, please check out the explanation there why _Utility Function_ is something you should care about.
10
8
 
11
9
  ## Example
12
10
 
@@ -29,7 +27,7 @@ test.rb -- 2 warnings:
29
27
 
30
28
  ## Current Support in reek
31
29
 
32
- `Utility Function` will warn about any method that:
30
+ _Utility Function_ will warn about any method that:
33
31
 
34
32
  * is non-empty
35
33
  * does not override an inherited method
@@ -37,10 +35,10 @@ test.rb -- 2 warnings:
37
35
  * doesn't use any of self's instance variables
38
36
  * doesn't use any of self's methods
39
37
 
40
- ## Configuration
38
+ ## Differences to _Feature Envy_
41
39
 
42
- `reek`'s `Utility Function` detector supports the [Basic Smell Options](Basic-Smell-Options.md), plus:
40
+ _[Feature Envy](Feature-Envy.md)_ is only triggered if there are some references to self and _Utility Function_ is triggered if there are no references to self.
41
+
42
+ ## Configuration
43
43
 
44
- | Option | Value | Effect |
45
- | ---------------|-------------|---------|
46
- | `max_helper_calls` | integer | The maximum number of method calls to other objects allowed within a method. Defaults to 2. |
44
+ `reek`'s _Utility Function_ detector supports the [Basic Smell Options](Basic-Smell-Options.md).
@@ -1,7 +1,7 @@
1
- Feature: The Reek API maintains backwards compatibility
1
+ Feature: The Reek CLI maintains backwards compatibility
2
2
  In order to use Reek without fuss
3
3
  As a developer
4
- I want to have a stable API
4
+ I want to have a stable basic command line interface
5
5
 
6
6
  Scenario: the demo example reports as expected
7
7
  Given the smelly file 'demo.rb' from the example in the README
@@ -3,12 +3,12 @@ Feature: Using reek programmatically
3
3
  As a developer
4
4
  I want to be able to use its classes
5
5
 
6
- Scenario:
6
+ Scenario: Accessing smells found by an examiner
7
7
  Given a smelly file called 'smelly.rb'
8
8
  And a file named "examine.rb" with:
9
9
  """
10
10
  require 'reek'
11
- examiner = Reek::Core::Examiner.new(['smelly.rb'])
11
+ examiner = Reek::Examiner.new(File.new('smelly.rb'))
12
12
  examiner.smells.each do |smell|
13
13
  puts smell.message
14
14
  end
@@ -22,3 +22,22 @@ Feature: Using reek programmatically
22
22
  has the name 'm'
23
23
  """
24
24
 
25
+ Scenario: Using reek's built-in report classes
26
+ Given a smelly file called 'smelly.rb'
27
+ And a file named "examine.rb" with:
28
+ """
29
+ require 'reek'
30
+ examiner = Reek::Examiner.new(File.new('smelly.rb'))
31
+ report = Reek::Report::TextReport.new
32
+ report.add_examiner examiner
33
+ report.show
34
+ """
35
+ When I run `ruby examine.rb`
36
+ Then it reports no errors
37
+ And it reports:
38
+ """
39
+ smelly.rb -- 3 warnings:
40
+ Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
41
+ Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall)
42
+ Smelly#m has the name 'm' (UncommunicativeMethodName)
43
+ """
@@ -9,8 +9,9 @@ Feature: Basic smell detection
9
9
  Then the exit status indicates smells
10
10
  And it reports:
11
11
  """
12
- inline.rb -- 43 warnings:
12
+ inline.rb -- 45 warnings:
13
13
  CompilationError has no descriptive comment (IrresponsibleModule)
14
+ Dir has no descriptive comment (IrresponsibleModule)
14
15
  File has no descriptive comment (IrresponsibleModule)
15
16
  File#self.write_with_backup has approx 6 statements (TooManyStatements)
16
17
  Inline declares the class variable @@directory (ClassVariable)
@@ -50,6 +51,7 @@ Feature: Basic smell detection
50
51
  Inline::C#parse_signature has the variable name 'x' (UncommunicativeVariableName)
51
52
  Inline::C#parse_signature is controlled by argument raw (ControlParameter)
52
53
  Inline::C#strip_comments doesn't depend on instance state (UtilityFunction)
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)
@@ -2,5 +2,5 @@
2
2
  # Reek's core functionality
3
3
  #
4
4
  require_relative 'reek/version'
5
- require_relative 'reek/core/examiner'
6
- require_relative 'reek/smells/smell_warning'
5
+ require_relative 'reek/examiner'
6
+ require_relative 'reek/report/report'
@@ -1,31 +1,31 @@
1
- require_relative 'ast_node'
2
- require_relative '../sexp/sexp_node'
3
- require_relative '../sexp/sexp_extensions'
1
+ require_relative 'node'
2
+ require_relative 'sexp_extensions'
4
3
 
5
4
  module Reek
6
- module Core
5
+ module AST
7
6
  # Maps AST node types to sublasses of ASTNode extended with the relevant
8
7
  # utility modules.
8
+ #
9
+ # @api private
9
10
  class ASTNodeClassMap
10
11
  def initialize
11
12
  @klass_map = {}
12
13
  end
13
14
 
14
15
  def klass_for(type)
15
- @klass_map[type] ||= Class.new(ASTNode).tap do |klass|
16
+ @klass_map[type] ||= Class.new(Node).tap do |klass|
16
17
  extension = extension_map[type]
17
18
  klass.send :include, extension if extension
18
- klass.send :include, Sexp::SexpNode
19
19
  end
20
20
  end
21
21
 
22
22
  def extension_map
23
23
  @extension_map ||=
24
24
  begin
25
- assoc = Sexp::SexpExtensions.constants.map do |const|
25
+ assoc = SexpExtensions.constants.map do |const|
26
26
  [
27
27
  const.to_s.sub(/Node$/, '').downcase.to_sym,
28
- Sexp::SexpExtensions.const_get(const)
28
+ SexpExtensions.const_get(const)
29
29
  ]
30
30
  end
31
31
  Hash[assoc]
@@ -1,10 +1,47 @@
1
+ require 'parser'
2
+
1
3
  module Reek
2
- module Sexp
3
- #
4
- # Extensions to +Sexp+ to allow +TreeWalker+ to navigate the abstract
5
- # syntax tree more easily.
4
+ # @api private
5
+ module AST
6
+ # Base class for AST nodes extended with utility methods. Contains some
7
+ # methods to ease the transition from Sexp to AST::Node.
6
8
  #
7
- module SexpNode
9
+ # @api private
10
+ class Node < ::Parser::AST::Node
11
+ attr_reader :parent
12
+
13
+ def initialize(type, children = [], options = {})
14
+ @comments = options.fetch(:comments, [])
15
+ @parent = options.fetch(:parent, nil)
16
+ super
17
+ end
18
+
19
+ def full_comment
20
+ @comments.map(&:text).join("\n")
21
+ end
22
+
23
+ def leading_comment
24
+ line = location.line
25
+ comment_lines = @comments.select do |comment|
26
+ comment.location.line < line
27
+ end
28
+ comment_lines.map(&:text).join("\n")
29
+ end
30
+
31
+ # @deprecated
32
+ def [](index)
33
+ elements[index]
34
+ end
35
+
36
+ def line
37
+ loc.line
38
+ end
39
+
40
+ # @deprecated
41
+ def first
42
+ type
43
+ end
44
+
8
45
  #
9
46
  # Carries out a depth-first traversal of this syntax tree, yielding
10
47
  # every Sexp of type `target_type`. The traversal ignores any node
@@ -84,7 +121,11 @@ module Reek
84
121
  private
85
122
 
86
123
  def each_sexp
87
- children.each { |elem| yield elem if elem.is_a? AST::Node }
124
+ children.each { |elem| yield elem if elem.is_a? ::Parser::AST::Node }
125
+ end
126
+
127
+ def elements
128
+ [type, *children]
88
129
  end
89
130
  end
90
131
  end
@@ -1,8 +1,9 @@
1
1
  module Reek
2
- module Core
2
+ module AST
3
3
  #
4
4
  # Manages and counts the references out of a method to other objects.
5
5
  #
6
+ # @api private
6
7
  class ObjectRefs # :nodoc:
7
8
  def initialize
8
9
  @refs = Hash.new(0)
@@ -1,9 +1,10 @@
1
1
  module Reek
2
- module Core
2
+ module AST
3
3
  #
4
4
  # Locates references to the current object within a portion
5
5
  # of an abstract syntax tree.
6
6
  #
7
+ # @api private
7
8
  class ReferenceCollector
8
9
  STOP_NODES = [:class, :module, :def, :defs]
9
10
 
@@ -1,12 +1,12 @@
1
- require_relative 'sexp_node'
2
- require_relative '../core/reference_collector'
1
+ require_relative 'reference_collector'
3
2
 
4
3
  module Reek
5
- module Sexp
4
+ module AST
6
5
  #
7
6
  # Extension modules providing utility methods to ASTNode objects, depending
8
7
  # on their type.
9
8
  #
9
+ # @api private
10
10
  module SexpExtensions
11
11
  # Base module for utility methods for argument nodes.
12
12
  module ArgNodeBase
@@ -264,7 +264,12 @@ module Reek
264
264
  end
265
265
 
266
266
  def depends_on_instance?
267
- Core::ReferenceCollector.new(self).num_refs_to_self > 0
267
+ ReferenceCollector.new(self).num_refs_to_self > 0
268
+ end
269
+
270
+ def singleton_method?
271
+ # This catches the case where methods are defined within the "class << self" syntax.
272
+ parent.type == :sclass if parent
268
273
  end
269
274
  end
270
275
 
@@ -327,7 +332,7 @@ module Reek
327
332
  def name() self[1] end
328
333
 
329
334
  def simple_name
330
- name.is_a?(AST::Node) ? name.simple_name : name
335
+ name.is_a?(::Parser::AST::Node) ? name.simple_name : name
331
336
  end
332
337
 
333
338
  def full_name(outer)
@@ -4,19 +4,21 @@ Reek::CLI::Silencer.silently do
4
4
  end
5
5
 
6
6
  module Reek
7
- module Sexp
7
+ module AST
8
8
  #
9
9
  # Formats snippets of syntax tree back into Ruby source code.
10
10
  #
11
- # :reek:DuplicateMethodCall { max_calls: 2 } is ok for lines.first
11
+ # @api private
12
12
  class SexpFormatter
13
13
  # Formats the given sexp.
14
14
  #
15
- # sexp - S-expression of type AST::Node or something that is at least to_s-able.
15
+ # @param [AST::Node, #to_s] sexp - The expression to format
16
16
  #
17
- # Returns a formatted string representation.
17
+ # @return [String] a formatted string representation.
18
+ #
19
+ # :reek:DuplicateMethodCall { max_calls: 2 } is ok for lines.first
18
20
  def self.format(sexp)
19
- return sexp.to_s unless sexp.is_a? AST::Node
21
+ return sexp.to_s unless sexp.is_a? ::Parser::AST::Node
20
22
  lines = Unparser.unparse(sexp).split "\n"
21
23
  case lines.length
22
24
  when 1 then lines.first
@@ -9,6 +9,7 @@ module Reek
9
9
  # This is the entry point for all invocations of Reek from the
10
10
  # command line.
11
11
  #
12
+ # @api private
12
13
  class Application
13
14
  STATUS_SUCCESS = 0
14
15
  STATUS_ERROR = 1
@@ -3,6 +3,7 @@ module Reek
3
3
  #
4
4
  # Base class for all commands
5
5
  #
6
+ # @api private
6
7
  class Command
7
8
  attr_reader :options
8
9
 
@@ -1,8 +1,11 @@
1
+ require_relative '../source/source_locator'
2
+
1
3
  module Reek
2
4
  module CLI
3
5
  #
4
6
  # CLI Input utility
5
7
  #
8
+ # @api private
6
9
  module Input
7
10
  def sources
8
11
  if no_source_files_given?
@@ -37,7 +40,7 @@ module Reek
37
40
  end
38
41
 
39
42
  def source_from_pipe
40
- [Source::SourceCode.from($stdin)]
43
+ [$stdin]
41
44
  end
42
45
  end
43
46
  end
@@ -1,16 +1,17 @@
1
1
  require 'forwardable'
2
2
  require_relative 'input'
3
- require_relative 'report/report'
4
- require_relative 'report/formatter'
5
- require_relative 'report/heading_formatter'
3
+ require_relative '../report/report'
4
+ require_relative '../report/formatter'
5
+ require_relative '../report/heading_formatter'
6
6
 
7
7
  module Reek
8
8
  module CLI
9
9
  #
10
10
  # Interprets the options set from the command line
11
11
  #
12
+ # @api private
12
13
  class OptionInterpreter
13
- include CLI::Input
14
+ include Input
14
15
 
15
16
  extend Forwardable
16
17
 
@@ -30,6 +31,7 @@ module Reek
30
31
  heading_formatter: heading_formatter)
31
32
  end
32
33
 
34
+ # TODO: Move report type mapping into Report
33
35
  def report_class
34
36
  case @options.report_format
35
37
  when :yaml
@@ -9,7 +9,8 @@ module Reek
9
9
  #
10
10
  # Parses the command line
11
11
  #
12
- # See docs/Command-Line-Options for details.
12
+ # See {file:docs/Command-Line-Options.md} for details.
13
+ # @api private
13
14
  class Options
14
15
  def initialize(argv = [])
15
16
  @argv = argv
@@ -1,5 +1,5 @@
1
1
  require_relative 'command'
2
- require_relative '../core/examiner'
2
+ require_relative '../examiner'
3
3
 
4
4
  module Reek
5
5
  module CLI
@@ -7,10 +7,11 @@ module Reek
7
7
  # A command to collect smells from a set of sources and write them out in
8
8
  # text report format.
9
9
  #
10
+ # @api private
10
11
  class ReekCommand < Command
11
12
  def execute(app)
12
13
  @options.sources.each do |source|
13
- reporter.add_examiner Core::Examiner.new(source, smell_names)
14
+ reporter.add_examiner Examiner.new(source, smell_names)
14
15
  end
15
16
  reporter.smells? ? app.report_smells : app.report_success
16
17
  reporter.show
@@ -1,6 +1,7 @@
1
1
  module Reek
2
2
  module CLI
3
3
  # CLI silencer
4
+ # @api private
4
5
  module Silencer
5
6
  def self.silently
6
7
  old_verbose, $VERBOSE = $VERBOSE, nil
@@ -1,10 +1,11 @@
1
1
  require 'set'
2
2
 
3
3
  module Reek
4
- module Core
4
+ module CLI
5
5
  #
6
6
  # Collects and sorts smells warnings.
7
7
  #
8
+ # @api private
8
9
  class WarningCollector
9
10
  def initialize
10
11
  @warnings = Set.new