Skip to content

Commit b8ad7f9

Browse files
author
Tom Reitz
committed
fix bugs line_number bugs
1 parent 18637d0 commit b8ad7f9

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lightbeam/validate.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,12 @@ async def validate_endpoint(self, endpoint):
217217

218218
for file_name in data_files:
219219
self.logger.info(f"validating {file_name} against {definition} schema...")
220+
file_counter = 0
220221
with open(file_name) as file:
221222
for i, line in enumerate(file):
222223
line_number = i + 1
223224
total_counter += 1
225+
file_counter += 1
224226
data = line.strip()
225227

226228
tasks.append(asyncio.create_task(
@@ -255,7 +257,7 @@ async def validate_endpoint(self, endpoint):
255257
num_others = self.lightbeam.num_errors - self.MAX_VALIDATION_ERRORS_TO_DISPLAY
256258
if self.lightbeam.num_errors > self.MAX_VALIDATION_ERRORS_TO_DISPLAY:
257259
self.logger.warn(f"... and {num_others} others!")
258-
self.logger.warn(f"... VALIDATION ERRORS on {self.lightbeam.num_errors} of {line_counter} lines in {file_name}; see details above.")
260+
self.logger.warn(f"... VALIDATION ERRORS on {self.lightbeam.num_errors} of {file_counter} lines in {file_name}; see details above.")
259261

260262
# free up some memory
261263
self.uniqueness_hashes = {}
@@ -298,7 +300,7 @@ async def do_validate_payload(self, endpoint, file_name, data, line_number):
298300
if "uniqueness" in self.validation_methods:
299301
error_message = self.violates_uniqueness(endpoint, payload, path="")
300302
if error_message != "":
301-
self.log_validation_error(endpoint, file_name, line_counter, "uniqueness", error_message)
303+
self.log_validation_error(endpoint, file_name, line_number, "uniqueness", error_message)
302304

303305
# check references values are valid
304306
if "references" in self.validation_methods and "Descriptor" not in endpoint: # Descriptors have no references

0 commit comments

Comments
 (0)