Parent

Class/Module Index [+]

Quicksearch

Reek::Smells::Attribute

A class that publishes a getter or setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

Currently this detector raises a warning for every attr, attr_reader, attr_writer and attr_accessor – including those that are private.

TODO:

Public Class Methods

default_config() click to toggle source
# File lib/reek/smells/attribute.rb, line 32
def self.default_config
  super.adopt(Core::SmellConfiguration::ENABLED_KEY => false)
end
new(source, config = Attribute.default_config) click to toggle source
# File lib/reek/smells/attribute.rb, line 36
def initialize(source, config = Attribute.default_config)
  super(source, config)
end

Public Instance Methods

examine_context(ctx) click to toggle source

Checks whether the given class declares any attributes.

@return [Array<SmellWarning>]

# File lib/reek/smells/attribute.rb, line 45
def examine_context(ctx)
  attributes_in(ctx).map do |attr, line|
    smell = SmellWarning.new(SMELL_CLASS, ctx.full_name, [line],
      "declares the attribute #{attr}",
      @source, SMELL_SUBCLASS,
      {ATTRIBUTE_KEY => attr.to_s})
    smell
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.