fix(lint): resolve E205 Printf/Format usage and add missing fmt deps
Replace Printf.sprintf/printf with Fmt.str/pr across cbort, cfdp, cgr, claudeio, clcw, conpool, cookeio, and cpio packages. Add fmt library dependency to dune files where needed.
···212212 let endpoint_idx = Random.int (Array.length endpoints) in
213213 let endpoint = endpoints.(endpoint_idx) in
214214 let message =
215215- Printf.sprintf "c%d-%s" client_id (generate_message cfg.message_size)
215215+ Fmt.str "c%d-%s" client_id (generate_message cfg.message_size)
216216 in
217217 run_client_test ~clock ~test_start_time pool endpoint message latency_stats
218218 errors
···353353354354(** Convert result to JSON string *)
355355let result_to_json result =
356356- Printf.sprintf
356356+ Fmt.str
357357 {|{
358358 "test_name": "%s",
359359 "num_servers": %d,
···409409 let bucket_labels =
410410 List.init num_buckets (fun i ->
411411 let start = min_lat +. (float_of_int i *. bucket_width) in
412412- Printf.sprintf "%.2f" start)
412412+ Fmt.str "%.2f" start)
413413 in
414414 let bucket_counts = Array.to_list buckets in
415415 (bucket_labels, bucket_counts)
···418418let generate_html_report results =
419419 let timestamp = Unix.time () |> Unix.gmtime in
420420 let date_str =
421421- Printf.sprintf "%04d-%02d-%02d %02d:%02d:%02d UTC"
421421+ Fmt.str "%04d-%02d-%02d %02d:%02d:%02d UTC"
422422 (timestamp.Unix.tm_year + 1900)
423423 (timestamp.Unix.tm_mon + 1)
424424 timestamp.Unix.tm_mday timestamp.Unix.tm_hour timestamp.Unix.tm_min
···440440 let test_names =
441441 String.concat ", "
442442 (List.map
443443- (fun r -> Printf.sprintf "\"%s\"" (js_escape r.test_name))
443443+ (fun r -> Fmt.str "\"%s\"" (js_escape r.test_name))
444444 results)
445445 in
446446 let throughputs =
447447 String.concat ", "
448448- (List.map (fun r -> Printf.sprintf "%.2f" r.throughput) results)
448448+ (List.map (fun r -> Fmt.str "%.2f" r.throughput) results)
449449 in
450450 let avg_latencies =
451451 String.concat ", "
452452- (List.map (fun r -> Printf.sprintf "%.2f" r.avg_latency) results)
452452+ (List.map (fun r -> Fmt.str "%.2f" r.avg_latency) results)
453453 in
454454 let error_rates =
455455 String.concat ", "
456456 (List.map
457457 (fun r ->
458458 if r.total_messages > 0 then
459459- Printf.sprintf "%.2f"
459459+ Fmt.str "%.2f"
460460 (float_of_int r.total_errors
461461 /. float_of_int r.total_messages
462462 *. 100.0)
···474474 in
475475 let hist_labels_str =
476476 String.concat ", "
477477- (List.map (fun s -> Printf.sprintf "\"%s\"" s) hist_labels)
477477+ (List.map (fun s -> Fmt.str "\"%s\"" s) hist_labels)
478478 in
479479 let hist_counts_str =
480480 String.concat ", " (List.map string_of_int hist_counts)
···489489 let timeline_data =
490490 String.concat ", "
491491 (List.map
492492- (fun (t, l) -> Printf.sprintf "{x: %.2f, y: %.3f}" t l)
492492+ (fun (t, l) -> Fmt.str "{x: %.2f, y: %.3f}" t l)
493493 sampled_data)
494494 in
495495496496- Printf.sprintf
496496+ Fmt.str
497497 {|
498498 <div class="test-detail">
499499 <h3>%s</h3>
···590590 results)
591591 in
592592593593- Printf.sprintf
593593+ Fmt.str
594594 {|<!DOCTYPE html>
595595<html lang="en">
596596<head>
···870870</html>|}
871871 date_str (List.length results)
872872 (if total_messages >= 1000 then
873873- Printf.sprintf "%d,%03d" (total_messages / 1000) (total_messages mod 1000)
873873+ Fmt.str "%d,%03d" (total_messages / 1000) (total_messages mod 1000)
874874 else string_of_int total_messages)
875875 total_errors total_duration test_details test_names throughputs
876876 avg_latencies error_rates
···879879let run_all_presets ~env =
880880 List.map
881881 (fun config ->
882882- Printf.eprintf "Running test: %s\n%!" config.name;
882882+ Fmt.epr "Running test: %s\n%!" config.name;
883883 run_stress_test ~env config)
884884 presets
885885···914914 (fun p ->
915915 match List.find_opt (fun c -> c.name = p) presets with
916916 | Some c -> mode := Single c
917917- | None -> failwith (Printf.sprintf "Unknown preset: %s" p)),
917917+ | None -> failwith (Fmt.str "Unknown preset: %s" p)),
918918 "Use a named preset configuration" );
919919 ("-n", Arg.Set_string name, "Test name");
920920 ( "-s",
921921 Arg.Set_int num_servers,
922922- Printf.sprintf "Number of servers (default: %d)"
922922+ Fmt.str "Number of servers (default: %d)"
923923 default_config.num_servers );
924924 ( "-c",
925925 Arg.Set_int num_clients,
926926- Printf.sprintf "Clients per server (default: %d)"
926926+ Fmt.str "Clients per server (default: %d)"
927927 default_config.num_clients );
928928 ( "-m",
929929 Arg.Set_int messages_per_client,
930930- Printf.sprintf "Messages per client (default: %d)"
930930+ Fmt.str "Messages per client (default: %d)"
931931 default_config.messages_per_client );
932932 ( "-p",
933933 Arg.Set_int max_parallel,
934934- Printf.sprintf "Max parallel clients (default: %d)"
934934+ Fmt.str "Max parallel clients (default: %d)"
935935 default_config.max_parallel_clients );
936936 ( "-b",
937937 Arg.Set_int message_size,
938938- Printf.sprintf "Message size (default: %d)" default_config.message_size
938938+ Fmt.str "Message size (default: %d)" default_config.message_size
939939 );
940940 ( "-P",
941941 Arg.Set_int pool_size,
942942- Printf.sprintf "Pool size per endpoint (default: %d)"
942942+ Fmt.str "Pool size per endpoint (default: %d)"
943943 default_config.pool_size );
944944 ( "-o",
945945 Arg.Set_string output_file,
···970970971971 match mode with
972972 | List_presets ->
973973- Printf.printf "Available presets:\n";
973973+ Fmt.pr "Available presets:\n";
974974 List.iter
975975 (fun c ->
976976- Printf.printf
976976+ Fmt.pr
977977 " %s: %d servers, %d clients, %d msgs/client, pool=%d\n" c.name
978978 c.num_servers c.num_clients c.messages_per_client c.pool_size)
979979 presets
···984984 let results = [ result ] in
985985986986 (* Write JSON *)
987987- let json = Printf.sprintf "[%s]" (result_to_json result) in
987987+ let json = Fmt.str "[%s]" (result_to_json result) in
988988 let oc = open_out output_file in
989989 output_string oc json;
990990 close_out oc;
991991- Printf.printf "Results written to %s\n" output_file;
991991+ Fmt.pr "Results written to %s\n" output_file;
992992993993 (* Write HTML *)
994994 let html_file =
···10001000 let oc_html = open_out html_file in
10011001 output_string oc_html html;
10021002 close_out oc_html;
10031003- Printf.printf "HTML report written to %s\n" html_file;
10031003+ Fmt.pr "HTML report written to %s\n" html_file;
1004100410051005- Printf.printf
10051005+ Fmt.pr
10061006 "Test: %s - %d messages, %.2f msg/s, %.2fms avg latency, %d errors\n"
10071007 result.test_name result.total_messages result.throughput
10081008 result.avg_latency result.total_errors
···10171017 let oc = open_out output_file in
10181018 output_string oc json;
10191019 close_out oc;
10201020- Printf.printf "Results written to %s\n" output_file;
10201020+ Fmt.pr "Results written to %s\n" output_file;
1021102110221022 (* Write HTML *)
10231023 let html_file =
···10291029 let oc_html = open_out html_file in
10301030 output_string oc_html html;
10311031 close_out oc_html;
10321032- Printf.printf "HTML report written to %s\n" html_file;
10321032+ Fmt.pr "HTML report written to %s\n" html_file;
1033103310341034 List.iter
10351035 (fun r ->
10361036- Printf.printf
10361036+ Fmt.pr
10371037 " %s: %d messages, %.2f msg/s, %.2fms avg latency, %d errors\n"
10381038 r.test_name r.total_messages r.throughput r.avg_latency
10391039 r.total_errors)
10401040 results
10411041 | Extended ->
10421042- Printf.printf
10421042+ Fmt.pr
10431043 "Running extended stress test: %d servers, %d clients/server, %d \
10441044 msgs/client\n"
10451045 extended_preset.num_servers extended_preset.num_clients
10461046 extended_preset.messages_per_client;
10471047- Printf.printf "Total messages: %d\n%!"
10471047+ Fmt.pr "Total messages: %d\n%!"
10481048 (extended_preset.num_servers * extended_preset.num_clients
10491049 * extended_preset.messages_per_client);
10501050 Eio_main.run @@ fun env ->
···10521052 let results = [ result ] in
1053105310541054 (* Write JSON *)
10551055- let json = Printf.sprintf "[%s]" (result_to_json result) in
10551055+ let json = Fmt.str "[%s]" (result_to_json result) in
10561056 let oc = open_out output_file in
10571057 output_string oc json;
10581058 close_out oc;
10591059- Printf.printf "Results written to %s\n" output_file;
10591059+ Fmt.pr "Results written to %s\n" output_file;
1060106010611061 (* Write HTML *)
10621062 let html_file =
···10681068 let oc_html = open_out html_file in
10691069 output_string oc_html html;
10701070 close_out oc_html;
10711071- Printf.printf "HTML report written to %s\n" html_file;
10711071+ Fmt.pr "HTML report written to %s\n" html_file;
1072107210731073- Printf.printf
10731073+ Fmt.pr
10741074 "Test: %s - %d messages, %.2f msg/s, %.2fms avg latency, %d errors\n"
10751075 result.test_name result.total_messages result.throughput
10761076 result.avg_latency result.total_errors
+1-1
test/test_config.ml
···28282929let test_pp () =
3030 let c = Conpool.Config.default in
3131- let s = Format.asprintf "%a" Conpool.Config.pp c in
3131+ let s = Fmt.str "%a" Conpool.Config.pp c in
3232 Alcotest.(check bool) "non-empty" true (String.length s > 0)
33333434let suite =
+1-1
test/test_endpoint.ml
···17171818let test_pp () =
1919 let ep = Conpool.Endpoint.v ~host:"example.com" ~port:8080 in
2020- let s = Format.asprintf "%a" Conpool.Endpoint.pp ep in
2020+ let s = Fmt.str "%a" Conpool.Endpoint.pp ep in
2121 Alcotest.(check bool) "contains host" true (String.length s > 0)
22222323let suite =
+1-1
test/test_stats.ml
···2020 Conpool.Stats.v ~active:0 ~idle:0 ~total_created:0 ~total_reused:0
2121 ~total_closed:0 ~errors:0
2222 in
2323- let str = Format.asprintf "%a" Conpool.Stats.pp s in
2323+ let str = Fmt.str "%a" Conpool.Stats.pp s in
2424 Alcotest.(check bool) "non-empty" true (String.length str > 0)
25252626let suite =