From 180780c0afe4de45426cc8126b9b2b8b1602a18f Mon Sep 17 00:00:00 2001
From: Cam Saul <1455846+camsaul@users.noreply.github.com>
Date: Wed, 22 Jul 2020 12:35:11 -0700
Subject: [PATCH] Remove unused occurances-of-substring fn (#12979)

---
 src/metabase/util.clj       |  9 ---------
 test/metabase/util_test.clj | 19 -------------------
 2 files changed, 28 deletions(-)

diff --git a/src/metabase/util.clj b/src/metabase/util.clj
index 761f2a0200b..3866b35ef5c 100644
--- a/src/metabase/util.clj
+++ b/src/metabase/util.clj
@@ -554,15 +554,6 @@
   "Increment `n` if it is non-`nil`, otherwise return `1` (e.g. as if incrementing `0`)."
   (fnil inc 0))
 
-(defn occurances-of-substring
-  "Return the number of times SUBSTR occurs in string S."
-  ^Long [^String s, ^String substr]
-  (when (and (seq s) (seq substr))
-    (loop [index 0, cnt 0]
-      (if-let [^long new-index (str/index-of s substr index)]
-        (recur (inc new-index) (inc cnt))
-        cnt))))
-
 (defn select-non-nil-keys
   "Like `select-keys`, but returns a map only containing keys in KS that are present *and non-nil* in M.
 
diff --git a/test/metabase/util_test.clj b/test/metabase/util_test.clj
index 7e1cd4127cf..096b14ba39a 100644
--- a/test/metabase/util_test.clj
+++ b/test/metabase/util_test.clj
@@ -151,25 +151,6 @@
     "<<>>"          false
     "{\"a\": 10}"   false))
 
-(deftest occurances-of-substring-test
-  (testing "should return nil if one or both strings are nil or empty"
-    (are+ [s substr expected] (= expected
-                                 (u/occurances-of-substring s substr))
-      nil                                                                                 nil      nil
-      nil                                                                                 ""       nil
-      ""                                                                                  nil      nil
-      ""                                                                                  ""       nil
-      "ABC"                                                                               ""       nil
-      ""                                                                                  "  ABC"  nil
-      ;; non-empty strings
-      "ABC"                                                                               "A"      1
-      "ABA"                                                                               "A"      2
-      "AAA"                                                                               "A"      3
-      "ABC"                                                                               "{{id}}" 0
-      "WHERE ID = {{id}}"                                                                 "{{id}}" 1
-      "WHERE ID = {{id}} OR USER_ID = {{id}}"                                             "{{id}}" 2
-      "WHERE ID = {{id}} OR USER_ID = {{id}} OR TOUCAN_ID = {{id}} OR BIRD_ID = {{bird}}" "{{id}}" 3)))
-
 (deftest select-keys-test
   (testing "select-non-nil-keys"
     (is (= {:a 100}
-- 
GitLab