diff --git a/rust/kcl-lib/src/lint/checks/offset_plane.rs b/rust/kcl-lib/src/lint/checks/offset_plane.rs index f615059a1..68828ab60 100644 --- a/rust/kcl-lib/src/lint/checks/offset_plane.rs +++ b/rust/kcl-lib/src/lint/checks/offset_plane.rs @@ -229,12 +229,12 @@ pub fn common( let normalized_plane_info = normalize_plane_info(&plane_info); - println!("normalized plane info: {:?}", normalized_plane_info); + println!("normalized plane info: {:#?}", normalized_plane_info); // Check our default planes. let Some((matched_plane_name, _)) = DEFAULT_PLANE_INFO .iter() - .find(|(_, plane)| **plane == normalized_plane_info) + .find(|(_, plane)| plane_equal_excluding_z(plane, &normalized_plane_info)) else { return Ok(None); }; @@ -279,6 +279,7 @@ mod tests { use super::{Z0003, lint_should_be_offset_plane}; use crate::lint::rule::{test_finding, test_no_finding}; + // Both axes here are normalized. test_finding!( z0003_bad_sketch_on, lint_should_be_offset_plane, @@ -295,6 +296,30 @@ startSketchOn({ Some("offsetPlane(XZ, offset = -14.3)".to_string()) ); + // This test uses a Y axis that isn't normalized, to check the normalization code doesn't + // stop this lint from firing. + test_finding!( + z0003_bad_sketch_on_not_normalized_axes, + lint_should_be_offset_plane, + Z0003, + "\ +a1 = startSketchOn({ + origin = { x = 0, y = 0, z = 0 }, + xAxis = { x = 1, y = 0, z = 0 }, + yAxis = { x = 0, y = 12, z = 0 }, + }) + |> startProfile(at = [0, 0]) + |> line(end = [100.0, 0]) + |> yLine(length = -100.0) + |> xLine(length = -100.0) + |> yLine(length = 100.0) + |> close() + |> extrude(length = 3.14) +", + "custom plane in startSketchOn; offsetPlane from XY would work here", + Some("offsetPlane(XY, offset = 12)".to_string()) + ); + test_no_finding!( z0003_good_sketch_on, lint_should_be_offset_plane,