コード例 #1
0
  /**
   * Génère un rapport de métriques McCabe.
   *
   * @param pReport le nom de rapport à générer.
   * @throws Exception si un problème d'exécution apparaît.
   */
  protected void createReport(final String pReport) throws Exception {
    LOGGER.info(McCabeMessages.getString("logs.create.report", pReport));
    // Lancement de la création de tous les rapports
    String reportFileName = computeReportFileName(pReport);
    ArrayList params = new ArrayList();
    params.add(mConfiguration.getCliCommand());
    String param = null;
    for (int j = 0; j < mConfiguration.getMetricsCommand().length; j++) {
      // Remplacer les paramètres configurables (%...%), ce sont des paramètres
      // qui remplacent des clés dans les paramètres de configuration
      // des analyses McCabe (classpath pour Java,...)
      param =
          mConfiguration.getMetricsCommand()[j].replaceAll(
              McCabeMessages.getString("key.substition.report_name"), pReport);
      param =
          param.replaceAll(McCabeMessages.getString("key.substition.report_out"), reportFileName);
      params.add(param);
    }
    String type[] = new String[0];
    String modifiedParams[] = (String[]) params.toArray(type);

    mProcess =
        createProcessManager(
            modifiedParams, mConfiguration.getSubWorkspace(), mConfiguration.getLogger());
    // On veut gérer les informations lancées par le processus en sortie
    mProcess.setOutputHandler(this);
    int resultMetrics = mProcess.startProcess(this);
    if (resultMetrics != 0) {
      throw new McCabeException(
          McCabeMessages.getString("error.processing") + " #" + resultMetrics);
    }
  }