From 4aaf0cfd27f170cc51f3853c3eb324f276e1dc3c Mon Sep 17 00:00:00 2001 From: "Lara A. Ross" Date: Sat, 31 Jan 2015 21:30:33 -0800 Subject: [PATCH] Sort errors by the position of their occurence Closes #12. --- proselint/command_line.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/proselint/command_line.py b/proselint/command_line.py index 8316ba497..4b3f506fd 100644 --- a/proselint/command_line.py +++ b/proselint/command_line.py @@ -50,10 +50,13 @@ def proselint(version, file): else: with open(file, "r") as f: text = f.read() + errors = [] for check in checks: - errors = check(text) - if errors: - for error in errors: - (start, end, error_code, msg) = error - (line, column) = line_and_column(text, start) - log_error(file, line, column, error_code, msg) + errors += check(text) + + errors = sorted(errors) + + for error in errors: + (start, end, error_code, msg) = error + (line, column) = line_and_column(text, start) + log_error(file, line, column, error_code, msg)