ROX-36764: Add rules for default work arguments - #61
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 SummarySummary by CodeRabbit
Walkthrough
ChangesWork Argument Defaults
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Work nodes now receive default workers and duration values when omitted while preserving explicit values. No merge-blocking risk is identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 Clippy (1.97.1)Clippy execution failed Comment |
Molter73
left a comment
There was a problem hiding this comment.
Overall looks good, just a few comments on ownership in the rules.rs file.
| if !new_args.contains_key("workers") { | ||
| debug!("Applying default number of workers"); | ||
| new_args.insert("workers".to_string(), "1".to_string()); | ||
| } |
There was a problem hiding this comment.
[nitpick] If we remove the debug statement, these assignments could be condensed to:
let _ = new_args.entry("workers").or_insert("1".to_string);There was a problem hiding this comment.
to_string part has to stay in both cases anyway. Having this in mind, how is it condensed?
new_args.insert("workers".to_string(), "1".to_string());
// vs
let _ = new_args.entry("workers".to_string()).or_insert("1".to_string());
There was a problem hiding this comment.
You don need to the the initial check, you can go from
if !new_args.contains_key("workers") {
new_args.insert("workers".to_string(), "1".to_string());
}To just:
let _ = new_args.entry("workers").or_insert("1".to_string());There was a problem hiding this comment.
Ah, I see what you mean. But I find the debug message valuable here, how about or_insert_with?
There was a problem hiding this comment.
or_insert_with leaves you with the same number of lines I think, so I'm fine leaving it as is or changing it, whichever you find more readable.
8cf70c6 to
79d8dd2
Compare
Extend rules to apply new type of rule -- to add default values to work
arguments, if they were omitted. Currently only number of workers and
duration is set, so that
main() {}
is transformed into
main(workers=1, duration=0) {}
where duration=0 means run until stopped.
79d8dd2 to
508455f
Compare
Extend rules to apply new type of rule -- to add default values to work arguments, if they were omitted. Currently only number of workers and duration is set, so that
is transformed into
where duration=0 means run until stopped.