CPD Results

The following document contains the results of PMD's CPD 6.55.0.

Duplications

File Line
gov/nist/secauto/metaschema/cli/commands/AbstractConvertSubcommand.java 157
gov/nist/secauto/metaschema/cli/commands/GenerateSchemaCommand.java 173
List<String> extraArgs = cmdLine.getArgList();

      Path destination = null;
      if (extraArgs.size() > 1) {
        destination = Paths.get(extraArgs.get(1)).toAbsolutePath();
      }

      if (destination != null) {
        if (Files.exists(destination)) {
          if (!cmdLine.hasOption(OVERWRITE_OPTION)) {
            return ExitCode.INVALID_ARGUMENTS.exitMessage(
                String.format("The provided destination '%s' already exists and the '%s' option was not provided.",
                    destination,
                    OptionUtils.toArgument(OVERWRITE_OPTION)));
          }
          if (!Files.isWritable(destination)) {
            return ExitCode.IO_ERROR.exitMessage(
                "The provided destination '" + destination + "' is not writable.");
          }
        } else {
          Path parent = destination.getParent();
          if (parent != null) {
            try {
              Files.createDirectories(parent);
            } catch (IOException ex) {
              return ExitCode.INVALID_TARGET.exit().withThrowable(ex); // NOPMD readability
            }
          }
        }
      }