From 986b39208f5b98ae83fc214fcbec8a7598e9067d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Fri, 28 Aug 2020 13:59:13 +0200 Subject: [PATCH] Remove dead code in PMDCommandLineInterface --- .../pmd/cli/PMDCommandLineInterface.java | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 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 402b7726fd..04daf8b5dc 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 @@ -41,12 +41,12 @@ public final class PMDCommandLineInterface { jcommander.parse(args); if (arguments.isHelp()) { jcommander.usage(); - System.out.println(buildUsageText(jcommander)); + System.out.println(buildUsageText()); setStatusCodeOrExit(NO_ERRORS_STATUS); } } catch (ParameterException e) { jcommander.usage(); - System.out.println(buildUsageText(jcommander)); + System.out.println(buildUsageText()); System.err.println(e.getMessage()); setStatusCodeOrExit(ERROR_STATUS); } @@ -54,19 +54,6 @@ public final class PMDCommandLineInterface { } public static String buildUsageText() { - return buildUsageText(null); - } - - public static String buildUsageText(JCommander jcommander) { - StringBuilder usage = new StringBuilder(); - - StringBuilder allCommandsDescription = new StringBuilder(); - if (jcommander != null && jcommander.getCommands() != null) { - for (String command : jcommander.getCommands().keySet()) { - allCommandsDescription.append(jcommander.getCommandDescription(command)).append(PMD.EOL); - } - } - // TODO: Externalize that to a file available within the classpath ? - // with a poor's man templating ? String fullText = PMD.EOL + "Mandatory arguments:" + PMD.EOL + "1) A java source code filename or directory" @@ -77,18 +64,17 @@ public final class PMDCommandLineInterface { fullText += supportedVersions() + PMD.EOL; - if (allCommandsDescription.length() != 0) { - fullText += "Optional arguments that may be put before or after the mandatory arguments: " + PMD.EOL - + allCommandsDescription + PMD.EOL; - } - fullText += "Available report formats and their configuration properties are:" + PMD.EOL + getReports() + PMD.EOL + getExamples() + PMD.EOL + PMD.EOL + PMD.EOL; - fullText += usage.toString(); return fullText; } + @Deprecated + public static String buildUsageText(JCommander jcommander) { + return buildUsageText(); + } + private static String getExamples() { return getWindowsExample() + getUnixExample(); }