reek 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +6 -0
- data/README.md +15 -9
- data/bin/reek +1 -1
- data/config/defaults.reek +71 -86
- data/features/command_line_interface/options.feature +0 -15
- data/features/reports/reports.feature +23 -0
- data/features/samples.feature +3 -12
- data/lib/reek.rb +3 -3
- data/lib/reek/cli/application.rb +1 -1
- data/lib/reek/cli/command_line.rb +10 -8
- data/lib/reek/cli/reek_command.rb +6 -7
- data/lib/reek/cli/report.rb +34 -38
- data/lib/reek/cli/version_command.rb +1 -1
- data/lib/reek/cli/yaml_command.rb +1 -1
- data/lib/reek/core/code_parser.rb +4 -4
- data/lib/reek/core/hash_extensions.rb +2 -2
- data/lib/reek/core/method_context.rb +2 -2
- data/lib/reek/core/module_context.rb +4 -4
- data/lib/reek/core/singleton_method_context.rb +1 -1
- data/lib/reek/core/smell_repository.rb +7 -6
- data/lib/reek/core/sniffer.rb +4 -4
- data/lib/reek/examiner.rb +10 -3
- data/lib/reek/smell_warning.rb +0 -2
- data/lib/reek/smells.rb +22 -21
- data/lib/reek/smells/attribute.rb +4 -8
- data/lib/reek/smells/boolean_parameter.rb +2 -2
- data/lib/reek/smells/class_variable.rb +3 -2
- data/lib/reek/smells/{control_couple.rb → control_parameter.rb} +5 -5
- data/lib/reek/smells/data_clump.rb +13 -29
- data/lib/reek/smells/{duplication.rb → duplicate_method_call.rb} +9 -11
- data/lib/reek/smells/feature_envy.rb +2 -2
- data/lib/reek/smells/irresponsible_module.rb +3 -2
- data/lib/reek/smells/long_parameter_list.rb +6 -10
- data/lib/reek/smells/long_yield_list.rb +4 -8
- data/lib/reek/smells/nested_iterators.rb +31 -25
- data/lib/reek/smells/nil_check.rb +11 -12
- data/lib/reek/smells/{simulated_polymorphism.rb → repeated_conditional.rb} +6 -10
- data/lib/reek/smells/smell_detector.rb +3 -6
- data/lib/reek/smells/too_many_instance_variables.rb +60 -0
- data/lib/reek/smells/too_many_methods.rb +62 -0
- data/lib/reek/smells/{long_method.rb → too_many_statements.rb} +7 -12
- data/lib/reek/smells/uncommunicative_method_name.rb +3 -7
- data/lib/reek/smells/uncommunicative_module_name.rb +3 -7
- data/lib/reek/smells/uncommunicative_parameter_name.rb +4 -8
- data/lib/reek/smells/uncommunicative_variable_name.rb +5 -9
- data/lib/reek/smells/unused_parameters.rb +62 -13
- data/lib/reek/smells/utility_function.rb +3 -7
- data/lib/reek/source.rb +8 -8
- data/lib/reek/source/core_extras.rb +1 -1
- data/lib/reek/source/source_code.rb +2 -2
- data/lib/reek/source/source_file.rb +2 -2
- data/lib/reek/source/source_locator.rb +1 -1
- data/lib/reek/source/source_repository.rb +4 -2
- data/lib/reek/spec.rb +9 -3
- data/lib/reek/spec/should_reek.rb +2 -2
- data/lib/reek/spec/should_reek_of.rb +1 -1
- data/lib/reek/spec/should_reek_only_of.rb +2 -2
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +3 -1
- data/spec/gem/updates_spec.rb +1 -1
- data/spec/gem/yard_spec.rb +1 -1
- data/spec/matchers/smell_of_matcher.rb +53 -19
- data/spec/reek/cli/help_command_spec.rb +2 -2
- data/spec/reek/cli/reek_command_spec.rb +6 -6
- data/spec/reek/cli/report_spec.rb +6 -6
- data/spec/reek/cli/version_command_spec.rb +2 -2
- data/spec/reek/cli/yaml_command_spec.rb +2 -2
- data/spec/reek/core/code_context_spec.rb +4 -4
- data/spec/reek/core/code_parser_spec.rb +2 -2
- data/spec/reek/core/config_spec.rb +4 -4
- data/spec/reek/core/method_context_spec.rb +3 -3
- data/spec/reek/core/module_context_spec.rb +3 -3
- data/spec/reek/core/object_refs_spec.rb +3 -3
- data/spec/reek/core/singleton_method_context_spec.rb +4 -4
- data/spec/reek/core/smell_configuration_spec.rb +2 -2
- data/spec/reek/core/stop_context_spec.rb +2 -2
- data/spec/reek/core/warning_collector_spec.rb +3 -3
- data/spec/reek/examiner_spec.rb +13 -4
- data/spec/reek/smell_warning_spec.rb +2 -2
- data/spec/reek/smells/attribute_spec.rb +4 -4
- data/spec/reek/smells/boolean_parameter_spec.rb +3 -3
- data/spec/reek/smells/class_variable_spec.rb +4 -4
- data/spec/reek/smells/{control_couple_spec.rb → control_parameter_spec.rb} +10 -10
- data/spec/reek/smells/data_clump_spec.rb +3 -3
- data/spec/reek/smells/{duplication_spec.rb → duplicate_method_call_spec.rb} +42 -26
- data/spec/reek/smells/feature_envy_spec.rb +3 -3
- data/spec/reek/smells/irresponsible_module_spec.rb +3 -3
- data/spec/reek/smells/long_parameter_list_spec.rb +3 -3
- data/spec/reek/smells/long_yield_list_spec.rb +3 -3
- data/spec/reek/smells/nested_iterators_spec.rb +42 -4
- data/spec/reek/smells/nil_check_spec.rb +23 -11
- data/spec/reek/smells/{simulated_polymorphism_spec.rb → repeated_conditional_spec.rb} +6 -6
- data/spec/reek/smells/smell_detector_shared.rb +2 -2
- data/spec/reek/smells/too_many_instance_variables_spec.rb +62 -0
- data/spec/reek/smells/{large_class_spec.rb → too_many_methods_spec.rb} +11 -56
- data/spec/reek/smells/{long_method_spec.rb → too_many_statements_spec.rb} +17 -17
- data/spec/reek/smells/uncommunicative_method_name_spec.rb +5 -5
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +5 -5
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +4 -4
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +5 -5
- data/spec/reek/smells/unused_parameters_spec.rb +19 -4
- data/spec/reek/smells/utility_function_spec.rb +3 -3
- data/spec/reek/source/code_comment_spec.rb +2 -2
- data/spec/reek/source/object_source_spec.rb +1 -1
- data/spec/reek/source/reference_collector_spec.rb +2 -2
- data/spec/reek/source/sexp_formatter_spec.rb +2 -2
- data/spec/reek/source/source_code_spec.rb +2 -2
- data/spec/reek/source/tree_dresser_spec.rb +2 -2
- data/spec/reek/spec/should_reek_of_spec.rb +2 -2
- data/spec/reek/spec/should_reek_only_of_spec.rb +2 -2
- data/spec/reek/spec/should_reek_spec.rb +2 -2
- data/spec/samples/all_but_one_masked/masked.reek +1 -1
- data/spec/samples/clean_due_to_masking/masked.reek +1 -1
- data/spec/samples/config/allow_duplication.reek +2 -2
- data/spec/samples/inline_config/dirty.rb +2 -2
- data/spec/samples/mask_some/some.reek +1 -1
- data/spec/samples/masked_by_dotfile/dirty.rb +8 -0
- data/spec/samples/not_quite_masked/smelly.rb +3 -0
- data/spec/samples/overrides/masked/lower.reek +1 -1
- data/spec/samples/overrides/upper.reek +1 -1
- data/spec/spec_helper.rb +4 -9
- data/tasks/test.rake +0 -2
- metadata +253 -263
- data/lib/reek/smells/large_class.rb +0 -87
- data/lib/xp.reek +0 -66
- data/spec/gem/manifest_spec.rb +0 -22
- data/spec/spec.opts +0 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'reek/examiner'
|
2
2
|
|
3
3
|
module Reek
|
4
4
|
module Cli
|
@@ -8,13 +8,13 @@ module Reek
|
|
8
8
|
# text report format.
|
9
9
|
#
|
10
10
|
class ReekCommand
|
11
|
-
def self.create(sources,
|
12
|
-
new(
|
11
|
+
def self.create(sources, reporter, config_files = [])
|
12
|
+
new(reporter, sources, config_files)
|
13
13
|
end
|
14
14
|
|
15
|
-
def initialize(
|
15
|
+
def initialize(reporter, sources, config_files = [])
|
16
16
|
@sources = sources
|
17
|
-
@
|
17
|
+
@reporter = reporter
|
18
18
|
@config_files = config_files
|
19
19
|
end
|
20
20
|
|
@@ -22,9 +22,8 @@ module Reek
|
|
22
22
|
had_smells = false
|
23
23
|
@sources.each do |source|
|
24
24
|
examiner = Examiner.new(source, @config_files)
|
25
|
-
rpt = @report_class.new(examiner)
|
26
25
|
had_smells ||= examiner.smelly?
|
27
|
-
view.output
|
26
|
+
view.output @reporter.report(examiner)
|
28
27
|
end
|
29
28
|
if had_smells
|
30
29
|
view.report_smells
|
data/lib/reek/cli/report.rb
CHANGED
@@ -1,38 +1,47 @@
|
|
1
1
|
module Reek
|
2
2
|
module Cli
|
3
|
-
|
4
3
|
module ReportFormatter
|
5
|
-
def
|
6
|
-
|
4
|
+
def self.format_list(warnings, formatter = SimpleWarningFormatter)
|
5
|
+
warnings.map do |warning|
|
6
|
+
" #{formatter.format warning}"
|
7
|
+
end.join("\n")
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.header(examiner)
|
11
|
+
count = examiner.smells_count
|
12
|
+
result = "#{examiner.description} -- #{count} warning"
|
7
13
|
result += 's' unless count == 1
|
8
14
|
result
|
9
15
|
end
|
16
|
+
end
|
10
17
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end.join("\n")
|
18
|
+
module SimpleWarningFormatter
|
19
|
+
def self.format(warning)
|
20
|
+
"#{warning.context} #{warning.message} (#{warning.subclass})"
|
15
21
|
end
|
22
|
+
end
|
16
23
|
|
17
|
-
|
24
|
+
module WarningFormatterWithLineNumbers
|
25
|
+
def self.format(warning)
|
26
|
+
"#{warning.lines.inspect}:#{SimpleWarningFormatter.format(warning)}"
|
27
|
+
end
|
18
28
|
end
|
19
29
|
|
20
30
|
#
|
21
31
|
# A report that lists every source, including those that have no smells.
|
22
32
|
#
|
23
33
|
class VerboseReport
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
def initialize(examiner)
|
28
|
-
@examiner = examiner
|
34
|
+
def initialize(warning_formatter = SimpleWarningFormatter, report_formatter = ReportFormatter)
|
35
|
+
@warning_formatter = warning_formatter
|
36
|
+
@report_formatter = report_formatter
|
29
37
|
end
|
30
38
|
|
31
|
-
def report
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
39
|
+
def report(examiner)
|
40
|
+
result = @report_formatter.header examiner
|
41
|
+
if examiner.smelly?
|
42
|
+
formatted_list = @report_formatter.format_list examiner.smells, @warning_formatter
|
43
|
+
result += ":\n#{formatted_list}"
|
44
|
+
end
|
36
45
|
result + "\n"
|
37
46
|
end
|
38
47
|
end
|
@@ -40,26 +49,13 @@ module Reek
|
|
40
49
|
#
|
41
50
|
# A report that lists a section for each source that has smells.
|
42
51
|
#
|
43
|
-
class QuietReport
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
@desc = examiner.description
|
51
|
-
end
|
52
|
-
|
53
|
-
def report
|
54
|
-
@smell_count > 0 ? "#{header(@desc, @smell_count)}:\n#{format_list(@warnings)}\n" : ''
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
class ShowLineReport < VerboseReport
|
59
|
-
def format_list(warnings)
|
60
|
-
warnings.map do |warning|
|
61
|
-
" #{warning.lines.inspect}:#{warning.context} #{warning.message} (#{warning.subclass})"
|
62
|
-
end.join("\n")
|
52
|
+
class QuietReport < VerboseReport
|
53
|
+
def report(examiner)
|
54
|
+
if examiner.smelly?
|
55
|
+
super
|
56
|
+
else
|
57
|
+
''
|
58
|
+
end
|
63
59
|
end
|
64
60
|
end
|
65
61
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'sexp'
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
2
|
+
require 'reek/core/method_context'
|
3
|
+
require 'reek/core/module_context'
|
4
|
+
require 'reek/core/stop_context'
|
5
|
+
require 'reek/core/singleton_method_context'
|
6
6
|
|
7
7
|
module Reek
|
8
8
|
module Core
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'reek/core/code_context'
|
2
|
+
require 'reek/core/code_parser'
|
3
|
+
require 'reek/core/sniffer'
|
4
|
+
require 'reek/source/sexp_formatter'
|
5
5
|
|
6
6
|
module Reek
|
7
7
|
module Core
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'reek/smells'
|
2
2
|
|
3
3
|
module Reek
|
4
4
|
module Core
|
@@ -10,18 +10,19 @@ module Reek
|
|
10
10
|
Smells::Attribute,
|
11
11
|
Smells::BooleanParameter,
|
12
12
|
Smells::ClassVariable,
|
13
|
-
Smells::
|
13
|
+
Smells::ControlParameter,
|
14
14
|
Smells::DataClump,
|
15
|
-
Smells::
|
15
|
+
Smells::DuplicateMethodCall,
|
16
16
|
Smells::FeatureEnvy,
|
17
17
|
Smells::IrresponsibleModule,
|
18
|
-
Smells::LargeClass,
|
19
|
-
Smells::LongMethod,
|
20
18
|
Smells::LongParameterList,
|
21
19
|
Smells::LongYieldList,
|
22
20
|
Smells::NestedIterators,
|
23
21
|
Smells::NilCheck,
|
24
|
-
Smells::
|
22
|
+
Smells::RepeatedConditional,
|
23
|
+
Smells::TooManyInstanceVariables,
|
24
|
+
Smells::TooManyMethods,
|
25
|
+
Smells::TooManyStatements,
|
25
26
|
Smells::UncommunicativeMethodName,
|
26
27
|
Smells::UncommunicativeModuleName,
|
27
28
|
Smells::UncommunicativeParameterName,
|
data/lib/reek/core/sniffer.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'reek/core/code_parser'
|
2
|
+
require 'reek/core/smell_repository'
|
3
|
+
require 'reek/source/config_file'
|
4
4
|
require 'yaml'
|
5
|
-
require
|
5
|
+
require 'reek/core/hash_extensions'
|
6
6
|
|
7
7
|
module Reek
|
8
8
|
module Core
|
data/lib/reek/examiner.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'reek/core/sniffer'
|
2
|
+
require 'reek/core/warning_collector'
|
3
|
+
require 'reek/source/source_repository'
|
4
4
|
|
5
5
|
module Reek
|
6
6
|
|
@@ -44,6 +44,13 @@ module Reek
|
|
44
44
|
@smells
|
45
45
|
end
|
46
46
|
|
47
|
+
#
|
48
|
+
# Returns the number of smells found in the source
|
49
|
+
#
|
50
|
+
def smells_count
|
51
|
+
@smells.length
|
52
|
+
end
|
53
|
+
|
47
54
|
#
|
48
55
|
# True if and only if there are code smells in the source.
|
49
56
|
#
|
data/lib/reek/smell_warning.rb
CHANGED
data/lib/reek/smells.rb
CHANGED
@@ -1,24 +1,25 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
1
|
+
require 'reek/smells/attribute'
|
2
|
+
require 'reek/smells/boolean_parameter'
|
3
|
+
require 'reek/smells/class_variable'
|
4
|
+
require 'reek/smells/control_parameter'
|
5
|
+
require 'reek/smells/data_clump'
|
6
|
+
require 'reek/smells/duplicate_method_call'
|
7
|
+
require 'reek/smells/feature_envy'
|
8
|
+
require 'reek/smells/irresponsible_module'
|
9
|
+
require 'reek/smells/long_parameter_list'
|
10
|
+
require 'reek/smells/long_yield_list'
|
11
|
+
require 'reek/smells/nested_iterators'
|
12
|
+
require 'reek/smells/nil_check'
|
13
|
+
require 'reek/smells/repeated_conditional'
|
14
|
+
require 'reek/smells/too_many_instance_variables'
|
15
|
+
require 'reek/smells/too_many_methods'
|
16
|
+
require 'reek/smells/too_many_statements'
|
17
|
+
require 'reek/smells/uncommunicative_method_name'
|
18
|
+
require 'reek/smells/uncommunicative_module_name'
|
19
|
+
require 'reek/smells/uncommunicative_parameter_name'
|
20
|
+
require 'reek/smells/uncommunicative_variable_name'
|
21
|
+
require 'reek/smells/unused_parameters'
|
22
|
+
require 'reek/smells/utility_function'
|
22
23
|
# SMELL: Duplication -- all these should be found automagically
|
23
24
|
|
24
25
|
module Reek
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'reek/smells/smell_detector'
|
2
|
+
require 'reek/smell_warning'
|
3
|
+
require 'reek/core/smell_configuration'
|
4
4
|
|
5
5
|
module Reek
|
6
6
|
module Smells
|
@@ -33,10 +33,6 @@ module Reek
|
|
33
33
|
super.adopt(Core::SmellConfiguration::ENABLED_KEY => false)
|
34
34
|
end
|
35
35
|
|
36
|
-
def initialize(source, config = Attribute.default_config)
|
37
|
-
super(source, config)
|
38
|
-
end
|
39
|
-
|
40
36
|
#
|
41
37
|
# Checks whether the given class declares any attributes.
|
42
38
|
#
|
@@ -53,7 +49,7 @@ module Reek
|
|
53
49
|
end
|
54
50
|
|
55
51
|
private
|
56
|
-
|
52
|
+
|
57
53
|
def attributes_in(module_ctx)
|
58
54
|
result = Set.new
|
59
55
|
attr_defn_methods = [:attr, :attr_reader, :attr_writer, :attr_accessor]
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'reek/smells/smell_detector'
|
2
|
+
require 'reek/smell_warning'
|
3
3
|
|
4
4
|
module Reek
|
5
5
|
module Smells
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'set'
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require 'reek/smells/smell_detector'
|
3
|
+
require 'reek/smell_warning'
|
4
4
|
|
5
5
|
module Reek
|
6
6
|
module Smells
|
@@ -17,6 +17,7 @@ module Reek
|
|
17
17
|
|
18
18
|
SMELL_CLASS = self.name.split(/::/)[-1]
|
19
19
|
SMELL_SUBCLASS = SMELL_CLASS
|
20
|
+
|
20
21
|
VARIABLE_KEY = 'variable'
|
21
22
|
|
22
23
|
def self.contexts # :nodoc:
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'reek/smells/smell_detector'
|
2
|
+
require 'reek/smell_warning'
|
3
3
|
|
4
4
|
module Reek
|
5
5
|
module Smells
|
@@ -41,10 +41,10 @@ module Reek
|
|
41
41
|
# that remains next to where the caller invokes it in
|
42
42
|
# the source code.
|
43
43
|
#
|
44
|
-
class
|
44
|
+
class ControlParameter < SmellDetector
|
45
45
|
|
46
|
-
SMELL_CLASS =
|
47
|
-
SMELL_SUBCLASS =
|
46
|
+
SMELL_CLASS = 'ControlCouple'
|
47
|
+
SMELL_SUBCLASS = self.name.split(/::/)[-1]
|
48
48
|
PARAMETER_KEY = 'parameter'
|
49
49
|
|
50
50
|
#
|
@@ -1,15 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
|
5
|
-
#
|
6
|
-
# Extensions to +Array+ needed by Reek.
|
7
|
-
#
|
8
|
-
class Array
|
9
|
-
def intersection
|
10
|
-
self.inject { |res, elem| elem & res }
|
11
|
-
end
|
12
|
-
end
|
1
|
+
require 'reek/smells/smell_detector'
|
2
|
+
require 'reek/smell_warning'
|
3
|
+
require 'reek/source'
|
13
4
|
|
14
5
|
module Reek
|
15
6
|
module Smells
|
@@ -29,6 +20,7 @@ module Reek
|
|
29
20
|
class DataClump < SmellDetector
|
30
21
|
|
31
22
|
SMELL_CLASS = self.name.split(/::/)[-1]
|
23
|
+
SMELL_SUBCLASS = self.name.split(/::/)[-1]
|
32
24
|
|
33
25
|
METHODS_KEY = 'methods'
|
34
26
|
OCCURRENCES_KEY = 'occurrences'
|
@@ -58,15 +50,11 @@ module Reek
|
|
58
50
|
|
59
51
|
def self.default_config
|
60
52
|
super.adopt(
|
61
|
-
|
62
|
-
|
53
|
+
MAX_COPIES_KEY => DEFAULT_MAX_COPIES,
|
54
|
+
MIN_CLUMP_SIZE_KEY => DEFAULT_MIN_CLUMP_SIZE
|
63
55
|
)
|
64
56
|
end
|
65
57
|
|
66
|
-
def initialize(source, config = DataClump.default_config)
|
67
|
-
super(source, config)
|
68
|
-
end
|
69
|
-
|
70
58
|
#
|
71
59
|
# Checks the given class or module for multiple identical parameter sets.
|
72
60
|
#
|
@@ -76,14 +64,14 @@ module Reek
|
|
76
64
|
@max_copies = value(MAX_COPIES_KEY, ctx, DEFAULT_MAX_COPIES)
|
77
65
|
@min_clump_size = value(MIN_CLUMP_SIZE_KEY, ctx, DEFAULT_MIN_CLUMP_SIZE)
|
78
66
|
MethodGroup.new(ctx, @min_clump_size, @max_copies).clumps.map do |clump, methods|
|
79
|
-
SmellWarning.new(
|
67
|
+
SmellWarning.new(SMELL_CLASS, ctx.full_name,
|
80
68
|
methods.map {|meth| meth.line},
|
81
69
|
"takes parameters #{DataClump.print_clump(clump)} to #{methods.length} methods",
|
82
|
-
@source,
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
70
|
+
@source, SMELL_SUBCLASS, {
|
71
|
+
PARAMETERS_KEY => clump.map {|name| name.to_s},
|
72
|
+
OCCURRENCES_KEY => methods.length,
|
73
|
+
METHODS_KEY => methods.map {|meth| meth.name}
|
74
|
+
})
|
87
75
|
end
|
88
76
|
end
|
89
77
|
|
@@ -98,10 +86,6 @@ module Reek
|
|
98
86
|
# @private
|
99
87
|
class MethodGroup
|
100
88
|
|
101
|
-
def self.intersection_of_parameters_of(methods)
|
102
|
-
methods.map {|meth| meth.arg_names}.intersection
|
103
|
-
end
|
104
|
-
|
105
89
|
def initialize(ctx, min_clump_size, max_copies)
|
106
90
|
@min_clump_size = min_clump_size
|
107
91
|
@max_copies = max_copies
|
@@ -114,7 +98,7 @@ module Reek
|
|
114
98
|
|
115
99
|
def clumps_containing(method, methods, results)
|
116
100
|
methods.each do |other_method|
|
117
|
-
clump =
|
101
|
+
clump = method.arg_names & other_method.arg_names
|
118
102
|
if clump.length >= @min_clump_size
|
119
103
|
others = methods.select { |other| clump - other.arg_names == [] }
|
120
104
|
results[clump] += [method] + others
|