Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E970DC433E0 for ; Sat, 20 Feb 2021 12:02:24 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 938B864EDB for ; Sat, 20 Feb 2021 12:02:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 938B864EDB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-kernel-mentees-bounces@lists.linuxfoundation.org Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 5DC2D83AEA for ; Sat, 20 Feb 2021 12:02:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id h2KRnhoGv1YI for ; Sat, 20 Feb 2021 12:02:23 +0000 (UTC) Received: by smtp1.osuosl.org (Postfix, from userid 1001) id 7709283AE6; Sat, 20 Feb 2021 12:02:23 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTP id CFB7083AAC; Sat, 20 Feb 2021 12:02:21 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id AF1D1C000A; Sat, 20 Feb 2021 12:02:21 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id B8161C0001 for ; Sat, 20 Feb 2021 12:02:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id A77BB874C7 for ; Sat, 20 Feb 2021 12:02:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Y-cNujaZCshv for ; Sat, 20 Feb 2021 12:02:20 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by hemlock.osuosl.org (Postfix) with ESMTPS id 21F25874DA for ; Sat, 20 Feb 2021 12:02:20 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id t29so3614582pfg.11 for ; Sat, 20 Feb 2021 04:02:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wq6g82nsj4oHvtZvnLkkAyzvX7bdqmsVNynOg49+qAY=; b=ExFnD7ldQCZRfHTPwOM/miJmuvlt96QtDSXJeYGu0pPyJkRtKoHzk7hCdqmOJ1S0MP tYJP1IdIVtE/Dlq2fUmoM/xKTSpc9pGcU4gimcsZOb7Qdx0+S8YcdN67xSbw5rlc5qzx n9YgktdNzvo+YhHi13W8yVqMYGBYlrR4GzVUybfS6iOMVEyn4DD2jTPvh7fVGHwVKZVx rwOSAJ7FEzIeqliVEnaLm6b41GxBrhRbp/Lob/da5gEn0XBhrx53D6ElUM6o7aE9ouoS xhGSglGzzQkd/DOTlqIi2X+gA0YfMhWPZVsc+spjepzn85ly5sHFtXFyDaU42AO242A7 WO3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wq6g82nsj4oHvtZvnLkkAyzvX7bdqmsVNynOg49+qAY=; b=nlqqhyzrYES4QgkX/aBVRzxQJUd+K54PyspXOU8TrJ3eKK+guMi0dJzUmglyPDb2mk nKbsD/KI1rSEr9uuF+ejGFuud0nqHe++nj6OLmOoPSAI63Igs69Jp7nPdRz2H+YxvarW zADz3RZsUCMr4uqq3A9STkbpLBN96DGdx4mOtPnofU2lRVL6W82Dsq1sYkAOL9rzw7oU 8MqDuwqHMDt/82VeikhzJ5GoOL2hmEfIE0UXKazy3g/VdP5GExg6Yd5Zz8C+fOCnjV+r G1tI5SYGpcDWyMZ83L1EFKoPRLXLZ4QVw3MVMboD5AFaEj9AejiJJunypQk+wLxhESQb hTzg== X-Gm-Message-State: AOAM532vAMH8q5YGQKuj5HSffaMsuDDHnQA9tm//Tr+Vh+0w+L/d+MsP QjN5hQH2+09ypYJFZYDbgw8= X-Google-Smtp-Source: ABdhPJwgpodUPNjWBeOY9z9W0mZBD2BxFItk0w6Y6+sGEW9Dg9wBnvc2PceChXET+iNH8Y/tp8Z4CQ== X-Received: by 2002:a63:524b:: with SMTP id s11mr12013149pgl.332.1613822539529; Sat, 20 Feb 2021 04:02:19 -0800 (PST) Received: from localhost.localdomain ([2405:201:9004:6b3c:bf56:7f84:6ce5:cf93]) by smtp.gmail.com with ESMTPSA id ml7sm6567046pjb.28.2021.02.20.04.02.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Feb 2021 04:02:19 -0800 (PST) From: Dwaipayan Ray To: joe@perches.com Date: Sat, 20 Feb 2021 17:32:19 +0530 Message-Id: <20210220120220.32585-2-dwaipayanray1@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210220120220.32585-1-dwaipayanray1@gmail.com> References: <20210220120220.32585-1-dwaipayanray1@gmail.com> MIME-Version: 1.0 Cc: linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, Dwaipayan Ray Subject: [Linux-kernel-mentees] [PATCH v5 1/2] checkpatch: add verbose mode X-BeenThere: linux-kernel-mentees@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-kernel-mentees-bounces@lists.linuxfoundation.org Sender: "Linux-kernel-mentees" Add a new verbose mode to checkpatch.pl to emit additional verbose test descriptions. The verbose mode is optional and can be enabled by the flag -v or --verbose. The test descriptions are parsed from the checkpatch documentation file at `Documentation/dev-tools/checkpatch.rst`. The test descriptions in the docs are kept in a fixed format grouped by usage. Some examples of this format are: **LINE_SPACING** Vertical space is wasted given the limited number of lines an editor window can display when multiple blank lines are used. **MISSING_SIGN_OFF** The patch is missing a Signed-off-by line. A signed-off-by line should be added according to Developer's certificate of Origin. To avoid lengthy output, the verbose description is printed only for the first instance of a particular message type. The --verbose option cannot be used along with the --terse option. Signed-off-by: Dwaipayan Ray --- scripts/checkpatch.pl | 63 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 9a549b009d2f..0a91f818ab6f 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -23,6 +23,9 @@ my $V = '0.32'; use Getopt::Long qw(:config no_auto_abbrev); my $quiet = 0; +my $verbose = 0; +my %verbose_messages = (); +my %verbose_emitted = (); my $tree = 1; my $chk_signoff = 1; my $chk_patch = 1; @@ -61,6 +64,7 @@ my $spelling_file = "$D/spelling.txt"; my $codespell = 0; my $codespellfile = "/usr/share/codespell/dictionary.txt"; my $conststructsfile = "$D/const_structs.checkpatch"; +my $docsfile = "$D/../Documentation/dev-tools/checkpatch.rst"; my $typedefsfile; my $color = "auto"; my $allow_c99_comments = 1; # Can be overridden by --ignore C99_COMMENT_TOLERANCE @@ -78,6 +82,7 @@ Version: $V Options: -q, --quiet quiet + -v, --verbose verbose mode --no-tree run without a kernel tree --no-signoff do not check for 'Signed-off-by' line --patch treat FILE as patchfile (default) @@ -198,6 +203,46 @@ if (-f $conf) { unshift(@ARGV, @conf_args) if @conf_args; } +sub load_docs { + open(my $docs, '<', "$docsfile") + or warn "$P: Can't read the documentation file $docsfile $!\n"; + + my $type = ''; + my $desc = ''; + my $in_desc = 0; + + while (<$docs>) { + chomp; + my $line = $_; + $line =~ s/\s+$//; + + if ($line =~ /^\s*\*\*(.+)\*\*$/) { + if ($desc ne '') { + $verbose_messages{$type} = trim($desc); + } + $type = $1; + $desc = ''; + $in_desc = 1; + } elsif ($in_desc) { + if ($line =~ /^(?:\s{4,}|$)/) { + $line =~ s/^\s{4}//; + $desc .= $line; + $desc .= "\n"; + } else { + $verbose_messages{$type} = trim($desc); + $type = ''; + $desc = ''; + $in_desc = 0; + } + } + } + + if ($desc ne '') { + $verbose_messages{$type} = trim($desc); + } + close($docs); +} + # Perl's Getopt::Long allows options to take optional arguments after a space. # Prevent --color by itself from consuming other arguments foreach (@ARGV) { @@ -208,6 +253,7 @@ foreach (@ARGV) { GetOptions( 'q|quiet+' => \$quiet, + 'v|verbose!' => \$verbose, 'tree!' => \$tree, 'signoff!' => \$chk_signoff, 'patch!' => \$chk_patch, @@ -247,13 +293,15 @@ GetOptions( help(0) if ($help); +die "$P: --git cannot be used with --file or --fix\n" if ($git && ($file || $fix)); +die "$P: --verbose cannot be used with --terse\n" if ($verbose && $terse); + list_types(0) if ($list_types); +load_docs() if ($verbose); $fix = 1 if ($fix_inplace); $check_orig = $check; -die "$P: --git cannot be used with --file or --fix\n" if ($git && ($file || $fix)); - my $exit = 0; my $perl_version_ok = 1; @@ -2209,7 +2257,16 @@ sub report { splice(@lines, 1, 1); $output = join("\n", @lines); } - $output = (split('\n', $output))[0] . "\n" if ($terse); + + if ($terse) { + $output = (split('\n', $output))[0] . "\n"; + } + + if ($verbose && exists($verbose_messages{$type}) && + !exists($verbose_emitted{$type})) { + $output .= $verbose_messages{$type} . "\n\n"; + $verbose_emitted{$type} = 1; + } push(our @report, $output); -- 2.30.0 _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees