MCPcopy Create free account
hub / github.com/alibaba/graph-learn / CheckHeaderFileIncluded

Function CheckHeaderFileIncluded

dynamic_graph_service/ci/cpplint.py:2204–2228  ·  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

2202
2203
2204def CheckHeaderFileIncluded(filename, include_state, error):
2205 """Logs an error if a source file does not include its header."""
2206
2207 # Do not check test files
2208 fileinfo = FileInfo(filename)
2209 if Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()):
2210 return
2211
2212 for ext in GetHeaderExtensions():
2213 basefilename = filename[0:len(filename) - len(fileinfo.Extension())]
2214 headerfile = basefilename + '.' + ext
2215 if not os.path.exists(headerfile):
2216 continue
2217 headername = FileInfo(headerfile).RepositoryName()
2218 first_include = None
2219 for section_list in include_state.include_list:
2220 for f in section_list:
2221 if headername in f[0] or f[0] in headername:
2222 return
2223 if not first_include:
2224 first_include = f[1]
2225
2226 error(filename, first_include, 'build/include', 5,
2227 '%s should include its header file %s' % (fileinfo.RepositoryName(),
2228 headername))
2229
2230
2231def CheckForBadCharacters(filename, lines, error):

Callers 1

ProcessFileDataFunction · 0.85

Calls 6

BaseNameMethod · 0.95
ExtensionMethod · 0.95
RepositoryNameMethod · 0.95
FileInfoClass · 0.85
SearchFunction · 0.85
GetHeaderExtensionsFunction · 0.85

Tested by

no test coverage detected