Logs an error if a .cc file does not include its header.
(filename, include_state, error)
| 1886 | |
| 1887 | |
| 1888 | def CheckHeaderFileIncluded(filename, include_state, error): |
| 1889 | """Logs an error if a .cc file does not include its header.""" |
| 1890 | |
| 1891 | # Do not check test files |
| 1892 | fileinfo = FileInfo(filename) |
| 1893 | if Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()): |
| 1894 | return |
| 1895 | |
| 1896 | headerfile = filename[0:len(filename) - len(fileinfo.Extension())] + '.h' |
| 1897 | if not os.path.exists(headerfile): |
| 1898 | return |
| 1899 | headername = FileInfo(headerfile).RepositoryName() |
| 1900 | first_include = 0 |
| 1901 | for section_list in include_state.include_list: |
| 1902 | for f in section_list: |
| 1903 | if headername in f[0] or f[0] in headername: |
| 1904 | return |
| 1905 | if not first_include: |
| 1906 | first_include = f[1] |
| 1907 | |
| 1908 | error(filename, first_include, 'build/include', 5, |
| 1909 | '%s should include its header file %s' % (fileinfo.RepositoryName(), |
| 1910 | headername)) |
| 1911 | |
| 1912 | |
| 1913 | def CheckForBadCharacters(filename, lines, error): |
no test coverage detected