MCPcopy Create free account
hub / github.com/alibaba/GraphScope / CheckHeaderFileIncluded

Function CheckHeaderFileIncluded

analytical_engine/misc/cpplint.py:2469–2499  ·  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

2467
2468
2469def CheckHeaderFileIncluded(filename, include_state, error):
2470 """Logs an error if a source file does not include its header."""
2471
2472 # Do not check test files
2473 fileinfo = FileInfo(filename)
2474 if Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()):
2475 return
2476
2477 for ext in GetHeaderExtensions():
2478 basefilename = filename[0:len(filename) - len(fileinfo.Extension())]
2479 headerfile = basefilename + '.' + ext
2480 if not os.path.exists(headerfile):
2481 continue
2482 headername = FileInfo(headerfile).RepositoryName()
2483 first_include = None
2484 include_uses_unix_dir_aliases = False
2485 for section_list in include_state.include_list:
2486 for f in section_list:
2487 include_text = f[0]
2488 if "./" in include_text:
2489 include_uses_unix_dir_aliases = True
2490 if headername in include_text or include_text in headername:
2491 return
2492 if not first_include:
2493 first_include = f[1]
2494
2495 message = '%s should include its header file %s' % (fileinfo.RepositoryName(), headername)
2496 if include_uses_unix_dir_aliases:
2497 message += ". Relative paths like . and .. are not allowed."
2498
2499 error(filename, first_include, 'build/include', 5, message)
2500
2501
2502def CheckForBadCharacters(filename, lines, error):

Callers 1

ProcessFileDataFunction · 0.85

Calls 7

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

Tested by

no test coverage detected