// Path: src/main/java/net/nandgr/cba/custom/visitor/helper/StringsHelper.java
// public class StringsHelper {
// 
//   private static final String CLASS_SUFFIX = ".class";
// 
//   private StringsHelper() {
//     throw new IllegalAccessError("Cannot instantiate this utility class.");
//   }
// 
//   public static String dotsToSlashes(String s) {
//     return s.replaceAll("\\.", "/");
//   }
// 
//   public static String spacesToDashesLowercase(String s) {
//     return s.replaceAll(" ", "-").toLowerCase();
//   }
// 
//   public static String simpleDescriptorToHuman(String s) {
//     String result = s;
//     if(result.startsWith("[")) {
//       result = result.substring(1, result.length());
//     }
//     if (result.startsWith("L")) {
//       result = result.substring(1, result.length());
//     }
//     if (result.endsWith(";")) {
//       result = result.substring(0, result.length()-1);
// 
//     }
//     return result;
//   }
// 
//   public static String removeClassSuffix(String s) {
//     if (s.endsWith(CLASS_SUFFIX)) {
//       return s.substring(0, s.length()-CLASS_SUFFIX.length());
//     }
//     return s;
//   }
// }
// 
// Path: src/main/java/net/nandgr/cba/cli/CliHelper.java
// public class CliHelper {
// 
//   private static CommandLineParser commandLineParser = new DefaultParser();
//   private static CommandLine commandLine;
//   private static Rules rules;
// 
//   private CliHelper() {
//     throw new IllegalAccessError("Cannot instantiate this utility class.");
//   }
// 
//   public static void parseCliArguments(String[] args) throws ParseException {
//     commandLine = commandLineParser.parse(CliArguments.getOptions(), args);
//   }
// 
//   public static String getPathToAnalyze() {
//     return commandLine.getOptionValue("a");
//   }
// 
//   public static int getMaxThreads() {
//     return Integer.parseInt(commandLine.getOptionValue("t", CliArguments.MAX_THREADS_DEFAULT));
//   }
// 
//   public static boolean hasOutputDir() {
//     return commandLine.hasOption("o");
//   }
// 
//   public static String getOutputDir() {
//     return commandLine.getOptionValue("o", CliArguments.OUTPUT_DEFAULT);
//   }
// 
//   public static boolean hasMaxItemsInReport() {
//     return commandLine.hasOption("i");
//   }
// 
//   public static int getMaxItemsInReport() {
//     return Integer.parseInt(commandLine.getOptionValue("i", CliArguments.MAX_ITEMS_IN_REPORT_DEFAULT));
//   }
// 
//   public static boolean hasChecks() {
//     return commandLine.hasOption("c");
//   }
// 
//   public static String[] getChecks() {
//     return commandLine.getOptionValues("c");
//   }
// 
//   public static boolean hasCustomFile() {
//     return commandLine.hasOption("f");
//   }
// 
//   public static String getCustomFile() {
//     return commandLine.getOptionValue("f");
//   }
// 
//   public static void printHelp() {
//     HelpFormatter helpFormatter = new HelpFormatter();
//     helpFormatter.printHelp("java -jar cba-cli.jar [OPTIONS] -a DIRECTORY_TO_ANALYZE", CliArguments.getOptions());
//   }
// 
//   public static boolean hasHelp() {
//     return commandLine.hasOption("h");
//   }
// 
//   public static boolean hasVerboseDebug() {
//     return commandLine.hasOption("v");
//   }
// 
//   public static boolean hasVerboseTrace() {
//     return commandLine.hasOption("vv");
//   }
// 
//   public static Rules getRules() {
//     return rules;
//   }
// 
//   public static void setRules(Rules rules) {
//     CliHelper.rules = rules;
//   }
// }


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.Lists;
import java.io.StringWriter;
import java.util.Properties;
import net.nandgr.cba.custom.visitor.helper.StringsHelper;
import net.nandgr.cba.cli.CliHelper;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
/*
 * Copyright (c) 2016-2017, Fernando Garcia
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package net.nandgr.cba.report;


public class ReportBuilder {

  private static final Logger logger = LoggerFactory.getLogger(ReportBuilder.class);

  private ReportBuilder() {
    throw new IllegalAccessError("Do not instantiate this class.");
  }

  public static void saveAsHtml(Map<String, List<ReportItem>> reportItems) {
    for (Map.Entry<String,List<ReportItem>> entry : reportItems.entrySet()) {
      String ruleName = entry.getKey();
      saveAsHtml(ruleName,entry.getValue());
    }
  }

  public static void saveAsHtml(String ruleName, List<ReportItem> reportItemList) {
// Path: src/main/java/net/nandgr/cba/custom/visitor/helper/StringsHelper.java
// public class StringsHelper {
// 
//   private static final String CLASS_SUFFIX = ".class";
// 
//   private StringsHelper() {
//     throw new IllegalAccessError("Cannot instantiate this utility class.");
//   }
// 
//   public static String dotsToSlashes(String s) {
//     return s.replaceAll("\\.", "/");
//   }
// 
//   public static String spacesToDashesLowercase(String s) {
//     return s.replaceAll(" ", "-").toLowerCase();
//   }
// 
//   public static String simpleDescriptorToHuman(String s) {
//     String result = s;
//     if(result.startsWith("[")) {
//       result = result.substring(1, result.length());
//     }
//     if (result.startsWith("L")) {
//       result = result.substring(1, result.length());
//     }
//     if (result.endsWith(";")) {
//       result = result.substring(0, result.length()-1);
// 
//     }
//     return result;
//   }
// 
//   public static String removeClassSuffix(String s) {
//     if (s.endsWith(CLASS_SUFFIX)) {
//       return s.substring(0, s.length()-CLASS_SUFFIX.length());
//     }
//     return s;
//   }
// }
// 
// Path: src/main/java/net/nandgr/cba/cli/CliHelper.java
// public class CliHelper {
// 
//   private static CommandLineParser commandLineParser = new DefaultParser();
//   private static CommandLine commandLine;
//   private static Rules rules;
// 
//   private CliHelper() {
//     throw new IllegalAccessError("Cannot instantiate this utility class.");
//   }
// 
//   public static void parseCliArguments(String[] args) throws ParseException {
//     commandLine = commandLineParser.parse(CliArguments.getOptions(), args);
//   }
// 
//   public static String getPathToAnalyze() {
//     return commandLine.getOptionValue("a");
//   }
// 
//   public static int getMaxThreads() {
//     return Integer.parseInt(commandLine.getOptionValue("t", CliArguments.MAX_THREADS_DEFAULT));
//   }
// 
//   public static boolean hasOutputDir() {
//     return commandLine.hasOption("o");
//   }
// 
//   public static String getOutputDir() {
//     return commandLine.getOptionValue("o", CliArguments.OUTPUT_DEFAULT);
//   }
// 
//   public static boolean hasMaxItemsInReport() {
//     return commandLine.hasOption("i");
//   }
// 
//   public static int getMaxItemsInReport() {
//     return Integer.parseInt(commandLine.getOptionValue("i", CliArguments.MAX_ITEMS_IN_REPORT_DEFAULT));
//   }
// 
//   public static boolean hasChecks() {
//     return commandLine.hasOption("c");
//   }
// 
//   public static String[] getChecks() {
//     return commandLine.getOptionValues("c");
//   }
// 
//   public static boolean hasCustomFile() {
//     return commandLine.hasOption("f");
//   }
// 
//   public static String getCustomFile() {
//     return commandLine.getOptionValue("f");
//   }
// 
//   public static void printHelp() {
//     HelpFormatter helpFormatter = new HelpFormatter();
//     helpFormatter.printHelp("java -jar cba-cli.jar [OPTIONS] -a DIRECTORY_TO_ANALYZE", CliArguments.getOptions());
//   }
// 
//   public static boolean hasHelp() {
//     return commandLine.hasOption("h");
//   }
// 
//   public static boolean hasVerboseDebug() {
//     return commandLine.hasOption("v");
//   }
// 
//   public static boolean hasVerboseTrace() {
//     return commandLine.hasOption("vv");
//   }
// 
//   public static Rules getRules() {
//     return rules;
//   }
// 
//   public static void setRules(Rules rules) {
//     CliHelper.rules = rules;
//   }
// }


// Path: src/main/java/net/nandgr/cba/report/ReportBuilder.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.Lists;
import java.io.StringWriter;
import java.util.Properties;
import net.nandgr.cba.custom.visitor.helper.StringsHelper;
import net.nandgr.cba.cli.CliHelper;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;

/*
 * Copyright (c) 2016-2017, Fernando Garcia
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package net.nandgr.cba.report;


public class ReportBuilder {

  private static final Logger logger = LoggerFactory.getLogger(ReportBuilder.class);

  private ReportBuilder() {
    throw new IllegalAccessError("Do not instantiate this class.");
  }

  public static void saveAsHtml(Map<String, List<ReportItem>> reportItems) {
    for (Map.Entry<String,List<ReportItem>> entry : reportItems.entrySet()) {
      String ruleName = entry.getKey();
      saveAsHtml(ruleName,entry.getValue());
    }
  }

  public static void saveAsHtml(String ruleName, List<ReportItem> reportItemList) {
    File reportsDirectory = new File(CliHelper.getOutputDir());