| @@ 2141-2156 (lines=16) @@ | ||
| 2138 | error(filename, linenum, 'readability/nul', 5, 'Line contains NUL byte.') |
|
| 2139 | ||
| 2140 | ||
| 2141 | def CheckForNewlineAtEOF(filename, lines, error): |
|
| 2142 | """Logs an error if there is no newline char at the end of the file. |
|
| 2143 | ||
| 2144 | Args: |
|
| 2145 | filename: The name of the current file. |
|
| 2146 | lines: An array of strings, each representing a line of the file. |
|
| 2147 | error: The function to call with any errors found. |
|
| 2148 | """ |
|
| 2149 | ||
| 2150 | # The array lines() was created by adding two newlines to the |
|
| 2151 | # original file (go figure), then splitting on \n. |
|
| 2152 | # To verify that the file ends in \n, we just have to make sure the |
|
| 2153 | # last-but-two element of lines() exists and is empty. |
|
| 2154 | if len(lines) < 3 or lines[-2]: |
|
| 2155 | error(filename, len(lines) - 2, 'whitespace/ending_newline', 5, |
|
| 2156 | 'Could not find a newline character at the end of the file.') |
|
| 2157 | ||
| 2158 | ||
| 2159 | def CheckForMultilineCommentsAndStrings(filename, clean_lines, linenum, error): |
|
| @@ 2141-2156 (lines=16) @@ | ||
| 2138 | error(filename, linenum, 'readability/nul', 5, 'Line contains NUL byte.') |
|
| 2139 | ||
| 2140 | ||
| 2141 | def CheckForNewlineAtEOF(filename, lines, error): |
|
| 2142 | """Logs an error if there is no newline char at the end of the file. |
|
| 2143 | ||
| 2144 | Args: |
|
| 2145 | filename: The name of the current file. |
|
| 2146 | lines: An array of strings, each representing a line of the file. |
|
| 2147 | error: The function to call with any errors found. |
|
| 2148 | """ |
|
| 2149 | ||
| 2150 | # The array lines() was created by adding two newlines to the |
|
| 2151 | # original file (go figure), then splitting on \n. |
|
| 2152 | # To verify that the file ends in \n, we just have to make sure the |
|
| 2153 | # last-but-two element of lines() exists and is empty. |
|
| 2154 | if len(lines) < 3 or lines[-2]: |
|
| 2155 | error(filename, len(lines) - 2, 'whitespace/ending_newline', 5, |
|
| 2156 | 'Could not find a newline character at the end of the file.') |
|
| 2157 | ||
| 2158 | ||
| 2159 | def CheckForMultilineCommentsAndStrings(filename, clean_lines, linenum, error): |
|