[ 
https://issues.apache.org/jira/browse/HIVE-30291?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

László Bodor updated HIVE-30291:
--------------------------------
    Fix Version/s: 4.3.0

> Checkstyle: indent switch case labels one level (Google Java Style)
> -------------------------------------------------------------------
>
>                 Key: HIVE-30291
>                 URL: https://issues.apache.org/jira/browse/HIVE-30291
>             Project: Hive
>          Issue Type: Improvement
>            Reporter: László Bodor
>            Assignee: László Bodor
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 4.3.0
>
>
> Hive's Checkstyle configs set {{caseIndent=0}}, which requires {{case}} and 
> {{default}} labels to sit in the same column as the {{switch}}. That follows 
> the old Sun/Oracle code conventions. Modern Java style, including the Google 
> Java Style Guide, Checkstyle's own default and IntelliJ's default formatter, 
> indents the labels one level inside the switch block. That is also what most 
> editors produce, so new code gets flagged by Checkstyle (and by SonarCloud, 
> which imports the Checkstyle report) for following standard formatting.
> The project is already inconsistent:
> * the {{iceberg}} module uses {{caseIndent=2}}
> * the root, {{standalone-metastore}}, {{storage-api}} and {{hcatalog}} 
> configs use {{caseIndent=0}}
> Survey of hand-written Java on master (first label of each switch):
> ||Style||Switches||
> |Same column as switch|1038|
> |Indented one level|513|
> |Arrow-style ({{case X ->}}) only: same column / indented|6 / 68|
> Older switch statements mostly use the same-column style, while nearly all of 
> the newer arrow-style switches are already indented. The arrow-style switches 
> show where the code base is heading.
> h3. Proposed change
> * Set {{caseIndent}} to 2 (one {{basicOffset}} level) in 
> {{checkstyle/checkstyle.xml}}, 
> {{standalone-metastore/checkstyle/checkstyle.xml}}, 
> {{storage-api/checkstyle/checkstyle.xml}} and 
> {{hcatalog/build-support/checkstyle/coding_style.xml}}, matching {{iceberg}}.
> * Set {{indent_switchstatements_compare_to_switch}} to {{true}} in 
> {{dev-support/eclipse-styles.xml}} so the Eclipse formatter agrees.
> Existing code is not reformatted. Checkstyle is not enforced in the build, 
> and SonarCloud only reports on new code, so old switches that use the 
> same-column style won't cause any pull request to fail.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to