<commit_before>(ns spekl-package-manager.command-check
  (:require [clojure.java.io :as io]
            [clojure.tools.logging :as log]
            [spekl-package-manager.util :as util]
            [spekl-package-manager.constants :as constants]
            [spekl-package-manager.download :as download]
            [spekl-package-manager.package :as package]
            [spekl-package-manager.check :as check]
            [clojure.core.reducers :as r]
            [org.satta.glob :as glob]
            [clojure.string :as string]
            [clojure.java.shell :as shell]
            
            )

    (:import
    (java.io FileNotFoundException)
    (org.spekl.spm.utils PackageLoadException
                         ProjectConfigurationException))
  )



;; expands a string like [src/*.java]
(defn expand-glob [globs]
  (let [groups (map (fn [x] (glob/glob (.trim x))) globs)]
    ;; combine
    (map (fn [x] (.getPath x)) (r/reduce (fn [acc x] (concat acc x)) []  groups))
    ))


(defn path-resolve [env]
  (let [package-base (env :path-to-package) package-index (env :resolved-packages)]
    (fn
      ;; write this
      ([package asset] (.toString (.resolve (.toPath (io/file ((package-index package) :dir))) asset)))
      ([asset] (.toString (.resolve (.toPath (io/file package-base)) asset)))  
      ))
  )

(defn fallback-to-default [check]
  (if (= nil (check :check))
    "default"
    (check :check)))


;; read the package file for the package that runs the tool
;; build a map for each package it DEPENDS on
;; :file, :dir, :description


(seq? ((first ((package/read-local-conf "spekl.yml") :checks)) :classpath))


(defn run-configured-check [configuration]
  (let [package (configuration :package-data) config (configuration :configured-check)]<commit_msg>removed test<commit_after>(ns spekl-package-manager.command-check
  (:require [clojure.java.io :as io]
            [clojure.tools.logging :as log]
            [spekl-package-manager.util :as util]
            [spekl-package-manager.constants :as constants]
            [spekl-package-manager.download :as download]
            [spekl-package-manager.package :as package]
            [spekl-package-manager.check :as check]
            [clojure.core.reducers :as r]
            [org.satta.glob :as glob]
            [clojure.string :as string]
            [clojure.java.shell :as shell]
            
            )

    (:import
    (java.io FileNotFoundException)
    (org.spekl.spm.utils PackageLoadException
                         ProjectConfigurationException))
  )



;; expands a string like [src/*.java]
(defn expand-glob [globs]
  (let [groups (map (fn [x] (glob/glob (.trim x))) globs)]
    ;; combine
    (map (fn [x] (.getPath x)) (r/reduce (fn [acc x] (concat acc x)) []  groups))
    ))


(defn path-resolve [env]
  (let [package-base (env :path-to-package) package-index (env :resolved-packages)]
    (fn
      ;; write this
      ([package asset] (.toString (.resolve (.toPath (io/file ((package-index package) :dir))) asset)))
      ([asset] (.toString (.resolve (.toPath (io/file package-base)) asset)))  
      ))
  )

(defn fallback-to-default [check]
  (if (= nil (check :check))
    "default"
    (check :check)))


;; read the package file for the package that runs the tool
;; build a map for each package it DEPENDS on
;; :file, :dir, :description



(defn run-configured-check [configuration]
  (let [package (configuration :package-data) config (configuration :configured-check)]
{'fraction_non_alphanumeric': 0.14363532110091742, 'fraction_numerical': 0.0, 'mean_word_length': 2.5858170606372046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7310235', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1080, 'n_words': 298}