Skip to content
This repository was archived by the owner on Aug 11, 2024. It is now read-only.

Commit 2a3a6d9

Browse files
authored
Introduce Swiftlint (#572)
Trying out a basic set of rules for catching mistakes like line length etc. everything is configured as a warning rather than an error right now so the build will never fail for lint reasons. I started with all the rules on and removed anything that was obviously in conflict with our existing style / rules. We have ~500 lint warnings in the codebase atm and it would be good to fix them because github actions can only display a maximum of 10 linting errors per run (yeah, I know). So lint errors introduced in a PR won't actually show up in the UI until we clear the backlog of underlying lint issues. The github action I used (made by the author of Swiftlint) purports to be able to scope the linting to only files changed in the PR but I get errors whenever I try to configure it as per their example. --- Swiftlint can fix basic issues by running `swiftlint --fix` but we need to pick our moment carefully to avoid conflicts with in-flight work. You can also choose to integrate swiftlint into Xcode as a build action (see this draft PR #573). If we gain enough confidence in rules I would be tempted to add a pre-commit hook that autofixes.
1 parent 8ce3c8e commit 2a3a6d9

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

.github/workflows/swiftlint.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
on:
2+
pull_request:
3+
paths:
4+
- '.github/workflows/swiftlint.yml'
5+
- '.swiftlint.yml'
6+
- '**/*.swift'
7+
8+
name: SwiftLint
9+
10+
jobs:
11+
SwiftLint:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: GitHub Action for SwiftLint
16+
uses: norio-nomura/action-swiftlint@master

.swiftlint.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
only_rules:
2+
- line_length
3+
- vertical_whitespace
4+
- redundant_discardable_let
5+
- unused_closure_parameter
6+
- mark
7+
- implicit_getter
8+
- trailing_comma
9+
- orphaned_doc_comment
10+
- control_statement
11+
- multiple_closures_with_trailing_closure
12+
- opening_brace
13+
- empty_enum_arguments
14+
- for_where
15+
- redundant_string_enum_value
16+
- colon
17+
- syntactic_sugar
18+
19+
line_length: 100

0 commit comments

Comments
 (0)