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

Commit

Permalink
Introduce Swiftlint (#572)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bfollington authored May 12, 2023
1 parent 8ce3c8e commit 2a3a6d9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/swiftlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
pull_request:
paths:
- '.github/workflows/swiftlint.yml'
- '.swiftlint.yml'
- '**/*.swift'

name: SwiftLint

jobs:
SwiftLint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: GitHub Action for SwiftLint
uses: norio-nomura/action-swiftlint@master
19 changes: 19 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
only_rules:
- line_length
- vertical_whitespace
- redundant_discardable_let
- unused_closure_parameter
- mark
- implicit_getter
- trailing_comma
- orphaned_doc_comment
- control_statement
- multiple_closures_with_trailing_closure
- opening_brace
- empty_enum_arguments
- for_where
- redundant_string_enum_value
- colon
- syntactic_sugar

line_length: 100

0 comments on commit 2a3a6d9

Please sign in to comment.