Logs an error if a .cc file does not include its header.
(filename, include_state, error)
| 1981 | |
| 1982 | |
| 1983 | def CheckHeaderFileIncluded(filename, include_state, error): |
| 1984 | """Logs an error if a .cc file does not include its header.""" |
| 1985 | |
| 1986 | # Do not check test files |
| 1987 | fileinfo = FileInfo(filename) |
| 1988 | if Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()): |
| 1989 | return |
| 1990 | |
| 1991 | headerfile = filename[0:len(filename) - len(fileinfo.Extension())] + '.h' |
| 1992 | if not os.path.exists(headerfile): |
| 1993 | return |
| 1994 | headername = FileInfo(headerfile).RepositoryName() |
| 1995 | first_include = 0 |
| 1996 | for section_list in include_state.include_list: |
| 1997 | for f in section_list: |
| 1998 | if headername in f[0] or f[0] in headername: |
| 1999 | return |
| 2000 | if not first_include: |
| 2001 | first_include = f[1] |
| 2002 | |
| 2003 | error(filename, first_include, 'build/include', 5, |
| 2004 | '%s should include its header file %s' % (fileinfo.RepositoryName(), |
| 2005 | headername)) |
| 2006 | |
| 2007 | |
| 2008 | def CheckForBadCharacters(filename, lines, error): |
no test coverage detected
searching dependent graphs…