Skip to content

Commit 2322e4f

Browse files
committed
Make "root" flag configurable via CPPLINT.CFG
1 parent 175866f commit 2322e4f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cpplint/cpplint.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
filter=+filter1,-filter2,...
143143
exclude_files=regex
144144
linelength=80
145+
root=subdir
145146
146147
"set noparent" option prevents cpplint from traversing directory tree
147148
upwards looking for more .cfg files in parent directories. This option
@@ -157,6 +158,9 @@
157158
158159
"linelength" allows to specify the allowed line length for the project.
159160
161+
The "root" option is similar in function to the --root flag (see example
162+
above).
163+
160164
CPPLINT.cfg has an effect on files in the same directory and all
161165
sub-directories, unless overridden by a nested configuration file.
162166
@@ -1666,7 +1670,7 @@ def GetHeaderGuardCPPVariable(filename):
16661670
filename = re.sub(r'/\.flymake/([^/]*)$', r'/\1', filename)
16671671
# Replace 'c++' with 'cpp'.
16681672
filename = filename.replace('C++', 'cpp').replace('c++', 'cpp')
1669-
1673+
16701674
fileinfo = FileInfo(filename)
16711675
file_path_from_root = fileinfo.RepositoryName()
16721676
if _root:
@@ -4794,7 +4798,7 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension,
47944798

47954799
# Make Windows paths like Unix.
47964800
fullname = os.path.abspath(filename).replace('\\', '/')
4797-
4801+
47984802
# Perform other checks now that we are sure that this is not an include line
47994803
CheckCasts(filename, clean_lines, linenum, error)
48004804
CheckGlobalStatic(filename, clean_lines, linenum, error)
@@ -6034,7 +6038,7 @@ def ProcessFileData(filename, file_extension, lines, error,
60346038
nesting_state.CheckCompletedBlocks(filename, error)
60356039

60366040
CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error)
6037-
6041+
60386042
# Check that the .cc file has included its header if it exists.
60396043
if file_extension == 'cc':
60406044
CheckHeaderFileIncluded(filename, include_state, error)
@@ -6103,6 +6107,9 @@ def ProcessConfigOverrides(filename):
61036107
_line_length = int(val)
61046108
except ValueError:
61056109
sys.stderr.write('Line length must be numeric.')
6110+
elif name == 'root':
6111+
global _root
6112+
_root = val
61066113
else:
61076114
sys.stderr.write(
61086115
'Invalid configuration option (%s) in file %s\n' %

0 commit comments

Comments
 (0)