lib/codacy/formatter.rb in codacy-coverage-0.0.1 vs lib/codacy/formatter.rb in codacy-coverage-0.1.0

- old
+ new

@@ -1,16 +1,24 @@ module Codacy class Formatter def format(result) - parse_result = Codacy::Parser.parse_file(result) - Codacy::ClientAPI.post_results(parse_result) + if should_run? + parse_result = Codacy::Parser.parse_file(result) + Codacy::ClientAPI.post_results(parse_result) + else + logger.info("Running locally, skipping Codacy coverage") + end rescue => ex logger.fatal(ex) false end private + + def should_run? + ENV["CI"] || ENV["JENKINS_URL"] || ENV['TDDIUM'] || ENV["CODACY_RUN_LOCAL"] + end def logger Codacy::Configuration.logger end