Sha256: a5b290dfb47e8b6ebb61b92ab08962b68b7b3eca73f778c625418828288369fd

Contents?: true

Size: 1.35 KB

Versions: 6900

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Formatter
    # A basic formatter that displays the lines disabled
    # inline comments.
    class DisabledLinesFormatter < BaseFormatter
      include PathUtil
      include Colorizable

      attr_reader :cop_disabled_line_ranges

      def started(_target_files)
        @cop_disabled_line_ranges = {}
      end

      def file_started(file, options)
        return unless options[:cop_disabled_line_ranges]

        @cop_disabled_line_ranges[file] =
          options[:cop_disabled_line_ranges]
      end

      def finished(_inspected_files)
        cops_disabled_in_comments_summary
      end

      private

      def cops_disabled_in_comments_summary
        summary = "\nCops disabled line ranges:\n\n"

        @cop_disabled_line_ranges.each do |file, disabled_cops|
          disabled_cops.each do |cop, line_ranges|
            line_ranges.each do |line_range|
              file = cyan(smart_path(file))
              summary += "#{file}:#{line_range}: #{cop}\n"
            end
          end
        end

        output.puts summary
      end

      def smart_path(path)
        # Ideally, we calculate this relative to the project root.
        base_dir = Dir.pwd

        if path.start_with? base_dir
          relative_path(path, base_dir)
        else
          path
        end
      end
    end
  end
end

Version data entries

6,900 entries across 6,875 versions & 29 rubygems

Version Path
cybrid_api_organization_ruby-0.123.162 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_id_ruby-0.123.162 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_id_ruby-0.123.161 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_organization_ruby-0.123.161 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_organization_ruby-0.123.160 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_id_ruby-0.123.160 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_organization_ruby-0.123.159 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_id_ruby-0.123.159 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_id_ruby-0.123.158 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_organization_ruby-0.123.158 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_id_ruby-0.123.157 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_organization_ruby-0.123.157 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_organization_ruby-0.123.156 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_id_ruby-0.123.156 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
messente_api-2.3.0 vendor/bundle/ruby/3.4.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_bank_ruby-0.123.153 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_id_ruby-0.123.153 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_organization_ruby-0.123.153 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_bank_ruby-0.123.152 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb
cybrid_api_id_ruby-0.123.152 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/formatter/disabled_lines_formatter.rb