|
| 1 | +# Conventions |
| 2 | + |
| 3 | + |
| 4 | +## File formatting |
| 5 | + |
| 6 | +To maintain consistent coding styles, indentation, line length and so on we are using [.editorconfig](https://editorconfig.org/). |
| 7 | + |
| 8 | + |
| 9 | +## Coding style |
| 10 | + |
| 11 | +For golang code, please use `gofumpt` (a strict formatter for Go language, stricter than gofmt) before contributing. On top of that please fix all reported issues by linters such as `revive`, `go vet`, `staticcheck` and `golangci-lint` (up-to-date list of used linters is in `Taskfile.yml` in `lint` task. |
| 12 | + |
| 13 | + |
| 14 | +## Guidelines for writing good functional code |
| 15 | + |
| 16 | +When writing code, you MUST follow these principles: |
| 17 | +- Code should be easy to read and understand. |
| 18 | +- Keep the code as simple as possible. Avoid unnecessary complexity. |
| 19 | +- Use meaningful names for variables, functions, etc. Names should reveal intent. |
| 20 | +- Functions should be small and do one thing well. They should not exceed a few lines. |
| 21 | +- Function names should describe the action being performed. |
| 22 | +- Prefer fewer arguments in functions. Ideally, aim for no more than two or three. |
| 23 | +- Only use comments when necessary, as they can become outdated. Instead, strive to make the code self-explanatory. |
| 24 | +- When comments are used, they should add useful information that is not readily apparent from the code itself. |
| 25 | +- Properly handle errors and exceptions to ensure the software's robustness. |
| 26 | +- Use exceptions rather than error codes for handling errors. |
| 27 | +- Consider security implications of the code. Implement security best practices to protect against vulnerabilities and attacks. |
| 28 | +- Adhere to these 4 principles of Functional Programming: |
| 29 | + 1. Pure Functions |
| 30 | + 2. Immutability |
| 31 | + 3. Function Composition |
| 32 | + 4. Declarative Code |
| 33 | +- Do not use object oriented programming. |
| 34 | + |
| 35 | + |
| 36 | +## Commit message guidelines |
| 37 | + |
| 38 | +Please follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. |
| 39 | + |
| 40 | + |
| 41 | +### Developer Sign-Off |
| 42 | + |
| 43 | +For purposes of tracking code-origination, we follow a simple sign-off process. If you can attest to the [Developer Certificate of Origin](https://developercertificate.org/) then you append in each git commit text a line such as: |
| 44 | + |
| 45 | +``` |
| 46 | +Signed-off-by: Your Name <username@youremail.com> |
| 47 | +``` |
| 48 | + |
| 49 | + |
| 50 | +### Use of AI generated content |
| 51 | + |
| 52 | +Use of AI generated content is permitted, however please mark it as AI generated in the commit message body by adding: |
| 53 | +``` |
| 54 | +AI-Generated: true |
| 55 | +AI-Model: <model used> |
| 56 | +``` |
| 57 | +For example: |
| 58 | +``` |
| 59 | +feat(...): add new feature |
| 60 | +
|
| 61 | +- adding new fun thing |
| 62 | +
|
| 63 | +AI-Generated: true |
| 64 | +AI-Model: ChatGPT o3-mini |
| 65 | +Signed-off-by: ... |
| 66 | +``` |
| 67 | + |
| 68 | +This must follow [git trailer convention](https://git-scm.com/docs/git-interpret-trailers). |
0 commit comments