From 1c017ce3e11d9d8009dbf9e4371ce7682d7fc348 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)