Sha256: 062e4191204dc2bde060eb12b369840b08d409f0725d7295003198830d4810c0

Contents?: true

Size: 661 Bytes

Versions: 4

Compression:

Stored size: 661 Bytes

Contents

module Codacy
  class Formatter

    def format(result)
      if should_run?
        parse_result = Codacy::Parser.parse_file(result)
        Codacy::ClientAPI.post_results(parse_result, partial: partial)
      else
        logger.info("Running locally, skipping Codacy coverage")
      end
    rescue => ex
      logger.fatal(ex)
      false
    end

    private

    def partial
      false
    end

    def should_run?
      ENV["CI"] || ENV["JENKINS_URL"] || ENV['TDDIUM'] || ENV["CODACY_RUN_LOCAL"]
    end

    def logger
      Codacy::Configuration.logger
    end

  end

  class PartialFormatter < Formatter
    def partial
      true
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
codacy-coverage-2.2.1 lib/codacy/formatter.rb
codacy-coverage-2.2.0 lib/codacy/formatter.rb
codacy-coverage-2.1.5 lib/codacy/formatter.rb
codacy-coverage-2.1.4 lib/codacy/formatter.rb