Sha256: ddeb806b4e38ab1eeee4cda83ce572e384251e10bd08fbd812c613da44a1306f

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'undercover'
require 'rainbow'

module Undercover
  module CLI
    # TODO: Report calls >parser< for each file instead of
    # traversing the whole project at first!

    WARNINGS_TO_S = {
      stale_coverage: Rainbow('♻️  Coverage data is older than your' \
        'latest changes. Re-run tests to update').yellow,
      no_changes: Rainbow('✅ No reportable changes').green
    }.freeze

    # TODO: add executable in ./bin later
    # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
    def self.run(args)
      opts = Undercover::Options.new.parse(args)
      report = Undercover::Report.new(
        opts.lcov,
        opts.path,
        git_dir: opts.git_dir,
        compare: opts.compare
      ).build

      error = report.validate(opts.lcov)
      if error
        puts(WARNINGS_TO_S[error])
        return 1
      end

      warnings = report.build_warnings
      puts Undercover::Formatter.new(warnings)
      warnings.any? ? 1 : 0
    end
    # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
undercover-0.1.0 lib/undercover/cli.rb