MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / CheckCommaSpacing

Function CheckCommaSpacing

src/tests/coding/cpplint.py:3949–3982  ·  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

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