Sha256: 392104de3d3cb6670078f4e2c8e9f2d13146b5f75d2dd1ade1890bd3aa5a699a

Contents?: true

Size: 685 Bytes

Versions: 8

Compression:

Stored size: 685 Bytes

Contents

require_relative '../ast/node'
require 'private_attr/everywhere'

module Reek
  module Context
    # Responsible for counting the statements in a `CodeContext`.
    class StatementCounter
      attr_reader :value
      private_attr_writer :value

      def initialize
        @value = 0
      end

      def increase_by(sexp)
        return unless sexp
        case sexp
        when Reek::AST::Node
          self.value = value + 1
        when Array
          self.value = value + sexp.length
        else
          raise ArgumentError, "Invalid type #{sexp} given"
        end
      end

      def decrease_by(number)
        self.value = value - number
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
reek-3.10.1 lib/reek/context/statement_counter.rb
reek-3.10.0 lib/reek/context/statement_counter.rb
reek-3.9.1 lib/reek/context/statement_counter.rb
reek-3.9.0 lib/reek/context/statement_counter.rb
reek-3.8.3 lib/reek/context/statement_counter.rb
reek-3.8.2 lib/reek/context/statement_counter.rb
reek-3.8.1 lib/reek/context/statement_counter.rb
reek-3.8.0 lib/reek/context/statement_counter.rb