This is the mail archive of the
mailing list for the GCC project.
Re: Some real-life feedback on -Wmisleading-indentation
- From: Jeff Law <law at redhat dot com>
- To: David Malcolm <dmalcolm at redhat dot com>, Gerald Pfeifer <gerald at pfeifer dot com>
- Cc: gcc at gcc dot gnu dot org, bernds_cb1 at t-online dot de
- Date: Mon, 11 Jan 2016 22:44:40 -0700
- Subject: Re: Some real-life feedback on -Wmisleading-indentation
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot LSU dot 2 dot 20 dot 1601101928330 dot 5144 at anthias> <1452524029 dot 5803 dot 80 dot camel at surprise>
On 01/11/2016 07:53 AM, David Malcolm wrote:
In Chapter 31 of "Code Complete" (I'm looking at the 2nd edition),
McConnell discusses the use of whitespace in code layout; he talks about
both blank lines and indentation as being useful for providing hints to
the human reader about the structure of the code.
In several places he talks about the use of blank lines for separating
groups of related statements into "paragraphs", that blank lines in code
can and should be used to demarcate logical "blocks" of related
statements (e.g. pp747-8 of 2nd edition).
I think that in the Wine example above the blank lines do effectively
create "paragraphs" of code to a human, and I agree that a human reader
is unlikely to think of the
as guarding the
params.cArgs = 1;
since they're in different "paragraphs".
I apologize if I'm belaboring the point here, but I think that
-Wmisleading-indentation should make use of blank lines of code.
I've posted patches to do so here, firstly here:
which was rejected thusly by Jeff:
I would argue that each of these does represent misleading
indentation and that the warning is warranted for each.
Perhaps they aren't as bad as prior cases, but I'd still
consider them mis-leading.
I still stand by that assessment.
ISTM for the wine case the backwards indentation (column-wise) of the IF
may be the right filter, maybe that in conjunction with the blank line
heuristic. However, I stand by my belief that the blank line heuristic
is wrong when used by itself.