anvilsign in

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
136136 // string the panel matches against the working directories tmux reports,
137137 // and tmux reports a pane's real one. `~/code` being a link to `~/Code`
138138 // 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;
143143 }
144144 Some(Listing {
145145 creates: missing_ancestors(&path),
⋯ 141 unchanged lines
modifieddaemon/src/pty.rs+6 −10
⋯ 160 unchanged lines
161161 /// command line sent to a live tmux server, so nothing else is allowed through.
162162 pub fn valid_pane_id(raw: &str) -> Option<String> {
163163 let s = raw.trim();
164- let Some(digits) = s.strip_prefix('%') else {
165- return None;
166- };
164+ let digits = s.strip_prefix('%')?;
167165 if digits.is_empty() || digits.len() > 12 || !digits.chars().all(|c| c.is_ascii_digit()) {
168166 return None;
169167 }
⋯ 7 unchanged lines
177175 /// index is part of a `session:index.pane` target syntax with its own escapes.
178176 pub fn valid_window_id(raw: &str) -> Option<String> {
179177 let s = raw.trim();
180- let Some(digits) = s.strip_prefix('@') else {
181- return None;
182- };
178+ let digits = s.strip_prefix('@')?;
183179 if digits.is_empty() || digits.len() > 12 || !digits.chars().all(|c| c.is_ascii_digit()) {
184180 return None;
185181 }
⋯ 82 unchanged lines
268264 break; // First command word; globals are all before it.
269265 }
270266 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());
275271 }
276272 }
277273 out
⋯ 162 unchanged lines
modifieddaemon/src/server.rs+6 −0
⋯ 293 unchanged lines
294294 detail: None,
295295 });
296296 // 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)]
297300 let _ = tokio_tungstenite::accept_hdr_async(stream, |_: &Request, _| {
298301 Err(deny(Denied::RateLimited))
299302 })
⋯ 97 unchanged lines
397400 let so = Arc::clone(&seen_origin);
398401 let he = Arc::clone(&handshake_err);
399402
403+ // `ErrorResponse` is tungstenite's `Callback::on_request` return type, not
404+ // ours to box.
405+ #[allow(clippy::result_large_err)]
400406 let ws = tokio_tungstenite::accept_hdr_async(stream, move |req: &Request, res: Response| {
401407 let header = |name: &str| {
402408 req.headers()
⋯ 1795 unchanged lines
modifieddaemon/src/tls.rs+11 −11
⋯ 141 unchanged lines
142142 fn rustls_pemfile_certs(
143143 r: &mut std::io::Cursor<&[u8]>,
144144 ) -> 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();
146146 let mut out = Vec::new();
147147 for block in text.split("-----BEGIN CERTIFICATE-----").skip(1) {
148148 let Some(body) = block.split("-----END CERTIFICATE-----").next() else {
⋯ 58 unchanged lines
207207 "-----END RSA PRIVATE KEY-----",
208208 ),
209209 ] {
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+ });
220220 }
221221 }
222222 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
246246
247247 let got = tokio::time::timeout(Duration::from_secs(10), async {
248248 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());
253253 }
254254 }
255255 None
⋯ 621 unchanged lines
modifieddaemon/tests/security.rs+4 −4
⋯ 242 unchanged lines
243243 // Say nothing. The deadline must close us.
244244 let outcome = tokio::time::timeout(Duration::from_secs(2), async {
245245 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;
250250 }
251251 }
252252 false
⋯ 333 unchanged lines