contrib/checkpatch: check for SPDX tags
This commit is contained in:
@@ -48,6 +48,7 @@ our $filename;
|
|||||||
our $line_no;
|
our $line_no;
|
||||||
our $indent;
|
our $indent;
|
||||||
our $check_is_todo;
|
our $check_is_todo;
|
||||||
|
our $expect_spdx;
|
||||||
|
|
||||||
sub new_hunk
|
sub new_hunk
|
||||||
{
|
{
|
||||||
@@ -57,6 +58,7 @@ sub new_hunk
|
|||||||
|
|
||||||
sub new_file
|
sub new_file
|
||||||
{
|
{
|
||||||
|
$expect_spdx = 0;
|
||||||
$check_is_todo = 1;
|
$check_is_todo = 1;
|
||||||
$filename = shift;
|
$filename = shift;
|
||||||
@functions_seen = ();
|
@functions_seen = ();
|
||||||
@@ -170,12 +172,17 @@ next if $filename =~ /\bsrc\/systemd\//
|
|||||||
and not $filename =~ /\/nm-/;
|
and not $filename =~ /\/nm-/;
|
||||||
next if $filename =~ /\/(n-acd|c-list|c-siphash|n-dhcp4)\//;
|
next if $filename =~ /\/(n-acd|c-list|c-siphash|n-dhcp4)\//;
|
||||||
|
|
||||||
|
$expect_spdx = 1 if $line_no == 1;
|
||||||
|
$expect_spdx = 0 if $line =~ /SPDX-License-Identifier/;
|
||||||
|
complain ('Missing a SPDX-License-Identifier') if $line_no == 2 and $expect_spdx;
|
||||||
|
|
||||||
complain ('Tabs are only allowed at the beginning of a line') if $line =~ /[^\t]\t/;
|
complain ('Tabs are only allowed at the beginning of a line') if $line =~ /[^\t]\t/;
|
||||||
complain ('Trailing whitespace') if $line =~ /[ \t]$/;
|
complain ('Trailing whitespace') if $line =~ /[ \t]$/;
|
||||||
complain ('Don\'t use glib typedefs for char/short/int/long/float/double') if $line =~ /\bg(char|short|int|long|float|double)\b/;
|
complain ('Don\'t use glib typedefs for char/short/int/long/float/double') if $line =~ /\bg(char|short|int|long|float|double)\b/;
|
||||||
complain ("Don't use \"$1 $2\" instead of \"$2 $1\"") if $line =~ /\b(char|short|int|long) +(unsigned|signed)\b/;
|
complain ("Don't use \"$1 $2\" instead of \"$2 $1\"") if $line =~ /\b(char|short|int|long) +(unsigned|signed)\b/;
|
||||||
complain ("Don't use \"unsigned int\" but just use \"unsigned\"") if $line =~ /\b(unsigned) +(int)\b/;
|
complain ("Don't use \"unsigned int\" but just use \"unsigned\"") if $line =~ /\b(unsigned) +(int)\b/;
|
||||||
complain ("Please use LGPL2+ for new files") if $is_patch and $line =~ /under the terms of the GNU General Public License/;
|
complain ("Please use LGPL-2.1+ SPDX tag for new files") if $is_patch and $line =~ /SPDX-License-Identifier/ and not /LGPL-2.1\+/;
|
||||||
|
complain ("Use a SPDX-License-Identifier instead of Licensing boilerplate") if $is_patch and $line =~ /under the terms of/;
|
||||||
complain ("Don't use space inside elvis operator ?:") if $line =~ /\?[\t ]+:/;
|
complain ("Don't use space inside elvis operator ?:") if $line =~ /\?[\t ]+:/;
|
||||||
complain ("Don't add Emacs editor formatting hints to source files") if $line_no == 1 and $line =~ /-\*-.+-\*-/;
|
complain ("Don't add Emacs editor formatting hints to source files") if $line_no == 1 and $line =~ /-\*-.+-\*-/;
|
||||||
complain ("XXX marker are reserved for development while work-in-progress. Use TODO or FIXME comment instead?") if $line =~ /\bXXX\b/;
|
complain ("XXX marker are reserved for development while work-in-progress. Use TODO or FIXME comment instead?") if $line =~ /\bXXX\b/;
|
||||||
|
Reference in New Issue
Block a user