Skip to content
GitHub Actions / clippy succeeded Jun 12, 2024 in 0s

clippy

1 warning

Details

Results

Message level Amount
Internal compiler error 0
Error 0
Warning 1
Note 0
Help 0

Versions

  • rustc 1.81.0-nightly (d0227c6a1 2024-06-11)
  • cargo 1.81.0-nightly (b1feb75d0 2024-06-07)
  • clippy 0.1.80 (d0227c6 2024-06-11)

Annotations

Check warning on line 140 in src/lease.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unneeded `return` statement

warning: unneeded `return` statement
   --> src/lease.rs:87:9
    |
87  | /         return match self.lease_api.get(&self.params.lease_name).await {
88  | |             Ok(l) => {
89  | |                 if self.are_we_leading(&l)? {
90  | |                     let lease = self.renew_lease().await?;
...   |
139 | |             Err(e) => Err(e.into()),
140 | |         };
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
    = note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
    |
87  ~         match self.lease_api.get(&self.params.lease_name).await {
88  +             Ok(l) => {
89  +                 if self.are_we_leading(&l)? {
90  +                     let lease = self.renew_lease().await?;
91  +                     log::debug!("successfully renewed lease {}", l.name_any());
92  + 
93  +                     Ok(LeaseLockResult {
94  +                         acquired_lease: true,
95  +                         lease: Some(lease),
96  +                     })
97  +                 } else if self.has_lease_expired(&l)? {
98  +                     let lease = self.acquire_lease(&l).await?;
99  +                     log::info!("successfully acquired lease {}", lease.name_any());
100 + 
101 +                     Ok(LeaseLockResult {
102 +                         acquired_lease: true,
103 +                         lease: Some(lease),
104 +                     })
105 +                 } else {
106 +                     log::info!(
107 +                         "lease is held by {} and has not yet expired",
108 +                         l.spec
109 +                             .as_ref()
110 +                             .ok_or(Error::TraverseLease {
111 +                                 key: "spec".to_string()
112 +                             })?
113 +                             .holder_identity
114 +                             .as_ref()
115 +                             .ok_or(Error::TraverseLease {
116 +                                 key: "spec.holderIdentity".to_string()
117 +                             })?
118 +                     );
119 + 
120 +                     Ok(LeaseLockResult {
121 +                         acquired_lease: false,
122 +                         lease: None,
123 +                     })
124 +                 }
125 +             }
126 +             Err(kube::Error::Api(api_err)) => {
127 +                 if api_err.code != 404 {
128 +                     return Err(Error::ApiError { response: api_err });
129 +                 }
130 + 
131 +                 let lease = self.create_lease().await?;
132 +                 log::info!("successfully acquired lease {}", lease.name_any());
133 + 
134 +                 Ok(LeaseLockResult {
135 +                     acquired_lease: true,
136 +                     lease: Some(lease),
137 +                 })
138 +             }
139 +             Err(e) => Err(e.into()),
140 ~         }
    |