Sha256: bedae1f1fd611f64df566da30ee26edd008494b4e3204774fb360709481f92ed

Contents?: true

Size: 764 Bytes

Versions: 5

Compression:

Stored size: 764 Bytes

Contents

module Pelusa
  module Lint
    class CaseStatements
      def initialize
        @violations = Set.new
      end

      def check(klass)
        initialize
        iterate_lines!(klass)

        return SuccessfulAnalysis.new(name) if @violations.empty?

        FailedAnalysis.new(name, @violations) do |violations|
          "There are #{violations.length} case statements in lines #{violations.to_a.join(', ')}"
        end
      end

      private

      def name
        "Doesn't use case statements"
      end

      def iterate_lines!(klass)
        iterator = Iterator.new do |node|
          if node.is_a?(Rubinius::AST::Case)
            @violations << node.line
          end
        end
        Array(klass).each(&iterator)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pelusa-0.2.2 lib/pelusa/lint/case_statements.rb
pelusa-0.2.1 lib/pelusa/lint/case_statements.rb
pelusa-0.2.0 lib/pelusa/lint/case_statements.rb
pelusa-0.1.1 lib/pelusa/lint/case_statements.rb
pelusa-0.1.0 lib/pelusa/lint/case_statements.rb