From 395b08361578ac1607a8b6a0c1ea2ad18e1039ca Mon Sep 17 00:00:00 2001 From: "Lara A. Ross" <lara@amperser.com> 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)