Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/codacy/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@ def self.logger_to_stdout
end

def self.logger_to_file
log_filename = self.temp_dir + 'codacy-coverage_' + Date.today.to_s + '.log'
log_file = File.open(log_filename, 'a')
log_file_path = self.temp_dir + self.log_file_name
log_file = File.open(log_file_path, 'a')
Logger.new(log_file)
end

def self.log_file_name
today = Date.today
# rails overrides to_s method of Date class
# https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/date/conversions.rb#L52
timestamp = today.respond_to?(:to_default_s) ? today.to_default_s : today.to_s
'codacy-coverage_' + timestamp + '.log'
end

def self.temp_dir
directory_name = Dir.tmpdir + "/codacy-coverage/"
Dir.mkdir(directory_name) unless File.exists?(directory_name)
Expand Down
5 changes: 5 additions & 0 deletions lib/codacy/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def self.commit_id
commit
end

def self.work_dir
work_dir = ENV['WORK_DIR'] || git_dir
work_dir
end

def self.git_commit
git("log -1 --pretty=format:'%H'")
end
Expand Down
4 changes: 2 additions & 2 deletions lib/codacy/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Codacy
module Parser

def self.parse_file(simplecov_result)
project_dir = Codacy::Git.git_dir
project_dir = Codacy::Git.work_dir

logger.info("Parsing simplecov result to Codacy format...")
logger.debug(simplecov_result.original_result)
Expand Down Expand Up @@ -36,4 +36,4 @@ def self.logger
Codacy::Configuration.logger
end
end
end
end