<commit_before>/*
 * Copyright (c) 2015-2016 <NAME> & contributors.
 * All rights reserved.
 *
 * Copyright (c) 2010-2014 <NAME> & contributors
 * All rights reserved.
 *
 * This program and the accompanying materials are made available under the terms of the Eclipse
 * Public License v1.0 which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html.
 */
package uk.co.josephearl.sbt.findbugs

import java.io.File

import sbt.Keys._
import sbt._

private[findbugs] trait CommandLine extends Object with Filters {
  def commandLine(findbugsClasspath: Classpath, compileClasspath: Classpath,
      paths: PathSettings, filters: FilterSettings, filterPath: File, misc: MiscSettings, streams: TaskStreams) = {
    
    def findbugsCommandLine = findbugsJavaCall ++ findbugsCallOptions ++ findbugsCallArguments

    def findbugsJavaCall = {
      val classpath = commandLineClasspath(findbugsClasspath.files)
      streams.log.debug("FindBugs classpath: %s" format classpath)
  
      List("-Xmx%dm".format(misc.maxMemory),
          "-cp", classpath, "edu.umd.cs.findbugs.LaunchAppropriateUI", "-textui")
    }

    def findbugsCallArguments = paths.analyzedPath map (_.getPath)
    
    def findbugsCallOptions = {
      if (paths.reportPath.isDefined && misc.reportType.isEmpty)
        sys.error("If a report path is defined, a report type is required!")

      val auxClasspath = paths.auxPath ++ (findbugsClasspath.files filter (_.getName startsWith "jsr305"))

      addPluginListParameter(addOnlyAnalyzeParameter(addSortByClassParameter(addFilterFiles(filters, filterPath,
        misc.reportType.map(`type` => List(`type`.toString)).getOrElse(Nil) ++
        paths.reportPath.map(path => List("-output", path.absolutePath)).getOrElse(Nil) ++ List(
          "-nested:%b".format(misc.analyzeNestedArchives),
          "-auxclasspath", commandLineClasspath(auxClasspath),
          misc.priority.toString,
          "-effort:%s".format(misc.effort.toString))))))
    }
  
    def addOnlyAnalyzeParameter(arguments: List[String]) = misc.onlyAnalyze match {
      case None => arguments
      case Some(Nil) => arguments
      case Some(packagesAndClasses) => arguments ++ List("-onlyAnalyze", packagesAndClasses mkString ",")
    }

    def addPluginListParameter(arguments: List[String]) = misc.pluginList match {
      case Nil => arguments
      case plugins => arguments ++ List("-pluginList", plugins mkString ":")<commit_msg>Change pluginList separator from ":" to java.io.File.pathSeparator<commit_after>/*
 * Copyright (c) 2015-2016 <NAME> & contributors.
 * All rights reserved.
 *
 * Copyright (c) 2010-2014 <NAME> & contributors
 * All rights reserved.
 *
 * This program and the accompanying materials are made available under the terms of the Eclipse
 * Public License v1.0 which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html.
 */
package uk.co.josephearl.sbt.findbugs

import java.io.File

import sbt.Keys._
import sbt._

private[findbugs] trait CommandLine extends Object with Filters {
  def commandLine(findbugsClasspath: Classpath, compileClasspath: Classpath,
      paths: PathSettings, filters: FilterSettings, filterPath: File, misc: MiscSettings, streams: TaskStreams) = {
    
    def findbugsCommandLine = findbugsJavaCall ++ findbugsCallOptions ++ findbugsCallArguments

    def findbugsJavaCall = {
      val classpath = commandLineClasspath(findbugsClasspath.files)
      streams.log.debug("FindBugs classpath: %s" format classpath)
  
      List("-Xmx%dm".format(misc.maxMemory),
          "-cp", classpath, "edu.umd.cs.findbugs.LaunchAppropriateUI", "-textui")
    }

    def findbugsCallArguments = paths.analyzedPath map (_.getPath)
    
    def findbugsCallOptions = {
      if (paths.reportPath.isDefined && misc.reportType.isEmpty)
        sys.error("If a report path is defined, a report type is required!")

      val auxClasspath = paths.auxPath ++ (findbugsClasspath.files filter (_.getName startsWith "jsr305"))

      addPluginListParameter(addOnlyAnalyzeParameter(addSortByClassParameter(addFilterFiles(filters, filterPath,
        misc.reportType.map(`type` => List(`type`.toString)).getOrElse(Nil) ++
        paths.reportPath.map(path => List("-output", path.absolutePath)).getOrElse(Nil) ++ List(
          "-nested:%b".format(misc.analyzeNestedArchives),
          "-auxclasspath", commandLineClasspath(auxClasspath),
          misc.priority.toString,
          "-effort:%s".format(misc.effort.toString))))))
    }
  
    def addOnlyAnalyzeParameter(arguments: List[String]) = misc.onlyAnalyze match {
      case None => arguments
      case Some(Nil) => arguments
      case Some(packagesAndClasses) => arguments ++ List("-onlyAnalyze", packagesAndClasses mkString ",")
    }

    def addPluginListParameter(arguments: List[String]) = misc.pluginList match {
      case Nil => arguments
      case plugins => arguments ++ List("-pluginList", plugins mkString File.pathSeparator)
{'fraction_non_alphanumeric': 0.11398963730569948, 'fraction_numerical': 0.009166998804304504, 'mean_word_length': 3.9448275862068964, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3521560', 'n_tokens_mistral': 1508, 'n_tokens_neox': 1418, 'n_words': 340}