Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

Commit 63ad8d3

Browse files
authored
Merge pull request #34 from codacy/FT-3155
Add zero lines to coverage reports
2 parents b2888eb + 9db17b0 commit 63ad8d3

File tree

8 files changed

+147
-34
lines changed

8 files changed

+147
-34
lines changed

.circleci/config.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: 2
2+
jobs:
3+
build:
4+
working_directory: ~/circleci-working-dir
5+
docker:
6+
- image: circleci/python:2.7.13
7+
# - image: circleci/python:3.6.2
8+
steps:
9+
- checkout
10+
- run:
11+
command: |
12+
sudo python -m pip install --upgrade pip setuptools wheel
13+
sudo python -m pip install --upgrade pep8 pyflakes coverage tox
14+
sudo python -m pip install --upgrade virtualenv==12.0.2
15+
- run:
16+
command: |
17+
tox -e py27,py350,pep8,pyflakes,coverage
18+
sudo python setup.py develop
19+
- deploy:
20+
name: Push coverage
21+
command: |
22+
if [ "${CIRCLE_BRANCH}" == "master" ]; then
23+
tox -e upload_coverage
24+
fi

circle.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/codacy/reporter.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ def percent(s):
141141
}
142142
for line in lines:
143143
hits = int(line.attributes['hits'].value)
144-
if hits >= 1:
145-
# The API assumes 0 if a line is missing
146-
file_report['coverage'][line.attributes['number'].value] = hits
144+
file_report['coverage'][line.attributes['number'].value] = hits
147145
report['fileReports'] += [file_report]
148146

149147
report['codeLines'] = total_lines

tests/coverage-merge/coverage-merge.json

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"coverage": {
99
"4": 1,
1010
"5": 1,
11+
"6": 0,
1112
"7": 2
1213
},
1314
"filename": "src/test/resources/TestSourceFile1.scala"
@@ -16,6 +17,7 @@
1617
"total": 66,
1718
"codeLines": 3,
1819
"coverage": {
20+
"5": 0,
1921
"9": 1,
2022
"10": 1
2123
},
@@ -25,7 +27,11 @@
2527
"total": 20,
2628
"codeLines": 5,
2729
"coverage": {
28-
"2": 1
30+
"1": 0,
31+
"2": 1,
32+
"3": 0,
33+
"4": 0,
34+
"7": 0
2935
},
3036
"filename": "src/test/resources/TestSourceFile3.scala"
3137
},
@@ -34,7 +40,8 @@
3440
"codeLines": 3,
3541
"coverage": {
3642
"1": 1,
37-
"4": 1
43+
"4": 1,
44+
"5": 0
3845
},
3946
"filename": "src/codacy/__init__.py"
4047
},
@@ -70,7 +77,37 @@
7077
"51": 1,
7178
"36": 1,
7279
"34": 1,
73-
"57": 1
80+
"57": 1,
81+
"21": 0,
82+
"23": 0,
83+
"62": 0,
84+
"63": 0,
85+
"64": 0,
86+
"69": 0,
87+
"71": 0,
88+
"73": 0,
89+
"74": 0,
90+
"76": 0,
91+
"77": 0,
92+
"81": 0,
93+
"82": 0,
94+
"83": 0,
95+
"84": 0,
96+
"86": 0,
97+
"88": 0,
98+
"89": 0,
99+
"91": 0,
100+
"92": 0,
101+
"93": 0,
102+
"95": 0,
103+
"96": 0,
104+
"98": 0,
105+
"99": 0,
106+
"100": 0,
107+
"102": 0,
108+
"103": 0,
109+
"105": 0,
110+
"106": 0
74111
},
75112
"filename": "src/codacy/reporter.py"
76113
}

tests/coverage3/coverage.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"coverage": {
99
"4": 1,
1010
"5": 1,
11+
"6": 0,
1112
"7": 2
1213
},
1314
"filename": "src/test/resources/TestSourceFile1.scala"
@@ -16,6 +17,7 @@
1617
"total": 66,
1718
"codeLines": 3,
1819
"coverage": {
20+
"5": 0,
1921
"9": 1,
2022
"10": 1
2123
},
@@ -25,7 +27,11 @@
2527
"total": 20,
2628
"codeLines": 5,
2729
"coverage": {
28-
"2": 1
30+
"1": 0,
31+
"2": 1,
32+
"3": 0,
33+
"4": 0,
34+
"7": 0
2935
},
3036
"filename": "src/test/resources/TestSourceFile3.scala"
3137
}

tests/coverage4/coverage.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,37 @@
4343
"51": 1,
4444
"36": 1,
4545
"34": 1,
46-
"57": 1
46+
"57": 1,
47+
"21": 0,
48+
"23": 0,
49+
"62": 0,
50+
"63": 0,
51+
"64": 0,
52+
"69": 0,
53+
"71": 0,
54+
"73": 0,
55+
"74": 0,
56+
"76": 0,
57+
"77": 0,
58+
"81": 0,
59+
"82": 0,
60+
"83": 0,
61+
"84": 0,
62+
"86": 0,
63+
"88": 0,
64+
"89": 0,
65+
"91": 0,
66+
"92": 0,
67+
"93": 0,
68+
"95": 0,
69+
"96": 0,
70+
"98": 0,
71+
"99": 0,
72+
"100": 0,
73+
"102": 0,
74+
"103": 0,
75+
"105": 0,
76+
"106": 0
4777
},
4878
"filename": "src/codacy/reporter.py"
4979
}

tests/filepath/coverage.json

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"codeLines": 3,
88
"coverage": {
99
"1": 1,
10-
"4": 1
10+
"4": 1,
11+
"5": 0
1112
},
1213
"filename": "__init__.py"
1314
},
@@ -43,7 +44,37 @@
4344
"51": 1,
4445
"36": 1,
4546
"34": 1,
46-
"57": 1
47+
"57": 1,
48+
"21": 0,
49+
"23": 0,
50+
"62": 0,
51+
"63": 0,
52+
"64": 0,
53+
"69": 0,
54+
"71": 0,
55+
"73": 0,
56+
"74": 0,
57+
"76": 0,
58+
"77": 0,
59+
"81": 0,
60+
"82": 0,
61+
"83": 0,
62+
"84": 0,
63+
"86": 0,
64+
"88": 0,
65+
"89": 0,
66+
"91": 0,
67+
"92": 0,
68+
"93": 0,
69+
"95": 0,
70+
"96": 0,
71+
"98": 0,
72+
"99": 0,
73+
"100": 0,
74+
"102": 0,
75+
"103": 0,
76+
"105": 0,
77+
"106": 0
4778
},
4879
"filename": "reporter.py"
4980
}

tests/tests.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,20 @@ def file_get_contents(filename):
1717
with open(filename) as f:
1818
return f.read()
1919

20+
def to_utf8(d):
21+
if type(d) is dict:
22+
result = {}
23+
for key, value in d.items():
24+
result[to_utf8(key)] = to_utf8(value)
25+
elif type(d) is unicode:
26+
return d.encode('utf8')
27+
else:
28+
return d
29+
2030
json_content = file_get_contents(expected_filename)
2131
expected = json.loads(json_content)
2232

23-
self.assertEqual(generated, expected)
33+
self.assertEqual(to_utf8(generated), to_utf8(expected))
2434

2535
def test_parser_coverage3(self):
2636
self.maxDiff = None

0 commit comments

Comments
 (0)