Fix the short option for 'no-warning-for-unkeyed-lists' 23/100723/1
authorSangwook Ha <sangwook.ha@verizon.com>
Fri, 22 Apr 2022 16:13:03 +0000 (09:13 -0700)
committerSangwook Ha <sangwook.ha@verizon.com>
Fri, 22 Apr 2022 16:35:34 +0000 (09:35 -0700)
Dash "-" is not allowed in the short option string. Replace it
with 'K', a single character option consistent with others.

Having two options to control warnings on the unkeyed list,
although mutually exclusive, makes the default behavior unclear
when neither option is used.

Simplify the options by removing 'warning-for-unkeyed-lists'
while preserving the original default behavior of warning against
unkeyed lists when neither option is used.

JIRA: YANGTOOLS-1429
Change-Id: I6c37892ae7e39864420a0e6c15dd2fc1cf0ba952
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
tools/yang-model-validator/src/main/java/org/opendaylight/yangtools/yang/validator/Main.java

index 858d7b9e229d2d9ca6b5506bd18ac360afbf5978..1d9aac62deaf758f987533ac6eaa8eebe4c0a7e0 100644 (file)
@@ -49,8 +49,8 @@ import org.slf4j.LoggerFactory;
  *  -v, --verbose         shows details about the results of test running.
  *  -o, --output          path to output file for logs. Output file will be overwritten.
  *  -m, --module-name     validate yang by module name.
- *  -wul, --warning-for-unkeyed-lists
- *                        add warnings about unkeyed lists with config true.
+ *  -K, --no-warning-for-unkeyed-lists
+ *                        do not add warnings about unkeyed lists with config true.
  */
 @SuppressWarnings({"checkstyle:LoggerMustBeSlf4j", "checkstyle:LoggerFactoryClassParameter"})
 public final class Main {
@@ -78,9 +78,7 @@ public final class Main {
     private static final Option QUIET = new Option("q", "quiet", false, "completely suppress output.");
     private static final Option VERBOSE = new Option("v", "verbose", false,
         "shows details about the results of test running.");
-    private static final Option LIST_WARNING_ON = new Option("wul", "warning-for-unkeyed-lists", false,
-        "add warnings about unkeyed lists with config true");
-    private static final Option LIST_WARNING_OFF = new Option("no-wul", "no-warning-for-unkeyed-lists", false,
+    private static final Option LIST_WARNING_OFF = new Option("K", "no-warning-for-unkeyed-lists", false,
         "do not add warnings about unkeyed lists with config true");
 
     private Main() {
@@ -93,7 +91,7 @@ public final class Main {
             .addOption(PATH)
             .addOption(RECURSIVE)
             .addOptionGroup(new OptionGroup().addOption(DEBUG).addOption(QUIET).addOption(VERBOSE))
-            .addOptionGroup(new OptionGroup().addOption(LIST_WARNING_ON).addOption(LIST_WARNING_OFF))
+            .addOption(LIST_WARNING_OFF)
             .addOption(OUTPUT)
             .addOption(MODULE_NAME)
             .addOption(FEATURE);
@@ -123,12 +121,7 @@ public final class Main {
             LOG_ROOT.detachAndStopAllAppenders();
         }
 
-        final boolean warnForUnkeyedLists;
-        if (arguments.hasOption(LIST_WARNING_ON.getLongOpt()) || !arguments.hasOption(LIST_WARNING_OFF.getLongOpt())) {
-            warnForUnkeyedLists = true;
-        } else {
-            warnForUnkeyedLists = false;
-        }
+        final boolean warnForUnkeyedLists = !arguments.hasOption(LIST_WARNING_OFF.getLongOpt());
 
         final List<String> yangLibDirs = initYangDirsPath(arguments);
         final List<String> yangFiles = new ArrayList<>();