Sha256: ad306067161d2efa5bf14877641b94d14e5176e00a822495e41364ee933f35dc

Contents?: true

Size: 1.84 KB

Versions: 16

Compression:

Stored size: 1.84 KB

Contents

# frozen_string_literal: true
require_relative 'base_command'
require_relative '../../examiner'
require_relative '../../report'

module Reek
  module CLI
    module Command
      #
      # A command to collect smells from a set of sources and write them out in
      # text report format.
      #
      class ReportCommand < BaseCommand
        def execute
          populate_reporter_with_smells
          reporter.show
          result_code
        end

        private

        def populate_reporter_with_smells
          sources.each do |source|
            reporter.add_examiner Examiner.new(source,
                                               filter_by_smells: smell_names,
                                               configuration: configuration)
          end
        end

        def result_code
          reporter.smells? ? options.failure_exit_code : options.success_exit_code
        end

        def reporter
          @reporter ||=
            report_class.new(
              warning_formatter: warning_formatter,
              report_formatter: Report::Formatter,
              sort_by_issue_count: sort_by_issue_count,
              heading_formatter: heading_formatter)
        end

        def report_class
          Report.report_class(options.report_format)
        end

        def warning_formatter
          warning_formatter_class.new(location_formatter: location_formatter)
        end

        def warning_formatter_class
          Report.warning_formatter_class(options.show_links ? :wiki_links : :simple)
        end

        def location_formatter
          Report.location_formatter(options.location_format)
        end

        def heading_formatter
          Report.heading_formatter(options.show_empty ? :verbose : :quiet)
        end

        def sort_by_issue_count
          options.sorting == :smelliness
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
reek-4.4.2 lib/reek/cli/command/report_command.rb
reek-4.4.1 lib/reek/cli/command/report_command.rb
reek-4.4.0 lib/reek/cli/command/report_command.rb
reek-4.3.0 lib/reek/cli/command/report_command.rb
reek-4.2.5 lib/reek/cli/command/report_command.rb
reek-4.2.4 lib/reek/cli/command/report_command.rb
reek-4.2.3 lib/reek/cli/command/report_command.rb
reek-4.2.2 lib/reek/cli/command/report_command.rb
reek-4.2.1 lib/reek/cli/command/report_command.rb
reek-4.2.0 lib/reek/cli/command/report_command.rb
reek-4.1.1 lib/reek/cli/command/report_command.rb
reek-4.1.0 lib/reek/cli/command/report_command.rb
reek-4.0.5 lib/reek/cli/command/report_command.rb
reek-4.0.4 lib/reek/cli/command/report_command.rb
reek-4.0.3 lib/reek/cli/command/report_command.rb
reek-4.0.2 lib/reek/cli/command/report_command.rb