Sha256: aadc503748f783e18864eba91f6b337c66665cf9f1a23d3ffa98152ed9f00bf7

Contents?: true

Size: 773 Bytes

Versions: 11

Compression:

Stored size: 773 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module RSpec
      # Avoid describing symbols.
      #
      # @example
      #   # bad
      #   describe :my_method do
      #     # ...
      #   end
      #
      #   # good
      #   describe '#my_method' do
      #     # ...
      #   end
      #
      # @see https://github.com/rspec/rspec-core/issues/1610
      class DescribeSymbol < Cop
        MSG = 'Avoid describing symbols.'.freeze

        def_node_matcher :describe_symbol?, <<-PATTERN
          (send {(const nil? :RSpec) nil?} :describe $sym ...)
        PATTERN

        def on_send(node)
          describe_symbol?(node) do |match|
            add_offense(match, location: :expression)
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rubocop-rspec-1.32.0 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.31.0 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.30.1 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.30.0 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.29.1 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.29.0 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.28.0 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.27.0 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.26.0 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.25.1 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.25.0 lib/rubocop/cop/rspec/describe_symbol.rb