MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / CheckComment

Function CheckComment

rtpose_wrapper/scripts/cpp_lint.py:2457–2484  ·  view source on GitHub ↗

Checks for common mistakes in TODO comments. Args: comment: The text of the comment from the line in question. filename: The name of the current file. linenum: The number of the line to check. error: The function to call with any errors found.

(comment, filename, linenum, error)

Source from the content-addressed store, hash-verified

2455
2456
2457def CheckComment(comment, filename, linenum, error):
2458 """Checks for common mistakes in TODO comments.
2459
2460 Args:
2461 comment: The text of the comment from the line in question.
2462 filename: The name of the current file.
2463 linenum: The number of the line to check.
2464 error: The function to call with any errors found.
2465 """
2466 match = _RE_PATTERN_TODO.match(comment)
2467 if match:
2468 # One whitespace is correct; zero whitespace is handled elsewhere.
2469 leading_whitespace = match.group(1)
2470 if len(leading_whitespace) > 1:
2471 error(filename, linenum, 'whitespace/todo', 2,
2472 'Too many spaces before TODO')
2473
2474 username = match.group(2)
2475 if not username:
2476 error(filename, linenum, 'readability/todo', 2,
2477 'Missing username in TODO; it should look like '
2478 '"// TODO(my_username): Stuff."')
2479
2480 middle_whitespace = match.group(3)
2481 # Comparisons made explicit for correctness -- pylint: disable=g-explicit-bool-comparison
2482 if middle_whitespace != ' ' and middle_whitespace != '':
2483 error(filename, linenum, 'whitespace/todo', 2,
2484 'TODO(my_username) should be followed by a space')
2485
2486def CheckAccess(filename, clean_lines, linenum, nesting_state, error):
2487 """Checks for improper use of DISALLOW* macros.

Callers 1

CheckSpacingFunction · 0.85

Calls 1

errorFunction · 0.85

Tested by

no test coverage detected