Sha256: b8a285c2c04c6c77b06b07874a62006421d011fff190f11e2456a57366cf8481

Contents?: true

Size: 1.55 KB

Versions: 6517

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Formatter
    # This formatter formats report data in clang style.
    # The precise location of the problem is shown together with the
    # relevant source code.
    class ClangStyleFormatter < SimpleTextFormatter
      ELLIPSES = '...'.freeze

      def report_file(file, offenses)
        offenses.each { |offense| report_offense(file, offense) }
      end

      private

      def report_offense(file, offense)
        output.printf("%s:%d:%d: %s: %s\n",
                      cyan(smart_path(file)), offense.line, offense.real_column,
                      colored_severity_code(offense), message(offense))

        # rubocop:disable Lint/HandleExceptions
        begin
          return unless valid_line?(offense)

          report_line(offense.location)
          report_highlighted_area(offense.highlighted_area)
        rescue IndexError
          # range is not on a valid line; perhaps the source file is empty
        end
        # rubocop:enable Lint/HandleExceptions
      end

      def valid_line?(offense)
        !offense.location.source_line.blank?
      end

      def report_line(location)
        source_line = location.source_line

        if location.first_line == location.last_line
          output.puts(source_line)
        else
          output.puts("#{source_line} #{yellow(ELLIPSES)}")
        end
      end

      def report_highlighted_area(highlighted_area)
        output.puts("#{' ' * highlighted_area.begin_pos}" \
                    "#{'^' * highlighted_area.size}")
      end
    end
  end
end

Version data entries

6,517 entries across 6,511 versions & 25 rubygems

Version Path
cybrid_api_bank_ruby-0.122.47 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_id_ruby-0.122.47 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_organization_ruby-0.122.47 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_id_ruby-0.122.46 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_bank_ruby-0.122.46 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_organization_ruby-0.122.46 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_organization_ruby-0.122.45 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_id_ruby-0.122.45 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_bank_ruby-0.122.45 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_bank_ruby-0.122.44 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_id_ruby-0.122.44 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_organization_ruby-0.122.44 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_bank_ruby-0.122.43 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_organization_ruby-0.122.43 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_id_ruby-0.122.43 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_bank_ruby-0.122.42 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_id_ruby-0.122.42 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_organization_ruby-0.122.42 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
ory-client-1.15.10 vendor/bundle/ruby/3.1.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb
cybrid_api_organization_ruby-0.122.41 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/clang_style_formatter.rb