Sha256: 4191726c945d70e5b5e7d5a73590f764fef6d2f56cb6ecd9e91b5c1e0f775a34

Contents?: true

Size: 1.37 KB

Versions: 6791

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Naming
      # This cop checks that your heredocs are using the configured case.
      # By default it is configured to enforce uppercase heredocs.
      #
      # @example EnforcedStyle: uppercase (default)
      #   # bad
      #   <<-sql
      #     SELECT * FROM foo
      #   sql
      #
      #   # good
      #   <<-SQL
      #     SELECT * FROM foo
      #   SQL
      #
      # @example EnforcedStyle: lowercase
      #   # bad
      #   <<-SQL
      #     SELECT * FROM foo
      #   SQL
      #
      #   # good
      #   <<-sql
      #     SELECT * FROM foo
      #   sql
      class HeredocDelimiterCase < Cop
        include Heredoc
        include ConfigurableEnforcedStyle

        MSG = 'Use %<style>s heredoc delimiters.'.freeze

        def on_heredoc(node)
          return if correct_case_delimiters?(node)

          add_offense(node, location: :heredoc_end)
        end

        private

        def message(_node)
          format(MSG, style: style)
        end

        def correct_case_delimiters?(node)
          delimiter_string(node) == correct_delimiters(node)
        end

        def correct_delimiters(node)
          if style == :uppercase
            delimiter_string(node).upcase
          else
            delimiter_string(node).downcase
          end
        end
      end
    end
  end
end

Version data entries

6,791 entries across 6,785 versions & 25 rubygems

Version Path
cybrid_api_organization_ruby-0.123.143 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_id_ruby-0.123.143 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_bank_ruby-0.123.142 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_id_ruby-0.123.142 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_organization_ruby-0.123.142 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_bank_ruby-0.123.140 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_id_ruby-0.123.140 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_organization_ruby-0.123.140 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_bank_ruby-0.123.139 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_id_ruby-0.123.139 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_organization_ruby-0.123.139 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_id_ruby-0.123.137 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_organization_ruby-0.123.137 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_bank_ruby-0.123.137 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_organization_ruby-0.123.135 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_bank_ruby-0.123.135 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_id_ruby-0.123.135 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_bank_ruby-0.123.134 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_id_ruby-0.123.134 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb
cybrid_api_organization_ruby-0.123.134 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/naming/heredoc_delimiter_case.rb