diff --git a/lib/reek/smells/control_couple.rb b/lib/reek/smells/control_couple.rb index e9e8135f4..2302e2819 100644 --- a/lib/reek/smells/control_couple.rb +++ b/lib/reek/smells/control_couple.rb @@ -49,9 +49,9 @@ def initialize(config = ControlCouple.default_config) # # Checks whether the given conditional statement relies on a control couple. - # Any smells found are added to the +report+. + # Remembers any smells found. # - def examine_context(cond, report) + def examine_context(cond) return unless cond.tests_a_parameter? found(cond, "is controlled by argument #{SexpFormatter.format(cond.if_expr)}") end diff --git a/lib/reek/smells/duplication.rb b/lib/reek/smells/duplication.rb index f4a966426..394db3278 100644 --- a/lib/reek/smells/duplication.rb +++ b/lib/reek/smells/duplication.rb @@ -33,7 +33,7 @@ def initialize(config = Duplication.default_config) @max_calls = config[MAX_ALLOWED_CALLS_KEY] end - def examine_context(method, report) + def examine_context(method) smelly_calls(method).each do |call| found(method, "calls #{SexpFormatter.format(call)} multiple times") end diff --git a/lib/reek/smells/feature_envy.rb b/lib/reek/smells/feature_envy.rb index 2d6eed6f5..85669192b 100644 --- a/lib/reek/smells/feature_envy.rb +++ b/lib/reek/smells/feature_envy.rb @@ -45,9 +45,9 @@ def initialize(config = FeatureEnvy.default_config) # # Checks whether the given +context+ includes any code fragment that # might "belong" on another class. - # Any smells found are added to the +report+. + # Remembers any smells found. # - def examine_context(context, report) + def examine_context(context) context.envious_receivers.each do |ref| found(context, "refers to #{SexpFormatter.format(ref)} more than self") end diff --git a/lib/reek/smells/large_class.rb b/lib/reek/smells/large_class.rb index 5d58e53fc..28ec1a53f 100644 --- a/lib/reek/smells/large_class.rb +++ b/lib/reek/smells/large_class.rb @@ -42,13 +42,13 @@ def initialize(config = LargeClass.default_config) @max_instance_variables = config[MAX_ALLOWED_IVARS_KEY] end - def check_num_methods(klass, report) # :nodoc: + def check_num_methods(klass) # :nodoc: count = klass.num_methods return if count <= @max_methods found(klass, "has at least #{count} methods") end - def check_num_ivars(klass, report) # :nodoc: + def check_num_ivars(klass) # :nodoc: count = klass.variable_names.length return if count <= @max_instance_variables found(klass, "has at least #{count} instance variables") @@ -56,11 +56,11 @@ def check_num_ivars(klass, report) # :nodoc: # # Checks +klass+ for too many methods or too many instance variables. - # Any smells found are added to the +report+. + # Remembers any smells found. # - def examine_context(klass, report) - check_num_methods(klass, report) - check_num_ivars(klass, report) + def examine_context(klass) + check_num_methods(klass) + check_num_ivars(klass) end end end diff --git a/lib/reek/smells/long_method.rb b/lib/reek/smells/long_method.rb index 54492da62..81426b6d6 100644 --- a/lib/reek/smells/long_method.rb +++ b/lib/reek/smells/long_method.rb @@ -30,9 +30,9 @@ def initialize(config = LongMethod.default_config) # # Checks the length of the given +method+. - # Any smells found are added to the +report+. + # Remembers any smells found. # - def examine_context(method, report) + def examine_context(method) num = method.num_statements return false if num <= @max_statements found(method, "has approx #{num} statements") diff --git a/lib/reek/smells/long_parameter_list.rb b/lib/reek/smells/long_parameter_list.rb index 617bc7d35..85549a17c 100644 --- a/lib/reek/smells/long_parameter_list.rb +++ b/lib/reek/smells/long_parameter_list.rb @@ -30,9 +30,9 @@ def initialize(config) # # Checks the number of parameters in the given scope. - # Any smells found are added to the +report+. + # Remembers any smells found. # - def examine_context(ctx, report) + def examine_context(ctx) num_params = ctx.parameters.length return false if num_params <= @max_params found(ctx, "#{@action} #{num_params} parameters") diff --git a/lib/reek/smells/nested_iterators.rb b/lib/reek/smells/nested_iterators.rb index 173085004..6064934f4 100644 --- a/lib/reek/smells/nested_iterators.rb +++ b/lib/reek/smells/nested_iterators.rb @@ -17,9 +17,9 @@ def self.contexts # :nodoc: # # Checks whether the given +block+ is inside another. - # Any smells found are added to the +report+. + # Remembers any smells found. # - def examine_context(block, report) + def examine_context(block) return false unless block.nested_block? found(block, 'is nested') end diff --git a/lib/reek/smells/smell_detector.rb b/lib/reek/smells/smell_detector.rb index c1bdc848f..2171dbe76 100644 --- a/lib/reek/smells/smell_detector.rb +++ b/lib/reek/smells/smell_detector.rb @@ -47,11 +47,11 @@ def initialize(config) def examine(context) before = @smells_found.size - examine_context(context, nil) if @enabled and !exception?(context) + examine_context(context) if @enabled and !exception?(context) @smells_found.length > before end - def examine_context(context, report) + def examine_context(context) end def exception?(context) diff --git a/lib/reek/smells/uncommunicative_name.rb b/lib/reek/smells/uncommunicative_name.rb index c16b4de47..16cdda6af 100644 --- a/lib/reek/smells/uncommunicative_name.rb +++ b/lib/reek/smells/uncommunicative_name.rb @@ -47,21 +47,21 @@ def initialize(config = UncommunicativeName.default_config) # # Checks the given +context+ for uncommunicative names. - # Any smells found are added to the +report+. + # Remembers any smells found. # - def examine_context(context, report) - consider_name(context, report) - consider_variables(context, report) + def examine_context(context) + consider_name(context) + consider_variables(context) end - def consider_variables(context, report) # :nodoc: + def consider_variables(context) # :nodoc: context.variable_names.each do |name| next unless is_bad_name?(name) found(context, "has the variable name '#{name}'") end end - def consider_name(context, report) # :nodoc: + def consider_name(context) # :nodoc: name = context.name return false if @accept.include?(context.to_s) # TODO: fq_name() ? return false unless is_bad_name?(name) diff --git a/lib/reek/smells/utility_function.rb b/lib/reek/smells/utility_function.rb index 9f622ed5c..209a73750 100644 --- a/lib/reek/smells/utility_function.rb +++ b/lib/reek/smells/utility_function.rb @@ -20,9 +20,9 @@ class UtilityFunction < SmellDetector # # Checks whether the given +method+ is a utility function. - # Any smells found are added to the +report+. + # Remembers any smells found. # - def examine_context(method, report) + def examine_context(method) return false if method.calls.keys.length == 0 or method.num_statements == 0 or method.depends_on_instance?