This commit is contained in:
Anit Lulla 2024-03-19 10:46:52 -03:00 committed by GitHub
commit 19cc12adae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

19
cpplint/cpplint.py vendored
View File

@ -161,6 +161,7 @@ Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
filter=+filter1,-filter2,... filter=+filter1,-filter2,...
exclude_files=regex exclude_files=regex
linelength=80 linelength=80
access_indent=1
root=subdir root=subdir
headers=x,y,... headers=x,y,...
@ -178,6 +179,9 @@ Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
"linelength" allows to specify the allowed line length for the project. "linelength" allows to specify the allowed line length for the project.
"access_indent" allows to specify indentation levels for access modifiers
such as public, private, and protected.
The "root" option is similar in function to the --root flag (see example The "root" option is similar in function to the --root flag (see example
above). Paths are relative to the directory of the CPPLINT.cfg. above). Paths are relative to the directory of the CPPLINT.cfg.
@ -556,6 +560,9 @@ _root_debug = False
# This is set by --linelength flag. # This is set by --linelength flag.
_line_length = 80 _line_length = 80
# The indentation level for access modifiers (i.e. public/private)
_access_indent = 1
# The allowed extensions for file names # The allowed extensions for file names
# This is set by --extensions flag. # This is set by --extensions flag.
_valid_extensions = set(['cc', 'h', 'cpp', 'cu', 'cuh']) _valid_extensions = set(['cc', 'h', 'cpp', 'cu', 'cuh'])
@ -2691,7 +2698,7 @@ class NestingState(object):
# Check that access keywords are indented +1 space. Skip this # Check that access keywords are indented +1 space. Skip this
# check if the keywords are not preceded by whitespaces. # check if the keywords are not preceded by whitespaces.
indent = access_match.group(1) indent = access_match.group(1)
if (len(indent) != classinfo.class_indent + 1 and if (len(indent) != classinfo.class_indent + _access_indent and
Match(r'^\s*$', indent)): Match(r'^\s*$', indent)):
if classinfo.is_struct: if classinfo.is_struct:
parent = 'struct ' + classinfo.name parent = 'struct ' + classinfo.name
@ -2701,8 +2708,8 @@ class NestingState(object):
if access_match.group(3): if access_match.group(3):
slots = access_match.group(3) slots = access_match.group(3)
error(filename, linenum, 'whitespace/indent', 3, error(filename, linenum, 'whitespace/indent', 3,
'%s%s: should be indented +1 space inside %s' % ( '%s%s: should be indented +%i space inside %s' % (
access_match.group(2), slots, parent)) access_match.group(2), slots, _access_indent, parent))
# Consume braces or semicolons from what's left of the line # Consume braces or semicolons from what's left of the line
while True: while True:
@ -6004,6 +6011,12 @@ def ProcessConfigOverrides(filename):
_line_length = int(val) _line_length = int(val)
except ValueError: except ValueError:
sys.stderr.write('Line length must be numeric.') sys.stderr.write('Line length must be numeric.')
elif name == 'access_indent':
global _access_indent
try:
_access_indent = int(val)
except ValueError:
sys.stderr.write('Access indent must be numeric.')
elif name == 'root': elif name == 'root':
global _root global _root
# root directories are specified relative to CPPLINT.cfg dir. # root directories are specified relative to CPPLINT.cfg dir.