Skip to content

Commit

Permalink
Consistent Code Style (#37)
Browse files Browse the repository at this point in the history
* add swiftlint & swiftformat

* run formatter for while codebase

* fix redundant_void_return warnings

* fix void_function_in_ternary warning

* fix for_where warning

* change property to let

* fix unused_optional_binding warning

* fix multiple_closures_with_trailing_closure

* fix leading_whitespace warning

* fix deprecation warning

'white' was deprecated in iOS 13.0: renamed to 'UIActivityIndicatorView.Style.medium'

* add pull request template

* add githook

* update contributing

* remove macOS platform

* try iOS12 SwiftLintPlugin

* fix build error

* fix deprecation warning

* use new Hashable requirement

* remove unused code

* fix warning about wrong api usage

'encodedOffset' is deprecated: encodedOffset has been deprecated as most common usage is incorrect. Use utf16Offset(in:) to achieve the same behavior.

* fix duplicated

The "feedback_traffic" image asset name resolves to the symbol "feedbackTraffic" which already exists. Try renaming the asset.

* ensure self usage via SwiftFormat

* update contributing

* increase test timeout

* remove swiftlint plugin

* add swiftlint to build action

* rename workflow
  • Loading branch information
Patrick-Kladek authored Apr 19, 2024
1 parent a768d89 commit 0264009
Show file tree
Hide file tree
Showing 146 changed files with 3,834 additions and 3,720 deletions.
6 changes: 6 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# Will download all dependencies if not already existing
swift package plugin --list

./.tools/git-format-staged --formatter ".build/checkouts/SwiftFormat/CommandLineTool/swiftformat stdin --stdinpath '{}'" "*.swift"
10 changes: 10 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### Description



### Open Tasks

- [ ]

### Infos for Reviewer

42 changes: 28 additions & 14 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: iOS starter workflow
name: iOS

on:
push:
Expand All @@ -7,22 +7,36 @@ on:
pull_request:

jobs:
build:
name: Build and Test using Xcode 15.3 on iPhone 15 Pro
format:
name: Code Style
runs-on: macos-14
steps:
- name: Install tools
run: brew install swiftlint

- name: Checkout
uses: actions/checkout@v4

- name: Check format
run: swiftlint lint . --reporter github-actions-logging

test:
name: Build and Test
runs-on: macos-14
steps:
- name: Configure Xcode 15.3
run: |
sudo xcode-select -s /Applications/Xcode_15.3.app
- name: Print Xcode Version
run: |
xcode-select --print-path
- name: Install tools
run: brew install xcbeautify

- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build
run: |
set -o pipefail && xcodebuild build -scheme maplibre-navigation-ios -destination 'platform=iOS Simulator,OS=17.0.1,name=iPhone 15 Pro' | xcbeautify --renderer github-actions
run: set -o pipefail && xcodebuild build -scheme maplibre-navigation-ios -destination 'platform=iOS Simulator,OS=17.0.1,name=iPhone 15 Pro' | xcbeautify --renderer github-actions

- name: Test
run: |
set -o pipefail && xcodebuild test -scheme maplibre-navigation-ios -destination 'platform=iOS Simulator,OS=17.0.1,name=iPhone 15 Pro' | xcbeautify --renderer github-actions
run: set -o pipefail && xcodebuild test -scheme maplibre-navigation-ios -destination 'platform=iOS Simulator,OS=17.0.1,name=iPhone 15 Pro' | xcbeautify --renderer github-actions
85 changes: 85 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
--acronyms ID,URL,UUID
--allman false
--anonymousforeach convert
--assetliterals visual-width
--asynccapturing
--beforemarks
--binarygrouping none
--categorymark "MARK: %c"
--classthreshold 0
--closingparen balanced
--closurevoid remove
--commas inline
--conflictmarkers reject
--decimalgrouping 3,6
--doccomments before-declarations
--elseposition same-line
--emptybraces no-space
--enumnamespaces always
--enumthreshold 0
--exponentcase lowercase
--exponentgrouping disabled
--extensionacl on-extension
--extensionlength 0
--extensionmark "MARK: - %t + %c"
--fractiongrouping disabled
--fragment false
--funcattributes preserve
--generictypes
--groupedextension "MARK: %c"
--guardelse auto
--header ignore
--hexgrouping none
--hexliteralcase uppercase
--ifdef no-indent
--importgrouping alpha
--indent 4
--indentcase false
--indentstrings false
--lifecycle
--lineaftermarks true
--linebreaks lf
--markcategories true
--markextensions always
--marktypes always
--maxwidth none
--modifierorder
--nevertrailing
--nospaceoperators
--nowrapoperators
--octalgrouping none
--onelineforeach ignore
--operatorfunc spaced
--organizetypes actor,class,enum,struct
--patternlet hoist
--ranges spaced
--redundanttype infer-locals-only
--self insert
--selfrequired
--semicolons inline
--shortoptionals except-properties
--smarttabs enabled
--someany true
--stripunusedargs closure-only
--structthreshold 0
--tabwidth unspecified
--throwcapturing
--trailingclosures
--trimwhitespace nonblank-lines
--typeattributes preserve
--typeblanklines remove
--typemark "MARK: - %t"
--varattributes preserve
--voidtype void
--wraparguments disabled
--wrapcollections preserve
--wrapconditions preserve
--wrapeffects preserve
--wrapenumcases always
--wrapparameters after-first
--wrapreturntype preserve
--wrapternary default
--wraptypealiases preserve
--xcodeindentation disabled
--yodaswap always
--disable wrapMultilineStatementBraces
22 changes: 22 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
disabled_rules:
- trailing_whitespace
- private_over_fileprivate
- line_length
- force_cast
- function_body_length
- identifier_name
- cyclomatic_complexity
- type_body_length
- file_length
- force_try
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- MapboxCoreNavigationTests
- MapboxNavigationTests
- scripts
- .build

identifier_name:
max_length:
warning: 60
error: 100

nesting:
type_level:
warning: 3
error: 6
function_level:
warning: 5
error: 10
Loading

0 comments on commit 0264009

Please sign in to comment.