Skip to contentSkip to conversation

checkpatch: add --strict test for lines ending in [ or (

PATCH New [email protected] 1 participant 1 message Nov 17, 2017 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 45/94 checkpatch: add --strict test for lines ending in [ or (

From: Joe Perches <[email protected]>
Subject: checkpatch: add --strict test for lines ending in [ or (

Lines that end in an open bracket or open parenthesis are generally hard to follow. Lines following those ending with open parenthesis are also rarely aligned to that open parenthesis.

Suggest not ending lines with '[' or '('

---

 scripts/checkpatch.pl |    6 ++++++
 1 file changed, 6 insertions(+)
scripts/checkpatch.pl renamed from scripts/checkpatch.pl~checkpatch-add-strict-test-for-lines-ending-in-or +6 -0
diff -puN scripts/checkpatch.pl~checkpatch-add-strict-test-for-lines-ending-in-or scripts/checkpatch.pl
@@ -3184,6 +3184,12 @@ sub process {
 # check we are in a valid C source file if not then ignore this hunk
 		next if ($realfile !~ /\.(h|c)$/);
 
+# check for unusual line ending [ or (
+		if ($line =~ /^\+.*([\[\(])\s*$/) {
+			CHK("OPEN_ENDED_LINE",
+			    "Lines should not end with a '$1'\n" . $herecurr);
+		}
+
 # check if this appears to be the start function declaration, save the name
 		if ($sline =~ /^\+\{\s*$/ &&
 		    $prevline =~ /^\+(?:(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*)?($Ident)\(/) {

_