mirror of
https://github.com/mas-cli/mas
synced 2024-11-21 19:23:01 +00:00
57da9e0f51
Partial #592 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
1.9 KiB
1.9 KiB
All Files
- Use
script/format
to automatically fix a number of style violations. - Remove unnecessary whitespace from the end of lines.
- Use
script/lint
to look for these before committing. - Note that two trailing spaces
is intentional in markdown documents to create a line break like
<br>
, so these should not be removed.
- Use
- End each file with a newline character.
Swift
- Avoid force unwrapping optionals
with
!
in production code- Production code is what gets shipped with the app. Basically, everything under the
Sources/mas
folder. - However, force unwrapping is encouraged in tests for less code and tests should break when any expected conditions aren't met.
- Production code is what gets shipped with the app. Basically, everything under the
- Prefer
struct
s overclass
es wherever possible - Default to marking classes as
final
- Prefer protocol conformance to class inheritance
- Break lines at 120 characters
- Use 4 spaces for indentation
- Use
let
whenever possible to make immutable variables - Name all parameters in functions and enum cases
- Use trailing closures
- Let the compiler infer the type whenever possible
- Group computed properties below stored properties
- Use a blank line above and below computed properties
- Group functions into separate extensions for each level of access control
- When capitalizing acronyms or initialisms, follow the capitalization of the first letter.
- When using
Void
in function signatures, prefer()
for arguments andVoid
for return types. - Avoid evaluating a weak reference multiple times in the same scope. Strongify first, then use the strong reference.