Sha256: ea7ea4d8987ce6e601f42c1d9be728d1422921d54f78ef46176525e2a462b525

Contents?: true

Size: 920 Bytes

Versions: 6835

Compression:

Stored size: 920 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # Checks for if and unless statements used as modifiers of other if or
      # unless statements.
      #
      # @example
      #
      #  # bad
      #  tired? ? 'stop' : 'go faster' if running?
      #
      #  # bad
      #  if tired?
      #    "please stop"
      #  else
      #    "keep going"
      #  end if running?
      #
      #  # good
      #  if running?
      #    tired? ? 'stop' : 'go faster'
      #  end
      class IfUnlessModifierOfIfUnless < Cop
        include StatementModifier

        MSG = 'Avoid modifier `%<keyword>s` after another conditional.'.freeze

        def on_if(node)
          return unless node.modifier_form? && node.body.if_type?

          add_offense(node, location: :keyword,
                            message: format(MSG, keyword: node.keyword))
        end
      end
    end
  end
end

Version data entries

6,835 entries across 6,829 versions & 26 rubygems

Version Path
ory-client-0.0.1.alpha97 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha96 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha95 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha94 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha93 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha92 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-oathkeeper-client-0.38.20.beta1 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha91 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha90 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha89 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha88 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha87 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha86 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha85 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha84 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha83 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha82 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha81 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha80 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb
ory-client-0.0.1.alpha79 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb