[ovs-dev] [PATCH] checkpatch: check if some tags are wrongly written
Timothy Redaelli
tredaelli at redhat.com
Tue Aug 10 17:26:24 UTC 2021
Currently, there are some patches with the tags wrongly written (with
space instead of dash ) and this may prevent some automatic system or CI
to detect them correctly.
This commit adds a check in checkpatch to be sure the tag is written
correctly with dash and not with space.
The tags supported by the commit are:
Reported-by, Requested-by, Suggested-by, Reported-at, and Submitted-at
It's not necessary to add "Signed-off-by" since it's already checked in
checkpatch.
Signed-off-by: Timothy Redaelli <tredaelli at redhat.com>
---
tests/checkpatch.at | 44 +++++++++++++++++++++++++++++++++++++++++
utilities/checkpatch.py | 13 ++++++++++++
2 files changed, 57 insertions(+)
diff --git a/tests/checkpatch.at b/tests/checkpatch.at
index 0718acd99..8eb6a7558 100755
--- a/tests/checkpatch.at
+++ b/tests/checkpatch.at
@@ -348,3 +348,47 @@ try_checkpatch \
"
AT_CLEANUP
+
+AT_SETUP([checkpatch - malformed tags])
+try_checkpatch \
+ " Author: A
+
+ Reported by: foo...
+ Signed-off-by: A" \
+ "ERROR: Reported-by tag is malformed.
+ 1: Reported by: foo...
+"
+try_checkpatch \
+ " Author: A
+
+ Requested by: foo...
+ Signed-off-by: A" \
+ "ERROR: Requested-by tag is malformed.
+ 1: Requested by: foo...
+"
+try_checkpatch \
+ " Author: A
+
+ Suggested by: foo...
+ Signed-off-by: A" \
+ "ERROR: Suggested-by tag is malformed.
+ 1: Suggested by: foo...
+"
+try_checkpatch \
+ " Author: A
+
+ Reported at: foo...
+ Signed-off-by: A" \
+ "ERROR: Reported-at tag is malformed.
+ 1: Reported at: foo...
+"
+try_checkpatch \
+ " Author: A
+
+ Submitted at: foo...
+ Signed-off-by: A" \
+ "ERROR: Submitted-at tag is malformed.
+ 1: Submitted at: foo...
+"
+
+AT_CLEANUP
diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index 699fb4b02..97e21eeaa 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -749,6 +749,14 @@ def ovs_checkpatch_parse(text, filename, author=None, committer=None):
is_gerrit_change_id = re.compile(r'(\s*(change-id: )(.*))$',
re.I | re.M | re.S)
+ tags_typos = {
+ r'^Reported by:': 'Reported-by:',
+ r'^Requested by:': 'Requested-by:',
+ r'^Suggested by:': 'Suggested-by:',
+ r'^Reported at:': 'Reported-at:',
+ r'^Submitted at:': 'Submitted-at:'
+ }
+
reset_counters()
for line in text.splitlines():
@@ -838,6 +846,11 @@ def ovs_checkpatch_parse(text, filename, author=None, committer=None):
print("%d: %s\n" % (lineno, line))
elif spellcheck:
check_spelling(line, False)
+ for typo, correct in tags_typos.items():
+ m = re.match(typo, line, re.I)
+ if m:
+ print_error("%s tag is malformed." % (correct[:-1]))
+ print("%d: %s\n" % (lineno, line))
elif parse == PARSE_STATE_CHANGE_BODY:
newfile = hunks.match(line)
--
2.31.1
More information about the dev
mailing list