troessner/reek

View on GitHub
lib/reek/ast/sexp_extensions/logical_operators.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module Reek
  module AST
    module SexpExtensions
      # Base module for utility methods for :and and :or nodes.
      module LogicOperatorBase
        def condition
          children.first
        end

        def body_nodes(type, ignoring = [])
          children[1].each_node type, (ignoring | type)
        end
      end

      # Utility methods for :and nodes.
      module AndNode
        include LogicOperatorBase
      end

      # Utility methods for :or nodes.
      module OrNode
        include LogicOperatorBase
      end
    end
  end
end