[Config] Style Guidelines
Add SwiftLint under MIT License as a new package plugin during build phase (requires Xcode 12) to generate warnings and errors about style choices.
See .swiftlint.yml
for our configuration of rules from the rules directory, and the Style Guide on our Wiki.
Style-related MRs
Because introducing all the required style changes in a single commit is a bad idea, there are some additional MRs that addresses necessary style changes:
- !92 (merged) Fix whitespaces
- !94 (merged) Format TapRecognizerViewModifier
- !95 (merged) Format TwoFingerTapView
- !96 (merged) Format CertificateService
- !97 (merged) Rename iOS14Focus to Focuser
- !98 (merged) Format AlertManager
- !99 (merged) Misc Changes
Disabled Rules
Currently, the project disabled/did not enable many rules from SwiftLint due to the large number of warnings those rules generate, but these should be more or less not controversial:
- control_statement: there should be no parenthesis around the condition
- force_cast: force cast bad, but necessary for the current, weakly typed plugin system
- line_length: we have too many long lines. The default for this is warning at 120 and error at 200 columns
- force_unwrapping: force unwrapping bad, hence why there's an entire chapter on how to handle
Optional
values - redundant_type_annotation: Swift can figure it out without significantly slowing down the compiler most of the time
Notes for Future
All // swiftlint:disable
must have a reason explaining why, and applied to the smallest scope possible.
Edited by Apollo Zhu