|
| 1 | +# Web3swift code guidelines |
| 2 | +## General |
| 3 | +* Git methodology — gitflow |
| 4 | +* ci/cd must be ran successfully on every merge to develop |
| 5 | +* commits description should be verbose and concrete. |
| 6 | + * at least each change in file should be described in several words. |
| 7 | + * No *etc* description allowed. |
| 8 | +* Commit should not confusing by its size or content |
| 9 | + * If you’re adding or deleting a large amount of files you’ve should do it in separate commit, which will not include any code written by you. |
| 10 | + * If you’re renaming some type or do any other action that affects a large amount of source files do it as separate commit with such description `Rename ExampleType to AnotherExampleType`. |
| 11 | + * If you’re task is big enough, like, if it’s affecting 20+ source files where you’ll should to write your code, please, split it in separate commits that will affect less than 10 files at each. |
| 12 | + |
| 13 | +## CI/CD |
| 14 | +CI/CD including follow checks: |
| 15 | +- `swiftlint` with the ruleset which stores in `.swiftlint.yml` must produces no errors or warnings. |
| 16 | +- compiling as library (on each supported platform) |
| 17 | + - Carthage |
| 18 | + - CocoaPods |
| 19 | + - Swift Package Manager 5.4 |
| 20 | +- compiling as dependency (on each supported platform) |
| 21 | + - Carthage |
| 22 | + - CocoaPods |
| 23 | + - Swift Package Manager 5.4 |
| 24 | +- All test should be green. |
| 25 | + |
| 26 | +## General Code requirements |
| 27 | +### Active development |
| 28 | +- No rules for code quality applies while active development is going on. |
| 29 | + |
| 30 | +### Merge to `develop` |
| 31 | +- there’s shouldn’t have any commented out code in the library itself, but could be in Tests target. |
| 32 | +- there’s should run CI/CD pipeline successfully. |
| 33 | +- building the library should produce no warnings on both stages |
| 34 | + - no package manager warnings (Carthage, SPM, CocoaPods) |
| 35 | + - no target building warnings |
| 36 | + |
| 37 | +## Swift code formatting requirements |
| 38 | +### Active development |
| 39 | +- No rules for code quality applies while active development is going on. |
| 40 | + |
| 41 | +### Merge to `develop` |
| 42 | +- if you’re not 100% sure that this is required there’s shouldn’t be any `#if DEBUG` clauses in the code. |
| 43 | +- All required logs should be produced by `os_log()` method, not `print()` one. |
| 44 | + - all logs message should have clear descriptions. |
| 45 | +- `try` clause should should be used to return optional value, not trows and error at most, that is could be called without `do { } catch { }` block. You’re able to use block above, but it should be required there, for example, there’s should be error handling code in `catch`. |
| 46 | +- force optional try (`let someVar = try! someTrhowableMethod()`) are not allowed. |
| 47 | +- there’s shouldn’t be any unsafe force unwrap (`let someVar = optionalVar!` at all. But you could use such case as `if !array.isEmpty, let element = array.first! { }`. |
| 48 | +- All string types identifiers, like `if object.name == "someName" { }` should be strong typed as enum `if object.name = ExampleEnum.someName.rawValue` |
| 49 | +- Newly added methods should be followed with its description by the Xcode builtin tools (`cmd+option+/`). |
0 commit comments