Skip to content

Commit da34344

Browse files
Merge pull request #327 from codecov/joseph/fix-unset-lineno
Fix lineno being unset
2 parents e1fbc08 + ae8d4b0 commit da34344

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

codecov_cli/services/upload/upload_collector.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ def _get_file_fixes(
112112

113113
try:
114114
with open(filename, "r") as f:
115+
# If lineno is unset that means that the
116+
# file is empty thus the eof should be 0
117+
# so lineno will be set to -1 here
118+
lineno = -1
119+
# overwrite lineno in this for loop
120+
# if f is empty, lineno stays at -1
115121
for lineno, line_content in enumerate(f):
116122
if any(
117123
pattern.match(line_content)
@@ -123,7 +129,6 @@ def _get_file_fixes(
123129
for pattern in fix_patterns_to_apply.without_reason
124130
):
125131
fixed_lines_without_reason.add(lineno + 1)
126-
127132
if fix_patterns_to_apply.eof:
128133
eof = lineno + 1
129134
except UnicodeDecodeError as err:

0 commit comments

Comments
 (0)