Quantcast

flex plugin's new rules

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

flex plugin's new rules

Ann Campbell
Just upgraded to the new version of the Flex plugin & analyzed our (single!) Flex project.

We went from 0 violations to 1173, which I take as a good thing! (I was really suspicious of that 100% compliance score.)

But in browsing through the new-found violations, I'm seeing a lot of instances of this:
Inline image 1

And interestingly, only some of those violations are coupled with instances of the "Only one return rule." It looks like in a long switch, the first few cases only get one violation and the rest get both. I can investigate more thoroughly if needed...

I'm also seeing this: 
Inline image 2

On the plus side, I'm also seeing instances of "Do not use more than one statement per line"
I find that coding habit a particularly nasty one & want to thank Evgeny for this rule!

And also want to apologize for not participating in testing. :-(


Ann

--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: flex plugin's new rules

Evgeny Mandrikov
Hi Ann,

See my comments below :

On Tue, Jun 26, 2012 at 7:55 PM, Ann Campbell <[hidden email]> wrote:
Just upgraded to the new version of the Flex plugin & analyzed our (single!) Flex project.

We went from 0 violations to 1173, which I take as a good thing! (I was really suspicious of that 100% compliance score.)

But in browsing through the new-found violations, I'm seeing a lot of instances of this:
Inline image 1


This rule currently is out of our control , because it comes from third-party tool - FlexPMD. However we plan to fully get rid of FlexPMD and replace it by our own rules, so I created http://jira.codehaus.org/browse/SONARPLUGINS-1998
 
And interestingly, only some of those violations are coupled with instances of the "Only one return rule." It looks like in a long switch, the first few cases only get one violation and the rest get both. I can investigate more thoroughly if needed...

It would be valuable, if you could provide bigger snippet of code to show what you got and explain what you expected.
 
I'm also seeing this: 
Inline image 2


 
On the plus side, I'm also seeing instances of "Do not use more than one statement per line"
I find that coding habit a particularly nasty one & want to thank Evgeny for this rule!

You're welcome.
 
And also want to apologize for not participating in testing. :-(

You can do this in next time ;)
 

Ann

--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************




--
Best regards,
Evgeny Mandrikov aka Godin <http://godin.net.ru>
http://twitter.com/_godin_
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: flex plugin's new rules

Ann Campbell
Somehow I was under the (clearly mistaken) impression that you'd already fully replaced FlexPMD.

The longer snipped is below. On a second look, it seems that every case but the first gets the "Only one return" rule. I might have thought that every return in a multi-return method would be flagged, or every return except the last one. But I see the case for it the way it is.


switch (state) { # Avoid switch statement without a "default" clause
case A:
return boldGreen; # Non breakable switch case rule
case B:
return boldGreen; # Non breakable switch case rule; Only one return rule
case C:
return boldRed; # Non breakable switch case rule; Only one return rule
case D:
return purple; # Non breakable switch case rule; Only one return rule
case E:
return boldRed; # Non breakable switch case rule; Only one return rule
case F:
return boldYellow; # Non breakable switch case rule; Only one return rule
case G:
return yellow; # Non breakable switch case rule; Only one return rule
case H:
return boldYellow; # Non breakable switch case rule; Only one return rule
case I:
return boldGreen; # Non breakable switch case rule; Only one return rule
case J:
return boldGreen; # Non breakable switch case rule; Only one return rule
}
return yellow; # Only one return rule

--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: flex plugin's new rules

Evgeny Mandrikov
Here is my thoughts :
  • Avoid switch statement without a "default" clause : indeed this is the case - rule was violated
  • Non breakable switch case rule : false-positive from FlexPMD and should be solved by SONARPLUGINS-1998
  • Only one return rule : indeed this is a case - rule was violated, and that's why all return statements except first one were flagged, however goal of SONARPLUGINS-1999 is to replace FlexPMD rule and report violation only once for a method

On Tue, Jun 26, 2012 at 11:16 PM, Ann Campbell <[hidden email]> wrote:
Somehow I was under the (clearly mistaken) impression that you'd already fully replaced FlexPMD.

The longer snipped is below. On a second look, it seems that every case but the first gets the "Only one return" rule. I might have thought that every return in a multi-return method would be flagged, or every return except the last one. But I see the case for it the way it is.


switch (state) { # Avoid switch statement without a "default" clause
case A:
return boldGreen; # Non breakable switch case rule
case B:
return boldGreen; # Non breakable switch case rule; Only one return rule
case C:
return boldRed; # Non breakable switch case rule; Only one return rule
case D:
return purple; # Non breakable switch case rule; Only one return rule
case E:
return boldRed; # Non breakable switch case rule; Only one return rule
case F:
return boldYellow; # Non breakable switch case rule; Only one return rule
case G:
return yellow; # Non breakable switch case rule; Only one return rule
case H:
return boldYellow; # Non breakable switch case rule; Only one return rule
case I:
return boldGreen; # Non breakable switch case rule; Only one return rule
case J:
return boldGreen; # Non breakable switch case rule; Only one return rule
}
return yellow; # Only one return rule

--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************




--
Best regards,
Evgeny Mandrikov aka Godin <http://godin.net.ru>
http://twitter.com/_godin_
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: flex plugin's new rules

Ann Campbell
Below...

On Tue, Jun 26, 2012 at 1:41 PM, Evgeny Mandrikov <[hidden email]> wrote:
Here is my thoughts :
  • Avoid switch statement without a "default" clause : indeed this is the case - rule was violated
included only for completeness 
  • Non breakable switch case rule : false-positive from FlexPMD and should be solved by SONARPLUGINS-1998
cool 
  • Only one return rule : indeed this is a case - rule was violated, and that's why all return statements except first one were flagged, however goal of SONARPLUGINS-1999 is to replace FlexPMD rule and report violation only once for a method
 I like it! :-)



On Tue, Jun 26, 2012 at 11:16 PM, Ann Campbell <[hidden email]> wrote:
Somehow I was under the (clearly mistaken) impression that you'd already fully replaced FlexPMD.

The longer snipped is below. On a second look, it seems that every case but the first gets the "Only one return" rule. I might have thought that every return in a multi-return method would be flagged, or every return except the last one. But I see the case for it the way it is.


switch (state) { # Avoid switch statement without a "default" clause
case A:
return boldGreen; # Non breakable switch case rule
case B:
return boldGreen; # Non breakable switch case rule; Only one return rule
case C:
return boldRed; # Non breakable switch case rule; Only one return rule
case D:
return purple; # Non breakable switch case rule; Only one return rule
case E:
return boldRed; # Non breakable switch case rule; Only one return rule
case F:
return boldYellow; # Non breakable switch case rule; Only one return rule
case G:
return yellow; # Non breakable switch case rule; Only one return rule
case H:
return boldYellow; # Non breakable switch case rule; Only one return rule
case I:
return boldGreen; # Non breakable switch case rule; Only one return rule
case J:
return boldGreen; # Non breakable switch case rule; Only one return rule
}
return yellow; # Only one return rule

--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************




--
Best regards,
Evgeny Mandrikov aka Godin <http://godin.net.ru>
http://twitter.com/_godin_



--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: flex plugin's new rules

Evgeny Mandrikov
BTW, Ann, feel free to report more rules for migration as most probably we will do this in several release steps ;)

On Wed, Jun 27, 2012 at 2:03 AM, Ann Campbell <[hidden email]> wrote:
Below...

On Tue, Jun 26, 2012 at 1:41 PM, Evgeny Mandrikov <[hidden email]> wrote:
Here is my thoughts :
  • Avoid switch statement without a "default" clause : indeed this is the case - rule was violated
included only for completeness 
  • Non breakable switch case rule : false-positive from FlexPMD and should be solved by SONARPLUGINS-1998
cool 
  • Only one return rule : indeed this is a case - rule was violated, and that's why all return statements except first one were flagged, however goal of SONARPLUGINS-1999 is to replace FlexPMD rule and report violation only once for a method
 I like it! :-)



On Tue, Jun 26, 2012 at 11:16 PM, Ann Campbell <[hidden email]> wrote:
Somehow I was under the (clearly mistaken) impression that you'd already fully replaced FlexPMD.

The longer snipped is below. On a second look, it seems that every case but the first gets the "Only one return" rule. I might have thought that every return in a multi-return method would be flagged, or every return except the last one. But I see the case for it the way it is.


switch (state) { # Avoid switch statement without a "default" clause
case A:
return boldGreen; # Non breakable switch case rule
case B:
return boldGreen; # Non breakable switch case rule; Only one return rule
case C:
return boldRed; # Non breakable switch case rule; Only one return rule
case D:
return purple; # Non breakable switch case rule; Only one return rule
case E:
return boldRed; # Non breakable switch case rule; Only one return rule
case F:
return boldYellow; # Non breakable switch case rule; Only one return rule
case G:
return yellow; # Non breakable switch case rule; Only one return rule
case H:
return boldYellow; # Non breakable switch case rule; Only one return rule
case I:
return boldGreen; # Non breakable switch case rule; Only one return rule
case J:
return boldGreen; # Non breakable switch case rule; Only one return rule
}
return yellow; # Only one return rule

--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************




--
Best regards,
Evgeny Mandrikov aka Godin <http://godin.net.ru>
http://twitter.com/_godin_



--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************




--
Best regards,
Evgeny Mandrikov aka Godin <http://godin.net.ru>
http://twitter.com/_godin_
Loading...