Skip to content

Commit a8f7f61

Browse files
committed
docs: add CONVENTIONS.md and upadte CONTRIBUTING.md
- CONTRIBUTING.md is more about general contributing guidelines, such as creating issues, creating pull reqeusts and so on - CONVENTIONS.md defines coding, formatting, and architectural standards - CONVENTIONS.md / Guidelines for writing good functional code originates from: https://github.com/Aider-AI/conventions Signed-off-by: AtomicFS <vojtech.vesely@9elements.com>
1 parent 26426ce commit a8f7f61

File tree

3 files changed

+77
-18
lines changed

3 files changed

+77
-18
lines changed

.cspell.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090
"githubaction",
9191
"githubactions",
9292
"gocyclo",
93+
"gofmpt",
94+
"gofumpt",
9395
"golangci",
9496
"gorecurcopy",
9597
"goreleaser",
@@ -142,6 +144,7 @@
142144
"skipframes",
143145
"sloglint",
144146
"startswith",
147+
"staticcheck",
145148
"stmsg",
146149
"testregex",
147150
"textfile",

CONTRIBUTING.md

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,18 @@
22

33
We use GitHub to host code, to track issues and feature requests, as well as accept pull requests.
44

5+
For coding guidelines and commit message conventions, please look into [CONVENTIONS.md](https://github.com/9elements/firmware-action/blob/main/CONVENTIONS.md).
56

67
## Issues
78
As usual, [check if issue already exists](https://docs.github.com/en/github/searching-for-information-on-github/searching-on-github/searching-issues-and-pull-requests#search-by-the-title-body-or-comments) in GitHub issue tracker.
89

9-
## Commit messages
10-
Please conform to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.
1110

11+
## Pull Requests / Merge Requests
1212

13-
## Used tools
13+
We accept GitHub pull requests.
1414

15-
### Linters
15+
Fork the project on GitHub, work in your fork and in branches, push these to your GitHub fork, and when ready, do a GitHub pull requests against [https://github.com/9elements/firmware-action](https://github.com/9elements/firmware-action).
1616

17-
#### MegaLinter
18-
[MegaLinter](https://megalinter.io/latest/) is used in [GitHub Flow](https://docs.github.com/en/get-started/quickstart/github-flow), which checks all the source code.
19-
20-
Can be run locally, but it is pain. See [MegaLinter Runner](https://megalinter.io/latest/mega-linter-runner/).
21-
22-
23-
#### commitlint
24-
[commitlint](https://github.com/conventional-changelog/commitlint) checks if the commit message conforms to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.
25-
26-
To run locally, check [Tooling for Conventional Commits](https://www.conventionalcommits.org/en/about/#tooling-for-conventional-commits).
27-
28-
29-
### editorconfig
30-
Please make sure to conform to provided [editorconfig](https://editorconfig.org/).
17+
Organize your changes in small and meaningful commits which are easy to review. Not every commit in your pull request needs to be able to build and pass the CI tests, but the whole PR must build and pass CI all tests.
3118

19+
If the pull request closes an issue please note it as: "Fixes #NNN".

CONVENTIONS.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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

Comments
 (0)