Modifying NeedsBraces Check

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Modifying NeedsBraces Check

tymieniecki
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



 


Reply | Threaded
Open this post in threaded view
|

Re: Modifying NeedsBraces Check

Dinesh Bolkensteyn
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 <[hidden email]> 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-tp4338644p4338644.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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user


------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user
Reply | Threaded
Open this post in threaded view
|

Re: Modifying NeedsBraces Check

tymieniecki

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:[hidden email]]
Sent: 30 January 2012 07:20
To: [hidden email]
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 <[hidden email]> 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-tp4338644p4338644.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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user

 


------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user
Reply | Threaded
Open this post in threaded view
|

Re: Modifying NeedsBraces Check

tymieniecki
In reply to this post by Dinesh Bolkensteyn

Hi Dinesh,

 

I don’t suppose you have seen my observation regarding ‘cannot instantiate – LoggerAttrCheck’ . I suspect that its probably an incorrect setting is some mysterious XML file I have not detected from the documentation, but I am open to suggestions as to my code being crap.

 

Regards

 

 

From: Dinesh Bolkensteyn [mailto:[hidden email]]
Sent: 30 January 2012 07:20
To: [hidden email]
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 <[hidden email]> 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-tp4338644p4338644.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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user

 


------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user
Reply | Threaded
Open this post in threaded view
|

Re: Modifying NeedsBraces Check

Dinesh Bolkensteyn
To me it does not make sense to allow case 1 but not case 2 in your example.

I don't think that case 1 has a lower fixing priority than the case 2.

If your IDE is properly and consistently set up among your team members, all those missing braces will eventually get fixed automagically as you work on each file of the legacy codebase.

--
Dinesh Bolkensteyn
www.SonarSource.com
twitter.com/DBolkensteyn



On Mon, Jan 30, 2012 at 7:03 PM, Mark Tymieniecki <[hidden email]> wrote:

Hi Dinesh,

 

I don’t suppose you have seen my observation regarding ‘cannot instantiate – LoggerAttrCheck’ . I suspect that its probably an incorrect setting is some mysterious XML file I have not detected from the documentation, but I am open to suggestions as to my code being crap.

 

Regards

 

 

From: Dinesh Bolkensteyn [mailto:[hidden email]]
Sent: 30 January 2012 07:20
To: [hidden email]
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 <[hidden email]> 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-tp4338644p4338644.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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user

 


------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user



------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user