Sha256: 9d397b7482693c69444bf8d8d5330a17b5a8a4cc05cabd49e1e537fd0be4f878

Contents?: true

Size: 715 Bytes

Versions: 19

Compression:

Stored size: 715 Bytes

Contents

# encoding: utf-8

module RuboCop
  module Cop
    # Some common code shared between FavorUnlessOverNegatedIf and
    # FavorUntilOverNegatedWhile.
    module NegativeConditional
      def check_negative_conditional(node)
        condition, _body, _rest = *node

        # Look at last expression of contents if there's a parenthesis
        # around condition.
        condition = condition.children.last while condition.type == :begin
        return unless condition.type == :send

        _object, method = *condition
        return unless method == :! && !(node.loc.respond_to?(:else) &&
                                        node.loc.else)

        add_offense(node, :expression)
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/mixin/negative_conditional.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.34.2 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.34.1 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.34.0 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.33.0 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.32.1 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.32.0 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.31.0 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.30.1 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.30.0 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.29.1 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.29.0 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.28.0 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.27.1 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.27.0 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.26.1 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.26.0 lib/rubocop/cop/mixin/negative_conditional.rb
rubocop-0.25.0 lib/rubocop/cop/mixin/negative_conditional.rb