From 1d75b08b83c5d27cf6e0af1b7117e0c396aa3b1c Mon Sep 17 00:00:00 2001 From: Luca Di Sera Date: Thu, 23 Jun 2022 11:24:31 +0200 Subject: Warn about header files with a common non-.h extension It is an implied convention in the Qt project that header files should use a ".h" extension. As this might non be known by a contributor (especially if the contributor is from outside the QtCompany) or escape review, possibly requiring a bigger amount of work to change later, a new warning in the commit sanitizer script was included to warn about new files that have some common header extension that is not ".h". Change-Id: I83a25d829a63811c08a11f2a337707c62423f699 Reviewed-by: Oswald Buddenhagen Reviewed-by: Daniel Smith --- git-hooks/sanitize-commit | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'git-hooks') diff --git a/git-hooks/sanitize-commit b/git-hooks/sanitize-commit index b84e1ab..da73988 100755 --- a/git-hooks/sanitize-commit +++ b/git-hooks/sanitize-commit @@ -718,6 +718,7 @@ sub flushFile() my $merge; my $new_file; +my $foreign; my $is_bin; my $maybe_bin; my $is_special; @@ -771,6 +772,8 @@ while () { } elsif ($file =~ /\.(prl|la|pc|ilk)$/i) { complain("Adding build artifact", "generated") if ($new_file && !defined($cfg{generated})); $ws_check = 0; + } elsif ($file =~ /\.(hpp|ch|h\+\+|hh|hxx)$/i) { + complain("Adding header file with a non-.h extension", "extension") if ($new_file && !$foreign && !defined($cfg{extension})); } elsif ($file !~ /\.qmltypes$/i) { $check_gen = 1; } @@ -875,7 +878,7 @@ while () { $clike = ($file =~ /\.(c|cc|cpp|c\+\+|cxx|qdoc|m|mm|h|hpp|hxx|cs|java|js|qs|qml|g|y|ypp|pl|glsl)$/i); $qmake = ($file =~ /\.pr[filo]$/i); $is_bin = ($file =~ /\.(ps|pdf)$/); - my $foreign = $is_bin || ($file =~ /(^|\/)3rdparty\//); + $foreign = $is_bin || ($file =~ /(^|\/)3rdparty\//); $new_file = 0; $maybe_bin = 0; $is_special = 0; -- cgit v1.2.1