Sha256: 2e8ebaf4f2700ec8858f407a0e50c71d43bbec094b5af02fdec43b95e9a5738a

Contents?: true

Size: 841 Bytes

Versions: 3

Compression:

Stored size: 841 Bytes

Contents

# frozen_string_literal: true

module Codeowners
  # This class is responsible for print the reports
  class Reporter
    LABELS = {
      missing_ref: 'No owner defined',
      useless_pattern: 'Useless patterns',
      invalid_owner: 'Invalid owner',
      unrecognized_line: 'Unrecognized line'
    }.freeze

    class << self
      def print_delimiter_line(error_type)
        raise ArgumentError, "unknown error type '#{error_type}'" unless LABELS.key?(error_type)

        print('-' * 30, LABELS[error_type], '-' * 30)
      end

      def print_error(error_type, inconsistencies, meta)
        case error_type
        when :invalid_owner then print("#{inconsistencies} MISSING: #{meta.join(', ')}")
        else print(inconsistencies.to_s)
        end
      end

      def print(*args)
        puts(*args)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
codeowners-checker-1.1.2 lib/codeowners/reporter.rb
codeowners-checker-1.1.1 lib/codeowners/reporter.rb
codeowners-checker-1.0.5 lib/codeowners/reporter.rb