Skip to content

Commit

Permalink
checkpatch.py: Add check for "xxx" in comments.
Browse files Browse the repository at this point in the history
"xxx" is often used to indicate items that the developer wanted to look
at again before committing.  Flag those as a warning.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
  • Loading branch information
justinpettit committed Jan 25, 2018
1 parent 3276f2f commit 4e99b70
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions utilities/checkpatch.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# Copyright (c) 2016, 2017 Red Hat, Inc.
# Copyright (c) 2018 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -95,9 +96,11 @@ def reset_counters():
re.compile(r'[^\s]\) {(\s+/\*[\s\Sa-zA-Z0-9\.,\?\*/+-]*)?$')
__regex_ptr_declaration_missing_whitespace = re.compile(r'[a-zA-Z0-9]\*[^*]')
__regex_is_comment_line = re.compile(r'^\s*(/\*|\*\s)')
__regex_has_comment = re.compile(r'.*(/\*|\*\s)')
__regex_trailing_operator = re.compile(r'^[^ ]* [^ ]*[?:]$')
__regex_conditional_else_bracing = re.compile(r'^\s*else\s*{?$')
__regex_conditional_else_bracing2 = re.compile(r'^\s*}\selse\s*$')
__regex_has_xxx_mark = re.compile(r'.*xxx.*', re.IGNORECASE)

skip_leading_whitespace_check = False
skip_trailing_whitespace_check = False
Expand Down Expand Up @@ -213,11 +216,19 @@ def is_comment_line(line):
"""Returns TRUE if the current line is part of a block comment."""
return __regex_is_comment_line.match(line) is not None

def has_comment(line):
"""Returns TRUE if the current line contains a comment or is part of
a block comment."""
return __regex_has_comment.match(line) is not None

def trailing_operator(line):
"""Returns TRUE if the current line ends with an operatorsuch as ? or :"""
return __regex_trailing_operator.match(line) is not None

def has_xxx_mark(line):
"""Returns TRUE if the current line contains 'xxx'."""
return __regex_has_xxx_mark.match(line) is not None


checks = [
{'regex': None,
Expand Down Expand Up @@ -257,6 +268,11 @@ def trailing_operator(line):
'check': lambda x: trailing_operator(x),
'print':
lambda: print_error("Line has '?' or ':' operator at end of line")},

{'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
'prereq': lambda x: has_comment(x),
'check': lambda x: has_xxx_mark(x),
'print': lambda: print_warning("Comment with 'xxx' marker")},
]


Expand Down

0 comments on commit 4e99b70

Please sign in to comment.