Skip to content

Commit

Permalink
🐛 rename score_file to score (score_file deprecated)
Browse files Browse the repository at this point in the history
Signed-off-by: rjdbcm <[email protected]>
  • Loading branch information
rjdbcm committed Jun 9, 2024
1 parent cc78500 commit 756d2c1
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions ozi/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,20 @@ def diagnostic( # pragma: no cover
return count


def score_file(rel_path: Path, count: Counter[str]) -> float: # pragma: no cover
def score_file(count: Counter[str]) -> float:
"""Score a single file comment diagnostic.
.. deprecated:: 1.11.2
Use :py:function:`ozi.comment.score` instead.
"""
return score(count)

def score(count: Counter[str]) -> float: # pragma: no cover
"""Score a single comment diagnostic.
:param rel_path: path to the file scored
:type rel_path: Path
:param count: count of lines and comments
:type count: Counter[str]
:return: file comment score out of 5.0
:return: span comment score out of 5.0
:rtype: float
"""
t1 = sum(count[i] for i in TIER1_COMMENTS)
Expand All @@ -179,7 +185,7 @@ def score_file(rel_path: Path, count: Counter[str]) -> float: # pragma: no cove
def comment_diagnostic(target: Path, rel_path: Path, file: str) -> None: # pragma: no cover
"""Run a scored comment diagnostic on a python file."""
if str(file).endswith('.py'):
with open(target.joinpath(rel_path) / file, 'r') as g:
with open(target.joinpath(rel_path) / file, 'r', encoding='UTF-8') as g:
count = diagnostic(g.readlines(), rel_path / file)
if count.total() > 0:
TAP.diagnostic(
Expand All @@ -193,5 +199,5 @@ def comment_diagnostic(target: Path, rel_path: Path, file: str) -> None: # prag
'comment_diagnostic',
str(rel_path / file),
'quality score',
f'{score_file(rel_path / file, count)}/5.0',
f'{score(count)}/5.0',
)

0 comments on commit 756d2c1

Please sign in to comment.