Sha256: 75dee62d89ebfba60b4a8d3e83d17db68d51a3bbacb9729b2cfe13cb39f55064

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true
module Reek
  module Report
    module Formatter
      #
      # Base class for heading formatters.
      # Is responsible for formatting the heading emitted for each examiner
      #
      # @abstract Override {#show_header?} to implement a heading formatter.
      class HeadingFormatterBase
        attr_reader :report_formatter

        def initialize(report_formatter)
          @report_formatter = report_formatter
        end

        # :reek:UtilityFunction
        def show_header?(_examiner)
          raise NotImplementedError
        end

        def header(examiner)
          if show_header?(examiner)
            report_formatter.header examiner
          else
            ''
          end
        end
      end

      #
      # Lists out each examiner, even if it has no smell
      #
      class VerboseHeadingFormatter < HeadingFormatterBase
        def show_header?(_examiner)
          true
        end
      end

      #
      # Lists only smelly examiners
      #
      class QuietHeadingFormatter < HeadingFormatterBase
        # :reek:UtilityFunction
        def show_header?(examiner)
          examiner.smelly?
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
reek-4.6.1 lib/reek/report/formatter/heading_formatter.rb
reek-4.6.0 lib/reek/report/formatter/heading_formatter.rb
reek-4.5.6 lib/reek/report/formatter/heading_formatter.rb
reek-4.5.5 lib/reek/report/formatter/heading_formatter.rb
reek-4.5.4 lib/reek/report/formatter/heading_formatter.rb
reek-4.5.3 lib/reek/report/formatter/heading_formatter.rb
reek-4.5.2 lib/reek/report/formatter/heading_formatter.rb
reek-4.5.1 lib/reek/report/formatter/heading_formatter.rb
reek-4.5.0 lib/reek/report/formatter/heading_formatter.rb