Re: [pmd-devel] Missing Break in Switch - existing test case questions
A source code analyzer
Brought to you by:
adangel,
juansotuyo
From: Romain P. <be...@gm...> - 2012-05-27 20:51:05
|
IMO: I would rather fix the bug and leave with the test case being broken. But that's only my opinion... On 27 May 2012 19:58, Dinesh Bolkensteyn <din...@so... > wrote: > Indeed if there is no statement between the two cases, then no break > should be expected between those cases. > > In C, there is a MISRA rule 15.2 which states: > > "An unconditionnal break statement shall terminate every non-empty swtich > clause" > > -- > Dinesh Bolkensteyn > www.SonarSource.com <http://www.sonarsource.com/> > twitter.com/DBolkensteyn <http://www.sonarsource.com/> > > > > On Sun, May 27, 2012 at 5:07 PM, Andreas Dangel < > ad...@us...> wrote: > >> Hi guys, >> >> I'm trying to fix this bug: >> >> http://sourceforge.net/tracker/?func=detail&aid=3496028&group_id=56262&atid=479921 >> >> I've found a solution, but this would break an existing test case: >> >> >> <test-code> >> <description><![CDATA[ >> one break >> ]]></description> >> <expected-problems>0</expected-problems> >> <code><![CDATA[ >> public class Foo { >> void main() { >> switch(i) { >> case 1: >> case 2: >> break; >> default: >> } >> } >> } >> ]]></code> >> </test-code> >> >> >> Does anyone remember, why we don't expect a problem here? It has two >> cases and one default case (so in sum 3 cases) but only one break... Or >> did we interpret this as an intentional fall-through, as there is no >> statement between case 1 and 2? >> >> Regards, >> Andreas >> >> >> >> >> ------------------------------------------------------------------------------ >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and >> threat landscape has changed and how IT managers can respond. Discussions >> will include endpoint security, mobile security and the latest in malware >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >> _______________________________________________ >> Pmd-devel mailing list >> Pmd...@li... >> https://lists.sourceforge.net/lists/listinfo/pmd-devel >> > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Pmd-devel mailing list > Pmd...@li... > https://lists.sourceforge.net/lists/listinfo/pmd-devel > > -- Romain PELISSE, *"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it" -- Terry Pratchett* http://belaran.eu/wordpress/belaran |