MCPcopy Create free account
hub / github.com/BoomingTech/Piccolo / CheckCommaSpacing

Function CheckCommaSpacing

engine/3rdparty/tinyobjloader/deps/cpplint.py:3280–3313  ·  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

3278
3279
3280def CheckCommaSpacing(filename, clean_lines, linenum, error):
3281 """Checks for horizontal spacing near commas and semicolons.
3282
3283 Args:
3284 filename: The name of the current file.
3285 clean_lines: A CleansedLines instance containing the file.
3286 linenum: The number of the line to check.
3287 error: The function to call with any errors found.
3288 """
3289 raw = clean_lines.lines_without_raw_strings
3290 line = clean_lines.elided[linenum]
3291
3292 # You should always have a space after a comma (either as fn arg or operator)
3293 #
3294 # This does not apply when the non-space character following the
3295 # comma is another comma, since the only time when that happens is
3296 # for empty macro arguments.
3297 #
3298 # We run this check in two passes: first pass on elided lines to
3299 # verify that lines contain missing whitespaces, second pass on raw
3300 # lines to confirm that those missing whitespaces are not due to
3301 # elided comments.
3302 if (Search(r',[^,\s]', ReplaceAll(r'\boperator\s*,\s*\(', 'F(', line)) and
3303 Search(r',[^,\s]', raw[linenum])):
3304 error(filename, linenum, 'whitespace/comma', 3,
3305 'Missing space after ,')
3306
3307 # You should always have a space after a semicolon
3308 # except for few corner cases
3309 # TODO(unknown): clarify if 'if (1) { return 1;}' is requires one more
3310 # space after ;
3311 if Search(r';[^\s};\\)/]', line):
3312 error(filename, linenum, 'whitespace/semicolon', 3,
3313 'Missing space after ;')
3314
3315
3316def CheckBracesSpacing(filename, clean_lines, linenum, error):

Callers 1

CheckStyleFunction · 0.85

Calls 3

SearchFunction · 0.85
ReplaceAllFunction · 0.85
errorFunction · 0.50

Tested by

no test coverage detected