Re: Modifying NeedsBraces Check
"Mark Tymieniecki" <[email protected]> Mon, 30 Jan 2012 14:14:18 -0000
| Newsgroups | gmane.comp.java.audit.checkstyle.user |
|---|---|
| Message-ID | <[email protected]> |
This is a multipart message in MIME format.
--===============4890934919633703231==
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0042_01CCDF59.74D9DCA0"
Content-Language: en-gb
This is a multipart message in MIME format.
------=_NextPart_000_0042_01CCDF59.74D9DCA0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi Dinesh,
I think we are at cross purposes here.
Currently Checkstyle NEEDSBRACES rule is absolute such that the constructs:
IF(condition)
Java Statement;
Or
IF(Condition)
Java Statement;
ELSE
{
Java Statement;
Java Statement;
}
will both raise a checkstyle obsevration. My pragmatic suggestion is that
for 1 statement line blocks this observation becomes optional. What I am
trying to do is avoid excessive observations in legacy code, bringing the
whole process into question, and allowing the team to focus on the real
howlers. The aim is for a progressive 'tightening' of rules as opposed to a
big bang.
Regards
Mark
From: Dinesh Bolkensteyn [mailto:[email protected]]
Sent: 30 January 2012 07:20
To: [email protected]
Subject: Re: [Checkstyle-user] Modifying NeedsBraces Check
If you have more than 1 statement to be executed conditionally, you will
*need* braces.
It is pointless to modify a "need braces" check so that it won't complain
about missing braces anymore.
I guess that what you want is more an indentation check, to allow:
if (condition)
statement
but to reject:
if (condition) statement
On Sun, Jan 29, 2012 at 5:48 PM, tymieniecki <[email protected]> wrote:
Hi Folks,
OK now lets accept that the NEEDSBRACES is absolute, but I am sure we come
across 'pragmatic' sites who take the view that if there is only one
statement, why have braces, of the form:
If (condition)
java statement;
Else
{
java statement;
java statement;
java statement;
}
is there any value in modifying NEEDS BRACES to accept one extra property :
TOKENS - Tokens within which single line blocks are acceptable
Regards
--
View this message in context:
http://checkstyle.2069334.n4.nabble.com/Modifying-NeedsBraces-Check-tp433864
4p4338644.html
Sent from the CheckStyle - User mailing list archive at Nabble.com.
----------------------------------------------------------------------------
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Checkstyle-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user
------=_NextPart_000_0042_01CCDF59.74D9DCA0
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40"><head><META =
HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii"><meta name=3DGenerator content=3D"Microsoft Word 14 =
(filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Times New Roman","serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DEN-GB link=3Dblue =
vlink=3Dpurple><div class=3DWordSection1><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'>Hi =
Dinesh,<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'><o:p> </o:p></span></p><p =
class=3DMsoNormal><span style=3D'font-size:11.0pt;color:#1F497D'>I think =
we are at cross purposes here.<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'>Currently Checkstyle =
NEEDSBRACES rule is absolute such that the =
constructs:<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'>IF(condition)<o:p></o:p></span><=
/p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'> Java =
Statement;<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'><o:p> </o:p></span></p><p =
class=3DMsoNormal><span style=3D'font-size:11.0pt;color:#1F497D'>Or =
<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'><o:p> </o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'>IF(Condition)<o:p></o:p></span><=
/p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'> Java =
Statement;<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'>ELSE<o:p></o:p></span></p><p =
class=3DMsoNormal><span style=3D'font-size:11.0pt;color:#1F497D'> =
{<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'> Java =
Statement;<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'> Java =
Statement;<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'>}<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'><o:p> </o:p></span></p><p =
class=3DMsoNormal><span style=3D'font-size:11.0pt;color:#1F497D'>will =
both raise a checkstyle obsevration. My pragmatic suggestion is that for =
1 statement line blocks this observation becomes optional. What I =
am trying to do is avoid excessive observations in legacy code, bringing =
the whole process into question, and allowing the team to focus on the =
real howlers. The aim is for a progressive ‘tightening’ of =
rules as opposed to a big bang.<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'><o:p> </o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'>Regards<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'><o:p> </o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'>Mark<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'font-size:11.0pt;color:#1F497D'><o:p> </o:p></span></p><p =
class=3DMsoNormal><b><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span>=
</b><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Dinesh =
Bolkensteyn [mailto:[email protected]] <br><b>Sent:</b> =
30 January 2012 07:20<br><b>To:</b> =
[email protected]<br><b>Subject:</b> Re: =
[Checkstyle-user] Modifying NeedsBraces Check<o:p></o:p></span></p><p =
class=3DMsoNormal><o:p> </o:p></p><div><p class=3DMsoNormal>If you =
have more than 1 statement to be executed conditionally, you will *need* =
braces.<o:p></o:p></p></div><div><p =
class=3DMsoNormal> <o:p></o:p></p></div><div><p =
class=3DMsoNormal>It is pointless to modify a "need braces" =
check so that it won't complain about missing braces =
anymore.<o:p></o:p></p></div><div><p =
class=3DMsoNormal> <o:p></o:p></p></div><div><p class=3DMsoNormal>I =
guess that what you want is more an indentation check, to =
allow:<o:p></o:p></p></div><div><p =
class=3DMsoNormal> <o:p></o:p></p></div><div><p =
class=3DMsoNormal>if (condition)<o:p></o:p></p></div><div><p =
class=3DMsoNormal> statement<o:p></o:p></p></div><div><p =
class=3DMsoNormal> <o:p></o:p></p></div><div><p =
class=3DMsoNormal>but to reject:<o:p></o:p></p></div><div><p =
class=3DMsoNormal> <o:p></o:p></p></div><div><p =
class=3DMsoNormal>if (condition) statement<o:p></o:p></p></div><div><p =
class=3DMsoNormal>On Sun, Jan 29, 2012 at 5:48 PM, tymieniecki <<a =
href=3D"mailto:[email protected]">[email protected]</a>> =
wrote:<o:p></o:p></p><p class=3DMsoNormal>Hi Folks,<br><br>OK now lets =
accept that the NEEDSBRACES is absolute, but I am sure we come<br>across =
'pragmatic' sites who take the view that if there is only =
one<br>statement, why have braces, of the form:<br>If =
(condition)<br> java statement;<br>Else<br>{<br> java =
statement;<br> java statement;<br> java =
statement;<br>}<br><br>is there any value in modifying NEEDS BRACES to =
accept one extra property :<br>TOKENS - Tokens within which single line =
blocks are =
acceptable<br><br>Regards<br><br><br><br><br><br><br><br><br>--<br>View =
this message in context: <a =
href=3D"http://checkstyle.2069334.n4.nabble.com/Modifying-NeedsBraces-Che=
ck-tp4338644p4338644.html" =
target=3D"_blank">http://checkstyle.2069334.n4.nabble.com/Modifying-Needs=
Braces-Check-tp4338644p4338644.html</a><br>Sent from the CheckStyle - =
User mailing list archive at =
Nabble.com.<br><br>------------------------------------------------------=
------------------------<br>Try before you buy =3D See our experts in =
action!<br>The most comprehensive online learning library for Microsoft =
developers<br>is just $99.99! Visual Studio, SharePoint, SQL - plus =
HTML5, CSS3, MVC3,<br>Metro Style Apps, more. Free future releases when =
you subscribe now!<br><a href=3D"http://p.sf.net/sfu/learndevnow-dev2" =
target=3D"_blank">http://p.sf.net/sfu/learndevnow-dev2</a><br>___________=
____________________________________<br>Checkstyle-user mailing =
list<br><a =
href=3D"mailto:[email protected]">Checkstyle-user@lis=
ts.sourceforge.net</a><br><a =
href=3D"https://lists.sourceforge.net/lists/listinfo/checkstyle-user" =
target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/checkstyle=
-user</a><o:p></o:p></p></div><p =
class=3DMsoNormal><o:p> </o:p></p></div></body></html>
------=_NextPart_000_0042_01CCDF59.74D9DCA0--
--===============4890934919633703231==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
--===============4890934919633703231==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Checkstyle-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user
--===============4890934919633703231==--