From efd87c50e491d55cfc0dfd25d112ca02b49e513b Mon Sep 17 00:00:00 2001 From: XenoAmess Date: Wed, 26 Aug 2020 21:08:51 +0800 Subject: [PATCH] Fix a NPE created by the last pr. Sorry about that. --- .../java/net/sourceforge/pmd/cli/PMDCommandLineInterface.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDCommandLineInterface.java b/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDCommandLineInterface.java index 8642562b11..402b7726fd 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDCommandLineInterface.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cli/PMDCommandLineInterface.java @@ -60,7 +60,7 @@ public final class PMDCommandLineInterface { public static String buildUsageText(JCommander jcommander) { StringBuilder usage = new StringBuilder(); - StringBuilder allCommandsDescription = null; + StringBuilder allCommandsDescription = new StringBuilder(); if (jcommander != null && jcommander.getCommands() != null) { for (String command : jcommander.getCommands().keySet()) { allCommandsDescription.append(jcommander.getCommandDescription(command)).append(PMD.EOL); @@ -77,7 +77,7 @@ public final class PMDCommandLineInterface { fullText += supportedVersions() + PMD.EOL; - if (allCommandsDescription != null) { + if (allCommandsDescription.length() != 0) { fullText += "Optional arguments that may be put before or after the mandatory arguments: " + PMD.EOL + allCommandsDescription + PMD.EOL; }