Sha256: 26cb0d2e1511fc2a5ae206e4aceb32d3c4324dfca942c9b84f52b785b540058a

Contents?: true

Size: 905 Bytes

Versions: 6778

Compression:

Stored size: 905 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Layout
      # This cop checks for space after `!`.
      #
      # @example
      #   # bad
      #   ! something
      #
      #   # good
      #   !something
      class SpaceAfterNot < Cop
        include RangeHelp

        MSG = 'Do not leave space between `!` and its argument.'.freeze

        def on_send(node)
          return unless node.prefix_bang? && whitespace_after_operator?(node)

          add_offense(node)
        end

        def whitespace_after_operator?(node)
          node.receiver.loc.column - node.loc.column > 1
        end

        def autocorrect(node)
          lambda do |corrector|
            corrector.remove(
              range_between(node.loc.selector.end_pos,
                            node.receiver.source_range.begin_pos)
            )
          end
        end
      end
    end
  end
end

Version data entries

6,778 entries across 6,772 versions & 24 rubygems

Version Path
cybrid_api_bank_ruby-0.123.132 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_id_ruby-0.123.132 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_organization_ruby-0.123.132 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_bank_ruby-0.123.131 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_id_ruby-0.123.131 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_organization_ruby-0.123.131 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_bank_ruby-0.123.129 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_id_ruby-0.123.129 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_organization_ruby-0.123.129 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_bank_ruby-0.123.127 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_id_ruby-0.123.127 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_organization_ruby-0.123.127 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_bank_ruby-0.123.126 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_id_ruby-0.123.126 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_organization_ruby-0.123.126 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
avalara_sdk-24.12.1 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_bank_ruby-0.123.125 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_organization_ruby-0.123.125 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_id_ruby-0.123.125 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb
cybrid_api_bank_ruby-0.123.124 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/layout/space_after_not.rb