| @@ 6054-6103 (lines=50) @@ | ||
| 6051 | ('<%s> is an unapproved C++14 header.') % include.group(1)) |
|
| 6052 | ||
| 6053 | ||
| 6054 | def ProcessFileData(filename, file_extension, lines, error, |
|
| 6055 | extra_check_functions=None): |
|
| 6056 | """Performs lint checks and reports any errors to the given error function. |
|
| 6057 | ||
| 6058 | Args: |
|
| 6059 | filename: Filename of the file that is being processed. |
|
| 6060 | file_extension: The extension (dot not included) of the file. |
|
| 6061 | lines: An array of strings, each representing a line of the file, with the |
|
| 6062 | last element being empty if the file is terminated with a newline. |
|
| 6063 | error: A callable to which errors are reported, which takes 4 arguments: |
|
| 6064 | filename, line number, error level, and message |
|
| 6065 | extra_check_functions: An array of additional check functions that will be |
|
| 6066 | run on each source line. Each function takes 4 |
|
| 6067 | arguments: filename, clean_lines, line, error |
|
| 6068 | """ |
|
| 6069 | lines = (['// marker so line numbers and indices both start at 1'] + lines + |
|
| 6070 | ['// marker so line numbers end in a known way']) |
|
| 6071 | ||
| 6072 | include_state = _IncludeState() |
|
| 6073 | function_state = _FunctionState() |
|
| 6074 | nesting_state = NestingState() |
|
| 6075 | ||
| 6076 | ResetNolintSuppressions() |
|
| 6077 | ||
| 6078 | CheckForCopyright(filename, lines, error) |
|
| 6079 | ProcessGlobalSuppresions(lines) |
|
| 6080 | RemoveMultiLineComments(filename, lines, error) |
|
| 6081 | clean_lines = CleansedLines(lines) |
|
| 6082 | ||
| 6083 | if file_extension in GetHeaderExtensions(): |
|
| 6084 | CheckForHeaderGuard(filename, clean_lines, error) |
|
| 6085 | ||
| 6086 | for line in range(clean_lines.NumLines()): |
|
| 6087 | ProcessLine(filename, file_extension, clean_lines, line, |
|
| 6088 | include_state, function_state, nesting_state, error, |
|
| 6089 | extra_check_functions) |
|
| 6090 | FlagCxx11Features(filename, clean_lines, line, error) |
|
| 6091 | nesting_state.CheckCompletedBlocks(filename, error) |
|
| 6092 | ||
| 6093 | CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error) |
|
| 6094 | ||
| 6095 | # Check that the .cc file has included its header if it exists. |
|
| 6096 | if _IsSourceExtension(file_extension): |
|
| 6097 | CheckHeaderFileIncluded(filename, include_state, error) |
|
| 6098 | ||
| 6099 | # We check here rather than inside ProcessLine so that we see raw |
|
| 6100 | # lines rather than "cleaned" lines. |
|
| 6101 | CheckForBadCharacters(filename, lines, error) |
|
| 6102 | ||
| 6103 | CheckForNewlineAtEOF(filename, lines, error) |
|
| 6104 | ||
| 6105 | def ProcessConfigOverrides(filename): |
|
| 6106 | """ Loads the configuration files and processes the config overrides. |
|
| @@ 6054-6103 (lines=50) @@ | ||
| 6051 | ('<%s> is an unapproved C++14 header.') % include.group(1)) |
|
| 6052 | ||
| 6053 | ||
| 6054 | def ProcessFileData(filename, file_extension, lines, error, |
|
| 6055 | extra_check_functions=None): |
|
| 6056 | """Performs lint checks and reports any errors to the given error function. |
|
| 6057 | ||
| 6058 | Args: |
|
| 6059 | filename: Filename of the file that is being processed. |
|
| 6060 | file_extension: The extension (dot not included) of the file. |
|
| 6061 | lines: An array of strings, each representing a line of the file, with the |
|
| 6062 | last element being empty if the file is terminated with a newline. |
|
| 6063 | error: A callable to which errors are reported, which takes 4 arguments: |
|
| 6064 | filename, line number, error level, and message |
|
| 6065 | extra_check_functions: An array of additional check functions that will be |
|
| 6066 | run on each source line. Each function takes 4 |
|
| 6067 | arguments: filename, clean_lines, line, error |
|
| 6068 | """ |
|
| 6069 | lines = (['// marker so line numbers and indices both start at 1'] + lines + |
|
| 6070 | ['// marker so line numbers end in a known way']) |
|
| 6071 | ||
| 6072 | include_state = _IncludeState() |
|
| 6073 | function_state = _FunctionState() |
|
| 6074 | nesting_state = NestingState() |
|
| 6075 | ||
| 6076 | ResetNolintSuppressions() |
|
| 6077 | ||
| 6078 | CheckForCopyright(filename, lines, error) |
|
| 6079 | ProcessGlobalSuppresions(lines) |
|
| 6080 | RemoveMultiLineComments(filename, lines, error) |
|
| 6081 | clean_lines = CleansedLines(lines) |
|
| 6082 | ||
| 6083 | if file_extension in GetHeaderExtensions(): |
|
| 6084 | CheckForHeaderGuard(filename, clean_lines, error) |
|
| 6085 | ||
| 6086 | for line in range(clean_lines.NumLines()): |
|
| 6087 | ProcessLine(filename, file_extension, clean_lines, line, |
|
| 6088 | include_state, function_state, nesting_state, error, |
|
| 6089 | extra_check_functions) |
|
| 6090 | FlagCxx11Features(filename, clean_lines, line, error) |
|
| 6091 | nesting_state.CheckCompletedBlocks(filename, error) |
|
| 6092 | ||
| 6093 | CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error) |
|
| 6094 | ||
| 6095 | # Check that the .cc file has included its header if it exists. |
|
| 6096 | if _IsSourceExtension(file_extension): |
|
| 6097 | CheckHeaderFileIncluded(filename, include_state, error) |
|
| 6098 | ||
| 6099 | # We check here rather than inside ProcessLine so that we see raw |
|
| 6100 | # lines rather than "cleaned" lines. |
|
| 6101 | CheckForBadCharacters(filename, lines, error) |
|
| 6102 | ||
| 6103 | CheckForNewlineAtEOF(filename, lines, error) |
|
| 6104 | ||
| 6105 | def ProcessConfigOverrides(filename): |
|
| 6106 | """ Loads the configuration files and processes the config overrides. |
|