Sha256: e369239ca042be578b0e674f14ae4513697600e3bb7740e1b8e6e3bb82232f79

Contents?: true

Size: 611 Bytes

Versions: 5

Compression:

Stored size: 611 Bytes

Contents

module Nitpick
  module Warnings
    class UnprotectedBlock < SimpleWarning
      attr_reader :condition, :yes_branch, :no_branch
      
      def initialize(*args)
        @condition, @yes_branch, @no_branch = args
      end
      
      def matches?
        # raise "YES: #{yes_branch.inspect}"
        yes_branch =~ s(:yield) && condition !~ s(:fcall, :block_given?)
      end
      
      def ==(other)
        yes_branch == other.yes_branch && no_branch == other.no_branch
      end
      
      def message
        "A block is being yielded to without a check for block_given?"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
kevinclark-nitpick-1.0.0 lib/nitpick/warnings/unprotected_block.rb
kevinclark-nitpick-1.0.1 lib/nitpick/warnings/unprotected_block.rb
nitpick-1.0.1 lib/nitpick/warnings/unprotected_block.rb
nitpick-1.0.2 lib/nitpick/warnings/unprotected_block.rb
nitpick-1.0.0 lib/nitpick/warnings/unprotected_block.rb