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
(filename, file_extension, lines, error, extra_check_functions=None)
| 7533 | |
| 7534 | |
| 7535 | def ProcessFileData(filename, file_extension, lines, error, extra_check_functions=None): |
| 7536 | """Performs lint checks and reports any errors to the given error function. |
| 7537 | |
| 7538 | Args: |
| 7539 | filename: Filename of the file that is being processed. |
| 7540 | file_extension: The extension (dot not included) of the file. |
| 7541 | lines: An array of strings, each representing a line of the file, with the |
| 7542 | last element being empty if the file is terminated with a newline. |
| 7543 | error: A callable to which errors are reported, which takes 4 arguments: |
| 7544 | filename, line number, error level, and message |
| 7545 | extra_check_functions: An array of additional check functions that will be |
| 7546 | run on each source line. Each function takes 4 |
| 7547 | arguments: filename, clean_lines, line, error |
| 7548 | """ |
| 7549 | lines = ( |
| 7550 | ["// marker so line numbers and indices both start at 1"] |
| 7551 | + lines |
| 7552 | + ["// marker so line numbers end in a known way"] |
| 7553 | ) |
| 7554 | |
| 7555 | include_state = _IncludeState() |
| 7556 | function_state = _FunctionState() |
| 7557 | nesting_state = NestingState() |
| 7558 | |
| 7559 | ResetNolintSuppressions() |
| 7560 | |
| 7561 | CheckForCopyright(filename, lines, error) |
| 7562 | ProcessGlobalSuppressions(filename, lines) |
| 7563 | RemoveMultiLineComments(filename, lines, error) |
| 7564 | clean_lines = CleansedLines(lines) |
| 7565 | |
| 7566 | cppvar = None |
| 7567 | if IsHeaderExtension(file_extension): |
| 7568 | cppvar = GetHeaderGuardCPPVariable(filename) |
| 7569 | CheckForHeaderGuard(filename, clean_lines, error, cppvar) |
| 7570 | |
| 7571 | for line in range(clean_lines.NumLines()): |
| 7572 | ProcessLine( |
| 7573 | filename, |
| 7574 | file_extension, |
| 7575 | clean_lines, |
| 7576 | line, |
| 7577 | include_state, |
| 7578 | function_state, |
| 7579 | nesting_state, |
| 7580 | error, |
| 7581 | extra_check_functions, |
| 7582 | cppvar, |
| 7583 | ) |
| 7584 | FlagCxxHeaders(filename, clean_lines, line, error) |
| 7585 | if _error_suppressions.HasOpenBlock(): |
| 7586 | error( |
| 7587 | filename, |
| 7588 | _error_suppressions.GetOpenBlockStart(), |
| 7589 | "readability/nolint", |
| 7590 | 5, |
| 7591 | "NONLINT block never ended", |
| 7592 | ) |
no test coverage detected
searching dependent graphs…