summaryrefslogtreecommitdiffstats
path: root/extras/checkpatch.pl
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@redhat.com>2014-09-29 17:27:14 -0400
committerVijay Bellur <vbellur@redhat.com>2014-10-02 07:01:15 -0700
commit0a8371bdfdd88e662d09def717cc0b822feb64e8 (patch)
treefcb26b68c162ffcfd55d7afcf84a295aab23af93 /extras/checkpatch.pl
parentf2131b8c79641c1bf9e20657757bcc9a62a0625a (diff)
extras: reverse test for '}' vs. following 'else' placement
The two-line form "}\nelse {" has been more common than the one-line form "} else {" in our code for years, and IMO for good reason (see the comment in the diff). Change-Id: Ic22c76fe76f0d91300daff36e755a18a8db58852 Signed-off-by: Jeff Darcy <jdarcy@redhat.com> Reviewed-on: http://review.gluster.org/8888 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'extras/checkpatch.pl')
-rwxr-xr-xextras/checkpatch.pl10
1 files changed, 5 insertions, 5 deletions
diff --git a/extras/checkpatch.pl b/extras/checkpatch.pl
index 02c2c2e02ee..18e8cc7aac7 100755
--- a/extras/checkpatch.pl
+++ b/extras/checkpatch.pl
@@ -3335,12 +3335,12 @@ sub process {
"trailing statements should be on next line\n" . $herecurr);
}
- # Check for }<nl>else {, these must be at the same
- # indent level to be relevant to each other.
- if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ and
- $previndent == $indent) {
+ # Check for "} else" which is less readable. Having if/else keywords
+ # line up is a good thing, and having control structures on the same
+ # line as a close-brace is bad.
+ if ($line=~/^.\s*}\selse\s*/) {
ERROR("ELSE_AFTER_BRACE",
- "else should follow close brace '}'\n" . $hereprev);
+ "'}' and 'else' should be on separate lines\n" . $hereprev);
}
if ($prevline=~/}\s*$/ and $line=~/^.\s*while\s*/ and