MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / CheckAltTokens

Function CheckAltTokens

steps/cpplint.py:4756–4785  ·  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

4754
4755
4756def CheckAltTokens(filename, clean_lines, linenum, error):
4757 """Check alternative keywords being used in boolean expressions.
4758
4759 Args:
4760 filename: The name of the current file.
4761 clean_lines: A CleansedLines instance containing the file.
4762 linenum: The number of the line to check.
4763 error: The function to call with any errors found.
4764 """
4765 line = clean_lines.elided[linenum]
4766
4767 # Avoid preprocessor lines
4768 if Match(r'^\s*#', line):
4769 return
4770
4771 # Last ditch effort to avoid multi-line comments. This will not help
4772 # if the comment started before the current line or ended after the
4773 # current line, but it catches most of the false positives. At least,
4774 # it provides a way to workaround this warning for people who use
4775 # multi-line comments in preprocessor macros.
4776 #
4777 # TODO(unknown): remove this once cpplint has better support for
4778 # multi-line comments.
4779 if line.find('/*') >= 0 or line.find('*/') >= 0:
4780 return
4781
4782 for match in _ALT_TOKEN_REPLACEMENT_PATTERN.finditer(line):
4783 error(filename, linenum, 'readability/alt_tokens', 2,
4784 'Use operator %s instead of %s' % (
4785 _ALT_TOKEN_REPLACEMENT[match.group(1)], match.group(1)))
4786
4787
4788def GetLineWidth(line):

Callers 1

CheckStyleFunction · 0.85

Calls 1

MatchFunction · 0.85

Tested by

no test coverage detected