From 8cb7e98a34f886bcb79e4c2667fc25a77e2cd56c Mon Sep 17 00:00:00 2001 From: James Graham Date: Sat, 11 Jun 2016 09:26:50 +0100 Subject: [PATCH] Bug 1279812 - Update wpt lint for mozlint compatibility, r=Ms2ger MozReview-Commit-ID: 6UJj8FSs5Ot --- testing/web-platform/tests/tools/lint/lint.py | 64 +++++++++++++------ 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/testing/web-platform/tests/tools/lint/lint.py b/testing/web-platform/tests/tools/lint/lint.py index 66720205efd3..91342179f21d 100644 --- a/testing/web-platform/tests/tools/lint/lint.py +++ b/testing/web-platform/tests/tools/lint/lint.py @@ -2,6 +2,7 @@ from __future__ import print_function, unicode_literals import argparse import fnmatch +import json import os import re import subprocess @@ -78,7 +79,7 @@ def filter_whitelist_errors(data, path, errors): for file_match, whitelist_errors in iteritems(data): if fnmatch.fnmatch(path, file_match): - for i, (error_type, msg, line) in enumerate(errors): + for i, (error_type, msg, path, line) in enumerate(errors): if "*" in whitelist_errors: whitelisted[i] = True elif error_type in whitelist_errors: @@ -107,32 +108,39 @@ class Regexp(object): class TrailingWhitespaceRegexp(Regexp): pattern = b"[ \t\f\v]$" error = "TRAILING WHITESPACE" + description = "Whitespace at EOL" class TabsRegexp(Regexp): pattern = b"^\t" error = "INDENT TABS" + description = "Tabs used for indentation" class CRRegexp(Regexp): pattern = b"\r$" error = "CR AT EOL" + description = "CR character in line separator" class W3CTestOrgRegexp(Regexp): pattern = b"w3c\-test\.org" error = "W3C-TEST.ORG" + description = "External w3c-test.org domain used" class Webidl2Regexp(Regexp): pattern = b"webidl2\.js" error = "WEBIDL2.JS" + description = "Legacy webidl2.js script used" class ConsoleRegexp(Regexp): pattern = b"console\.[a-zA-Z]+\s*\(" error = "CONSOLE" file_extensions = [".html", ".htm", ".js", ".xht", ".html", ".svg"] + description = "Console logging API used" class PrintRegexp(Regexp): pattern = b"print(?:\s|\s*\()" error = "PRINT STATEMENT" file_extensions = [".py"] + description = "Print function used" regexps = [item() for item in [TrailingWhitespaceRegexp, @@ -151,7 +159,7 @@ def check_regexp_line(repo_root, path, f): for i, line in enumerate(f): for regexp in applicable_regexps: if regexp.search(line): - errors.append((regexp.error, "%s line %i" % (path, i+1), i+1)) + errors.append((regexp.error, regexp.description, path, i+1)) return errors @@ -167,34 +175,34 @@ def check_parsed(repo_root, path, f): return [] if source_file.root is None: - return [("PARSE-FAILED", "Unable to parse file %s" % path, None)] + return [("PARSE-FAILED", "Unable to parse file", path, None)] if len(source_file.timeout_nodes) > 1: - errors.append(("MULTIPLE-TIMEOUT", "%s more than one meta name='timeout'" % path, None)) + errors.append(("MULTIPLE-TIMEOUT", "More than one meta name='timeout'", path, None)) for timeout_node in source_file.timeout_nodes: timeout_value = timeout_node.attrib.get("content", "").lower() if timeout_value != "long": - errors.append(("INVALID-TIMEOUT", "%s invalid timeout value %s" % (path, timeout_value), None)) + errors.append(("INVALID-TIMEOUT", "Invalid timeout value %s" % timeout_value, path, None)) if source_file.testharness_nodes: if len(source_file.testharness_nodes) > 1: errors.append(("MULTIPLE-TESTHARNESS", - "%s more than one