collin/browser-terminal-extension · 5114c62f
Fix clippy warnings from a newer clippy's stricter defaults
Collin Richards · 2026-08-18 06:45 UTC · 5114c62f5e29cb906a7d816a11e9da773ae34940 · parent 878ba185 · browse files
modifieddaemon/src/project.rs+4 −4
| ⋯ 135 unchanged lines | |||
| 136 | 136 | // string the panel matches against the working directories tmux reports, | |
| 137 | 137 | // and tmux reports a pane's real one. `~/code` being a link to `~/Code` | |
| 138 | 138 | // would otherwise be a session it could not see it already had. | |
| 139 | - | if kind == Kind::Dir { | |
| 140 | - | if let Ok(real) = std::fs::canonicalize(&path) { | |
| 141 | - | path = real; | |
| 142 | - | } | |
| 139 | + | if kind == Kind::Dir | |
| 140 | + | && let Ok(real) = std::fs::canonicalize(&path) | |
| 141 | + | { | |
| 142 | + | path = real; | |
| 143 | 143 | } | |
| 144 | 144 | Some(Listing { | |
| 145 | 145 | creates: missing_ancestors(&path), | |
| ⋯ 141 unchanged lines | |||
modifieddaemon/src/pty.rs+6 −10
| ⋯ 160 unchanged lines | |||
| 161 | 161 | /// command line sent to a live tmux server, so nothing else is allowed through. | |
| 162 | 162 | pub fn valid_pane_id(raw: &str) -> Option<String> { | |
| 163 | 163 | let s = raw.trim(); | |
| 164 | - | let Some(digits) = s.strip_prefix('%') else { | |
| 165 | - | return None; | |
| 166 | - | }; | |
| 164 | + | let digits = s.strip_prefix('%')?; | |
| 167 | 165 | if digits.is_empty() || digits.len() > 12 || !digits.chars().all(|c| c.is_ascii_digit()) { | |
| 168 | 166 | return None; | |
| 169 | 167 | } | |
| ⋯ 7 unchanged lines | |||
| 177 | 175 | /// index is part of a `session:index.pane` target syntax with its own escapes. | |
| 178 | 176 | pub fn valid_window_id(raw: &str) -> Option<String> { | |
| 179 | 177 | let s = raw.trim(); | |
| 180 | - | let Some(digits) = s.strip_prefix('@') else { | |
| 181 | - | return None; | |
| 182 | - | }; | |
| 178 | + | let digits = s.strip_prefix('@')?; | |
| 183 | 179 | if digits.is_empty() || digits.len() > 12 || !digits.chars().all(|c| c.is_ascii_digit()) { | |
| 184 | 180 | return None; | |
| 185 | 181 | } | |
| ⋯ 82 unchanged lines | |||
| 268 | 264 | break; // First command word; globals are all before it. | |
| 269 | 265 | } | |
| 270 | 266 | out.push(a.clone()); | |
| 271 | - | if matches!(a.as_str(), "-L" | "-S" | "-f") { | |
| 272 | - | if let Some(value) = args.next() { | |
| 273 | - | out.push(value.clone()); | |
| 274 | - | } | |
| 267 | + | if matches!(a.as_str(), "-L" | "-S" | "-f") | |
| 268 | + | && let Some(value) = args.next() | |
| 269 | + | { | |
| 270 | + | out.push(value.clone()); | |
| 275 | 271 | } | |
| 276 | 272 | } | |
| 277 | 273 | out | |
| ⋯ 162 unchanged lines | |||
modifieddaemon/src/server.rs+6 −0
| ⋯ 293 unchanged lines | |||
| 294 | 294 | detail: None, | |
| 295 | 295 | }); | |
| 296 | 296 | // Still perform the reject through the handshake so the client sees 429. | |
| 297 | + | // `ErrorResponse` is tungstenite's `Callback::on_request` return type, not | |
| 298 | + | // ours to box. | |
| 299 | + | #[allow(clippy::result_large_err)] | |
| 297 | 300 | let _ = tokio_tungstenite::accept_hdr_async(stream, |_: &Request, _| { | |
| 298 | 301 | Err(deny(Denied::RateLimited)) | |
| 299 | 302 | }) | |
| ⋯ 97 unchanged lines | |||
| 397 | 400 | let so = Arc::clone(&seen_origin); | |
| 398 | 401 | let he = Arc::clone(&handshake_err); | |
| 399 | 402 | ||
| 403 | + | // `ErrorResponse` is tungstenite's `Callback::on_request` return type, not | |
| 404 | + | // ours to box. | |
| 405 | + | #[allow(clippy::result_large_err)] | |
| 400 | 406 | let ws = tokio_tungstenite::accept_hdr_async(stream, move |req: &Request, res: Response| { | |
| 401 | 407 | let header = |name: &str| { | |
| 402 | 408 | req.headers() | |
| ⋯ 1795 unchanged lines | |||
modifieddaemon/src/tls.rs+11 −11
| ⋯ 141 unchanged lines | |||
| 142 | 142 | fn rustls_pemfile_certs( | |
| 143 | 143 | r: &mut std::io::Cursor<&[u8]>, | |
| 144 | 144 | ) -> std::io::Result<Vec<CertificateDer<'static>>> { | |
| 145 | - | let text = String::from_utf8_lossy(*r.get_ref()).to_string(); | |
| 145 | + | let text = String::from_utf8_lossy(r.get_ref()).to_string(); | |
| 146 | 146 | let mut out = Vec::new(); | |
| 147 | 147 | for block in text.split("-----BEGIN CERTIFICATE-----").skip(1) { | |
| 148 | 148 | let Some(body) = block.split("-----END CERTIFICATE-----").next() else { | |
| ⋯ 58 unchanged lines | |||
| 207 | 207 | "-----END RSA PRIVATE KEY-----", | |
| 208 | 208 | ), | |
| 209 | 209 | ] { | |
| 210 | - | if let Some(rest) = pem.split(begin).nth(1) { | |
| 211 | - | if let Some(body) = rest.split(end).next() { | |
| 212 | - | let b64: String = body.chars().filter(|c| !c.is_whitespace()).collect(); | |
| 213 | - | let der = base64_decode(&b64)?; | |
| 214 | - | return Ok(match begin { | |
| 215 | - | "-----BEGIN EC PRIVATE KEY-----" => PrivateKeyDer::Sec1(der.into()), | |
| 216 | - | "-----BEGIN RSA PRIVATE KEY-----" => PrivateKeyDer::Pkcs1(der.into()), | |
| 217 | - | _ => PrivateKeyDer::Pkcs8(der.into()), | |
| 218 | - | }); | |
| 219 | - | } | |
| 210 | + | if let Some(rest) = pem.split(begin).nth(1) | |
| 211 | + | && let Some(body) = rest.split(end).next() | |
| 212 | + | { | |
| 213 | + | let b64: String = body.chars().filter(|c| !c.is_whitespace()).collect(); | |
| 214 | + | let der = base64_decode(&b64)?; | |
| 215 | + | return Ok(match begin { | |
| 216 | + | "-----BEGIN EC PRIVATE KEY-----" => PrivateKeyDer::Sec1(der.into()), | |
| 217 | + | "-----BEGIN RSA PRIVATE KEY-----" => PrivateKeyDer::Pkcs1(der.into()), | |
| 218 | + | _ => PrivateKeyDer::Pkcs8(der.into()), | |
| 219 | + | }); | |
| 220 | 220 | } | |
| 221 | 221 | } | |
| 222 | 222 | Err(std::io::Error::other("no private key found in key.pem")) | |
| ⋯ 1 unchanged line | |||
modifieddaemon/tests/pty_e2e.rs+4 −4
| ⋯ 245 unchanged lines | |||
| 246 | 246 | ||
| 247 | 247 | let got = tokio::time::timeout(Duration::from_secs(10), async { | |
| 248 | 248 | while let Some(Ok(msg)) = ws.next().await { | |
| 249 | - | if let Message::Text(t) = msg { | |
| 250 | - | if t.contains("\"exit\"") { | |
| 251 | - | return Some(t.to_string()); | |
| 252 | - | } | |
| 249 | + | if let Message::Text(t) = msg | |
| 250 | + | && t.contains("\"exit\"") | |
| 251 | + | { | |
| 252 | + | return Some(t.to_string()); | |
| 253 | 253 | } | |
| 254 | 254 | } | |
| 255 | 255 | None | |
| ⋯ 621 unchanged lines | |||
modifieddaemon/tests/security.rs+4 −4
| ⋯ 242 unchanged lines | |||
| 243 | 243 | // Say nothing. The deadline must close us. | |
| 244 | 244 | let outcome = tokio::time::timeout(Duration::from_secs(2), async { | |
| 245 | 245 | while let Some(Ok(m)) = ws.next().await { | |
| 246 | - | if let Message::Text(t) = &m { | |
| 247 | - | if t.contains("auth timeout") { | |
| 248 | - | return true; | |
| 249 | - | } | |
| 246 | + | if let Message::Text(t) = &m | |
| 247 | + | && t.contains("auth timeout") | |
| 248 | + | { | |
| 249 | + | return true; | |
| 250 | 250 | } | |
| 251 | 251 | } | |
| 252 | 252 | false | |
| ⋯ 333 unchanged lines | |||