Skip to content

Commit

Permalink
Smell detectors no longer know about reports
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrutherford committed Jun 15, 2009
1 parent 80bc0d3 commit 742dcb9
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions lib/reek/smells/control_couple.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/reek/smells/duplication.rb
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/reek/smells/feature_envy.rb
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions lib/reek/smells/large_class.rb
Expand Up @@ -42,25 +42,25 @@ 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")
end

#
# 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
Expand Down
4 changes: 2 additions & 2 deletions lib/reek/smells/long_method.rb
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions lib/reek/smells/long_parameter_list.rb
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions lib/reek/smells/nested_iterators.rb
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/reek/smells/smell_detector.rb
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions lib/reek/smells/uncommunicative_name.rb
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/reek/smells/utility_function.rb
Expand Up @@ -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?
Expand Down

0 comments on commit 742dcb9

Please sign in to comment.