Sha256: 9070bf4cfeefbc0a483c4f57b1d23332f5fd4e700a9944a06acce18926a7177c

Contents?: true

Size: 738 Bytes

Versions: 1

Compression:

Stored size: 738 Bytes

Contents

module Pelusa
  module Lint
    class CaseStatements
      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} case statements in lines #{violations.to_a.join(', ')}"
        end
      end

      private

      def name
        "Doesn't use case statements"
      end

      def iterate_lines!(klass)
        ClassAnalyzer.walk(klass) do |node|
          if node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Case)
            @violations << node.line
          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/case_statements.rb