Sha256: 8b7f90bd3fb74635fcc0040c7380b891d781e86b05e5aa31d708c77877f47438
Contents?: true
Size: 916 Bytes
Versions: 1
Compression:
Stored size: 916 Bytes
Contents
module Pelusa module Lint class InstanceVariables def initialize @ivars = Set.new end def check(klass) iterate_lines!(klass) return SuccessfulAnalysis.new(name) if @ivars.length < limit FailedAnalysis.new(name, @ivars) do |ivars| "This class uses #{ivars.length} instance variables: #{ivars.to_a.join(', ')}." end end private def name "Uses less than #{limit} ivars" end def limit Pelusa.configuration['InstanceVariables'].fetch('limit', 3) end def iterate_lines!(klass) ClassAnalyzer.walk(klass) do |node| if node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::InstanceVariableAccess) || node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::InstanceVariableAssignment) @ivars << node.name end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pelusa-0.2.4 | lib/pelusa/lint/instance_variables.rb |