Skip to content

Commit

Permalink
lint: make output machine readable (#37)
Browse files Browse the repository at this point in the history
Using Unix-style line number links and delimitors makes it easier to
parse the output using standard tools.

Specifically, popular editors are able to understand how to navigate
directly to a file's line number, and awk can be used to parse the
different fields.
  • Loading branch information
andreastt authored and gsnedders committed Feb 23, 2017
1 parent 95b0f83 commit 96948da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lint/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ def output_errors_text(errors):
for error_type, description, path, line_number in errors:
pos_string = path
if line_number:
pos_string += " %s" % line_number
print("%s: %s %s" % (error_type, pos_string, description))
pos_string += ":%s" % line_number
print("%s: %s (%s)" % (pos_string, description, error_type))

def output_errors_json(errors):
for error_type, error, path, line_number in errors:
Expand Down
4 changes: 2 additions & 2 deletions lint/tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_lint_failing(capsys):
assert mocked_check_file_contents.call_count == 1
out, err = capsys.readouterr()
assert "TRAILING WHITESPACE" in out
assert "broken.html 1 " in out
assert "broken.html:1" in out
assert err == ""


Expand All @@ -164,7 +164,7 @@ def test_lint_passing_and_failing(capsys):
assert mocked_check_file_contents.call_count == 2
out, err = capsys.readouterr()
assert "TRAILING WHITESPACE" in out
assert "broken.html 1 " in out
assert "broken.html:1" in out
assert "okay.html" not in out
assert err == ""

Expand Down

0 comments on commit 96948da

Please sign in to comment.