MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / CheckHeaderFileIncluded

Function CheckHeaderFileIncluded

steps/cpplint.py:2480–2510  ·  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

2478
2479
2480def CheckHeaderFileIncluded(filename, include_state, error):
2481 """Logs an error if a source file does not include its header."""
2482
2483 # Do not check test files
2484 fileinfo = FileInfo(filename)
2485 if Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()):
2486 return
2487
2488 for ext in GetHeaderExtensions():
2489 basefilename = filename[0:len(filename) - len(fileinfo.Extension())]
2490 headerfile = basefilename + '.' + ext
2491 if not os.path.exists(headerfile):
2492 continue
2493 headername = FileInfo(headerfile).RepositoryName()
2494 first_include = None
2495 include_uses_unix_dir_aliases = False
2496 for section_list in include_state.include_list:
2497 for f in section_list:
2498 include_text = f[0]
2499 if "./" in include_text:
2500 include_uses_unix_dir_aliases = True
2501 if headername in include_text or include_text in headername:
2502 return
2503 if not first_include:
2504 first_include = f[1]
2505
2506 message = '%s should include its header file %s' % (fileinfo.RepositoryName(), headername)
2507 if include_uses_unix_dir_aliases:
2508 message += ". Relative paths like . and .. are not allowed."
2509
2510 error(filename, first_include, 'build/include', 5, message)
2511
2512
2513def 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