reek 3.2.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Rakefile +0 -1
- data/config/defaults.reek +1 -1
- data/features/samples.feature +17 -16
- data/lib/reek.rb +0 -1
- data/lib/reek/ast/ast_node_class_map.rb +5 -1
- data/lib/reek/ast/node.rb +10 -3
- data/lib/reek/ast/object_refs.rb +11 -5
- data/lib/reek/ast/reference_collector.rb +6 -2
- data/lib/reek/ast/sexp_extensions.rb +42 -1
- data/lib/reek/ast/sexp_formatter.rb +2 -1
- data/lib/reek/cli/application.rb +12 -9
- data/lib/reek/cli/command.rb +6 -0
- data/lib/reek/cli/input.rb +4 -4
- data/lib/reek/cli/option_interpreter.rb +11 -7
- data/lib/reek/cli/options.rb +42 -40
- data/lib/reek/cli/reek_command.rb +3 -3
- data/lib/reek/cli/silencer.rb +12 -3
- data/lib/reek/cli/warning_collector.rb +8 -3
- data/lib/reek/code_comment.rb +6 -1
- data/lib/reek/configuration/app_configuration.rb +65 -100
- data/lib/reek/configuration/configuration_file_finder.rb +4 -13
- data/lib/reek/configuration/configuration_validator.rb +35 -0
- data/lib/reek/configuration/default_directive.rb +12 -0
- data/lib/reek/configuration/directory_directives.rb +54 -0
- data/lib/reek/configuration/excluded_paths.rb +18 -0
- data/lib/reek/context/code_context.rb +19 -17
- data/lib/reek/examiner.rb +9 -7
- data/lib/reek/rake/task.rb +12 -22
- data/lib/reek/report/formatter.rb +6 -1
- data/lib/reek/report/report.rb +22 -13
- data/lib/reek/smells/attribute.rb +6 -53
- data/lib/reek/smells/control_parameter.rb +21 -13
- data/lib/reek/smells/data_clump.rb +17 -9
- data/lib/reek/smells/duplicate_method_call.rb +12 -6
- data/lib/reek/smells/long_parameter_list.rb +2 -2
- data/lib/reek/smells/long_yield_list.rb +4 -4
- data/lib/reek/smells/nested_iterators.rb +4 -2
- data/lib/reek/smells/nil_check.rb +6 -2
- data/lib/reek/smells/repeated_conditional.rb +3 -3
- data/lib/reek/smells/smell_configuration.rb +17 -7
- data/lib/reek/smells/smell_detector.rb +24 -11
- data/lib/reek/smells/smell_repository.rb +1 -1
- data/lib/reek/smells/smell_warning.rb +6 -6
- data/lib/reek/smells/too_many_instance_variables.rb +2 -2
- data/lib/reek/smells/too_many_methods.rb +4 -4
- data/lib/reek/smells/too_many_statements.rb +4 -4
- data/lib/reek/smells/uncommunicative_method_name.rb +5 -5
- data/lib/reek/smells/uncommunicative_module_name.rb +6 -6
- data/lib/reek/smells/uncommunicative_parameter_name.rb +8 -4
- data/lib/reek/smells/uncommunicative_variable_name.rb +9 -5
- data/lib/reek/smells/utility_function.rb +1 -1
- data/lib/reek/source/source_code.rb +5 -1
- data/lib/reek/source/source_locator.rb +3 -2
- data/lib/reek/spec.rb +3 -3
- data/lib/reek/spec/should_reek.rb +10 -5
- data/lib/reek/spec/should_reek_of.rb +9 -6
- data/lib/reek/spec/should_reek_only_of.rb +13 -8
- data/lib/reek/tree_dresser.rb +6 -2
- data/lib/reek/tree_walker.rb +40 -32
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +1 -1
- data/spec/reek/ast/node_spec.rb +1 -2
- data/spec/reek/ast/object_refs_spec.rb +40 -42
- data/spec/reek/ast/sexp_extensions_spec.rb +98 -104
- data/spec/reek/cli/warning_collector_spec.rb +8 -12
- data/spec/reek/code_comment_spec.rb +3 -5
- data/spec/reek/configuration/app_configuration_spec.rb +43 -57
- data/spec/reek/configuration/configuration_file_finder_spec.rb +5 -7
- data/spec/reek/configuration/default_directive_spec.rb +13 -0
- data/spec/reek/configuration/directory_directives_spec.rb +89 -0
- data/spec/reek/configuration/excluded_paths_spec.rb +30 -0
- data/spec/reek/context/code_context_spec.rb +63 -62
- data/spec/reek/context/method_context_spec.rb +8 -12
- data/spec/reek/context/module_context_spec.rb +1 -1
- data/spec/reek/context/root_context_spec.rb +3 -7
- data/spec/reek/examiner_spec.rb +14 -25
- data/spec/reek/smells/attribute_spec.rb +2 -4
- data/spec/reek/smells/boolean_parameter_spec.rb +5 -7
- data/spec/reek/smells/class_variable_spec.rb +29 -44
- data/spec/reek/smells/control_parameter_spec.rb +7 -9
- data/spec/reek/smells/data_clump_spec.rb +25 -32
- data/spec/reek/smells/duplicate_method_call_spec.rb +8 -7
- data/spec/reek/smells/feature_envy_spec.rb +16 -17
- data/spec/reek/smells/irresponsible_module_spec.rb +2 -4
- data/spec/reek/smells/long_parameter_list_spec.rb +6 -9
- data/spec/reek/smells/long_yield_list_spec.rb +6 -9
- data/spec/reek/smells/nested_iterators_spec.rb +14 -16
- data/spec/reek/smells/repeated_conditional_spec.rb +25 -25
- data/spec/reek/smells/smell_configuration_spec.rb +32 -27
- data/spec/reek/smells/smell_detector_shared.rb +12 -13
- data/spec/reek/smells/smell_warning_spec.rb +54 -58
- data/spec/reek/smells/too_many_instance_variables_spec.rb +9 -9
- data/spec/reek/smells/too_many_methods_spec.rb +13 -14
- data/spec/reek/smells/too_many_statements_spec.rb +8 -10
- data/spec/reek/smells/uncommunicative_method_name_spec.rb +8 -9
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +12 -13
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +7 -10
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +16 -20
- data/spec/reek/smells/utility_function_spec.rb +11 -15
- data/spec/reek/source/source_code_spec.rb +6 -11
- data/spec/reek/spec/should_reek_of_spec.rb +19 -30
- data/spec/reek/spec/should_reek_only_of_spec.rb +28 -34
- data/spec/reek/tree_walker_spec.rb +14 -2
- data/spec/spec_helper.rb +2 -3
- data/tasks/test.rake +0 -5
- metadata +10 -6
- data/docs/Configuration-Files.md +0 -49
- data/spec/gem/updates_spec.rb +0 -25
- data/spec/gem/yard_spec.rb +0 -11
- data/spec/reek/smells/behaves_like_variable_detector.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e18d9d5bd7b07494f2c0d1cf7f5bf271d87a918d
|
4
|
+
data.tar.gz: efebbdb49a7872897956b6c1ddf59aadee6dc158
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b8306b98fe28fa272395083b7c77a58572501780a2147a582320e433942ec18fa7b81b602a4043aa0cd421f691f2dc177c6a5e9a990ce78282130ee91fa5b99
|
7
|
+
data.tar.gz: f8d76ee8f1f8510b5357f0fa0e2031065d8759837ce05d0351f3bf622b7e286e8af30148482f07a9f2a1c4b35002fe78cb3f19326aae8a784c1605b55d449a21
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
data/config/defaults.reek
CHANGED
data/features/samples.feature
CHANGED
@@ -11,7 +11,7 @@ Feature: Basic smell detection
|
|
11
11
|
Then the exit status indicates smells
|
12
12
|
And it reports:
|
13
13
|
"""
|
14
|
-
inline.rb --
|
14
|
+
inline.rb -- 46 warnings:
|
15
15
|
CompilationError has no descriptive comment (IrresponsibleModule)
|
16
16
|
Dir has no descriptive comment (IrresponsibleModule)
|
17
17
|
File has no descriptive comment (IrresponsibleModule)
|
@@ -23,6 +23,7 @@ Feature: Basic smell detection
|
|
23
23
|
Inline#self.rootdir performs a nil-check (NilCheck)
|
24
24
|
Inline::C declares the class variable @@type_map (ClassVariable)
|
25
25
|
Inline::C has at least 13 instance variables (TooManyInstanceVariables)
|
26
|
+
Inline::C has at least 25 methods (TooManyMethods)
|
26
27
|
Inline::C takes parameters [options, src] to 5 methods (DataClump)
|
27
28
|
Inline::C tests $DEBUG at least 7 times (RepeatedConditional)
|
28
29
|
Inline::C tests $TESTING at least 4 times (RepeatedConditional)
|
@@ -58,13 +59,6 @@ Feature: Basic smell detection
|
|
58
59
|
Module#inline calls options[:testing] 2 times (DuplicateMethodCall)
|
59
60
|
Module#inline has approx 12 statements (TooManyStatements)
|
60
61
|
optparse.rb -- 121 warnings:
|
61
|
-
OptionParser declares the writable attribute banner (Attribute)
|
62
|
-
OptionParser declares the writable attribute default_argv (Attribute)
|
63
|
-
OptionParser declares the writable attribute program_name (Attribute)
|
64
|
-
OptionParser declares the writable attribute release (Attribute)
|
65
|
-
OptionParser declares the writable attribute summary_indent (Attribute)
|
66
|
-
OptionParser declares the writable attribute summary_width (Attribute)
|
67
|
-
OptionParser declares the writable attribute version (Attribute)
|
68
62
|
OptionParser has at least 42 methods (TooManyMethods)
|
69
63
|
OptionParser has at least 6 instance variables (TooManyInstanceVariables)
|
70
64
|
OptionParser has the variable name 'f' (UncommunicativeVariableName)
|
@@ -77,10 +71,12 @@ Feature: Basic smell detection
|
|
77
71
|
OptionParser tests default_pattern at least 7 times (RepeatedConditional)
|
78
72
|
OptionParser tests not_style at least 3 times (RepeatedConditional)
|
79
73
|
OptionParser tests s at least 7 times (RepeatedConditional)
|
74
|
+
OptionParser#banner is a writable attribute (Attribute)
|
80
75
|
OptionParser#complete contains iterators nested 2 deep (NestedIterators)
|
81
76
|
OptionParser#complete has 4 parameters (LongParameterList)
|
82
77
|
OptionParser#complete has approx 6 statements (TooManyStatements)
|
83
78
|
OptionParser#complete has boolean parameter 'icase' (BooleanParameter)
|
79
|
+
OptionParser#default_argv is a writable attribute (Attribute)
|
84
80
|
OptionParser#getopts calls result[opt] = false 2 times (DuplicateMethodCall)
|
85
81
|
OptionParser#getopts has approx 18 statements (TooManyStatements)
|
86
82
|
OptionParser#load has approx 6 statements (TooManyStatements)
|
@@ -122,12 +118,17 @@ Feature: Basic smell detection
|
|
122
118
|
OptionParser#permute calls argv[0] 2 times (DuplicateMethodCall)
|
123
119
|
OptionParser#permute refers to argv more than self (FeatureEnvy)
|
124
120
|
OptionParser#permute! has approx 6 statements (TooManyStatements)
|
121
|
+
OptionParser#program_name is a writable attribute (Attribute)
|
122
|
+
OptionParser#release is a writable attribute (Attribute)
|
125
123
|
OptionParser#search has the variable name 'k' (UncommunicativeVariableName)
|
126
124
|
OptionParser#self.inc performs a nil-check (NilCheck)
|
127
125
|
OptionParser#summarize has 4 parameters (LongParameterList)
|
128
126
|
OptionParser#summarize has the variable name 'l' (UncommunicativeVariableName)
|
129
127
|
OptionParser#summarize is controlled by argument blk (ControlParameter)
|
128
|
+
OptionParser#summary_indent is a writable attribute (Attribute)
|
129
|
+
OptionParser#summary_width is a writable attribute (Attribute)
|
130
130
|
OptionParser#ver has the variable name 'v' (UncommunicativeVariableName)
|
131
|
+
OptionParser#version is a writable attribute (Attribute)
|
131
132
|
OptionParser::Arguable has initialize method (ModuleInitialize)
|
132
133
|
OptionParser::Arguable#options has approx 6 statements (TooManyStatements)
|
133
134
|
OptionParser::Arguable#options= is controlled by argument opt (ControlParameter)
|
@@ -150,7 +151,7 @@ Feature: Basic smell detection
|
|
150
151
|
OptionParser::List#update has 5 parameters (LongParameterList)
|
151
152
|
OptionParser::List#update has approx 10 statements (TooManyStatements)
|
152
153
|
OptionParser::List#update has the variable name 'o' (UncommunicativeVariableName)
|
153
|
-
OptionParser::ParseError
|
154
|
+
OptionParser::ParseError#reason is a writable attribute (Attribute)
|
154
155
|
OptionParser::ParseError#set_option is controlled by argument eq (ControlParameter)
|
155
156
|
OptionParser::Switch has at least 7 instance variables (TooManyInstanceVariables)
|
156
157
|
OptionParser::Switch#add_banner has the variable name 's' (UncommunicativeVariableName)
|
@@ -180,12 +181,6 @@ Feature: Basic smell detection
|
|
180
181
|
OptionParser::Switch::OptionalArgument#parse has unused parameter 'argv' (UnusedParameters)
|
181
182
|
OptionParser::Switch::PlacedArgument#parse has approx 6 statements (TooManyStatements)
|
182
183
|
redcloth.rb -- 101 warnings:
|
183
|
-
RedCloth declares the writable attribute filter_html (Attribute)
|
184
|
-
RedCloth declares the writable attribute filter_styles (Attribute)
|
185
|
-
RedCloth declares the writable attribute hard_breaks (Attribute)
|
186
|
-
RedCloth declares the writable attribute lite_mode (Attribute)
|
187
|
-
RedCloth declares the writable attribute no_span_caps (Attribute)
|
188
|
-
RedCloth declares the writable attribute rules (Attribute)
|
189
184
|
RedCloth has at least 44 methods (TooManyMethods)
|
190
185
|
RedCloth has the variable name 'a' (UncommunicativeVariableName)
|
191
186
|
RedCloth has the variable name 'b' (UncommunicativeVariableName)
|
@@ -226,10 +221,13 @@ Feature: Basic smell detection
|
|
226
221
|
RedCloth#clean_html has the variable name 'q2' (UncommunicativeVariableName)
|
227
222
|
RedCloth#clean_white_space has approx 7 statements (TooManyStatements)
|
228
223
|
RedCloth#clean_white_space refers to text more than self (FeatureEnvy)
|
224
|
+
RedCloth#filter_html is a writable attribute (Attribute)
|
225
|
+
RedCloth#filter_styles is a writable attribute (Attribute)
|
229
226
|
RedCloth#flush_left doesn't depend on instance state (UtilityFunction)
|
230
227
|
RedCloth#footnote_ref doesn't depend on instance state (UtilityFunction)
|
231
228
|
RedCloth#glyphs_textile has approx 10 statements (TooManyStatements)
|
232
229
|
RedCloth#h_align doesn't depend on instance state (UtilityFunction)
|
230
|
+
RedCloth#hard_breaks is a writable attribute (Attribute)
|
233
231
|
RedCloth#htmlesc doesn't depend on instance state (UtilityFunction)
|
234
232
|
RedCloth#htmlesc is controlled by argument mode (ControlParameter)
|
235
233
|
RedCloth#incoming_entities doesn't depend on instance state (UtilityFunction)
|
@@ -252,6 +250,8 @@ Feature: Basic smell detection
|
|
252
250
|
RedCloth#lT doesn't depend on instance state (UtilityFunction)
|
253
251
|
RedCloth#lT has the name 'lT' (UncommunicativeMethodName)
|
254
252
|
RedCloth#lT is controlled by argument text (ControlParameter)
|
253
|
+
RedCloth#lite_mode is a writable attribute (Attribute)
|
254
|
+
RedCloth#no_span_caps is a writable attribute (Attribute)
|
255
255
|
RedCloth#no_textile doesn't depend on instance state (UtilityFunction)
|
256
256
|
RedCloth#pba calls $1.length 2 times (DuplicateMethodCall)
|
257
257
|
RedCloth#pba has approx 21 statements (TooManyStatements)
|
@@ -270,6 +270,7 @@ Feature: Basic smell detection
|
|
270
270
|
RedCloth#rip_offtags calls used_offtags.length 2 times (DuplicateMethodCall)
|
271
271
|
RedCloth#rip_offtags calls used_offtags["notextile"] 3 times (DuplicateMethodCall)
|
272
272
|
RedCloth#rip_offtags has approx 18 statements (TooManyStatements)
|
273
|
+
RedCloth#rules is a writable attribute (Attribute)
|
273
274
|
RedCloth#textile_bq has 4 parameters (LongParameterList)
|
274
275
|
RedCloth#textile_bq has unused parameter 'tag' (UnusedParameters)
|
275
276
|
RedCloth#textile_fn_ has 5 parameters (LongParameterList)
|
@@ -281,5 +282,5 @@ Feature: Basic smell detection
|
|
281
282
|
RedCloth#textile_popup_help has the parameter name 'windowW' (UncommunicativeParameterName)
|
282
283
|
RedCloth#to_html has approx 26 statements (TooManyStatements)
|
283
284
|
RedCloth#v_align doesn't depend on instance state (UtilityFunction)
|
284
|
-
|
285
|
+
268 total warnings
|
285
286
|
"""
|
data/lib/reek.rb
CHANGED
@@ -13,7 +13,7 @@ module Reek
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def klass_for(type)
|
16
|
-
|
16
|
+
klass_map[type] ||= Class.new(Node).tap do |klass|
|
17
17
|
extension = extension_map[type]
|
18
18
|
klass.send :include, extension if extension
|
19
19
|
end
|
@@ -31,6 +31,10 @@ module Reek
|
|
31
31
|
Hash[assoc]
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
private_attr_reader :klass_map
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|
data/lib/reek/ast/node.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'private_attr/everywhere'
|
2
|
+
require_relative '../cli/silencer'
|
3
|
+
|
4
|
+
Reek::CLI::Silencer.silently stderr: true, stdout: true do
|
5
|
+
require 'parser'
|
6
|
+
end
|
2
7
|
|
3
8
|
module Reek
|
4
9
|
# @api private
|
@@ -17,12 +22,12 @@ module Reek
|
|
17
22
|
end
|
18
23
|
|
19
24
|
def full_comment
|
20
|
-
|
25
|
+
comments.map(&:text).join("\n")
|
21
26
|
end
|
22
27
|
|
23
28
|
def leading_comment
|
24
29
|
line = location.line
|
25
|
-
comment_lines =
|
30
|
+
comment_lines = comments.select do |comment|
|
26
31
|
comment.location.line < line
|
27
32
|
end
|
28
33
|
comment_lines.map(&:text).join("\n")
|
@@ -120,6 +125,8 @@ module Reek
|
|
120
125
|
|
121
126
|
private
|
122
127
|
|
128
|
+
private_attr_reader :comments
|
129
|
+
|
123
130
|
def each_sexp
|
124
131
|
children.each { |elem| yield elem if elem.is_a? ::Parser::AST::Node }
|
125
132
|
end
|
data/lib/reek/ast/object_refs.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'private_attr/everywhere'
|
2
|
+
|
1
3
|
module Reek
|
2
4
|
# @api private
|
3
5
|
module AST
|
@@ -11,21 +13,25 @@ module Reek
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def most_popular
|
14
|
-
max =
|
15
|
-
|
16
|
+
max = refs.values.map(&:size).max
|
17
|
+
refs.select { |_name, refs| refs.size == max }
|
16
18
|
end
|
17
19
|
|
18
20
|
def record_reference_to(name, line: nil)
|
19
|
-
|
21
|
+
refs[name] << ObjectRef.new(name, line)
|
20
22
|
end
|
21
23
|
|
22
24
|
def references_to(name)
|
23
|
-
|
25
|
+
refs[name]
|
24
26
|
end
|
25
27
|
|
26
28
|
def self_is_max?
|
27
|
-
|
29
|
+
refs.empty? || most_popular.keys.include?(:self)
|
28
30
|
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
private_attr_reader :refs
|
29
35
|
end
|
30
36
|
end
|
31
37
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'private_attr/everywhere'
|
2
|
+
|
1
3
|
module Reek
|
2
4
|
module AST
|
3
5
|
#
|
@@ -18,14 +20,16 @@ module Reek
|
|
18
20
|
|
19
21
|
private
|
20
22
|
|
23
|
+
private_attr_reader :ast
|
24
|
+
|
21
25
|
def explicit_self_calls
|
22
26
|
[:self, :zsuper, :ivar, :ivasgn].flat_map do |node_type|
|
23
|
-
|
27
|
+
ast.each_node(node_type, STOP_NODES)
|
24
28
|
end
|
25
29
|
end
|
26
30
|
|
27
31
|
def implicit_self_calls
|
28
|
-
|
32
|
+
ast.each_node(:send, STOP_NODES).reject(&:receiver)
|
29
33
|
end
|
30
34
|
end
|
31
35
|
end
|
@@ -184,6 +184,24 @@ module Reek
|
|
184
184
|
def object_creation_call?
|
185
185
|
method_name == :new
|
186
186
|
end
|
187
|
+
|
188
|
+
def visibility_modifier?
|
189
|
+
VISIBILITY_MODIFIERS.include?(method_name)
|
190
|
+
end
|
191
|
+
|
192
|
+
def attribute_writer?
|
193
|
+
ATTR_DEFN_METHODS.include?(method_name) ||
|
194
|
+
attr_with_writable_flag?
|
195
|
+
end
|
196
|
+
|
197
|
+
# Handles the case where we create an attribute writer via:
|
198
|
+
# attr :foo, true
|
199
|
+
def attr_with_writable_flag?
|
200
|
+
method_name == :attr && args.last.type == :true
|
201
|
+
end
|
202
|
+
|
203
|
+
VISIBILITY_MODIFIERS = [:private, :public, :protected, :module_function]
|
204
|
+
ATTR_DEFN_METHODS = [:attr_writer, :attr_accessor]
|
187
205
|
end
|
188
206
|
|
189
207
|
Op_AsgnNode = SendNode
|
@@ -405,6 +423,7 @@ module Reek
|
|
405
423
|
MODULE_DEFINERS = [:Class, :Struct]
|
406
424
|
|
407
425
|
def defines_module?
|
426
|
+
return false if value.nil?
|
408
427
|
call = case value.type
|
409
428
|
when :block
|
410
429
|
value.call
|
@@ -420,8 +439,18 @@ module Reek
|
|
420
439
|
SexpFormatter.format(children[1])
|
421
440
|
end
|
422
441
|
|
442
|
+
# there are two valid forms of the casgn sexp
|
443
|
+
# (casgn <namespace> <name> <value>) and
|
444
|
+
# (casgn <namespace> <name>) used in or-asgn and mlhs
|
445
|
+
#
|
446
|
+
# source = "class Hi; THIS ||= 3; end"
|
447
|
+
# (class
|
448
|
+
# (const nil :Hi) nil
|
449
|
+
# (or-asgn
|
450
|
+
# (casgn nil :THIS)
|
451
|
+
# (int 3)))
|
423
452
|
def value
|
424
|
-
children
|
453
|
+
children[2]
|
425
454
|
end
|
426
455
|
end
|
427
456
|
|
@@ -442,6 +471,18 @@ module Reek
|
|
442
471
|
end
|
443
472
|
|
444
473
|
ZsuperNode = SuperNode
|
474
|
+
|
475
|
+
# Utility methods for :sym nodes.
|
476
|
+
module SymNode
|
477
|
+
def name
|
478
|
+
children.first
|
479
|
+
end
|
480
|
+
|
481
|
+
def full_name(outer)
|
482
|
+
prefix = outer == '' ? '' : "#{outer}#"
|
483
|
+
"#{prefix}#{name}"
|
484
|
+
end
|
485
|
+
end
|
445
486
|
end
|
446
487
|
end
|
447
488
|
end
|
data/lib/reek/cli/application.rb
CHANGED
@@ -20,9 +20,9 @@ module Reek
|
|
20
20
|
@status = STATUS_SUCCESS
|
21
21
|
options_parser = Options.new(argv)
|
22
22
|
begin
|
23
|
-
|
24
|
-
@command = ReekCommand.new(OptionInterpreter.new(
|
25
|
-
@configuration = Configuration::AppConfiguration.
|
23
|
+
options = options_parser.parse
|
24
|
+
@command = ReekCommand.new(OptionInterpreter.new(options))
|
25
|
+
@configuration = Configuration::AppConfiguration.from_path(options.config_file)
|
26
26
|
rescue OptionParser::InvalidOption, Reek::Configuration::ConfigFileException => error
|
27
27
|
$stderr.puts "Error: #{error}"
|
28
28
|
@status = STATUS_ERROR
|
@@ -30,9 +30,9 @@ module Reek
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def execute
|
33
|
-
return
|
34
|
-
|
35
|
-
|
33
|
+
return status if error_occured?
|
34
|
+
command.execute self
|
35
|
+
status
|
36
36
|
end
|
37
37
|
|
38
38
|
def output(text)
|
@@ -40,17 +40,20 @@ module Reek
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def report_success
|
43
|
-
|
43
|
+
self.status = STATUS_SUCCESS
|
44
44
|
end
|
45
45
|
|
46
46
|
def report_smells
|
47
|
-
|
47
|
+
self.status = STATUS_SMELLS
|
48
48
|
end
|
49
49
|
|
50
50
|
private
|
51
51
|
|
52
|
+
private_attr_accessor :status
|
53
|
+
private_attr_reader :command
|
54
|
+
|
52
55
|
def error_occured?
|
53
|
-
|
56
|
+
status == STATUS_ERROR
|
54
57
|
end
|
55
58
|
end
|
56
59
|
end
|
data/lib/reek/cli/command.rb
CHANGED
data/lib/reek/cli/input.rb
CHANGED
@@ -26,9 +26,9 @@ module Reek
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def no_source_files_given?
|
29
|
-
# At this point we have deleted all options from
|
30
|
-
# are paths to the source files. If
|
31
|
-
|
29
|
+
# At this point we have deleted all options from argv. The only remaining entries
|
30
|
+
# are paths to the source files. If argv is empty, this means that no files were given.
|
31
|
+
argv.empty?
|
32
32
|
end
|
33
33
|
|
34
34
|
def working_directory_as_source
|
@@ -36,7 +36,7 @@ module Reek
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def sources_from_argv
|
39
|
-
Source::SourceLocator.new(
|
39
|
+
Source::SourceLocator.new(argv).sources
|
40
40
|
end
|
41
41
|
|
42
42
|
def source_from_pipe
|