Sha256: 1f10e0fa0c660d025d0c63c0b4bf688e590e08cd41d4b3f553c5d1ebae940cbd
Contents?: true
Size: 1003 Bytes
Versions: 1
Compression:
Stored size: 1003 Bytes
Contents
module Pelusa module Lint class ElseClauses def initialize @violations = Set.new end def check(klass) iterate_lines!(klass) return SuccessfulAnalysis.new(name) if @violations.empty? FailedAnalysis.new(name, @violations) do |violations| "There are #{violations.length} else clauses in lines #{violations.to_a.join(', ')}" end end private def name "Doesn't use else clauses" end def iterate_lines!(klass) ClassAnalyzer.walk(klass) do |node| if node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::If) has_body = node.body && !node.body.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::NilLiteral) has_else = node.else && !node.else.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::NilLiteral) if has_body && has_else @violations << node.else.line end 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/else_clauses.rb |