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

Function CheckCommaSpacing

steps/cpplint.py:3962–3995  ·  view source on GitHub ↗

Checks for horizontal spacing near commas and semicolons. 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

3960
3961
3962def CheckCommaSpacing(filename, clean_lines, linenum, error):
3963 """Checks for horizontal spacing near commas and semicolons.
3964
3965 Args:
3966 filename: The name of the current file.
3967 clean_lines: A CleansedLines instance containing the file.
3968 linenum: The number of the line to check.
3969 error: The function to call with any errors found.
3970 """
3971 raw = clean_lines.lines_without_raw_strings
3972 line = clean_lines.elided[linenum]
3973
3974 # You should always have a space after a comma (either as fn arg or operator)
3975 #
3976 # This does not apply when the non-space character following the
3977 # comma is another comma, since the only time when that happens is
3978 # for empty macro arguments.
3979 #
3980 # We run this check in two passes: first pass on elided lines to
3981 # verify that lines contain missing whitespaces, second pass on raw
3982 # lines to confirm that those missing whitespaces are not due to
3983 # elided comments.
3984 if (Search(r',[^,\s]', ReplaceAll(r'\boperator\s*,\s*\(', 'F(', line)) and
3985 Search(r',[^,\s]', raw[linenum])):
3986 error(filename, linenum, 'whitespace/comma', 3,
3987 'Missing space after ,')
3988
3989 # You should always have a space after a semicolon
3990 # except for few corner cases
3991 # TODO(unknown): clarify if 'if (1) { return 1;}' is requires one more
3992 # space after ;
3993 if Search(r';[^\s};\\)/]', line):
3994 error(filename, linenum, 'whitespace/semicolon', 3,
3995 'Missing space after ;')
3996
3997
3998def _IsType(clean_lines, nesting_state, expr):

Callers 1

CheckStyleFunction · 0.85

Calls 2

SearchFunction · 0.85
ReplaceAllFunction · 0.85

Tested by

no test coverage detected