MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / CheckHeaderFileIncluded

Function CheckHeaderFileIncluded

src/tests/coding/cpplint.py:2466–2496  ·  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

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

Tested by

no test coverage detected