You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/12/04 17:09:21 UTC

[GitHub] [incubator-doris] jackwener commented on a change in pull request #7302: [refactor] modify the control flow code to improve code readability

jackwener commented on a change in pull request #7302:
URL: https://github.com/apache/incubator-doris/pull/7302#discussion_r762445660



##########
File path: fe/fe-core/src/main/java/org/apache/doris/PaloFe.java
##########
@@ -232,63 +232,67 @@ private static CommandLineOptions parseArgs(String[] args) {
         // version
         if (cmd.hasOption('v') || cmd.hasOption("version")) {
             return new CommandLineOptions(true, "", null);
-        } else if (cmd.hasOption('b') || cmd.hasOption("bdb")) {
+        }
+        // helper
+        if (cmd.hasOption('h') || cmd.hasOption("helper")) {
+            String helperNode = cmd.getOptionValue("helper");
+            if (Strings.isNullOrEmpty(helperNode)) {
+                System.err.println("Missing helper node");
+                System.exit(-1);
+            }
+            return new CommandLineOptions(false, helperNode, null);
+        }
+
+        if (cmd.hasOption('b') || cmd.hasOption("bdb")) {
             if (cmd.hasOption('l') || cmd.hasOption("listdb")) {
                 // list bdb je databases
                 BDBToolOptions bdbOpts = new BDBToolOptions(true, "", false, "", "", 0);
                 return new CommandLineOptions(false, "", bdbOpts);
-            } else if (cmd.hasOption('d') || cmd.hasOption("db")) {
+            } 
+            if (cmd.hasOption('d') || cmd.hasOption("db")) {
                 // specify a database
                 String dbName = cmd.getOptionValue("db");
                 if (Strings.isNullOrEmpty(dbName)) {
                     System.err.println("BDBJE database name is missing");
                     System.exit(-1);
                 }
-
                 if (cmd.hasOption('s') || cmd.hasOption("stat")) {
                     BDBToolOptions bdbOpts = new BDBToolOptions(false, dbName, true, "", "", 0);
                     return new CommandLineOptions(false, "", bdbOpts);
-                } else {
-                    String fromKey = "";
-                    String endKey = "";
-                    int metaVersion = 0;
-                    if (cmd.hasOption('f') || cmd.hasOption("from")) {
-                        fromKey = cmd.getOptionValue("from");
-                        if (Strings.isNullOrEmpty(fromKey)) {
-                            System.err.println("from key is missing");
-                            System.exit(-1);
-                        }
+                }
+                String fromKey = "";
+                String endKey = "";
+                int metaVersion = 0;
+                if (cmd.hasOption('f') || cmd.hasOption("from")) {
+                    fromKey = cmd.getOptionValue("from");
+                    if (Strings.isNullOrEmpty(fromKey)) {
+                        System.err.println("from key is missing");
+                        System.exit(-1);
                     }
-                    if (cmd.hasOption('t') || cmd.hasOption("to")) {
-                        endKey = cmd.getOptionValue("to");
-                        if (Strings.isNullOrEmpty(endKey)) {
-                            System.err.println("end key is missing");
-                            System.exit(-1);
-                        }
+                }
+                if (cmd.hasOption('t') || cmd.hasOption("to")) {
+                    endKey = cmd.getOptionValue("to");
+                    if (Strings.isNullOrEmpty(endKey)) {
+                        System.err.println("end key is missing");
+                        System.exit(-1);
                     }
-                    if (cmd.hasOption('m') || cmd.hasOption("metaversion")) {
-                        try {
-                            metaVersion = Integer.valueOf(cmd.getOptionValue("metaversion"));
-                        } catch (NumberFormatException e) {
-                            System.err.println("Invalid meta version format");
-                            System.exit(-1);
-                        }
+                }
+                if (cmd.hasOption('m') || cmd.hasOption("metaversion")) {
+                    try {
+                        metaVersion = Integer.valueOf(cmd.getOptionValue("metaversion"));
+                    } catch (NumberFormatException e) {
+                        System.err.println("Invalid meta version format");
+                        System.exit(-1);
                     }
-
-                    BDBToolOptions bdbOpts = new BDBToolOptions(false, dbName, false, fromKey, endKey, metaVersion);
-                    return new CommandLineOptions(false, "", bdbOpts);
+                }
+                
+                BDBToolOptions bdbOpts = new BDBToolOptions(false, dbName, false, fromKey, endKey, metaVersion);
+                return new CommandLineOptions(false, "", bdbOpts);
                 }
             } else {
                 System.err.println("Invalid options when running bdb je tools");
                 System.exit(-1);
             }
-        } else if (cmd.hasOption('h') || cmd.hasOption("helper")) {
-            String helperNode = cmd.getOptionValue("helper");
-            if (Strings.isNullOrEmpty(helperNode)) {
-                System.err.println("Missing helper node");
-                System.exit(-1);
-            }
-            return new CommandLineOptions(false, helperNode, null);
         }
 
         // helper node is null, means no helper node is specified

Review comment:
       This annotation is confusing. I think it's wrong because the last `return` isn't related with `helper node`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org