MCPcopy Create free account
hub / github.com/BVLC/caffe / CheckAltTokens

Function CheckAltTokens

scripts/cpp_lint.py:3409–3438  ·  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

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

Callers 1

CheckStyleFunction · 0.85

Calls 1

MatchFunction · 0.85

Tested by

no test coverage detected