Logs an error if a .cc file does not include its header.
(filename, include_state, error)
| 1986 | |
| 1987 | |
| 1988 | def 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 | |
| 2013 | def CheckForBadCharacters(filename, lines, error): |
no test coverage detected