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=[])
| 3812 | check_fn(filename, clean_lines, line, error) |
| 3813 | |
| 3814 | def ProcessFileData(filename, file_extension, lines, error, |
| 3815 | extra_check_functions=[]): |
| 3816 | """Performs lint checks and reports any errors to the given error function. |
| 3817 | |
| 3818 | Args: |
| 3819 | filename: Filename of the file that is being processed. |
| 3820 | file_extension: The extension (dot not included) of the file. |
| 3821 | lines: An array of strings, each representing a line of the file, with the |
| 3822 | last element being empty if the file is terminated with a newline. |
| 3823 | error: A callable to which errors are reported, which takes 4 arguments: |
| 3824 | filename, line number, error level, and message |
| 3825 | extra_check_functions: An array of additional check functions that will be |
| 3826 | run on each source line. Each function takes 4 |
| 3827 | arguments: filename, clean_lines, line, error |
| 3828 | """ |
| 3829 | lines = (['// marker so line numbers and indices both start at 1'] + lines + |
| 3830 | ['// marker so line numbers end in a known way']) |
| 3831 | |
| 3832 | include_state = _IncludeState() |
| 3833 | function_state = _FunctionState() |
| 3834 | nesting_state = _NestingState() |
| 3835 | |
| 3836 | ResetNolintSuppressions() |
| 3837 | |
| 3838 | CheckForCopyright(filename, lines, error) |
| 3839 | |
| 3840 | if file_extension == 'h': |
| 3841 | CheckForHeaderGuard(filename, lines, error) |
| 3842 | |
| 3843 | RemoveMultiLineComments(filename, lines, error) |
| 3844 | clean_lines = CleansedLines(lines) |
| 3845 | for line in xrange(clean_lines.NumLines()): |
| 3846 | ProcessLine(filename, file_extension, clean_lines, line, |
| 3847 | include_state, function_state, nesting_state, error, |
| 3848 | extra_check_functions) |
| 3849 | nesting_state.CheckClassFinished(filename, error) |
| 3850 | |
| 3851 | CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error) |
| 3852 | |
| 3853 | # We check here rather than inside ProcessLine so that we see raw |
| 3854 | # lines rather than "cleaned" lines. |
| 3855 | CheckForUnicodeReplacementCharacters(filename, lines, error) |
| 3856 | |
| 3857 | CheckForNewlineAtEOF(filename, lines, error) |
| 3858 | |
| 3859 | def ProcessFile(filename, vlevel, extra_check_functions=[]): |
| 3860 | """Does google-lint on a single file. |
no test coverage detected