From 53917e0d498711971b9b2daf6881cb5a2bb4ced8 Mon Sep 17 00:00:00 2001 From: Joao Machado Date: Mon, 4 Jan 2016 15:05:14 +0000 Subject: [PATCH] Fix coverage totals to int Codacy is expecting the total to be rounded as integer --- src/codacy/reporter.py | 3 ++- tests/coverage4/coverage.json | 6 +++--- tests/filepath/coverage.json | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/codacy/reporter.py b/src/codacy/reporter.py index 8882e91..bb52b93 100755 --- a/src/codacy/reporter.py +++ b/src/codacy/reporter.py @@ -6,6 +6,7 @@ import os from xml.dom import minidom import requests +from math import floor logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') @@ -61,7 +62,7 @@ def parse_report_file(report_file): # Convert decimal string to floored int percent value def percent(s): - return float(s) * 100 + return int(floor(float(s) * 100)) # Parse the XML into the format expected by the API report_xml = minidom.parse(report_file) diff --git a/tests/coverage4/coverage.json b/tests/coverage4/coverage.json index e0a780b..1a54232 100644 --- a/tests/coverage4/coverage.json +++ b/tests/coverage4/coverage.json @@ -1,8 +1,8 @@ { - "total": 50.0, + "total": 50, "fileReports": [ { - "total": 66.67, + "total": 66, "coverage": { "1": 1, "4": 1 @@ -10,7 +10,7 @@ "filename": "src/codacy/__init__.py" }, { - "total": 49.15, + "total": 49, "coverage": { "50": 1, "60": 1, diff --git a/tests/filepath/coverage.json b/tests/filepath/coverage.json index e0a780b..1a54232 100644 --- a/tests/filepath/coverage.json +++ b/tests/filepath/coverage.json @@ -1,8 +1,8 @@ { - "total": 50.0, + "total": 50, "fileReports": [ { - "total": 66.67, + "total": 66, "coverage": { "1": 1, "4": 1 @@ -10,7 +10,7 @@ "filename": "src/codacy/__init__.py" }, { - "total": 49.15, + "total": 49, "coverage": { "50": 1, "60": 1,