Skip to content

Commit 8aa1daf

Browse files
Trotttargos
authored andcommitted
tools: bump cpplint to 1.5.3
PR-URL: #36235 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
1 parent fdec18b commit 8aa1daf

File tree

1 file changed

+27
-114
lines changed

1 file changed

+27
-114
lines changed

tools/cpplint.py

+27-114
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
# if empty, use defaults
6060
_valid_extensions = set([])
6161

62-
__VERSION__ = '1.5.2'
62+
__VERSION__ = '1.5.3'
6363

6464
try:
6565
xrange # Python 2
@@ -295,7 +295,6 @@
295295
'build/include',
296296
'build/include_subdir',
297297
'build/include_alpha',
298-
'build/include_inline',
299298
'build/include_order',
300299
'build/include_what_you_use',
301300
'build/namespaces_headers',
@@ -311,13 +310,11 @@
311310
'readability/constructors',
312311
'readability/fn_size',
313312
'readability/inheritance',
314-
'readability/pointer_notation',
315313
'readability/multiline_comment',
316314
'readability/multiline_string',
317315
'readability/namespace',
318316
'readability/nolint',
319317
'readability/nul',
320-
'readability/null_usage',
321318
'readability/strings',
322319
'readability/todo',
323320
'readability/utf8',
@@ -337,7 +334,6 @@
337334
'runtime/string',
338335
'runtime/threadsafe_fn',
339336
'runtime/vlog',
340-
'runtime/v8_persistent',
341337
'whitespace/blank_line',
342338
'whitespace/braces',
343339
'whitespace/comma',
@@ -358,6 +354,13 @@
358354
'whitespace/todo',
359355
]
360356

357+
# keywords to use with --outputs which generate stdout for machine processing
358+
_MACHINE_OUTPUTS = [
359+
'junit',
360+
'sed',
361+
'gsed'
362+
]
363+
361364
# These error categories are no longer enforced by cpplint, but for backwards-
362365
# compatibility they may still appear in NOLINT comments.
363366
_LEGACY_ERROR_CATEGORIES = [
@@ -839,14 +842,6 @@
839842
'Missing space after ,': r's/,\([^ ]\)/, \1/g',
840843
}
841844

842-
_NULL_TOKEN_PATTERN = re.compile(r'\bNULL\b')
843-
844-
_V8_PERSISTENT_PATTERN = re.compile(r'\bv8::Persistent\b')
845-
846-
_RIGHT_LEANING_POINTER_PATTERN = re.compile(r'[^=|(,\s><);&?:}]'
847-
r'(?<!(sizeof|return))'
848-
r'\s\*[a-zA-Z_][0-9a-zA-Z_]*')
849-
850845
_regexp_compile_cache = {}
851846

852847
# {str, set(int)}: a map from error categories to sets of linenumbers
@@ -866,7 +861,7 @@
866861
# Files to exclude from linting. This is set by the --exclude flag.
867862
_excludes = None
868863

869-
# Whether to suppress PrintInfo messages
864+
# Whether to supress all PrintInfo messages, UNRELATED to --quiet flag
870865
_quiet = False
871866

872867
# The allowed line length of files.
@@ -1087,11 +1082,10 @@ class _IncludeState(object):
10871082
# needs to move backwards, CheckNextIncludeOrder will raise an error.
10881083
_INITIAL_SECTION = 0
10891084
_MY_H_SECTION = 1
1090-
_OTHER_H_SECTION = 2
1091-
_OTHER_SYS_SECTION = 3
1092-
_C_SECTION = 4
1093-
_CPP_SECTION = 5
1094-
1085+
_C_SECTION = 2
1086+
_CPP_SECTION = 3
1087+
_OTHER_SYS_SECTION = 4
1088+
_OTHER_H_SECTION = 5
10951089

10961090
_TYPE_NAMES = {
10971091
_C_SYS_HEADER: 'C system header',
@@ -1357,7 +1351,9 @@ def PrintErrorCounts(self):
13571351
self.PrintInfo('Total errors found: %d\n' % self.error_count)
13581352

13591353
def PrintInfo(self, message):
1360-
if not _quiet and self.output_format != 'junit':
1354+
# _quiet does not represent --quiet flag.
1355+
# Hide infos from stdout to keep stdout pure for machine consumption
1356+
if not _quiet and self.output_format not in _MACHINE_OUTPUTS:
13611357
sys.stdout.write(message)
13621358

13631359
def PrintError(self, message):
@@ -2524,21 +2520,6 @@ def CheckForBadCharacters(filename, lines, error):
25242520
error(filename, linenum, 'readability/nul', 5, 'Line contains NUL byte.')
25252521

25262522

2527-
def CheckInlineHeader(filename, include_state, error):
2528-
"""Logs an error if both a header and its inline variant are included."""
2529-
2530-
all_headers = dict(item for sublist in include_state.include_list
2531-
for item in sublist)
2532-
bad_headers = set('%s.h' % name[:-6] for name in all_headers.keys()
2533-
if name.endswith('-inl.h'))
2534-
bad_headers &= set(all_headers.keys())
2535-
2536-
for name in bad_headers:
2537-
err = '%s includes both %s and %s-inl.h' % (filename, name, name)
2538-
linenum = all_headers[name]
2539-
error(filename, linenum, 'build/include_inline', 5, err)
2540-
2541-
25422523
def CheckForNewlineAtEOF(filename, lines, error):
25432524
"""Logs an error if there is no newline char at the end of the file.
25442525
@@ -3562,7 +3543,7 @@ def CheckForFunctionLengths(filename, clean_lines, linenum,
35623543
"""Reports for long function bodies.
35633544
35643545
For an overview why this is done, see:
3565-
https://google.github.io/styleguide/cppguide.html#Write_Short_Functions
3546+
https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions
35663547
35673548
Uses a simplistic algorithm assuming other style guidelines
35683549
(especially spacing) are followed.
@@ -4788,71 +4769,6 @@ def CheckAltTokens(filename, clean_lines, linenum, error):
47884769
'Use operator %s instead of %s' % (
47894770
_ALT_TOKEN_REPLACEMENT[match.group(1)], match.group(1)))
47904771

4791-
def CheckNullTokens(filename, clean_lines, linenum, error):
4792-
"""Check NULL usage.
4793-
4794-
Args:
4795-
filename: The name of the current file.
4796-
clean_lines: A CleansedLines instance containing the file.
4797-
linenum: The number of the line to check.
4798-
error: The function to call with any errors found.
4799-
"""
4800-
line = clean_lines.elided[linenum]
4801-
4802-
# Avoid preprocessor lines
4803-
if Match(r'^\s*#', line):
4804-
return
4805-
4806-
if line.find('/*') >= 0 or line.find('*/') >= 0:
4807-
return
4808-
4809-
for match in _NULL_TOKEN_PATTERN.finditer(line):
4810-
error(filename, linenum, 'readability/null_usage', 2,
4811-
'Use nullptr instead of NULL')
4812-
4813-
def CheckV8PersistentTokens(filename, clean_lines, linenum, error):
4814-
"""Check v8::Persistent usage.
4815-
4816-
Args:
4817-
filename: The name of the current file.
4818-
clean_lines: A CleansedLines instance containing the file.
4819-
linenum: The number of the line to check.
4820-
error: The function to call with any errors found.
4821-
"""
4822-
line = clean_lines.elided[linenum]
4823-
4824-
# Avoid preprocessor lines
4825-
if Match(r'^\s*#', line):
4826-
return
4827-
4828-
if line.find('/*') >= 0 or line.find('*/') >= 0:
4829-
return
4830-
4831-
for match in _V8_PERSISTENT_PATTERN.finditer(line):
4832-
error(filename, linenum, 'runtime/v8_persistent', 2,
4833-
'Use v8::Global instead of v8::Persistent')
4834-
4835-
def CheckLeftLeaningPointer(filename, clean_lines, linenum, error):
4836-
"""Check for left-leaning pointer placement.
4837-
4838-
Args:
4839-
filename: The name of the current file.
4840-
clean_lines: A CleansedLines instance containing the file.
4841-
linenum: The number of the line to check.
4842-
error: The function to call with any errors found.
4843-
"""
4844-
line = clean_lines.elided[linenum]
4845-
4846-
# Avoid preprocessor lines
4847-
if Match(r'^\s*#', line):
4848-
return
4849-
4850-
if '/*' in line or '*/' in line:
4851-
return
4852-
4853-
for match in _RIGHT_LEANING_POINTER_PATTERN.finditer(line):
4854-
error(filename, linenum, 'readability/pointer_notation', 2,
4855-
'Use left leaning pointer instead of right leaning')
48564772

48574773
def GetLineWidth(line):
48584774
"""Determines the width of the line in column positions.
@@ -5007,9 +4923,6 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
50074923
CheckSpacingForFunctionCall(filename, clean_lines, linenum, error)
50084924
CheckCheck(filename, clean_lines, linenum, error)
50094925
CheckAltTokens(filename, clean_lines, linenum, error)
5010-
CheckNullTokens(filename, clean_lines, linenum, error)
5011-
CheckV8PersistentTokens(filename, clean_lines, linenum, error)
5012-
CheckLeftLeaningPointer(filename, clean_lines, linenum, error)
50134926
classinfo = nesting_state.InnermostClass()
50144927
if classinfo:
50154928
CheckSectionSpacing(filename, clean_lines, classinfo, linenum, error)
@@ -5195,10 +5108,11 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error):
51955108
include_state.include_list[-1].append((include, linenum))
51965109

51975110
# We want to ensure that headers appear in the right order:
5198-
# 1) for foo.cc, foo.h
5199-
# 2) other project headers
5200-
# 3) c system files
5201-
# 4) cpp system files
5111+
# 1) for foo.cc, foo.h (preferred location)
5112+
# 2) c system files
5113+
# 3) cpp system files
5114+
# 4) for foo.cc, foo.h (deprecated location)
5115+
# 5) other google headers
52025116
#
52035117
# We classify each include statement as one of those 5 types
52045118
# using a number of techniques. The include_state object keeps
@@ -5461,7 +5375,7 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension,
54615375
and line[-1] != '\\'):
54625376
error(filename, linenum, 'build/namespaces_headers', 4,
54635377
'Do not use unnamed namespaces in header files. See '
5464-
'https://google.github.io/styleguide/cppguide.html#Namespaces'
5378+
'https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces'
54655379
' for more information.')
54665380

54675381

@@ -6583,8 +6497,6 @@ def ProcessFileData(filename, file_extension, lines, error,
65836497

65846498
CheckForNewlineAtEOF(filename, lines, error)
65856499

6586-
CheckInlineHeader(filename, include_state, error)
6587-
65886500
def ProcessConfigOverrides(filename):
65896501
""" Loads the configuration files and processes the config overrides.
65906502
@@ -6603,7 +6515,7 @@ def ProcessConfigOverrides(filename):
66036515
if not base_name:
66046516
break # Reached the root directory.
66056517

6606-
cfg_file = os.path.join(abs_path, ".cpplint")
6518+
cfg_file = os.path.join(abs_path, "CPPLINT.cfg")
66076519
abs_filename = abs_path
66086520
if not os.path.isfile(cfg_file):
66096521
continue
@@ -6840,9 +6752,9 @@ def ParseArguments(args):
68406752
if opt == '--version':
68416753
PrintVersion()
68426754
elif opt == '--output':
6843-
if val not in ('emacs', 'vs7', 'eclipse', 'junit'):
6755+
if val not in ('emacs', 'vs7', 'eclipse', 'junit', 'sed', 'gsed'):
68446756
PrintUsage('The only allowed output formats are emacs, vs7, eclipse '
6845-
'and junit.')
6757+
'sed, gsed and junit.')
68466758
output_format = val
68476759
elif opt == '--quiet':
68486760
quiet = True
@@ -6985,3 +6897,4 @@ def main():
69856897

69866898
if __name__ == '__main__':
69876899
main()
6900+

0 commit comments

Comments
 (0)