<commit_before>(ns cake.tasks.check
    "Check syntax and warn on reflection."
  (:use cake
        cake.core
        [cake.file :only [file rmdir]]
        [cake.tasks.compile :only [source-dir]]))

(deftask check #{compile-java}
  "Check syntax and warn on reflection."
  (let [source-path (source-dir)]
    (bake (:use [bake.core :only [log print-stacktrace]]
                [bake.find-namespaces :only [find-clojure-sources-in-dir
                                             read-file-ns-decl]]
                [bake.nsdeps :only [deps-from-ns-decl]])
          [source-path source-path] ;; Just copy the var over to bake.
          (binding [*warn-on-reflection* true]
            (doseq [src-file (find-clojure-sources-in-dir source-path)]
              (let [depends-on-cake-core?
                    (fn [ns-decl]
                      (contains? (deps-from-ns-decl ns-decl) 'cake.core))
                    src-file-ns-decl (read-file-ns-decl src-file)]
                ;; Skip any namespaces that depend on cake.core, as they
                ;; will fail.
                (if (not (depends-on-cake-core? src-file-ns-decl))
                  (do (log "Compiling namespace " (second src-file-ns-decl))
                      (try
                        (load-file (.getPath src-file))
                        (catch ExceptionInInitializerError e
                          (print-stacktrace e))))
                  (do
                    (log "Skipping namespace " (second src-file-ns-decl))
                    (log "  Reason: Dependency on cake.core")))))))))<commit_msg>Updated check task to reload project before and after; this should fix problem which was causing unreliable results based on whether a class was already aot compiled or not. In particular, this was causing the check task to fail on clojure-protobuf and unreliable results when run on projects where certain classes were already aot-compiled.<commit_after>(ns cake.tasks.check
    "Check syntax and warn on reflection."
  (:use cake
        cake.core
        [cake.file :only [file rmdir]]
        [cake.project :only [reload!]]
        [cake.tasks.compile :only [source-dir]]))

(deftask check #{compile-java}
  "Check syntax and warn on reflection."
  (let [source-path (source-dir)]
    (reload!)
    (bake (:use [bake.core :only [log print-stacktrace]]
                [bake.find-namespaces :only [find-clojure-sources-in-dir
                                             read-file-ns-decl]]
                [bake.nsdeps :only [deps-from-ns-decl]])
          [source-path source-path] ;; Just copy the var over to bake.
          (binding [*warn-on-reflection* true]
            (doseq [src-file (find-clojure-sources-in-dir source-path)]
              (let [depends-on-cake-core?
                    (fn [ns-decl]
                      (contains? (deps-from-ns-decl ns-decl) 'cake.core))
                    src-file-ns-decl (read-file-ns-decl src-file)]
                ;; Skip any namespaces that depend on cake.core, as they
                ;; will fail.
                (if (not (depends-on-cake-core? src-file-ns-decl))
                  (do (log "Compiling namespace " (second src-file-ns-decl))
                      (try
                        (load-file (.getPath src-file))
                        (catch ExceptionInInitializerError e
                          (print-stacktrace e))))
                  (do
                    (log "Skipping namespace " (second src-file-ns-decl))
                    (log "  Reason: Dependency on cake.core")))))))
    (reload!)))
{'fraction_non_alphanumeric': 0.11878685762426285, 'fraction_numerical': 0.0, 'mean_word_length': 1.642433234421365, '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': '1326262', 'n_tokens_mistral': 1043, 'n_tokens_neox': 977, 'n_words': 279}