Skip to content

Commit

Permalink
[Disk Manager] add dm codestyle doc (#1894)
Browse files Browse the repository at this point in the history
* add dm codestyle doc

* eng
  • Loading branch information
BarkovBG authored Sep 6, 2024
1 parent 3c14209 commit 8437732
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions doc/disk_manager/codestyle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Main Part

The code style is based on https://go.dev/doc/effective_go and https://github.com/golang/go/wiki/CodeReviewComments, but there are some exceptions.

## Exceptions that will not be refactored

- Fixed line length of 80 characters
- Mandatory empty newlines at the beginning of each function if the signature is multiline
- Nested errors are discouraged
- By default, nil value receivers are not supported for methods, and this is not explicitly checked
- Underscores are allowed in package names
- Comments for exported objects are not mandatory
- Comments do not need to start with the name of the object being commented on
- Indent after `}` (exception: defer is pressed against the block above without indentation, for example: https://github.com/ydb-platform/nbs/blob/9c6622e69132261561cf582d4c6d8ad4fdccd67f/cloud/disk_manager/pkg/admin/disks.go#L99)
- Indent before `)` in the case of multiline calls (example: https://github.com/ydb-platform/nbs/blob/9c6622e69132261561cf582d4c6d8ad4fdccd67f/cloud/disk_manager/pkg/admin/images.go#L123)
- Comments are formatted as valid sentences: starting with a capital letter and ending with a period
- Use ID in all identifiers (not Id) (except for protobufs)

## Exceptions that can be refactored throughout the code and removed later

- The constructor is not placed directly below the structure declaration
- Constructors are not mandatory for classes (not talking about data container classes like Point, but rather logical ones like Storage)
- Named function result arguments are allowed wherever desired, not only where they add readability to the API
- Writer functions to channels are not logically separated from Readers in some multithreaded code
- Mixing receiver arguments in struct methods is allowed

0 comments on commit 8437732

Please sign in to comment.