mirror of
https://github.com/ZSeven-W/openpencil.git
synced 2026-06-01 03:14:29 +07:00
style: clear clippy lints for the workspace -D warnings gate
Some checks failed
Rust check (native) / macos-latest / 1.94 (push) Waiting to run
Rust check (native) / windows-latest / 1.94 (push) Waiting to run
Rust multi-platform build / linux-aarch64 (push) Waiting to run
Rust multi-platform build / macos-aarch64 (push) Waiting to run
Rust multi-platform build / windows-x86_64 (push) Waiting to run
Rust multi-platform build / macos-x86_64 (push) Waiting to run
Rust multi-platform build / windows-aarch64 (push) Waiting to run
Rust multi-platform build / ios-aarch64 (cargo check only) (push) Waiting to run
Rust multi-platform build / ios-aarch64-sim (cargo check only) (push) Waiting to run
Rust check (native) / ubuntu-latest / 1.94 (push) Failing after 2s
Rust check (native) / cargo-deny (native) (push) Failing after 1s
Rust multi-platform build / linux-x86_64 (push) Failing after 1s
Rust multi-platform build / wasm32-unknown-unknown / op-host-web (compile guard) (push) Failing after 2s
Rust multi-platform build / android-aarch64 (cargo check only) (push) Failing after 2s
Rust multi-platform build / android-x86_64 (cargo check only) (push) Failing after 2s
WASM bundle check (kickoff §1.2) / cargo check --target wasm32-unknown-unknown (push) Failing after 2s
WASM bundle check (kickoff §1.2) / cargo-deny --target wasm32-unknown-unknown check bans (push) Failing after 2s
Some checks failed
Rust check (native) / macos-latest / 1.94 (push) Waiting to run
Rust check (native) / windows-latest / 1.94 (push) Waiting to run
Rust multi-platform build / linux-aarch64 (push) Waiting to run
Rust multi-platform build / macos-aarch64 (push) Waiting to run
Rust multi-platform build / windows-x86_64 (push) Waiting to run
Rust multi-platform build / macos-x86_64 (push) Waiting to run
Rust multi-platform build / windows-aarch64 (push) Waiting to run
Rust multi-platform build / ios-aarch64 (cargo check only) (push) Waiting to run
Rust multi-platform build / ios-aarch64-sim (cargo check only) (push) Waiting to run
Rust check (native) / ubuntu-latest / 1.94 (push) Failing after 2s
Rust check (native) / cargo-deny (native) (push) Failing after 1s
Rust multi-platform build / linux-x86_64 (push) Failing after 1s
Rust multi-platform build / wasm32-unknown-unknown / op-host-web (compile guard) (push) Failing after 2s
Rust multi-platform build / android-aarch64 (cargo check only) (push) Failing after 2s
Rust multi-platform build / android-x86_64 (cargo check only) (push) Failing after 2s
WASM bundle check (kickoff §1.2) / cargo check --target wasm32-unknown-unknown (push) Failing after 2s
WASM bundle check (kickoff §1.2) / cargo-deny --target wasm32-unknown-unknown check bans (push) Failing after 2s
CI's Rust Check runs `cargo clippy --workspace --all-targets -- -D warnings`; the fmt failure had masked it, so accumulated lints surfaced once formatting was fixed. Resolve them: - op-acp / op-ai-skills (this change set): while-let loop, redundant struct update, and `should_implement_trait` allows on the Option / infallible token parsers. - Pre-existing in op-editor-core / op-figma, swept so the workspace gate is clean: redundant `drop`, `too_many_arguments` allow, collapsible `if let`, a type alias for a complex tuple, manual `Iterator::find`, and an `approx_constant` test value. Lint fixes only — no behaviour change.
This commit is contained in:
parent
74d8065cc2
commit
3d6ab1a0d3
10 changed files with 44 additions and 30 deletions
|
|
@ -58,15 +58,12 @@ impl AcpConnection {
|
|||
}
|
||||
});
|
||||
|
||||
// Reader task — classify + dispatch every inbound frame.
|
||||
// Reader task — classify + dispatch every inbound frame until
|
||||
// EOF or a transport failure ends the stream.
|
||||
let reader = tokio::spawn(async move {
|
||||
let mut buf = BufReader::new(read);
|
||||
loop {
|
||||
match read_frame(&mut buf).await {
|
||||
Ok(Some(value)) => dispatch_inbound(value, &pending, ¬if_tx, &reply_tx),
|
||||
// EOF or transport failure — stop reading.
|
||||
Ok(None) | Err(_) => break,
|
||||
}
|
||||
while let Ok(Some(value)) = read_frame(&mut buf).await {
|
||||
dispatch_inbound(value, &pending, ¬if_tx, &reply_tx);
|
||||
}
|
||||
// Connection closed: fail every in-flight request now so
|
||||
// callers get `Closed` immediately instead of stalling
|
||||
|
|
|
|||
|
|
@ -176,7 +176,6 @@ mod tests {
|
|||
memory: crate::types::ResolveMemory {
|
||||
document_context: Some(DesignContext::default()),
|
||||
generation_history: history("/a.op", 3),
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ impl Platform {
|
|||
}
|
||||
|
||||
/// Parse a platform token; unknown / missing → `Webapp` (TS parity).
|
||||
// Infallible token parser, not the `Result`-shaped `FromStr`.
|
||||
#[allow(clippy::should_implement_trait)]
|
||||
pub fn from_str(s: &str) -> Platform {
|
||||
match s.trim() {
|
||||
"mobile" => Platform::Mobile,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ impl Phase {
|
|||
}
|
||||
|
||||
/// Parse a phase token (as it appears in skill frontmatter).
|
||||
// Token parser — `Option`-returning, not the `Result`-shaped
|
||||
// `FromStr`, so the trait does not apply.
|
||||
#[allow(clippy::should_implement_trait)]
|
||||
pub fn from_str(s: &str) -> Option<Phase> {
|
||||
match s.trim() {
|
||||
"planning" => Some(Phase::Planning),
|
||||
|
|
@ -80,6 +83,8 @@ pub enum SkillCategory {
|
|||
impl SkillCategory {
|
||||
/// Parse a category token from skill frontmatter; defaults to
|
||||
/// `Domain` for an unknown / missing value (TS parity).
|
||||
// Infallible token parser, not the `Result`-shaped `FromStr`.
|
||||
#[allow(clippy::should_implement_trait)]
|
||||
pub fn from_str(s: &str) -> SkillCategory {
|
||||
match s.trim() {
|
||||
"base" => SkillCategory::Base,
|
||||
|
|
|
|||
|
|
@ -613,6 +613,9 @@ const CUBIC_FLATTEN_STEPS: usize = 24;
|
|||
/// time, into `CUBIC_FLATTEN_STEPS` straight anchors that trace it.
|
||||
/// `c1`/`c2` are the SVG control points, `(x, y)` the endpoint,
|
||||
/// `(ox, oy)` the document offset; the previous anchor is the start.
|
||||
// Each control point + endpoint + offset is its own scalar — bundling
|
||||
// them into a struct would only obscure a flat geometric signature.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn emit_cubic(
|
||||
anchors: &mut Vec<PenPathAnchor>,
|
||||
c1x: f64,
|
||||
|
|
|
|||
|
|
@ -65,7 +65,8 @@ pub(crate) fn path_anchor_bounds(anchors: &[PenPathAnchor], closed: bool) -> (f6
|
|||
);
|
||||
}
|
||||
}
|
||||
drop(acc);
|
||||
// `acc`'s captures (`&mut min_x` …) are released by NLL at its
|
||||
// last call above — the accumulators are free to read here.
|
||||
if !min_x.is_finite() {
|
||||
return (0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,16 +109,14 @@ pub fn apply_instance_overrides(
|
|||
|
||||
// Fast path — nothing to apply: just rescale to the instance size.
|
||||
if derived.is_empty() && overrides.is_empty() {
|
||||
if let (Some(size), Some(sym_size)) = (
|
||||
if let (Some(size), Some(Some(sym_size))) = (
|
||||
instance_size,
|
||||
symbol_node.figma.get("size").map(FigVec2::from_value),
|
||||
) {
|
||||
if let Some(sym_size) = sym_size {
|
||||
if sym_size.x != 0.0 && sym_size.y != 0.0 {
|
||||
let sx = size.x / sym_size.x;
|
||||
let sy = size.y / sym_size.y;
|
||||
return crate::common::scale_tree_children(&symbol_node.children, sx, sy);
|
||||
}
|
||||
if sym_size.x != 0.0 && sym_size.y != 0.0 {
|
||||
let sx = size.x / sym_size.x;
|
||||
let sy = size.y / sym_size.y;
|
||||
return crate::common::scale_tree_children(&symbol_node.children, sx, sy);
|
||||
}
|
||||
}
|
||||
return symbol_node.children.clone();
|
||||
|
|
@ -261,12 +259,10 @@ fn apply_to_node(
|
|||
}
|
||||
|
||||
// Override props — copy every non-blacklisted, present key.
|
||||
if let Some(ov) = ov {
|
||||
if let FigValue::Object(pairs) = ov {
|
||||
for (k, v) in pairs {
|
||||
if !OVERRIDE_SKIP_KEYS.contains(&k.as_str()) && !matches!(v, FigValue::Null) {
|
||||
figma.set(k, v.clone());
|
||||
}
|
||||
if let Some(FigValue::Object(pairs)) = ov {
|
||||
for (k, v) in pairs {
|
||||
if !OVERRIDE_SKIP_KEYS.contains(&k.as_str()) && !matches!(v, FigValue::Null) {
|
||||
figma.set(k, v.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,6 +205,12 @@ impl Schema {
|
|||
}
|
||||
}
|
||||
|
||||
/// One raw field before type resolution: `(name, type_code, is_array,
|
||||
/// value)`. Type codes stay numeric until every definition is known.
|
||||
type RawField = (String, i32, bool, u32);
|
||||
/// One raw definition before type resolution: `(name, kind, fields)`.
|
||||
type RawDef = (String, DefKind, Vec<RawField>);
|
||||
|
||||
/// Decode the self-describing binary schema chunk
|
||||
/// (`decodeBinarySchema`). Type codes are bound to names: a negative
|
||||
/// code is a native type (`!code` indexes [`NATIVE_TYPES`]), a
|
||||
|
|
@ -214,7 +220,7 @@ pub fn decode_binary_schema(bytes: &[u8]) -> Result<Schema, KiwiError> {
|
|||
let definition_count = bb.read_var_uint()?;
|
||||
// Raw types are kept as ints until every definition is known, so
|
||||
// forward references resolve.
|
||||
let mut raw: Vec<(String, DefKind, Vec<(String, i32, bool, u32)>)> = Vec::new();
|
||||
let mut raw: Vec<RawDef> = Vec::new();
|
||||
for _ in 0..definition_count {
|
||||
let name = bb.read_string()?;
|
||||
let kind = match bb.read_byte()? {
|
||||
|
|
|
|||
|
|
@ -199,7 +199,15 @@ fn omitted_message_fields_are_absent() {
|
|||
#[test]
|
||||
fn var_float_round_trips() {
|
||||
let mut w = ByteWriter::default();
|
||||
let cases = [0.0f32, 1.0, -1.0, 3.14159, 1e-6, -42.5, 65536.0];
|
||||
let cases = [
|
||||
0.0f32,
|
||||
1.0,
|
||||
-1.0,
|
||||
std::f32::consts::PI,
|
||||
1e-6,
|
||||
-42.5,
|
||||
65536.0,
|
||||
];
|
||||
for v in cases {
|
||||
w.var_float(v);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,12 +62,9 @@ fn find_eocd(buf: &[u8]) -> Option<usize> {
|
|||
}
|
||||
// EOCD is 22 bytes + up to 64 KiB comment.
|
||||
let scan_start = buf.len().saturating_sub(22 + 0xffff);
|
||||
for off in (scan_start..=buf.len() - 22).rev() {
|
||||
if u32_le(buf, off) == Some(EOCD_SIG) {
|
||||
return Some(off);
|
||||
}
|
||||
}
|
||||
None
|
||||
(scan_start..=buf.len() - 22)
|
||||
.rev()
|
||||
.find(|&off| u32_le(buf, off) == Some(EOCD_SIG))
|
||||
}
|
||||
|
||||
/// Parse a ZIP archive into its decompressed entries. Entry order
|
||||
|
|
|
|||
Loading…
Reference in a new issue