Sha256: 2281a61a965aaaab7c5b24ceefcd53e56d14d775d9eef09249a11fc5571cb491
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
require 'reek/smells/smell_detector' require 'reek/smell_warning' module Reek module Smells # # a module is usually a mixin, so when initialize method is present it is # hard to tell initialization order and parameters so having 'initialize' # in a module is usually a bad idea # class ModuleInitialize < SmellDetector SMELL_CLASS = smell_class_name SMELL_SUBCLASS = SMELL_CLASS def self.contexts # :nodoc: [:module] end # # Checks whether module has method 'initialize'. # # @return [Array<SmellWarning>] # def examine_context(module_ctx) module_ctx.local_nodes(:def) do |node| # FIXME: also search for :defs? if node.name.to_s == 'initialize' return [ SmellWarning.new(SMELL_CLASS, module_ctx.full_name, [module_ctx.exp.line], 'has initialize method', @source, SMELL_SUBCLASS, {}) ] end end [] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
reek-1.5.1 | lib/reek/smells/module_initialize.rb |
reek-1.5.0 | lib/reek/smells/module_initialize.rb |