Conversation
It came up that we could use a style guide to help people with things that are commonly nit-picked in code review. And with AI-assisted development being more common, it'd be useful to help AI write code that adheres to our standards the first time. So here's a first draft... this is mostly a brain dump of stuff I'm interested in and commonly call out in code reviews. I'm hoping this will spur discussion, since this is mostly just my opinion and others may disagree on some of this. It's also very incomplete, and we can add to it as we go. It's also disorganized (there's not a lot of logic to the ordering) and maybe a bit too example-heavy. Maybe brevity is better?
🛡️ Vulnerability Scan🚨 Found 74 vulnerability(ies) Severity Breakdown:
🔗 View full details in Security tab 🕐 Last updated: 2026-03-11 20:29:30 UTC | Commit: 04e9498 |
🔐 TruffleHog Secret Scan✅ No secrets or credentials found! Your code has been scanned for 700+ types of secrets and credentials. All clear! 🎉 🕐 Last updated: 2026-03-11 20:29:34 UTC | Commit: 04e9498 |
Matthias247
left a comment
There was a problem hiding this comment.
Thanks @kensimon . That's a great starting point.
I think priority wise I'd probable move some of the more "service design" related sections higher up, and the in-depth coding ones (avoid mut) further down.
Maybe we can add some headlines and intra-documented links to jump quicker between these sections.
| } | ||
| ``` | ||
|
|
||
| If your type has fields that can all be default values in the common case (like a Config object), prefer implementing |
There was a problem hiding this comment.
I think passing a Config object to new is also a good pattern. Doesn't necessarily need to be a builder. The core idea is to keep the amount of of arguments to the function low
STYLE_GUIDE.md
Outdated
| callers to pass a `PgPool` and avoid needing boilerplate to begin a transaction and commit it just to call a | ||
| read-only function. | ||
|
|
||
| ### Metrics |
There was a problem hiding this comment.
That can probably be its own top level section (promote to ##). Same for everything below.
All the super-general "rust nitpicks" stuff is now last, in a section "General Rust Coding Standards". Everything before it is now promoted to '##'-level, and I did some basic rearranging by priority: Reviewability is now first, then lints and warnings, etc.
| `machine_id` are probably the two most important examples, but try to express other relevant data as fields instead of | ||
| using interpolation if it makes sense. | ||
|
|
||
| ## Create Features |
Totally agree, I just pushed a commit that rearranged them:
|
|
This is exciting. I think a "Comments" section explaining how to write comments would also be useful, i.e. ..or maybe that's NOT how we want it? And same with structs: ..or maybe we want it the inverse? I've always done it this way, but maybe people like it the other way? |
Description
It came up that we could use a style guide to help people with things
that are commonly nit-picked in code review. And with AI-assisted
development being more common, it'd be useful to help AI write code that
adheres to our standards the first time.
So here's a first draft... this is mostly a brain dump of stuff I'm
interested in and commonly call out in code reviews. I'm hoping this
will spur discussion, since this is mostly just my opinion and others
may disagree on some of this. It's also very incomplete, and we can add
to it as we go.
It's also disorganized (there's not a lot of logic to the ordering) and
maybe a bit too example-heavy. Maybe brevity is better?
Type of Change
Related Issues (Optional)
Breaking Changes
Testing
Additional Notes
Rendered: https://github.com/kensimon/bare-metal-manager-core/tree/style-guide-first-draft/STYLE_GUIDE.md