Sha256: c79fdb23c4cc713c7e268d0aef38cd22bdc9f335ef4f6452dea8947374181849

Contents?: true

Size: 812 Bytes

Versions: 1

Compression:

Stored size: 812 Bytes

Contents

module Pelusa
  module Lint
    class Properties
      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 getters, setters or properties in lines #{violations.to_a.join(', ')}"
        end
      end

      private

      def name
        "Doesn't use getters, setters or properties"
      end

      def iterate_lines!(klass)
        ClassAnalyzer.walk(klass) do |node|
          if node.is_a?(Rubinius::AST::Send)
            if [:attr_accessor, :attr_writer, :attr_reader].include? node.name
              @violations << node.line
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pelusa-0.2.3 lib/pelusa/lint/properties.rb