[PATCH v3 2/2] checkpatch: add fix option for COMMIT_LOG_LONG_LINE with URLs

From: Aditya Srivastava
Date: Thu Jan 14 2021 - 02:36:28 EST


Currently checkpatch warns for long line in commit messages even for
URL lines.

An evaluation over v5.6..v5.8 found that out of 1703 warnings reported
by this class, 161 are due to the line containg URLs. Out of these 161,
53 are due to lines where URL is the first non-whitespace character of
the line.

E.g. running checkpatch on commit 3cde818cd02b ("ASoC: topology:
Consolidate how dtexts and dvalues are freed") reports this warning:

WARNING: Possible unwrapped commit description (prefer a maximum 75 chars per line)
https://mailman.alsa-project.org/pipermail/alsa-devel/2019-January/144761.html

Provide a simple fix option by prefixing the first non-whitespace
character of the line with "Link:"

Signed-off-by: Aditya Srivastava <yashsri421@xxxxxxxxx>
---
scripts/checkpatch.pl | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e8851ce73149..7030c4d6d126 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3023,9 +3023,12 @@ sub process {
$line =~ /^\s*(?:Fixes:|Link:|$signature_tags)/i ||
# A Fixes: or Link: line or signature tag line
$commit_log_possible_stack_dump)) {
- if ($line =~ /^\s*[a-z][\w\.\+\-]*:\/\/\S+/i) {
- WARN("COMMIT_LOG_LONG_LINE",
- "Consider prefixing the URL with 'Link:'\n" . $herecurr);
+ if ($line =~ /^\s*([a-z][\w\.\+\-]*:\/\/\S+)/i) {
+ if (WARN("COMMIT_LOG_LONG_LINE",
+ "Consider prefixing the URL with 'Link:'\n" . $herecurr) &&
+ $fix) {
+ $fixed[$fixlinenr] = "Link: $1";
+ }
} else {
WARN("COMMIT_LOG_LONG_LINE",
"Possible unwrapped commit description (prefer a maximum 75 chars per line)\n" . $herecurr);
--
2.17.1