Skip to content

Commit ba6038e

Browse files
committed
Use labels for string functions to make their usage safer
1 parent 02ceefa commit ba6038e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Cosmetrics.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let read_tree_exn t sha =
2525
module String = struct
2626
include String
2727

28-
let start_with prefix s =
28+
let starting ~w:prefix s =
2929
if String.length prefix <= String.length s then
3030
try
3131
for i = 0 to String.length prefix - 1 do
@@ -35,7 +35,7 @@ module String = struct
3535
with Exit -> false
3636
else false
3737

38-
let end_with postfix s =
38+
let ending ~w:postfix s =
3939
let ofs = String.length s - String.length postfix in
4040
if ofs >= 0 then
4141
try
@@ -379,7 +379,7 @@ module Tag = struct
379379
date = Calendar.from_unixfloat (Int64.to_float t) }
380380

381381
let get_ref t r =
382-
if String.start_with "refs/tags/" (Git.Reference.to_raw r) then
382+
if String.starting ~w:"refs/tags/" (Git.Reference.to_raw r) then
383383
Store.read_reference_exn t r >>= fun sha ->
384384
Store.read_exn t (Git.SHA.of_commit sha) >|= fun v ->
385385
match v with
@@ -500,9 +500,9 @@ let get_store ?(repo_dir="repo") ?(update=false) remote_uri =
500500
type classification = | OCaml | C
501501
| Undecided of string
502502

503-
let is_ml e = Git.Tree.(e.perm = `Normal && String.end_with ".ml" e.name)
503+
let is_ml e = Git.Tree.(e.perm = `Normal && String.ending ~w:".ml" e.name)
504504

505-
let is_c e = Git.Tree.(e.perm = `Normal && String.end_with ".c" e.name)
505+
let is_c e = Git.Tree.(e.perm = `Normal && String.ending ~w:".c" e.name)
506506

507507
let is_src e = Git.Tree.(e.perm = `Dir && (e.name = "src" || e.name = "lib"))
508508

0 commit comments

Comments
 (0)