Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2271)

Unified Diff: chrome/browser/web_dev_style/resource_checker.py

Issue 410603002: web_dev_style: add presubmit for superfluous </include> tags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/web_dev_style/regex_check.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/web_dev_style/resource_checker.py
diff --git a/chrome/browser/web_dev_style/resource_checker.py b/chrome/browser/web_dev_style/resource_checker.py
new file mode 100644
index 0000000000000000000000000000000000000000..860d88c6c305b11d548c7f4a380ff812aeefb5d0
--- /dev/null
+++ b/chrome/browser/web_dev_style/resource_checker.py
@@ -0,0 +1,45 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Presubmit for Chromium HTML/CSS/JS resources. See chrome/browser/PRESUBMIT.py.
+"""
+
+import regex_check
+
+
+class ResourceChecker(object):
+ def __init__(self, input_api, output_api, file_filter=None):
+ self.input_api = input_api
+ self.output_api = output_api
+ self.file_filter = file_filter
+
+ def IncludeCheck(self, line_number, line):
+ return regex_check.RegexCheck(self.input_api.re, line_number, line,
+ "(</include>)", "</include> is unnecessary. Please remove.")
+
+ def RunChecks(self):
+ """Check for violations of the Chromium web development style guide. See
+ http://chromium.org/developers/web-development-style-guide
+ """
+ results = []
+
+ affected_files = self.input_api.change.AffectedFiles(
+ file_filter=self.file_filter, include_deletes=False)
+
+ for f in affected_files:
+ errors = []
+
+ for line_number, line in enumerate(f.NewContents(), start=1):
+ error = self.IncludeCheck(line_number, line)
+ if error:
+ errors.append(error)
+
+ if errors:
+ abs_local_path = f.AbsoluteLocalPath()
+ file_indicator = 'Found resources style issues in %s' % abs_local_path
+ prompt_msg = file_indicator + '\n\n' + '\n'.join(errors) + '\n'
+ results.append(self.output_api.PresubmitPromptWarning(prompt_msg))
+
+ return results
« no previous file with comments | « chrome/browser/web_dev_style/regex_check.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698