MCPcopy Index your code
hub / github.com/nodejs/node / CheckHeaderFileIncluded

Function CheckHeaderFileIncluded

tools/cpplint.py:2743–2774  ·  view source on GitHub ↗

Logs an error if a source file does not include its header.

(filename, include_state, error)

Source from the content-addressed store, hash-verified

2741
2742
2743def CheckHeaderFileIncluded(filename, include_state, error):
2744 """Logs an error if a source file does not include its header."""
2745
2746 # Do not check test files
2747 fileinfo = FileInfo(filename)
2748 if re.search(_TEST_FILE_SUFFIX, fileinfo.BaseName()):
2749 return
2750
2751 first_include = message = None
2752 basefilename = filename[0 : len(filename) - len(fileinfo.Extension())]
2753 for ext in GetHeaderExtensions():
2754 headerfile = basefilename + "." + ext
2755 if not os.path.exists(headerfile):
2756 continue
2757 headername = FileInfo(headerfile).RepositoryName()
2758 include_uses_unix_dir_aliases = False
2759 for section_list in include_state.include_list:
2760 for f in section_list:
2761 include_text = f[0]
2762 if "./" in include_text:
2763 include_uses_unix_dir_aliases = True
2764 if headername in include_text or include_text in headername:
2765 return
2766 if not first_include:
2767 first_include = f[1]
2768
2769 message = f"{fileinfo.RepositoryName()} should include its header file {headername}"
2770 if include_uses_unix_dir_aliases:
2771 message += ". Relative paths like . and .. are not allowed."
2772
2773 if message:
2774 error(filename, first_include, "build/include", 5, message)
2775
2776
2777def CheckForBadCharacters(filename, lines, error):

Callers 1

ProcessFileDataFunction · 0.85

Calls 8

BaseNameMethod · 0.95
ExtensionMethod · 0.95
RepositoryNameMethod · 0.95
FileInfoClass · 0.85
GetHeaderExtensionsFunction · 0.85
errorFunction · 0.50
searchMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…