hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Yu <yuzhih...@gmail.com>
Subject Re: A checkstyle question: indentation in switch-case statements
Date Wed, 04 May 2016 17:18:17 GMT
Looks like there is no official indentation in this case.

I think you can go with what HBASE code style gives you.

On Wed, May 4, 2016 at 9:16 AM, Stephen Jiang <syuanjiangdev@gmail.com>
wrote:

> thanks, Matteo.  I also suspected that this is the issue.  I am just
> surprised that the code exists for a while and no complain in the past.
>
> When I loaded the HBASE code style in Eclipse, this is the indentation
> style I got when I hit 'return' after typing 'case'.  And I checked other
> existing code (eg. TableState.java and MetaTableAccessor.java), there are
> using the same indentation style (AKA, no indentation for case-statement);
> however, some other code (eg. HBaseAdmin.java), 2-space indentations are
> used.  So which style is official?
>
> thanks
> Stephen
>
> On Wed, May 4, 2016 at 7:20 AM, Matteo Bertozzi <theo.bertozzi@gmail.com>
> wrote:
>
> > I think it is complaining because the "case" is aligned with the "switch"
> > and not indented
> >
> > Matteo
> >
> >
> > On Wed, May 4, 2016 at 7:13 AM, Stephen Jiang <syuanjiangdev@gmail.com>
> > wrote:
> >
> > > I got two checkstyle warning for the style of switch-case statements:
> > >
> > >
> > >
> >
> ./hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/AddColumnFamilyProcedure.java:386:
> > >            cpHost.preAddColumnFamilyAction(tableName, cfDescriptor);:
> > > error: 'block' child have incorrect indentation level 12, expected
> > > level should be one of the following: 14, 16.
> > >
> > >
> >
> ./hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/AddColumnFamilyProcedure.java:386:
> > >            cpHost.preAddColumnFamilyAction(tableName, cfDescriptor);:
> > > error: 'method call' child have incorrect indentation level 12,
> > > expected level should be one of the following: 14, 16.
> > >
> > > To me, the 2-space indentation looks correct.  What is wrong for this
> > style
> > > (switch and case are in the same level, is this wrong?  I set up HBASE
> > > coding style in eclipse and it automatically did it this way)?
> > >
> > >           switch (state) {
> > >
> > >           case ADD_COLUMN_FAMILY_PRE_OPERATION:
> > >
> > >             cpHost.preAddColumnFamilyAction(tableName, cfDescriptor);
> > >
> > >             break;
> > >
> > >           case ADD_COLUMN_FAMILY_POST_OPERATION:
> > >
> > >             cpHost.postCompletedAddColumnFamilyAction(tableName,
> > > cfDescriptor);
> > >
> > >             break;
> > >
> > >           default:
> > >
> > >             throw new UnsupportedOperationException(this + " unhandled
> > > state=" + state);
> > >
> > >           }
> > >
> > >
> > > Any insight would be helpful.
> > >
> > > Thanks
> > >
> > > Stephen
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message