diff --git a/src/main/scala/com/codacy/transformation/FileNameMatcher.scala b/src/main/scala/com/codacy/transformation/FileNameMatcher.scala index 7a2c27b3..970b694a 100644 --- a/src/main/scala/com/codacy/transformation/FileNameMatcher.scala +++ b/src/main/scala/com/codacy/transformation/FileNameMatcher.scala @@ -7,20 +7,20 @@ object FileNameMatcher { def matchAndReturnName(filename: String, fileNames: Seq[String]): Option[String] = { fileNames - .filter(name => isTheSameFile(filename, name)) + .filter(name => isTheSameFile(filename.toLowerCase, name.toLowerCase)) .sortBy(name => Math.abs(filename.length - name.length)) .headOption } def getFilenameFromPath(filename: String): String = { - Try(Paths.get(filename).getFileName.toString).getOrElse(filename) + Try(Paths.get(filename).getFileName.toString.toLowerCase).getOrElse(filename.toLowerCase) } private def haveSameName(file: String, covFile: String): Boolean = - getFilenameFromPath(file).equalsIgnoreCase(getFilenameFromPath(covFile)) + getFilenameFromPath(file) == getFilenameFromPath(covFile) private def haveSamePath(file: String, covFile: String): Boolean = - file.equalsIgnoreCase(covFile) + file == covFile private def fileEndsWithReportPath(file: String, covFile: String): Boolean = file.endsWith(covFile) diff --git a/src/test/resources/test-paths-with-different-paths.xml b/src/test/resources/test-paths-with-different-paths.xml new file mode 100644 index 00000000..dc072ff7 --- /dev/null +++ b/src/test/resources/test-paths-with-different-paths.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/scala/com/codacy/rules/ReportRulesSpec.scala b/src/test/scala/com/codacy/rules/ReportRulesSpec.scala index 336824a2..6a25319a 100644 --- a/src/test/scala/com/codacy/rules/ReportRulesSpec.scala +++ b/src/test/scala/com/codacy/rules/ReportRulesSpec.scala @@ -165,6 +165,30 @@ class ReportRulesSpec extends WordSpec with Matchers with PrivateMethodTester wi ) } + "succeed even if the provider paths and the report paths have different cases" in { + val coverageServices = mock[CoverageServices] + val gitFileFetcher = mock[GitFileFetcher] + + gitFileFetcher.forCommit(any[String]).shouldReturn(Left("The report has files with different cases")) + + coverageServices.sendReport( + any[String], + any[String], + any[CoverageReport], + anyBoolean, + Some(RequestTimeout(1000, 10000)), + Some(10000), + Some(3) + ) returns SuccessfulResponse(RequestSuccess("Success")) + + assertCodacyCoverage( + coverageServices, + gitFileFetcher, + List("src/test/resources/test-paths-with-different-paths.xml"), + success = true + ) + } + "succeed even if one of the parsed reports ends up empty" in { val coverageServices = mock[CoverageServices] val gitFileFetcher = mock[GitFileFetcher]