tools: update cpplint to check for inline headers
Update cpplint.py to check for inline headers when the corresponding header is already included. PR-URL: https://github.com/nodejs/node/pull/21521 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
5842366ae8
commit
fc81e80191
17
tools/cpplint.py
vendored
17
tools/cpplint.py
vendored
@ -1900,6 +1900,21 @@ def CheckForBadCharacters(filename, lines, error):
|
||||
error(filename, linenum, 'readability/nul', 5, 'Line contains NUL byte.')
|
||||
|
||||
|
||||
def CheckInlineHeader(filename, include_state, error):
|
||||
"""Logs an error if both a header and its inline variant are included."""
|
||||
|
||||
all_headers = dict(item for sublist in include_state.include_list
|
||||
for item in sublist)
|
||||
bad_headers = set('%s.h' % name[:-6] for name in all_headers.keys()
|
||||
if name.endswith('-inl.h'))
|
||||
bad_headers &= set(all_headers.keys())
|
||||
|
||||
for name in bad_headers:
|
||||
err = '%s includes both %s and %s-inl.h' % (filename, name, name)
|
||||
linenum = all_headers[name]
|
||||
error(filename, linenum, 'build/include', 5, err)
|
||||
|
||||
|
||||
def CheckForNewlineAtEOF(filename, lines, error):
|
||||
"""Logs an error if there is no newline char at the end of the file.
|
||||
|
||||
@ -5866,6 +5881,8 @@ def ProcessFileData(filename, file_extension, lines, error,
|
||||
|
||||
CheckForNewlineAtEOF(filename, lines, error)
|
||||
|
||||
CheckInlineHeader(filename, include_state, error)
|
||||
|
||||
def ProcessConfigOverrides(filename):
|
||||
""" Loads the configuration files and processes the config overrides.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user