Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to never have undefined iteration order and lint against it #4665

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

jtran
Copy link
Collaborator

@jtran jtran commented Dec 4, 2024

Here is the lint: https://rust-lang.github.io/rust-clippy/stable/index.html#/iter_over_hash_type

Now all crates inherit the lints from the workspace.

@jtran jtran requested a review from adamchalmers December 4, 2024 23:01
Copy link

qa-wolf bot commented Dec 4, 2024

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

Copy link

vercel bot commented Dec 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview Dec 5, 2024 4:17pm

@@ -191,7 +188,7 @@ impl EnvironmentRef {

#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
pub struct Environment {
bindings: HashMap<String, KclValue>,
bindings: IndexMap<String, KclValue>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to prefer IndexMap over BTreeMap?

Copy link
Collaborator Author

@jtran jtran Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTreeMap keeps things in sorted order according to the key type's Ord trait. IndexMap preserves insertion order. Unless we want to sort things, insertion order is a better, more intuitive default, in my opinion. For bindings specifically, it will keep variables in the order that they were defined in the KCL source. That's pretty nice.

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.91%. Comparing base (1495cc6) to head (5a4b691).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/wasm-lib/kcl/src/std/sketch.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4665   +/-   ##
=======================================
  Coverage   85.91%   85.91%           
=======================================
  Files          81       81           
  Lines       30117    30117           
=======================================
  Hits        25876    25876           
  Misses       4241     4241           
Flag Coverage Δ
wasm-lib 85.91% <80.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Base automatically changed from jtran/fix-default-plane-iteration to main December 5, 2024 16:04
@jtran jtran force-pushed the jtran/lint-hashmap-iter branch from 5977853 to 5a4b691 Compare December 5, 2024 16:05
@jtran jtran enabled auto-merge (squash) December 5, 2024 16:44
@jtran jtran merged commit 2bf2098 into main Dec 5, 2024
31 of 32 checks passed
@jtran jtran deleted the jtran/lint-hashmap-iter branch December 5, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants