Re: [all] FindBugs' Switch statement found in class.method where default case is missing

2012-09-05 Thread Gary Gregory
On Wed, Sep 5, 2012 at 4:02 PM, sebb wrote: > Seems to me there are several reasons why the default case may have > been omitted: > > 1) It was accidentally omitted. > In this case, add the required clause. > > 2) It was omitted because nothing needs to be done. > In this case, this needs to be d

Re: [all] FindBugs' Switch statement found in class.method where default case is missing

2012-09-05 Thread Liviu Tudor
I understand your point about the code having to be descriptive about why the clause is not present, which is why I suggested using checkstyle, as it allows for configuration of a comment which skips that check. However, IMHO your point is valid about having an assertion/error such that future cha

Re: [all] FindBugs' Switch statement found in class.method where default case is missing

2012-09-05 Thread sebb
Seems to me there are several reasons why the default case may have been omitted: 1) It was accidentally omitted. In this case, add the required clause. 2) It was omitted because nothing needs to be done. In this case, this needs to be documented; the easiest way is to add: default: break; /

Re: [all] FindBugs' Switch statement found in class.method where default case is missing

2012-09-04 Thread Liviu Tudor
Hi guys, I am looking at this from a different perspective: the same check can be performed using checkstyle (http://checkstyle.sourceforge.net/config_coding.html#MissingSwitchDefault) as well as FindBugs. So if this is a valid case where there is no need for a default branch, we could perhaps s

Re: [all] FindBugs' Switch statement found in class.method where default case is missing

2012-09-04 Thread Gilles Sadowski
> > > > > > FindBugs can give warnings like: > > > > > > Switch statement found in > > > org.apache.commons.codec.binary.Base32.decode(byte[], int, int, > > > BaseNCodec$Context) where default case is missing > > > > > > In this case for [codec], it looks like the code was carefully > > constructed

Re: [all] FindBugs' Switch statement found in class.method where default case is missing

2012-09-04 Thread Sébastien Brisard
Sorry James, you misunderstood me. My point was just that Bloch seems to be consistently using the same exception, namely AssertionError, but that I'd rather use IllegalStateException. Of course, in some cases IllegalArgumentException would make sense. S 2012/9/4 James Carman : > I wasn't necessar

Re: [all] FindBugs' Switch statement found in class.method where default case is missing

2012-09-04 Thread James Carman
I wasn't necessarily saying that we should always use IllegalArgumentException (although it can be applicable if the thing being switched upon is an argument to the method). The idea was that we could throw an exception of some sort in our default clause. On Tue, Sep 4, 2012 at 10:44 AM, Sébastie

Re: [all] FindBugs' Switch statement found in class.method where default case is missing

2012-09-04 Thread Gary Gregory
On Tue, Sep 4, 2012 at 9:01 AM, Gilles Sadowski < gil...@harfang.homelinux.org> wrote: > Hi. > > > > > FindBugs can give warnings like: > > > > Switch statement found in > > org.apache.commons.codec.binary.Base32.decode(byte[], int, int, > > BaseNCodec$Context) where default case is missing > > >

Re: [all] FindBugs' Switch statement found in class.method where default case is missing

2012-09-04 Thread Sébastien Brisard
Hello, 2012/9/4 James Carman : > Something like: > > throw new IllegalArgumentException("This should never happen because > we are so smart we thought of every possibility in our case > statement."); > > would suffice :) > Not that it really matters, since this is never going to occur, but I think

Re: [all] FindBugs' Switch statement found in class.method where default case is missing

2012-09-04 Thread James Carman
Something like: throw new IllegalArgumentException("This should never happen because we are so smart we thought of every possibility in our case statement."); would suffice :) On Tue, Sep 4, 2012 at 9:02 AM, Benedikt Ritter wrote: > Hi Gary, > > IMHO FindBugs is supposed to point you at code f

Re: [all] FindBugs' Switch statement found in class.method where default case is missing

2012-09-04 Thread Benedikt Ritter
Hi Gary, IMHO FindBugs is supposed to point you at code fragments that potentially could cause subtle bugs. If say that the code in codec is carefully constructed and everything is backed up by junit tests, I'd say a default clause is nosy and doesn't add anything. OTOH if you can not see that no

Re: [all] FindBugs' Switch statement found in class.method where default case is missing

2012-09-04 Thread Gilles Sadowski
Hi. > > FindBugs can give warnings like: > > Switch statement found in > org.apache.commons.codec.binary.Base32.decode(byte[], int, int, > BaseNCodec$Context) where default case is missing > > In this case for [codec], it looks like the code was carefully constructed > and that no default claus