Sha256: cc5b0d478b94dfc088fc939fcf1843dc421efaa22c1276b8e5d5f8b79704e6e8

Contents?: true

Size: 408 Bytes

Versions: 2

Compression:

Stored size: 408 Bytes

Contents

# frozen_string_literal: true

module WhatDyaReturn
  module AST
    #
    # A node extension for `while` nodes.
    #
    class WhileNode < ::RuboCop::AST::WhileNode
      #
      # @example
      #
      #   while false # or `nil`
      #     42 # unreachable
      #   end
      #
      # @return [Boolean]
      #
      def body_reachable?
        condition.falsey_literal?.!
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
what_dya_return-0.2.1 lib/what_dya_return/ast/node/while_node.rb
what_dya_return-0.2.0 lib/what_dya_return/ast/node/while_node.rb