wtimme / OSM-Completionist

⛔️ DEPRECATED iOS companion app for OpenStreetMap that allows contributors to complete missing information
ISC License
18 stars 4 forks source link

Add SwiftFormat to the project using Swift Package Manager #72

Closed stavares843 closed 3 years ago

stavares843 commented 4 years ago

https://github.com/wtimme/OSM-Completionist/issues/53

Screenshot 2020-06-08 at 03 25 51
sonarcloud[bot] commented 4 years ago

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

wtimme commented 3 years ago

Thank you very much for your effort, @stavares843, and sorry for not getting back to you sooner!

With the recent commits, I have added a .swiftformat configuration file that excludes the src/ directory. The reason for this is that I want to avoid merge conflicts with the master branch of the original GoMap repository as much as possible. By limiting the formatting to only those Swift files that are used for this repository, merge conflicts should occur much less.

As for the implementation detail, I have opted for just using a locally installed swiftformat binary. (So you need to run brew install swiftformat first), since I was unsure about using Swift Package Manager for this. Looking at SwiftFormat's documentation, it sounds as if they suggest to use SPM in case one wanted to run SwiftFormat as part of a build phase. From my experience, this comes with a significant downside (that is also outlined in their documentation):

Adding this script will overwrite your source files as you work on them, which has the annoying side-effect of clearing the undo history.

I plan on adding a pre-commit hook that automatically formats the staged files.

What is your experience with this? Do you have another opinion or ideas? Again, thanks for your contribution and sorry for the delay!