Skip to content

Commit 8296c64

Browse files
refactor(xtask): replace bare .unwrap() with descriptive .expect() on PathBuf::to_str() (#1585)
* docs(diffguard-diff): add docstrings to ChangeKind, DiffLine, DiffStats, DiffParseError Add comprehensive docstrings to all public types in unified.rs: - ChangeKind: document each variant (Added, Changed, Deleted) - DiffLine: document fields and overall purpose - DiffStats: document fields and overflow behavior - DiffParseError: add top-level doc comment Also add explanatory comment for try_from usage at overflow check (issue #481 fix) explaining why we avoid silent truncation. * Revert "docs(diffguard-diff): add docstrings to ChangeKind, DiffLine, DiffStats, DiffParseError" This reverts commit 6aab7f8. * xtask: Replace bare .unwrap() with .expect() on PathBuf::to_str() Replace 24 bare .unwrap() calls on out_path.to_str() and sensor_path.to_str() in xtask/src/conform_real.rs with .expect() calls that provide descriptive panic messages identifying which path was invalid UTF-8. Fixes #403
1 parent 5937c00 commit 8296c64

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

‎xtask/src/conform_real.rs‎

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ fn test_schema_validation() -> Result<()> {
238238
"--head",
239239
"HEAD",
240240
"--out",
241-
out_path.to_str().unwrap(),
241+
out_path.to_str().expect("out_path must be valid UTF-8"),
242242
"--sensor",
243-
sensor_path.to_str().unwrap(),
243+
sensor_path.to_str().expect("sensor_path must be valid UTF-8"),
244244
],
245245
)?;
246246

@@ -292,9 +292,9 @@ fn test_determinism() -> Result<()> {
292292
"--head",
293293
"HEAD",
294294
"--out",
295-
out_path.to_str().unwrap(),
295+
out_path.to_str().expect("out_path must be valid UTF-8"),
296296
"--sensor",
297-
sensor_path.to_str().unwrap(),
297+
sensor_path.to_str().expect("sensor_path must be valid UTF-8"),
298298
],
299299
)?;
300300

@@ -353,9 +353,9 @@ fn test_survivability() -> Result<()> {
353353
"--head",
354354
"HEAD",
355355
"--out",
356-
out_path.to_str().unwrap(),
356+
out_path.to_str().expect("out_path must be valid UTF-8"),
357357
"--sensor",
358-
sensor_path.to_str().unwrap(),
358+
sensor_path.to_str().expect("sensor_path must be valid UTF-8"),
359359
])
360360
.current_dir(temp_dir.path())
361361
.output()
@@ -412,9 +412,9 @@ fn test_required_fields() -> Result<()> {
412412
"--head",
413413
"HEAD",
414414
"--out",
415-
out_path.to_str().unwrap(),
415+
out_path.to_str().expect("out_path must be valid UTF-8"),
416416
"--sensor",
417-
sensor_path.to_str().unwrap(),
417+
sensor_path.to_str().expect("sensor_path must be valid UTF-8"),
418418
],
419419
)?;
420420

@@ -495,9 +495,9 @@ fn test_vocabulary() -> Result<()> {
495495
"--head",
496496
"HEAD",
497497
"--out",
498-
out_path.to_str().unwrap(),
498+
out_path.to_str().expect("out_path must be valid UTF-8"),
499499
"--sensor",
500-
sensor_path.to_str().unwrap(),
500+
sensor_path.to_str().expect("sensor_path must be valid UTF-8"),
501501
],
502502
)?;
503503

@@ -577,9 +577,9 @@ fn test_json_schema_file() -> Result<()> {
577577
"--head",
578578
"HEAD",
579579
"--out",
580-
out_path.to_str().unwrap(),
580+
out_path.to_str().expect("out_path must be valid UTF-8"),
581581
"--sensor",
582-
sensor_path.to_str().unwrap(),
582+
sensor_path.to_str().expect("sensor_path must be valid UTF-8"),
583583
],
584584
)?;
585585

@@ -756,9 +756,9 @@ fn test_tool_error_code() -> Result<()> {
756756
"--head",
757757
"HEAD",
758758
"--out",
759-
out_path.to_str().unwrap(),
759+
out_path.to_str().expect("out_path must be valid UTF-8"),
760760
"--sensor",
761-
sensor_path.to_str().unwrap(),
761+
sensor_path.to_str().expect("sensor_path must be valid UTF-8"),
762762
])
763763
.current_dir(temp_dir.path())
764764
.output()
@@ -820,9 +820,9 @@ fn test_token_lint() -> Result<()> {
820820
"--head",
821821
"HEAD",
822822
"--out",
823-
out_path.to_str().unwrap(),
823+
out_path.to_str().expect("out_path must be valid UTF-8"),
824824
"--sensor",
825-
sensor_path.to_str().unwrap(),
825+
sensor_path.to_str().expect("sensor_path must be valid UTF-8"),
826826
],
827827
)?;
828828

@@ -922,9 +922,9 @@ fn test_path_hygiene() -> Result<()> {
922922
"--head",
923923
"HEAD",
924924
"--out",
925-
out_path.to_str().unwrap(),
925+
out_path.to_str().expect("out_path must be valid UTF-8"),
926926
"--sensor",
927-
sensor_path.to_str().unwrap(),
927+
sensor_path.to_str().expect("sensor_path must be valid UTF-8"),
928928
],
929929
)?;
930930

@@ -989,9 +989,9 @@ fn test_fingerprint_format() -> Result<()> {
989989
"--head",
990990
"HEAD",
991991
"--out",
992-
out_path.to_str().unwrap(),
992+
out_path.to_str().expect("out_path must be valid UTF-8"),
993993
"--sensor",
994-
sensor_path.to_str().unwrap(),
994+
sensor_path.to_str().expect("sensor_path must be valid UTF-8"),
995995
],
996996
)?;
997997

@@ -1040,9 +1040,9 @@ fn test_artifact_path_hygiene() -> Result<()> {
10401040
"--head",
10411041
"HEAD",
10421042
"--out",
1043-
out_path.to_str().unwrap(),
1043+
out_path.to_str().expect("out_path must be valid UTF-8"),
10441044
"--sensor",
1045-
sensor_path.to_str().unwrap(),
1045+
sensor_path.to_str().expect("sensor_path must be valid UTF-8"),
10461046
],
10471047
)?;
10481048

@@ -1208,9 +1208,9 @@ fn test_data_diffguard_shape() -> Result<()> {
12081208
"--head",
12091209
"HEAD",
12101210
"--out",
1211-
out_path.to_str().unwrap(),
1211+
out_path.to_str().expect("out_path must be valid UTF-8"),
12121212
"--sensor",
1213-
sensor_path.to_str().unwrap(),
1213+
sensor_path.to_str().expect("sensor_path must be valid UTF-8"),
12141214
],
12151215
)?;
12161216

0 commit comments

Comments
 (0)