...
 
Commits (6)
......@@ -39,7 +39,7 @@ code_quality_diff:
stage: code_quality_diff
script:
- git fetch -a
- pip install diff-cov-lint==0.1.2
- pip install diff-cov-lint==0.1.3
- pylint --exit-zero diff_cov_lint > pylint_output.txt
- diff-cov-lint origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME origin/$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME --cov_report coverage.xml --lint_report pylint_output.txt --show_missing
only:
......
......@@ -95,7 +95,7 @@ def diff_coverage_report(diff_coverage_dict: dict,
:rtype: str
"""
ans = "=" * 24 + " DIFF COVERAGE " + "=" * 24 + "\n"
padding = max(len(filename) for filename in diff_coverage_dict)
padding = max((len(filename) for filename in diff_coverage_dict), default=0)
ans += f"{'FILE':<{padding}}\t\t\t{'COVERED'}\t{'STMTS'}\t{'PERCENT'}"
if show_missing:
ans += "\tMISSING"
......
......@@ -66,5 +66,5 @@ def diff_lint_report(diff_lint_dict: dict) -> str:
for filename in diff_lint_dict:
for line in diff_lint_dict[filename]:
ans += f"{filename}:{line}:0 {diff_lint_dict[filename][line]['error']}: "\
f"{diff_lint_dict[filename][line]['msg']}"
f"{diff_lint_dict[filename][line]['msg']}\n"
return ans
......@@ -17,7 +17,7 @@ requirements = parse_requirements('requirements.txt')
setuptools.setup(
name="diff_cov_lint",
version="0.1.2",
version="0.1.3",
author="Sergey Verentsov",
author_email="[email protected]",
description="Linting and coverage reports for diff only",
......
Subproject commit a2a6e7da51b061f1dda6755b1931c31bb519bae0
Subproject commit d4e8f913e078b08902b5874f93f37cbc93876628
from pathlib import Path
true_processed_diff = {
'src/add.py': [1, 2, 3, 5, 6, 7, 9, 10],
'src/add.py': [1, 2, 3, 5, 6, 7, 9, 10, 11],
'src/modify.py': [2, 6],
'test/test_all.py': [6, 8, 11, 12, 15]
}
......@@ -16,7 +16,8 @@ true_processed_cov = {
6: 1,
7: 1,
9: 1,
10: 0 # function_add_badcode
10: 0, # function_add_badcode
11: 0
},
'src/modify.py': {
1: 1,
......@@ -49,7 +50,8 @@ true_filtered_cov = {
6: 1,
7: 1,
9: 1,
10: 0
10: 0,
11: 0
},
'src/modify.py': {
2: 0,
......@@ -59,18 +61,18 @@ true_filtered_cov = {
true_report = """======================== DIFF COVERAGE ========================
FILE COVERED STMTS PERCENT
src/add.py 5 8 62.5%
src/add.py 5 9 55.6%
src/modify.py 1 2 50.0%
===============================================================
TOTAL DIFF COV 6 10 60.0%
TOTAL DIFF COV 6 11 54.5%
"""
true_report_missing = """======================== DIFF COVERAGE ========================
FILE COVERED STMTS PERCENT MISSING
src/add.py 5 8 62.5% 2-3, 10
src/add.py 5 9 55.6% 2-3, 10-11
src/modify.py 1 2 50.0% 2
===============================================================
TOTAL DIFF COV 6 10 60.0%
TOTAL DIFF COV 6 11 54.5%
"""
true_processed_lint = {
......@@ -80,6 +82,12 @@ true_processed_lint = {
'E0602',
'msg':
"Undefined variable 'this_line_makes_no_sense' (undefined-variable)"
},
11: {
'error':
'E0602',
'msg':
"Undefined variable 'this_line_also_makes_no_sense' (undefined-variable)"
}
},
'src/modify.py': {
......@@ -107,19 +115,31 @@ true_filtered_lint = {
'E0602',
'msg':
"Undefined variable 'this_line_makes_no_sense' (undefined-variable)"
},
11: {
'error':
'E0602',
'msg':
"Undefined variable 'this_line_also_makes_no_sense' (undefined-variable)"
}
}
}
true_lint_report = """========================== DIFF LINT ==========================
src/add.py:10:0 E0602: Undefined variable 'this_line_makes_no_sense' (undefined-variable)"""
src/add.py:10:0 E0602: Undefined variable 'this_line_makes_no_sense' (undefined-variable)
src/add.py:11:0 E0602: Undefined variable 'this_line_also_makes_no_sense' (undefined-variable)
"""
true_full_report = """======================== DIFF COVERAGE ========================
FILE COVERED STMTS PERCENT
src/add.py 5 8 62.5%
src/add.py 5 9 55.6%
src/modify.py 1 2 50.0%
===============================================================
TOTAL DIFF COV 6 10 60.0%
TOTAL DIFF COV 6 11 54.5%
========================== DIFF LINT ==========================
src/add.py:10:0 E0602: Undefined variable 'this_line_makes_no_sense' (undefined-variable)"""
\ No newline at end of file
src/add.py:10:0 E0602: Undefined variable 'this_line_makes_no_sense' (undefined-variable)
src/add.py:11:0 E0602: Undefined variable 'this_line_also_makes_no_sense' (undefined-variable)
"""