Sha256: 4c17d7b604614ffa49e9b632a5e78bc2cc0ad5652dde240f358edeae4532e51a

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

module Reek
  module Report
    # @api private
    module HeadingFormatter
      #
      # 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 Base
        attr_reader :report_formatter

        def initialize(report_formatter)
          @report_formatter = report_formatter
        end

        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 Verbose < Base
        def show_header?(_examiner)
          true
        end
      end

      #
      # Lists only smelly examiners
      #
      class Quiet < Base
        def show_header?(examiner)
          examiner.smelly?
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
reek-3.3.1 lib/reek/report/heading_formatter.rb
reek-3.3.0 lib/reek/report/heading_formatter.rb
reek-3.2.1 lib/reek/report/heading_formatter.rb
reek-3.2 lib/reek/report/heading_formatter.rb
reek-3.1 lib/reek/report/heading_formatter.rb
reek-3.0.4 lib/reek/report/heading_formatter.rb