Parent

Class/Module Index [+]

Quicksearch

Reek::Smells::LargeClass

A Large Class is a class or module that has a large number of instance variables, methods or lines of code.

Currently LargeClass only reports classes having more than a configurable number of methods or instance variables. The method count includes public, protected and private methods, and excludes methods inherited from superclasses or included modules.

Constants

DEFAULT_MAX_IVARS
DEFAULT_MAX_METHODS
IVAR_COUNT_KEY
MAX_ALLOWED_IVARS_KEY

The name of the config field that sets the maximum number of instance variables permitted in a class.

MAX_ALLOWED_METHODS_KEY

The name of the config field that sets the maximum number of methods permitted in a class.

METHOD_COUNT_KEY
SMELL_CLASS
SUBCLASS_TOO_MANY_IVARS
SUBCLASS_TOO_MANY_METHODS

Public Class Methods

default_config() click to toggle source
# File lib/reek/smells/large_class.rb, line 41
def self.default_config
  super.adopt(
    MAX_ALLOWED_METHODS_KEY => DEFAULT_MAX_METHODS,
    MAX_ALLOWED_IVARS_KEY => DEFAULT_MAX_IVARS,
    EXCLUDE_KEY => []
    )
end
new(source, config = LargeClass.default_config) click to toggle source
# File lib/reek/smells/large_class.rb, line 49
def initialize(source, config = LargeClass.default_config)
  super(source, config)
end

Public Instance Methods

examine_context(ctx) click to toggle source

Checks klass for too many methods or too many instance variables.

@return [Array<SmellWarning>]

# File lib/reek/smells/large_class.rb, line 58
def examine_context(ctx)
  @max_allowed_ivars = value(MAX_ALLOWED_IVARS_KEY, ctx, DEFAULT_MAX_IVARS)
  @max_allowed_methods = value(MAX_ALLOWED_METHODS_KEY, ctx, DEFAULT_MAX_METHODS)
  check_num_methods(ctx) + check_num_ivars(ctx)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.