Skip to content

Commit

Permalink
Merge pull request #14 from w3c/sideshowbarker/messages
Browse files Browse the repository at this point in the history
Make the lint tool emit a pointer to the docs.
  • Loading branch information
sideshowbarker committed Jun 17, 2015
2 parents 9fc4323 + 26694b4 commit 364be4e
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions lint/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,27 +232,46 @@ def output_error_count(error_count):

def main():
error_count = defaultdict(int)
last = None

def run_lint(path, fn, *args):
def run_lint(path, fn, last, *args):
errors = whitelist_errors(path, fn(path, *args))
if errors:
last = (errors[-1][0], path)

output_errors(errors)
for error_type, error, line in errors:
error_count[error_type] += 1
return last

for path in iter_files():
abs_path = os.path.join(repo_root, path)
if not os.path.exists(path):
continue
for path_fn in path_lints:
run_lint(path, path_fn)
last = run_lint(path, path_fn, last)

if not os.path.isdir(abs_path):
with open(abs_path) as f:
for file_fn in file_lints:
run_lint(path, file_fn, f)
last = run_lint(path, file_fn, last, f)
f.seek(0)

output_error_count(error_count)
if error_count:
print
print "You must fix all errors; for details on how to fix them, see"
print "https://github.com/w3c/web-platform-tests/blob/master/docs/lint-tool.md"
print
print "However, instead of fixing a particular error, it's sometimes"
print "OK to add a line to the lint.whitelist file in the root of the"
print "web-platform-tests directory to make the lint tool ignore it."
print
print "For example, to make the lint tool ignore all '%s'" % last[0]
print "errors in the %s file," % last[1]
print "you could add the following line to the lint.whitelist file."
print
print "%s:%s" % (last[0], last[1])
return sum(error_count.itervalues())

path_lints = [check_path_length]
Expand Down

0 comments on commit 364be4e

Please sign in to comment.