MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / CheckAltTokens

Function CheckAltTokens

rtpose_wrapper/scripts/cpp_lint.py:3405–3434  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

3403
3404
3405def CheckAltTokens(filename, clean_lines, linenum, error):
3406 """Check alternative keywords being used in boolean expressions.
3407
3408 Args:
3409 filename: The name of the current file.
3410 clean_lines: A CleansedLines instance containing the file.
3411 linenum: The number of the line to check.
3412 error: The function to call with any errors found.
3413 """
3414 line = clean_lines.elided[linenum]
3415
3416 # Avoid preprocessor lines
3417 if Match(r'^\s*#', line):
3418 return
3419
3420 # Last ditch effort to avoid multi-line comments. This will not help
3421 # if the comment started before the current line or ended after the
3422 # current line, but it catches most of the false positives. At least,
3423 # it provides a way to workaround this warning for people who use
3424 # multi-line comments in preprocessor macros.
3425 #
3426 # TODO(unknown): remove this once cpplint has better support for
3427 # multi-line comments.
3428 if line.find('/*') >= 0 or line.find('*/') >= 0:
3429 return
3430
3431 for match in _ALT_TOKEN_REPLACEMENT_PATTERN.finditer(line):
3432 error(filename, linenum, 'readability/alt_tokens', 2,
3433 'Use operator %s instead of %s' % (
3434 _ALT_TOKEN_REPLACEMENT[match.group(1)], match.group(1)))
3435
3436
3437def GetLineWidth(line):

Callers 1

CheckStyleFunction · 0.85

Calls 2

MatchFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected