Check alternative keywords being used in boolean expressions. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
(filename, clean_lines, linenum, error)
| 4176 | |
| 4177 | |
| 4178 | def CheckAltTokens(filename, clean_lines, linenum, error): |
| 4179 | """Check alternative keywords being used in boolean expressions. |
| 4180 | |
| 4181 | Args: |
| 4182 | filename: The name of the current file. |
| 4183 | clean_lines: A CleansedLines instance containing the file. |
| 4184 | linenum: The number of the line to check. |
| 4185 | error: The function to call with any errors found. |
| 4186 | """ |
| 4187 | line = clean_lines.elided[linenum] |
| 4188 | |
| 4189 | # Avoid preprocessor lines |
| 4190 | if Match(r'^\s*#', line): |
| 4191 | return |
| 4192 | |
| 4193 | # Last ditch effort to avoid multi-line comments. This will not help |
| 4194 | # if the comment started before the current line or ended after the |
| 4195 | # current line, but it catches most of the false positives. At least, |
| 4196 | # it provides a way to workaround this warning for people who use |
| 4197 | # multi-line comments in preprocessor macros. |
| 4198 | # |
| 4199 | # TODO(unknown): remove this once cpplint has better support for |
| 4200 | # multi-line comments. |
| 4201 | if line.find('/*') >= 0 or line.find('*/') >= 0: |
| 4202 | return |
| 4203 | |
| 4204 | for match in _ALT_TOKEN_REPLACEMENT_PATTERN.finditer(line): |
| 4205 | error(filename, linenum, 'readability/alt_tokens', 2, |
| 4206 | 'Use operator %s instead of %s' % ( |
| 4207 | _ALT_TOKEN_REPLACEMENT[match.group(1)], match.group(1))) |
| 4208 | |
| 4209 | |
| 4210 | def GetLineWidth(line): |
no test coverage detected