From 1bcfb332eed308a0d4ac8dca9448f636a0b0ed59 Mon Sep 17 00:00:00 2001 From: Francisco Date: Tue, 26 May 2020 10:48:04 +0100 Subject: [PATCH] fix: Change generated JSON file directory to tmp folder :breaking: The file is now generated in a temporary folder with a unique name, instead of the same folder where the report is This file is used for troubleshooting purposes. --- src/main/scala/com/codacy/rules/ReportRules.scala | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/codacy/rules/ReportRules.scala b/src/main/scala/com/codacy/rules/ReportRules.scala index 4dc1b260..b6258299 100644 --- a/src/main/scala/com/codacy/rules/ReportRules.scala +++ b/src/main/scala/com/codacy/rules/ReportRules.scala @@ -92,16 +92,14 @@ class ReportRules(coverageServices: => CoverageServices) extends LogSupport { if (report.fileReports.isEmpty) Left(s"The provided coverage report ${file.getAbsolutePath} generated an empty result.") else { - val codacyReportFilename = - s"${file.getAbsoluteFile.getParent}${File.separator}codacy-coverage.json" - logger.debug(s"Saving parsed report to $codacyReportFilename") - val codacyReportFile = new File(codacyReportFilename) + val codacyReportFile = File.createTempFile("codacy-coverage-", ".json") + logger.debug(s"Saving parsed report to ${codacyReportFile.getAbsolutePath}") logger.debug(report.toString) FileHelper.writeJsonToFile(codacyReportFile, report) logUploadedFileInfo(codacyReportFile) - Right(codacyReportFilename) + Right(codacyReportFile.getAbsolutePath) } }