MCPcopy Create free account
hub / github.com/apache/mesos / CheckHeaderFileIncluded

Function CheckHeaderFileIncluded

support/cpplint.py:1988–2010  ·  view source on GitHub ↗

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

(filename, include_state, error)

Source from the content-addressed store, hash-verified

1986
1987
1988def CheckHeaderFileIncluded(filename, include_state, error):
1989 """Logs an error if a .cc file does not include its header."""
1990
1991 # Do not check test files
1992 fileinfo = FileInfo(filename)
1993 if Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()):
1994 return
1995
1996 headerfile = filename[0:len(filename) - len(fileinfo.Extension())] + '.h'
1997 if not os.path.exists(headerfile):
1998 return
1999 headername = FileInfo(headerfile).RepositoryName()
2000 first_include = 0
2001 for section_list in include_state.include_list:
2002 for f in section_list:
2003 if headername in f[0] or f[0] in headername:
2004 return
2005 if not first_include:
2006 first_include = f[1]
2007
2008 error(filename, first_include, 'build/include', 5,
2009 '%s should include its header file %s' % (fileinfo.RepositoryName(),
2010 headername))
2011
2012
2013def 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
errorFunction · 0.85
existsMethod · 0.45

Tested by

no test coverage detected