Sha256: 2b8172ff04eb2e3e7e6a02cec7341c4e4ed1b439513ee4b2c08bd7ab8e147b14

Contents?: true

Size: 775 Bytes

Versions: 45

Compression:

Stored size: 775 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Lint
      # This cop checks for `:true` and `:false` symbols.
      # In most cases it would be a typo.
      #
      # @example
      #
      #   # bad
      #   :true
      #
      #   # good
      #   true
      #
      # @example
      #
      #   # bad
      #   :false
      #
      #   # good
      #   false
      class BooleanSymbol < Cop
        MSG = 'Symbol with a boolean name - ' \
              'you probably meant to use `%<boolean>s`.'

        def_node_matcher :boolean_symbol?, '(sym {:true :false})'

        def on_sym(node)
          return unless boolean_symbol?(node)

          add_offense(node, message: format(MSG, boolean: node.value))
        end
      end
    end
  end
end

Version data entries

45 entries across 26 versions & 3 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.79.0/lib/rubocop/cop/lint/boolean_symbol.rb
rubocop-0.80.1 lib/rubocop/cop/lint/boolean_symbol.rb
rubocop-0.80.0 lib/rubocop/cop/lint/boolean_symbol.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.79.0/lib/rubocop/cop/lint/boolean_symbol.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/rubocop-0.79.0/lib/rubocop/cop/lint/boolean_symbol.rb
rubocop-0.79.0 lib/rubocop/cop/lint/boolean_symbol.rb
rubocop-0.78.0 lib/rubocop/cop/lint/boolean_symbol.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/lint/boolean_symbol.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.75.0/lib/rubocop/cop/lint/boolean_symbol.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.76.0/lib/rubocop/cop/lint/boolean_symbol.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/lint/boolean_symbol.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.74.0/lib/rubocop/cop/lint/boolean_symbol.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.77.0/lib/rubocop/cop/lint/boolean_symbol.rb
rubocop-0.77.0 lib/rubocop/cop/lint/boolean_symbol.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/lint/boolean_symbol.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/rubocop-0.74.0/lib/rubocop/cop/lint/boolean_symbol.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/rubocop-0.76.0/lib/rubocop/cop/lint/boolean_symbol.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/lint/boolean_symbol.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/rubocop-0.75.0/lib/rubocop/cop/lint/boolean_symbol.rb
rubocop-0.76.0 lib/rubocop/cop/lint/boolean_symbol.rb