reek 2.2.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +9 -4
- data/CHANGELOG +8 -0
- data/Gemfile +6 -4
- data/README.md +6 -0
- data/docs/API.md +51 -22
- data/docs/Configuration-Files.md +12 -1
- data/docs/Feature-Envy.md +30 -10
- data/docs/How-reek-works-internally.md +109 -39
- data/docs/RSpec-matchers.md +26 -22
- data/docs/Reek-Driven-Development.md +0 -8
- data/docs/Utility-Function.md +8 -10
- data/features/{ruby_api/api.feature → command_line_interface/basic_usage.feature} +2 -2
- data/features/programmatic_access.feature +21 -2
- data/features/samples.feature +3 -1
- data/lib/reek.rb +2 -2
- data/lib/reek/{core → ast}/ast_node_class_map.rb +8 -8
- data/lib/reek/{sexp/sexp_node.rb → ast/node.rb} +47 -6
- data/lib/reek/{core → ast}/object_refs.rb +2 -1
- data/lib/reek/{core → ast}/reference_collector.rb +2 -1
- data/lib/reek/{sexp → ast}/sexp_extensions.rb +10 -5
- data/lib/reek/{sexp → ast}/sexp_formatter.rb +7 -5
- data/lib/reek/cli/application.rb +1 -0
- data/lib/reek/cli/command.rb +1 -0
- data/lib/reek/cli/input.rb +4 -1
- data/lib/reek/cli/option_interpreter.rb +6 -4
- data/lib/reek/cli/options.rb +2 -1
- data/lib/reek/cli/reek_command.rb +3 -2
- data/lib/reek/cli/silencer.rb +1 -0
- data/lib/reek/{core → cli}/warning_collector.rb +2 -1
- data/lib/reek/code_comment.rb +36 -0
- data/lib/reek/configuration/app_configuration.rb +17 -2
- data/lib/reek/configuration/configuration_file_finder.rb +1 -0
- data/lib/reek/{core → context}/code_context.rb +7 -5
- data/lib/reek/{core → context}/method_context.rb +5 -3
- data/lib/reek/{core → context}/module_context.rb +8 -3
- data/lib/reek/{core/stop_context.rb → context/root_context.rb} +4 -2
- data/lib/reek/{core → context}/singleton_method_context.rb +2 -1
- data/lib/reek/examiner.rb +82 -0
- data/lib/reek/report/formatter.rb +70 -0
- data/lib/reek/report/heading_formatter.rb +45 -0
- data/lib/reek/report/location_formatter.rb +35 -0
- data/lib/reek/report/report.rb +198 -0
- data/lib/reek/smells.rb +24 -13
- data/lib/reek/smells/attribute.rb +6 -4
- data/lib/reek/smells/boolean_parameter.rb +3 -1
- data/lib/reek/smells/class_variable.rb +3 -1
- data/lib/reek/smells/control_parameter.rb +3 -1
- data/lib/reek/smells/data_clump.rb +3 -1
- data/lib/reek/smells/duplicate_method_call.rb +3 -1
- data/lib/reek/smells/feature_envy.rb +3 -1
- data/lib/reek/smells/irresponsible_module.rb +12 -7
- data/lib/reek/smells/long_parameter_list.rb +5 -3
- data/lib/reek/smells/long_yield_list.rb +3 -1
- data/lib/reek/smells/module_initialize.rb +3 -1
- data/lib/reek/smells/nested_iterators.rb +3 -1
- data/lib/reek/smells/nil_check.rb +3 -1
- data/lib/reek/smells/prima_donna_method.rb +3 -1
- data/lib/reek/smells/repeated_conditional.rb +5 -3
- data/lib/reek/{core → smells}/smell_configuration.rb +3 -1
- data/lib/reek/smells/smell_detector.rb +9 -7
- data/lib/reek/{core → smells}/smell_repository.rb +3 -2
- data/lib/reek/smells/smell_warning.rb +6 -4
- data/lib/reek/smells/too_many_instance_variables.rb +3 -1
- data/lib/reek/smells/too_many_methods.rb +3 -1
- data/lib/reek/smells/too_many_statements.rb +3 -1
- data/lib/reek/smells/uncommunicative_method_name.rb +3 -1
- data/lib/reek/smells/uncommunicative_module_name.rb +3 -1
- data/lib/reek/smells/uncommunicative_parameter_name.rb +3 -1
- data/lib/reek/smells/uncommunicative_variable_name.rb +3 -1
- data/lib/reek/smells/unused_parameters.rb +3 -1
- data/lib/reek/smells/utility_function.rb +5 -2
- data/lib/reek/source/source_code.rb +40 -9
- data/lib/reek/source/source_locator.rb +30 -12
- data/lib/reek/spec/should_reek.rb +5 -4
- data/lib/reek/spec/should_reek_of.rb +3 -2
- data/lib/reek/spec/should_reek_only_of.rb +5 -4
- data/lib/reek/tree_dresser.rb +32 -0
- data/lib/reek/tree_walker.rb +182 -0
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +3 -3
- data/spec/factories/factories.rb +2 -0
- data/spec/reek/{sexp/sexp_node_spec.rb → ast/node_spec.rb} +2 -2
- data/spec/reek/{core → ast}/object_refs_spec.rb +3 -3
- data/spec/reek/{core → ast}/reference_collector_spec.rb +2 -2
- data/spec/reek/{sexp → ast}/sexp_extensions_spec.rb +6 -16
- data/spec/reek/{sexp → ast}/sexp_formatter_spec.rb +2 -2
- data/spec/reek/cli/option_interpreter_spec.rb +2 -1
- data/spec/reek/{core → cli}/warning_collector_spec.rb +3 -3
- data/spec/reek/{core/code_comment_spec.rb → code_comment_spec.rb} +3 -3
- data/spec/reek/configuration/app_configuration_spec.rb +31 -18
- data/spec/reek/{core → context}/code_context_spec.rb +14 -15
- data/spec/reek/{core → context}/method_context_spec.rb +8 -8
- data/spec/reek/{core → context}/module_context_spec.rb +4 -4
- data/spec/reek/context/root_context_spec.rb +14 -0
- data/spec/reek/{core → context}/singleton_method_context_spec.rb +4 -4
- data/spec/reek/{core/examiner_spec.rb → examiner_spec.rb} +3 -42
- data/spec/reek/{cli → report}/html_report_spec.rb +5 -5
- data/spec/reek/report/json_report_spec.rb +20 -0
- data/spec/reek/{cli → report}/text_report_spec.rb +14 -14
- data/spec/reek/{cli → report}/xml_report_spec.rb +7 -7
- data/spec/reek/report/yaml_report_spec.rb +20 -0
- data/spec/reek/smells/attribute_spec.rb +2 -1
- data/spec/reek/smells/boolean_parameter_spec.rb +1 -1
- data/spec/reek/smells/class_variable_spec.rb +5 -5
- data/spec/reek/smells/control_parameter_spec.rb +1 -1
- data/spec/reek/smells/data_clump_spec.rb +1 -1
- data/spec/reek/smells/duplicate_method_call_spec.rb +3 -3
- data/spec/reek/smells/feature_envy_spec.rb +1 -1
- data/spec/reek/smells/irresponsible_module_spec.rb +24 -28
- data/spec/reek/smells/long_parameter_list_spec.rb +2 -2
- data/spec/reek/smells/long_yield_list_spec.rb +2 -2
- data/spec/reek/smells/nested_iterators_spec.rb +1 -1
- data/spec/reek/smells/nil_check_spec.rb +2 -2
- data/spec/reek/smells/prima_donna_method_spec.rb +3 -3
- data/spec/reek/smells/repeated_conditional_spec.rb +6 -6
- data/spec/reek/{core → smells}/smell_configuration_spec.rb +4 -4
- data/spec/reek/smells/smell_detector_shared.rb +2 -2
- data/spec/reek/{core → smells}/smell_repository_spec.rb +5 -4
- data/spec/reek/smells/too_many_instance_variables_spec.rb +1 -1
- data/spec/reek/smells/too_many_methods_spec.rb +4 -4
- data/spec/reek/smells/too_many_statements_spec.rb +2 -2
- data/spec/reek/smells/uncommunicative_method_name_spec.rb +1 -1
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +4 -4
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +2 -2
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +3 -3
- data/spec/reek/smells/utility_function_spec.rb +23 -1
- data/spec/reek/source/source_code_spec.rb +1 -1
- data/spec/reek/source/source_locator_spec.rb +30 -0
- data/spec/reek/spec/should_reek_of_spec.rb +0 -17
- data/spec/reek/spec/should_reek_spec.rb +0 -25
- data/spec/reek/tree_dresser_spec.rb +16 -0
- data/spec/reek/{core/tree_walker_spec.rb → tree_walker_spec.rb} +5 -5
- data/spec/samples/{simple_configuration.reek → configuration/simple_configuration.reek} +0 -0
- data/spec/samples/configuration/with_excluded_paths.reek +4 -0
- data/spec/samples/source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb +5 -0
- data/spec/samples/source_with_exclude_paths/nested/ignore_me_as_well/irresponsible_module.rb +2 -0
- data/spec/samples/source_with_exclude_paths/nested/uncommunicative_parameter_name.rb +6 -0
- data/spec/spec_helper.rb +6 -7
- data/tasks/develop.rake +2 -2
- metadata +71 -69
- data/lib/reek/cli/report/formatter.rb +0 -69
- data/lib/reek/cli/report/heading_formatter.rb +0 -45
- data/lib/reek/cli/report/location_formatter.rb +0 -34
- data/lib/reek/cli/report/report.rb +0 -191
- data/lib/reek/core/ast_node.rb +0 -38
- data/lib/reek/core/code_comment.rb +0 -37
- data/lib/reek/core/examiner.rb +0 -85
- data/lib/reek/core/tree_dresser.rb +0 -24
- data/lib/reek/core/tree_walker.rb +0 -180
- data/lib/reek/source/source_repository.rb +0 -43
- data/spec/reek/cli/json_report_spec.rb +0 -20
- data/spec/reek/cli/yaml_report_spec.rb +0 -20
- data/spec/reek/core/object_source_spec.rb +0 -18
- data/spec/reek/core/stop_context_spec.rb +0 -14
- 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:
|
data/docs/Utility-Function.md
CHANGED
@@ -2,11 +2,9 @@
|
|
2
2
|
|
3
3
|
## Introduction
|
4
4
|
|
5
|
-
A
|
5
|
+
A _Utility Function_ is any instance method that has no dependency on the state of the instance.
|
6
6
|
|
7
|
-
|
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
|
-
|
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
|
-
##
|
38
|
+
## Differences to _Feature Envy_
|
41
39
|
|
42
|
-
|
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
|
-
|
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
|
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
|
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::
|
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
|
+
"""
|
data/features/samples.feature
CHANGED
@@ -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 --
|
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)
|
data/lib/reek.rb
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
require_relative '
|
2
|
-
require_relative '
|
3
|
-
require_relative '../sexp/sexp_extensions'
|
1
|
+
require_relative 'node'
|
2
|
+
require_relative 'sexp_extensions'
|
4
3
|
|
5
4
|
module Reek
|
6
|
-
module
|
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(
|
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 =
|
25
|
+
assoc = SexpExtensions.constants.map do |const|
|
26
26
|
[
|
27
27
|
const.to_s.sub(/Node$/, '').downcase.to_sym,
|
28
|
-
|
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
|
-
|
3
|
-
|
4
|
-
#
|
5
|
-
#
|
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
|
-
|
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,12 +1,12 @@
|
|
1
|
-
require_relative '
|
2
|
-
require_relative '../core/reference_collector'
|
1
|
+
require_relative 'reference_collector'
|
3
2
|
|
4
3
|
module Reek
|
5
|
-
module
|
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
|
-
|
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
|
7
|
+
module AST
|
8
8
|
#
|
9
9
|
# Formats snippets of syntax tree back into Ruby source code.
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# @api private
|
12
12
|
class SexpFormatter
|
13
13
|
# Formats the given sexp.
|
14
14
|
#
|
15
|
-
#
|
15
|
+
# @param [AST::Node, #to_s] sexp - The expression to format
|
16
16
|
#
|
17
|
-
#
|
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
|
data/lib/reek/cli/application.rb
CHANGED
data/lib/reek/cli/command.rb
CHANGED
data/lib/reek/cli/input.rb
CHANGED
@@ -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
|
-
[
|
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
|
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
|
data/lib/reek/cli/options.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require_relative 'command'
|
2
|
-
require_relative '../
|
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
|
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
|
data/lib/reek/cli/silencer.rb
CHANGED