@@ 4387-4416 (lines=30) @@ | ||
4384 | check_macro, operator)) |
|
4385 | ||
4386 | ||
4387 | def CheckAltTokens(filename, clean_lines, linenum, error): |
|
4388 | """Check alternative keywords being used in boolean expressions. |
|
4389 | ||
4390 | Args: |
|
4391 | filename: The name of the current file. |
|
4392 | clean_lines: A CleansedLines instance containing the file. |
|
4393 | linenum: The number of the line to check. |
|
4394 | error: The function to call with any errors found. |
|
4395 | """ |
|
4396 | line = clean_lines.elided[linenum] |
|
4397 | ||
4398 | # Avoid preprocessor lines |
|
4399 | if Match(r'^\s*#', line): |
|
4400 | return |
|
4401 | ||
4402 | # Last ditch effort to avoid multi-line comments. This will not help |
|
4403 | # if the comment started before the current line or ended after the |
|
4404 | # current line, but it catches most of the false positives. At least, |
|
4405 | # it provides a way to workaround this warning for people who use |
|
4406 | # multi-line comments in preprocessor macros. |
|
4407 | # |
|
4408 | # TODO(unknown): remove this once cpplint has better support for |
|
4409 | # multi-line comments. |
|
4410 | if line.find('/*') >= 0 or line.find('*/') >= 0: |
|
4411 | return |
|
4412 | ||
4413 | for match in _ALT_TOKEN_REPLACEMENT_PATTERN.finditer(line): |
|
4414 | error(filename, linenum, 'readability/alt_tokens', 2, |
|
4415 | 'Use operator %s instead of %s' % ( |
|
4416 | _ALT_TOKEN_REPLACEMENT[match.group(1)], match.group(1))) |
|
4417 | ||
4418 | ||
4419 | def GetLineWidth(line): |
@@ 4387-4416 (lines=30) @@ | ||
4384 | check_macro, operator)) |
|
4385 | ||
4386 | ||
4387 | def CheckAltTokens(filename, clean_lines, linenum, error): |
|
4388 | """Check alternative keywords being used in boolean expressions. |
|
4389 | ||
4390 | Args: |
|
4391 | filename: The name of the current file. |
|
4392 | clean_lines: A CleansedLines instance containing the file. |
|
4393 | linenum: The number of the line to check. |
|
4394 | error: The function to call with any errors found. |
|
4395 | """ |
|
4396 | line = clean_lines.elided[linenum] |
|
4397 | ||
4398 | # Avoid preprocessor lines |
|
4399 | if Match(r'^\s*#', line): |
|
4400 | return |
|
4401 | ||
4402 | # Last ditch effort to avoid multi-line comments. This will not help |
|
4403 | # if the comment started before the current line or ended after the |
|
4404 | # current line, but it catches most of the false positives. At least, |
|
4405 | # it provides a way to workaround this warning for people who use |
|
4406 | # multi-line comments in preprocessor macros. |
|
4407 | # |
|
4408 | # TODO(unknown): remove this once cpplint has better support for |
|
4409 | # multi-line comments. |
|
4410 | if line.find('/*') >= 0 or line.find('*/') >= 0: |
|
4411 | return |
|
4412 | ||
4413 | for match in _ALT_TOKEN_REPLACEMENT_PATTERN.finditer(line): |
|
4414 | error(filename, linenum, 'readability/alt_tokens', 2, |
|
4415 | 'Use operator %s instead of %s' % ( |
|
4416 | _ALT_TOKEN_REPLACEMENT[match.group(1)], match.group(1))) |
|
4417 | ||
4418 | ||
4419 | def GetLineWidth(line): |