-
Notifications
You must be signed in to change notification settings - Fork 369
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
Define style guidelines #696
Comments
traits:
imports:
testing:
casing: comments / in-code docs: |
Here's a rough contract mod layout guide. A. Outer contract elements
B. Inner contract elements
|
Regarding scoping:
|
Proposed rules for grouping imports:
Instead of this:
Use this:
Three lines is allowed:
NOTE: Sometimes could make sense to allow more than three lines, this is just a generic rule. |
Traits representing external interfaces should begin with |
Contracts should order component impls, storage, and events in the same order that they're imported
|
Rules for test assertions:
|
Is this really wanted? Won't we lose the error message when the test fails? Because that's crucial to quickly spot the failing line, even if there's some redundancy in error strings (possible error lines get very reduced when it's test name + error string) |
We don't need the message to spot the line, by default we have test name + the assertion failed, and I think that's enough (even more if the assertion naming is explicit). For example: From the test:
Sometimes the message provides context and is helpful, but I don't think redundancy is giving us any real advantage. |
In tests, we should perform checks/asserts right after state changes/calls/queries, instead of performing several of them an asserting later. For example: let bar = contract.bar(args..);
assert!(bar);
let foo = contract.foo(args...);
assert!(foo);
let baz = contract.baz(args..);
assert!(baz); instead of: let bar = contract.bar(args..);
let foo = contract.foo(args...);
let baz = contract.baz(args..);
assert!(bar);
assert!(foo);
assert!(baz); |
Closing this issue as this is done internally. |
We need to update, settle, and write down our coding conventions around naming, in-code documentation, parameter order, etc. for variables, storage structs, events, impls, traits, ABIs, and presets.
This includes Trait/ABI distinction, casing, internal/external/private functions (if still applies) and all related patterns.
Tasks
The text was updated successfully, but these errors were encountered: