<commit_before>(ns frontend.components.build-config
  (:require [cljs.core.async :as async :refer [>! <! alts! chan sliding-buffer close!]]
            [frontend.async :refer [raise!]]
            [frontend.components.common :as common]
            [frontend.state :as state]
            [frontend.utils :as utils :include-macros true]
            [frontend.utils.github :as gh-utils]
            [frontend.utils.vcs-url :as vcs-url]
            [om.core :as om :include-macros true])
    (:require-macros [frontend.utils :refer [html]]))

(defn diagnostics [config owner]
  (reify
    om/IInitState
    (init-state [_]
      ;; TODO convert CI.inner.Diagnostics to clojurescript
      {:configDiagnostics (js/CI.inner.Diagnostics. (:string config) (clj->js (:errors config)))})
    om/IRenderState
    (render-state [_ {:keys [configDiagnostics]}]
      (html
       [:section
        [:table.code
         [:thead [:tr [:th] [:th]]]
         [:tbody
          (for [line (aget configDiagnostics "lines")]
            (list [:tr {:class (when (aget line "has_errors") "error")}
                   [:td.line-number (aget line "line")]
                   [:td.line
                    (for [piece (aget line "pieces")]
                      (list
                       (when (aget piece "data")
                         [:span {:class (when (aget piece "error") "error")}
                          (aget piece "data")])
                       (when (aget piece "error_flag")
                         [:span [:a.error-flag {:on-click #(do ((aget piece "select"))
                                                               (om/refresh! owner))
                                                :class (when ((aget piece "get_selected")) "selected")}
                                 (inc (aget piece "number"))]])))]]
                  (for [error (aget line "errors")]
                    [:tr.error-message {:class (when ((aget error "get_selected")) "opened")}
                     [:td.line-number]
                     [:td.error-message
                      (when (aget error "path")
                        [:span.path (aget error "path")])
                      (aget error "message") "."
                      [:div.next-button
                       [:a {:on-click #(do ((aget error "select_next"))
                                           (om/refresh! owner))}
                        [:i.fa.fa-angle-right]]]]])))]]]))))

(defn config-errors [build owner]
  (reify
    om/IRender
    (render [_]
      (let [config (:circle_yml build)]
        (html
         [:div.config-diagnostics.heroic
          (when-not (:lethal config)
            [:button.dismiss {:on-click #(raise! owner [:dismiss-config-errors])}
             "Dismiss "
             [:i.fa.fa-times-circle]])
          [:header
           [:div.head-left
            (if (:lethal config)
              (common/icon {:name "fail" :type "status"})
              [:i.error.fa.fa-exclamation-triangle])]
           [:div.head-right
            [:h2 "Dang."]
            [:p
             "We spotted some issues with your " [:code "circle.yml"] "."

             (when-not (:lethal config)
               (if (:failed build)
                 " These may be causing your build to fail! We recommend that you fix them as soon as possible."
                 " These may lead to unexpected behavior and may cause your build to fail soon. We recommend that you fix them as soonas possible."))]
            [:p
             "You may want to look at "<commit_msg>Typo: "soonas" -> "soon as"<commit_after>(ns frontend.components.build-config
  (:require [cljs.core.async :as async :refer [>! <! alts! chan sliding-buffer close!]]
            [frontend.async :refer [raise!]]
            [frontend.components.common :as common]
            [frontend.state :as state]
            [frontend.utils :as utils :include-macros true]
            [frontend.utils.github :as gh-utils]
            [frontend.utils.vcs-url :as vcs-url]
            [om.core :as om :include-macros true])
    (:require-macros [frontend.utils :refer [html]]))

(defn diagnostics [config owner]
  (reify
    om/IInitState
    (init-state [_]
      ;; TODO convert CI.inner.Diagnostics to clojurescript
      {:configDiagnostics (js/CI.inner.Diagnostics. (:string config) (clj->js (:errors config)))})
    om/IRenderState
    (render-state [_ {:keys [configDiagnostics]}]
      (html
       [:section
        [:table.code
         [:thead [:tr [:th] [:th]]]
         [:tbody
          (for [line (aget configDiagnostics "lines")]
            (list [:tr {:class (when (aget line "has_errors") "error")}
                   [:td.line-number (aget line "line")]
                   [:td.line
                    (for [piece (aget line "pieces")]
                      (list
                       (when (aget piece "data")
                         [:span {:class (when (aget piece "error") "error")}
                          (aget piece "data")])
                       (when (aget piece "error_flag")
                         [:span [:a.error-flag {:on-click #(do ((aget piece "select"))
                                                               (om/refresh! owner))
                                                :class (when ((aget piece "get_selected")) "selected")}
                                 (inc (aget piece "number"))]])))]]
                  (for [error (aget line "errors")]
                    [:tr.error-message {:class (when ((aget error "get_selected")) "opened")}
                     [:td.line-number]
                     [:td.error-message
                      (when (aget error "path")
                        [:span.path (aget error "path")])
                      (aget error "message") "."
                      [:div.next-button
                       [:a {:on-click #(do ((aget error "select_next"))
                                           (om/refresh! owner))}
                        [:i.fa.fa-angle-right]]]]])))]]]))))

(defn config-errors [build owner]
  (reify
    om/IRender
    (render [_]
      (let [config (:circle_yml build)]
        (html
         [:div.config-diagnostics.heroic
          (when-not (:lethal config)
            [:button.dismiss {:on-click #(raise! owner [:dismiss-config-errors])}
             "Dismiss "
             [:i.fa.fa-times-circle]])
          [:header
           [:div.head-left
            (if (:lethal config)
              (common/icon {:name "fail" :type "status"})
              [:i.error.fa.fa-exclamation-triangle])]
           [:div.head-right
            [:h2 "Dang."]
            [:p
             "We spotted some issues with your " [:code "circle.yml"] "."

             (when-not (:lethal config)
               (if (:failed build)
                 " These may be causing your build to fail! We recommend that you fix them as soon as possible."
                 " These may lead to unexpected behavior and may cause your build to fail soon. We recommend that you fix them as soon as possible."))]
            [:p
             "You may want to look at "
{'fraction_non_alphanumeric': 0.13837455830388692, 'fraction_numerical': 0.0002826855123674912, 'mean_word_length': 1.4595064303093501, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1879509', 'n_tokens_mistral': 2041, 'n_tokens_neox': 1900, 'n_words': 538}