You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "István Fajth (Jira)" <ji...@apache.org> on 2021/08/10 16:52:00 UTC
[jira] [Comment Edited] (HDDS-5600) Allow nested blocks in switch
case statements in checkstyle checks
[ https://issues.apache.org/jira/browse/HDDS-5600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17396782#comment-17396782 ]
István Fajth edited comment on HDDS-5600 at 8/10/21, 4:51 PM:
--------------------------------------------------------------
As [~adoroszlai] pointed out in the PR:
{quote}
Allowing nested blocks for switch/case is great. Is see two potential problems:
The nested block requires odd indentation, e.g.:
case STRING: {
String value = from.get(key, defaultValue);
forcedFieldSet(field, configuration, value);
}
break;
Otherwise checkstyle complains about incorrect indentation level.
Sonar also gives warning for the block: Extract this nested code block into a method.
{quote}
This made me think, and I relaized in any of these cases one can use a method to exract the block out, and that probably is better as it makes the code easier to look through and understand, and also provides the wanted properties of having a separate block that handles a case branch.
Closing this as not a problem.
was (Author: pifta):
As [~adoroszlai] pointed out in the PR:
{quote}
Allowing nested blocks for switch/case is great. Is see two potential problems:
The nested block requires odd indentation, e.g.:
case STRING: {
String value = from.get(key, defaultValue);
forcedFieldSet(field, configuration, value);
}
break;
Otherwise checkstyle complains about incorrect indentation level.
Sonar also gives warning for the block: Extract this nested code block into a method.
{quote}
This made me think, and I relaized in any of these cases one can use a method to exract the block out, and that probably is better as it makes the code easier to look through and understand, and also provides the wanted properties of having a separate block that handles a case branch.
Closing this as won't fix
> Allow nested blocks in switch case statements in checkstyle checks
> ------------------------------------------------------------------
>
> Key: HDDS-5600
> URL: https://issues.apache.org/jira/browse/HDDS-5600
> Project: Apache Ozone
> Issue Type: Improvement
> Reporter: István Fajth
> Assignee: István Fajth
> Priority: Major
> Labels: pull-request-available
>
> In the checkstyle rules, we enable the module AvoidNestedBlocks.
> This is a problem, if for example a variable scope needs to be created inside a switch case statement, where this rule gives a warning if a case defines a code block ("{}").
> This JIRA is to loosen this rule, and allow nested blocks in switch statements.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org