Performs lint checks and reports any errors to the given error function. Args: filename: Filename of the file that is being processed. file_extension: The extension (dot not included) of the file. lines: An array of strings, each representing a line of the file, with the la
(filename, file_extension, lines, error,
extra_check_functions=[])
| 5995 | |
| 5996 | |
| 5997 | def ProcessFileData(filename, file_extension, lines, error, |
| 5998 | extra_check_functions=[]): |
| 5999 | """Performs lint checks and reports any errors to the given error function. |
| 6000 | |
| 6001 | Args: |
| 6002 | filename: Filename of the file that is being processed. |
| 6003 | file_extension: The extension (dot not included) of the file. |
| 6004 | lines: An array of strings, each representing a line of the file, with the |
| 6005 | last element being empty if the file is terminated with a newline. |
| 6006 | error: A callable to which errors are reported, which takes 4 arguments: |
| 6007 | filename, line number, error level, and message |
| 6008 | extra_check_functions: An array of additional check functions that will be |
| 6009 | run on each source line. Each function takes 4 |
| 6010 | arguments: filename, clean_lines, line, error |
| 6011 | """ |
| 6012 | lines = (['// marker so line numbers and indices both start at 1'] + lines + |
| 6013 | ['// marker so line numbers end in a known way']) |
| 6014 | |
| 6015 | include_state = _IncludeState() |
| 6016 | function_state = _FunctionState() |
| 6017 | nesting_state = NestingState() |
| 6018 | |
| 6019 | ResetNolintSuppressions() |
| 6020 | |
| 6021 | CheckForCopyright(filename, lines, error) |
| 6022 | |
| 6023 | RemoveMultiLineComments(filename, lines, error) |
| 6024 | clean_lines = CleansedLines(lines) |
| 6025 | |
| 6026 | if file_extension == 'h': |
| 6027 | CheckForHeaderGuard(filename, clean_lines, error) |
| 6028 | |
| 6029 | for line in xrange(clean_lines.NumLines()): |
| 6030 | ProcessLine(filename, file_extension, clean_lines, line, |
| 6031 | include_state, function_state, nesting_state, error, |
| 6032 | extra_check_functions) |
| 6033 | FlagCxx11Features(filename, clean_lines, line, error) |
| 6034 | nesting_state.CheckCompletedBlocks(filename, error) |
| 6035 | |
| 6036 | CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error) |
| 6037 | |
| 6038 | # Check that the .cc file has included its header if it exists. |
| 6039 | if file_extension == 'cc': |
| 6040 | CheckHeaderFileIncluded(filename, include_state, error) |
| 6041 | |
| 6042 | # We check here rather than inside ProcessLine so that we see raw |
| 6043 | # lines rather than "cleaned" lines. |
| 6044 | CheckForBadCharacters(filename, lines, error) |
| 6045 | |
| 6046 | CheckForNewlineAtEOF(filename, lines, error) |
| 6047 | |
| 6048 | def ProcessConfigOverrides(filename): |
| 6049 | """ Loads the configuration files and processes the config overrides. |
no test coverage detected