Skip to content

Commit

Permalink
fix logic and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Kitti Kristof committed Feb 16, 2024
1 parent a3a3bcb commit 11229b8
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions cloverage/src/cloverage/coverage.clj
Original file line number Diff line number Diff line change
Expand Up @@ -290,21 +290,20 @@

(defn- coverage-under? [forms failure-threshold line-failure-threshold form-failure-threshold]
(let [{:keys [percent-lines-covered percent-forms-covered]} (rep/total-stats forms)]
(when (pos? failure-threshold)
(if (pos? failure-threshold)
(let [pct-covered (min percent-lines-covered percent-forms-covered)
failed? (< pct-covered failure-threshold)]
(when failed?
(println "Failing build as coverage is below threshold of" failure-threshold "%"))
failed?))
(when (or (pos? line-failure-threshold) (pos? form-failure-threshold))
(let [line-failed? (< percent-lines-covered line-failure-threshold)
form-failed? (< percent-forms-covered form-failure-threshold)
failed? (or line-failed? form-failed?)]
(when failed?
(if line-failed?
(println "Failing build as line coverage is below threshold of" line-failure-threshold "%")
(println "Failing build as form coverage is below threshold of" form-failure-threshold "%")))
failed?))))
failed?)
(when (or (pos? line-failure-threshold) (pos? form-failure-threshold))
(let [line-failed? (< percent-lines-covered line-failure-threshold)
form-failed? (< percent-forms-covered form-failure-threshold)]
(when line-failed?
(println "Failing build as line coverage is below threshold of" line-failure-threshold "%"))
(when form-failed?
(println "Failing build as form coverage is below threshold of" form-failure-threshold "%"))
(or line-failed? form-failed?))))))

(defn run-main
[[{:keys [debug? fail-threshold line-fail-threshold form-fail-threshold help?], :as opts} add-nses help] project-opts]
Expand Down

0 comments on commit 11229b8

Please sign in to comment.