From 11b341547a92b6b33d8a175c39b23ebeef49dda2 Mon Sep 17 00:00:00 2001 From: Fletcher Woodruff Date: Thu, 23 Apr 2020 21:21:40 +0000 Subject: [PATCH] cpplint: move a build/include check to subcategory There is a cpplint include check that ensures that all includes have a directory name preceding them. However, if all source lives in the root of a repository, there is no point in having a directory. Because this check lives under 'build/include', it's impossible to filter without filtering other useful checks. Move it to 'build/include_directory' so it can be more easily filtered. BUG=chromium:1073191 TEST=cros lint on a file with 'filter=-build/include_directory' in CPPLINT.cfg Change-Id: Ie15fb2398a6d0297ef96219e67076ea262abf853 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2159690 Reviewed-by: Edward Lesmes Commit-Queue: Edward Lesmes Auto-Submit: Fletcher Woodruff --- cpplint.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cpplint.py b/cpplint.py index f7ad8d8b7..abfb5116a 100755 --- a/cpplint.py +++ b/cpplint.py @@ -188,6 +188,7 @@ _ERROR_CATEGORIES = [ 'build/header_guard', 'build/include', 'build/include_alpha', + 'build/include_directory', 'build/include_order', 'build/include_what_you_use', 'build/namespaces', @@ -424,8 +425,8 @@ _TYPES = re.compile( r')$') -# These headers are excluded from [build/include] and [build/include_order] -# checks: +# These headers are excluded from [build/include], [build/include_directory], +# and [build/include_order] checks: # - Anything not following google file name conventions (containing an # uppercase character, such as Python.h or nsStringAPI.h, for example). # - Lua headers. @@ -4412,7 +4413,7 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error): # naming convention but not the include convention. match = Match(r'#include\s*"([^/]+\.h)"', line) if match and not _THIRD_PARTY_HEADERS_PATTERN.match(match.group(1)): - error(filename, linenum, 'build/include', 4, + error(filename, linenum, 'build/include_directory', 4, 'Include the directory when naming .h files') # we shouldn't include a file more than once. actually, there are a