From 542029012e23c49fe2c8f702d36fc37896b48ffc Mon Sep 17 00:00:00 2001 From: Romain Beauxis Date: Wed, 27 Mar 2024 16:26:54 -0500 Subject: [PATCH] Cleanup --- .ocamlformat | 1 + src/dune | 2 +- src/lastfm.ocamlnet.ml | 12 ++++++------ src/lastfm_generic.ml | 14 +++++++------- src/lastfm_generic.mli | 4 ++-- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.ocamlformat b/.ocamlformat index 533d804..857030a 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -1,3 +1,4 @@ +version=0.25.1 profile = conventional break-separators = after space-around-lists = false diff --git a/src/dune b/src/dune index 73a15ba..0a7bdaa 100644 --- a/src/dune +++ b/src/dune @@ -12,7 +12,7 @@ (-> lastfm.noop.ml))) (modules lastfm_constants lastfm_generic lastfm) (synopsis - "Implementation of the API used by the last.fm to keep count of played songs")) + "Implementation of the API used by the last.fm to keep count of played songs")) (rule (target lastfm_constants.ml) diff --git a/src/lastfm.ocamlnet.ml b/src/lastfm.ocamlnet.ml index 7a47311..e522a65 100644 --- a/src/lastfm.ocamlnet.ml +++ b/src/lastfm.ocamlnet.ml @@ -52,12 +52,12 @@ module Http_ocamlnet = struct http_headers#set_fields headers; begin match request with - | Get -> () - | Post post -> - body#set_value post; - call#set_request_body body; - http_headers#update_field "Content-length" - (string_of_int (String.length post)) + | Get -> () + | Post post -> + body#set_value post; + call#set_request_body body; + http_headers#update_field "Content-length" + (string_of_int (String.length post)) end; call#set_request_header http_headers; pipeline#add call; diff --git a/src/lastfm_generic.ml b/src/lastfm_generic.ml index b906766..551cdc2 100644 --- a/src/lastfm_generic.ml +++ b/src/lastfm_generic.ml @@ -91,8 +91,7 @@ let of_hex1 c = let url_decode ?(plus = true) s = Pcre.substitute - ~rex:(Pcre.regexp - "\\+|%..") + ~rex:(Pcre.regexp "\\+|%..") (* TODO why do we match %. and % and seem to exclude them below ? *) ~subst:(fun s -> if s = "+" then if plus then " " else "+" @@ -134,12 +133,13 @@ let to_hex2 = Bytes.to_string s let url_encode ?(plus = true) s = - Pcre.substitute ~rex:(Pcre.regexp "[^A-Za-z0-9_.!*-]") + Pcre.substitute + ~rex:(Pcre.regexp "[^A-Za-z0-9_.!*-]") ~subst:(fun x -> if plus && x = " " then "+" else ( let k = Char.code x.[0] in - "%" ^ to_hex2 k )) + "%" ^ to_hex2 k)) s module type Http_t = sig @@ -380,7 +380,7 @@ module Audioscrobbler_generic (Http : Http_t) = struct Hashtbl.replace sessions (user, pass, (host, port)) id; Hashtbl.replace urls id v; id - | e -> raise e ) + | e -> raise e) let check_song s a = match s.source with @@ -412,7 +412,7 @@ module Audioscrobbler_generic (Http : Http_t) = struct (BadData "bad rating value (ban and skip are for \ lastfm sources only)") - | _ -> () ) ) ) ) + | _ -> ())))) let audioscrobbler_post ?timeout id base_url values = let host, port, req = parse_url base_url in @@ -753,7 +753,7 @@ module Radio_generic (Http : Http_t) = struct base_url; base_path; }; - args ) + args) else begin clear id; raise (Adjust (req, ret)) diff --git a/src/lastfm_generic.mli b/src/lastfm_generic.mli index a580adb..9823bcc 100644 --- a/src/lastfm_generic.mli +++ b/src/lastfm_generic.mli @@ -305,8 +305,8 @@ end (** Generic implementation of Audioscrobbler, independent * from the Http request. *) -module Audioscrobbler_generic (Http : Http_t) : Audioscrobbler_t +module Audioscrobbler_generic (_ : Http_t) : Audioscrobbler_t (** Generic implementation of the Radio API, independant * from the Http request. *) -module Radio_generic (Http : Http_t) : Radio_t +module Radio_generic (_ : Http_t) : Radio_t