chore: deny clippy warning about unwrap being used
An unwrap (or unwrap_err, or their expect variants) can result in run time panics: unwrapping an Option that is None can’t return a useful result, so it panics. Similar for a Result. I’ve previously tried to grep for uses of unwrap, but the clippy warning is much more precise.
Add “deny(clippy::unwrap_used)” to the top of src/lib.rs, so it affects the whole crate. Then fix any places where unwrap is used.
It’s OK to use unwrap in tests: if the value is expected, but isn’t there, the test should fail, and panic is a fine way to fail the test.
Everywhere else it’s better to make sure unwrap can’t fail, and if it can, return a Result and have the caller handle that.
Signed-off-by: Lars Wirzenius liw@liw.fi
9 files changed
+67
-22
a9fea0fd
→
47064e57
modified src/bin/cib.rs
@@ -18,7 +18,7 @@ use radicle_ci_broker::{
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -116,7 +116,7 @@ impl InsertCmd {
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -151,14 +151,18 @@ impl QueuedCmd {
|
|
|
|
|
|
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
|
|
|
|
|
| - | |
| - | |
| + | |
| + | |
|
|
|
|
|
@@ -174,7 +178,12 @@ impl QueuedCmd {
|
|
|
|
|
|
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -193,7 +202,7 @@ impl ProcessEventsCmd {
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -208,7 +217,12 @@ impl ProcessEventsCmd {
|
|
|
|
|
|
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -224,8 +238,8 @@ impl ProcessEventsCmd {
|
|
|
|
|
|
| - | |
| - | |
| + | |
| + | |
|
|
|
|
|
@@ -282,6 +296,9 @@ enum CibError {
|
|
|
|
|
|
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -316,4 +333,8 @@ impl CibError {
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
|
modified src/bin/cibtool.rs
@@ -34,7 +34,7 @@ use radicle_ci_broker::{
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -349,4 +349,7 @@ enum CibToolError {
|
|
|
|
|
|
| + | |
| + | |
| + | |
|
modified src/bin/cibtoolcmd/report.rs
@@ -21,7 +21,12 @@ impl Leaf for ReportCmd {
|
|
|
|
|
|
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
modified src/ci_event.rs
@@ -241,6 +241,7 @@ impl CiEventError {
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -533,6 +534,7 @@ impl ParseError {
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -568,6 +570,7 @@ mod test_namespaced_branch {
|
|
|
|
|
|
| + | |
|
|
|
|
|
modified src/ci_event_source.rs
@@ -24,14 +24,14 @@ impl CiEventSource {
|
|
|
|
|
|
| - | |
| - | |
| + | |
| + | |
|
|
| - | |
| + | |
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -39,7 +39,7 @@ impl CiEventSource {
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
modified src/filter.rs
@@ -119,6 +119,7 @@ impl Filters {
|
|
|
|
|
|
| + | |
|
|
|
|
|
modified src/lib.rs
@@ -5,6 +5,8 @@
|
|
|
|
|
|
| + | |
| + | |
|
|
|
|
|
modified src/msg.rs
@@ -407,7 +407,7 @@ impl<'a> RequestBuilder<'a> {
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -906,6 +906,7 @@ pub enum MessageError {
|
|
|
|
|
|
| + | |
|
|
|
|
|
modified src/notif.rs
@@ -35,13 +35,22 @@ impl Default for NotificationChannel {
|
|
|
|
|
|
| - | |
| - | |
| + | |
| + | |
|
|
|
|
|
|
|
|
| - | |
| - | |
| + | |
| + | |
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |