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

Unified Diff: PRESUBMIT.py

Issue 1481723003: Enable cpplint for webrtc/video_engine (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month 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
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index a832761c89dbd05a4205729a132260d5df334b22..3fdfe7fc111eea8b658a1eeb6f4eb0560674375c 100755
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -14,6 +14,12 @@ import subprocess
import sys
+# Directories that will be scanned by cpplint by the presubmit script.
+CPPLINT_DIRS = [
+ 'webrtc/video_engine',
+]
+
+
def _CheckNoIOStreamInHeaders(input_api, output_api):
"""Checks to make sure no .h files include <iostream>."""
files = []
@@ -54,6 +60,14 @@ def _CheckNoFRIEND_TEST(input_api, output_api):
'use FRIEND_TEST_ALL_PREFIXES() instead.\n' + '\n'.join(problems))]
+def _IsLintWhitelisted(whitelist_dirs, file_path):
+ """ Checks if a file is whitelisted for lint check."""
+ for path in whitelist_dirs:
+ if os.path.dirname(file_path).startswith(path):
+ return True
+ return False
+
+
def _CheckApprovedFilesLintClean(input_api, output_api,
source_file_filter=None):
"""Checks that all new or whitelisted .cc and .h files pass cpplint.py.
@@ -68,6 +82,10 @@ def _CheckApprovedFilesLintClean(input_api, output_api,
# pylint: disable=W0212
cpplint._cpplint_state.ResetErrorCounts()
+ # Create a platform independent whitelist for the CPPLINT_DIRS.
+ whitelist_dirs = [input_api.os_path.join(*path.split('/'))
+ for path in CPPLINT_DIRS]
+
# Use the strictest verbosity level for cpplint.py (level 1) which is the
# default when running cpplint.py from command line.
# To make it possible to work with not-yet-converted code, we're only applying
@@ -76,7 +94,7 @@ def _CheckApprovedFilesLintClean(input_api, output_api,
files = []
for f in input_api.AffectedSourceFiles(source_file_filter):
# Note that moved/renamed files also count as added.
- if f.Action() == 'A':
+ if f.Action() == 'A' or _IsLintWhitelisted(whitelist_dirs, f.LocalPath()):
files.append(f.AbsoluteLocalPath())
for file_name in files:
@@ -249,6 +267,7 @@ def _RunPythonTests(input_api, output_api):
def _CommonChecks(input_api, output_api):
"""Checks common to both upload and commit."""
results = []
+ results.extend(_CheckApprovedFilesLintClean(input_api, output_api))
results.extend(input_api.canned_checks.RunPylint(input_api, output_api,
black_list=(r'^.*gviz_api\.py$',
r'^.*gaeunit\.py$',
@@ -298,7 +317,6 @@ def _CommonChecks(input_api, output_api):
input_api, output_api))
results.extend(input_api.canned_checks.CheckChangeTodoHasOwner(
input_api, output_api))
- results.extend(_CheckApprovedFilesLintClean(input_api, output_api))
results.extend(_CheckNoIOStreamInHeaders(input_api, output_api))
results.extend(_CheckNoFRIEND_TEST(input_api, output_api))
results.extend(_CheckGypChanges(input_api, output_api))
« no previous file with comments | « no previous file | webrtc/video_engine/overuse_frame_detector.h » ('j') | webrtc/video_engine/overuse_frame_detector.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698