From c1a06604798ae496b4932367972587845dadcbb6 Mon Sep 17 00:00:00 2001
From: Adam Young
Date: Mon, 26 Feb 2024 19:36:03 +0000
Subject: [PATCH 1/5] Housekeeping
---
.github/ISSUE_TEMPLATE/bug_report.md | 29 ++++++
.github/ISSUE_TEMPLATE/feature_request.md | 20 ++++
.github/codeql/codeql-config.yml | 3 +
.github/workflows/ci-documentation.yml | 24 +++++
.github/workflows/ci.yml | 78 ++++++++-------
.github/workflows/code-scan.yml | 40 --------
.github/workflows/codeql.yml | 47 +++++++++
.github/workflows/documentation.yml | 49 +++++-----
.github/workflows/integration.yml | 24 +++--
.github/workflows/lint-markdown.yml | 33 +++++++
.github/workflows/lint.yml | 42 ++++++++
.swift-version | 1 +
.swiftformat | 11 +++
Makefile | 97 +++++++++++++++++++
Package.resolved | 23 -----
Package.swift | 13 ++-
.../Availability/AvailabilityError.swift | 37 +++++--
.../Availability/AvailabilityService.swift | 19 ++++
.../Cache/AvailabilityDefaultCache.swift | 19 ++++
.../AvailableDataSetsCachingKey.swift | 21 +++-
.../Endpoints/AvailabilityEndpoint.swift | 21 +++-
.../Availability/Models/DataSet.swift | 19 ++++
.../Protocols/AvailabilityCache.swift | 19 ++++
Sources/PoliceDataKit/Cache/CacheItem.swift | 19 ++++
.../PoliceDataKit/Cache/InMemoryCache.swift | 25 ++++-
.../CrimeCategoriesCachingKey.swift | 19 ++++
.../CrimesForStreetCachingKey.swift | 19 ++++
...onForCategoryInPoliceForceCachingKey.swift | 19 ++++
.../Crimes/Cache/CrimeDefaultCache.swift | 48 +++++++--
Sources/PoliceDataKit/Crimes/CrimeError.swift | 50 +++++++---
.../PoliceDataKit/Crimes/CrimeService.swift | 60 +++++++++---
.../Crimes/Endpoints/CrimesEndpoint.swift | 43 +++++---
.../PoliceDataKit/Crimes/Models/Crime.swift | 19 ++++
.../Crimes/Models/CrimeCategory.swift | 19 ++++
.../Crimes/Models/CrimeLocationType.swift | 23 ++++-
.../Crimes/Protocols/CrimeCache.swift | 36 ++++++-
.../DateFormatter+PoliceDataAPI.swift | 19 ++++
.../JSONDecoder+PoliceDataAPI.swift | 19 ++++
...erDateDecodingStrategy+PoliceDataAPI.swift | 19 ++++
.../Extensions/String+HTML.swift | 19 ++++
.../Extensions/URL+QueryItem.swift | 21 +++-
.../CLLocationCoordinate2D+Codable.swift | 19 ++++
...Coordinate2D+CustomStringConvertible.swift | 19 ++++
.../CLLocationCoordinate2D+Equatable.swift | 19 ++++
.../General/Models/ContactDetails.swift | 19 ++++
.../General/Models/Location.swift | 25 ++++-
...egion+ContainsCLLocationCoordinate2D.swift | 27 +++++-
.../Models/MKCoordinateRegion+Regions.swift | 19 ++++
.../General/Models/PoliceOfficer.swift | 19 ++++
.../PoliceDataKit/General/Models/Street.swift | 19 ++++
.../General/Protocols/APIClient.swift | 19 ++++
.../General/Protocols/Cache.swift | 19 ++++
.../General/Protocols/CachingKey.swift | 19 ++++
.../General/Protocols/Endpoint.swift | 19 ++++
.../PoliceDataKit/Logger+PoliceDataKit.swift | 19 ++++
.../NeighbourhoodBoundaryCachingKey.swift | 19 ++++
.../CachingKeys/NeighbourhoodCachingKey.swift | 19 ++++
...eighbourhoodPoliceOfficersCachingKey.swift | 19 ++++
.../NeighbourhoodPrioritiesCachingKey.swift | 19 ++++
...eighbourhoodsInPoliceForceCachingKey.swift | 19 ++++
.../Cache/NeighbourhoodDefaultCache.swift | 83 ++++++++++++----
.../Endpoints/NeighbourhoodsEndpoint.swift | 43 +++++---
.../Neighbourhoods/Models/Link.swift | 19 ++++
.../Neighbourhoods/Models/Neighbourhood.swift | 25 ++++-
.../Models/NeighbourhoodLocation.swift | 25 ++++-
.../Models/NeighbourhoodPolicingTeam.swift | 19 ++++
.../Models/NeighbourhoodPriority.swift | 19 ++++
.../Models/NeighbourhoodReference.swift | 19 ++++
.../Neighbourhoods/NeighbourhoodError.swift | 50 +++++++---
.../Neighbourhoods/NeighbourhoodService.swift | 57 ++++++++---
.../Protocols/NeighbourhoodCache.swift | 71 +++++++++++---
.../Networking/JSONSerialiser.swift | 21 +++-
.../Networking/PoliceDataAPIClient.swift | 19 ++++
.../PoliceDataKit/Networking/Serialiser.swift | 19 ++++
...omesAtStreetLevelForStreetCachingKey.swift | 19 ++++
.../OutcomesForCrimeCachingKey.swift | 19 ++++
.../Outcomes/Cache/OutcomeDefaultCache.swift | 19 ++++
.../Outcomes/Endpoints/OutcomesEndpoint.swift | 35 +++++--
.../Outcomes/Models/CaseHistory.swift | 19 ++++
.../Outcomes/Models/CaseHistoryCrime.swift | 19 ++++
.../Outcomes/Models/CaseHistoryOutcome.swift | 19 ++++
.../Outcomes/Models/Outcome.swift | 19 ++++
.../Outcomes/Models/OutcomeCategory.swift | 19 ++++
.../Outcomes/Models/OutcomeCrime.swift | 19 ++++
.../Outcomes/Models/OutcomeStatus.swift | 19 ++++
.../PoliceDataKit/Outcomes/OutcomeError.swift | 50 +++++++---
.../Outcomes/OutcomeService.swift | 47 +++++++--
.../Outcomes/Protocols/OutcomeCache.swift | 19 ++++
.../PoliceDataKit/PoliceDataKitFactory.swift | 41 +++++---
.../CachingKeys/PoliceForceCachingKey.swift | 19 ++++
.../PoliceForceSeniorOfficersCachingKey.swift | 19 ++++
.../CachingKeys/PoliceForcesCachingKey.swift | 21 +++-
.../Cache/PoliceForceDefaultCache.swift | 19 ++++
.../Endpoints/PoliceForcesEndpoint.swift | 29 +++++-
.../Models/EngagementMethod.swift | 25 ++++-
.../PoliceForces/Models/PoliceForce.swift | 19 ++++
.../Models/PoliceForceReference.swift | 19 ++++
.../PoliceForces/PoliceForceError.swift | 41 +++++---
.../PoliceForces/PoliceForceService.swift | 19 ++++
.../Protocols/PoliceForceCache.swift | 19 ++++
.../StopAndSearchesAtLocationCachingKey.swift | 19 ++++
...pAndSearchesForPoliceForceCachingKey.swift | 19 ++++
...pAndSearchesWithNoLocationCachingKey.swift | 19 ++++
.../Cache/StopAndSearchDefaultCache.swift | 46 +++++++--
.../Endpoints/StopAndSearchesEndpoint.swift | 39 ++++++--
.../StopAndSearches/Models/Gender.swift | 25 ++++-
.../Models/StopAndSearch.swift | 19 ++++
.../Models/StopAndSearchType.swift | 25 ++++-
.../Protocols/StopAndSearchCache.swift | 46 +++++++--
.../StopAndSearches/StopAndSearchError.swift | 50 +++++++---
.../StopAndSearchService.swift | 63 +++++++++---
.../AvailabilityIntegrationTests.swift | 19 ++++
.../CrimeIntegrationTests.swift | 27 +++++-
.../Helpers/Date+ISO8601.swift | 19 ++++
.../NeighbourhoodIntegrationTests.swift | 65 ++++++++++---
.../OutcomeIntegrationTests.swift | 25 ++++-
.../PoliceForceIntegrationTests.swift | 19 ++++
.../StopAndSearchIntegrationTests.swift | 31 +++++-
.../AvailabilityServiceTests.swift | 19 ++++
.../Cache/AvailabilityDefaultCacheTests.swift | 19 ++++
.../AvailableDataSetsCachingKeyTests.swift | 19 ++++
.../Endpoints/AvailabilityEndpointTests.swift | 19 ++++
.../Mocks/AvailabilityMockCache.swift | 21 +++-
.../Availability/Models/DataSetTests.swift | 19 ++++
.../Cache/CacheItemTests.swift | 19 ++++
.../Cache/InMemoryCacheTests.swift | 19 ++++
.../CrimeCategoriesCachingKeyTests.swift | 19 ++++
.../CrimesForStreetCachingKeyTests.swift | 19 ++++
...CategoryInPoliceForceCachingKeyTests.swift | 26 ++++-
.../Crimes/Cache/CrimeDefaultCacheTests.swift | 41 ++++++--
.../Crimes/CrimeServiceTests.swift | 55 ++++++++---
.../Endpoints/CrimesEndpointTests.swift | 26 ++++-
.../Crimes/Mocks/CrimeMockCache.swift | 42 ++++++--
.../Crimes/Models/CrimeCategoryTests.swift | 19 ++++
.../Models/CrimeLocationTypeTests.swift | 19 ++++
.../Crimes/Models/CrimeTests.swift | 19 ++++
.../DateFormatter+PoliceDataAPITests.swift | 19 ++++
...eDecodingStrategy+PoliceDataAPITests.swift | 25 ++++-
.../Extensions/StringHTMLTests.swift | 31 ++++--
.../Extensions/URL+QueryItemTests.swift | 25 ++++-
.../General/Models/ContactDetailsTests.swift | 19 ++++
.../General/Models/GenderTests.swift | 19 ++++
.../General/Models/LocationTests.swift | 19 ++++
...rdinateRegionContainsCoordinateTests.swift | 19 ++++
.../General/Models/PoliceOfficerTests.swift | 19 ++++
.../Helpers/Data+LoadFromFile.swift | 25 ++++-
.../Helpers/JSONDecoder+DecodeFromFile.swift | 26 ++++-
.../Helpers/MockError.swift | 19 ++++
.../Helpers/URLProtocolMock.swift | 27 +++++-
.../URLSessionConfiguration+Mock.swift | 19 ++++
.../Helpers/XCTestCase+URLProtocolMock.swift | 19 ++++
.../Mocks/Cache/MockCache.swift | 23 ++++-
.../Mocks/Client/MockAPIClient.swift | 19 ++++
.../CLLocationCoordinate2D+Mocks.swift | 19 ++++
.../MapKit/MKCoordinateRegion+Mocks.swift | 19 ++++
.../Mocks/Models/CaseHistory+Mocks.swift | 21 +++-
.../Mocks/Models/ContactDetails+Mocks.swift | 19 ++++
.../Mocks/Models/Crime+Mocks.swift | 27 +++++-
.../Mocks/Models/CrimeCategory+Mocks.swift | 19 ++++
.../Models/CrimeLocationType+Mocks.swift | 19 ++++
.../Mocks/Models/DataSet+Mocks.swift | 19 ++++
.../Mocks/Models/EngagementMethod+Mocks.swift | 19 ++++
.../Mocks/Models/Link+Mocks.swift | 19 ++++
.../Mocks/Models/Location+Mocks.swift | 22 ++++-
.../Mocks/Models/Neighbourhood+Mocks.swift | 19 ++++
.../Models/NeighbourhoodLocation+Mocks.swift | 19 ++++
.../NeighbourhoodPolicingTeam+Mocks.swift | 19 ++++
.../Models/NeighbourhoodPriority+Mocks.swift | 19 ++++
.../Models/NeighbourhoodReference+Mocks.swift | 19 ++++
.../Mocks/Models/Outcome+Mocks.swift | 27 +++++-
.../Mocks/Models/OutcomeCategory+Mocks.swift | 19 ++++
.../Mocks/Models/OutcomeCrime+Mocks.swift | 23 ++++-
.../Mocks/Models/OutcomeStatus+Mocks.swift | 19 ++++
.../Mocks/Models/PoliceForce+Mocks.swift | 19 ++++
.../Models/PoliceForceReference+Mocks.swift | 19 ++++
.../Mocks/Models/PoliceOfficer+Mocks.swift | 19 ++++
.../Mocks/Models/StopAndSearch+Mocks.swift | 23 ++++-
...NeighbourhoodBoundaryCachingKeyTests.swift | 19 ++++
.../NeighbourhoodCachingKeyTests.swift | 19 ++++
...ourhoodPoliceOfficersCachingKeyTests.swift | 19 ++++
...ighbourhoodPrioritiesCachingKeyTests.swift | 19 ++++
...ourhoodsInPoliceForceCachingKeyTests.swift | 19 ++++
.../NeighbourhoodDefaultCacheTests.swift | 31 +++++-
.../NeighbourhoodsEndpointTests.swift | 19 ++++
.../Mocks/NeighbourhoodMockCache.swift | 73 ++++++++++----
.../Neighbourhoods/Models/LinkTests.swift | 19 ++++
.../Models/NeighbourhoodLocationTests.swift | 19 ++++
.../NeighbourhoodPolicingTeamTests.swift | 19 ++++
.../Models/NeighbourhoodPriorityTests.swift | 19 ++++
.../Models/NeighbourhoodReferenceTests.swift | 19 ++++
.../Models/NeighbourhoodTests.swift | 19 ++++
.../NeighbourhoodServiceTests.swift | 29 +++++-
.../Networking/JSONSerialiserTests.swift | 19 ++++
.../Networking/MockURLProtocol.swift | 41 ++++++--
.../Networking/PoliceDataAPIClientTests.swift | 59 +++++++----
...tStreetLevelForStreetCachingKeyTests.swift | 19 ++++
.../OutcomesForCrimeCachingKeyTests.swift | 19 ++++
.../Cache/OutcomeDefaultCacheTests.swift | 19 ++++
.../Endpoints/OutcomesEndpointTests.swift | 19 ++++
.../Outcomes/Mocks/OutcomeMockCache.swift | 19 ++++
.../Outcomes/Models/CaseHistoryTests.swift | 19 ++++
.../Models/OutcomeCategoryTests.swift | 19 ++++
.../Outcomes/Models/OutcomeCrimeTests.swift | 19 ++++
.../Models/OutcomeStatusDataModelTests.swift | 19 ++++
.../Outcomes/Models/OutcomeTests.swift | 19 ++++
.../Outcomes/OutcomeServiceTests.swift | 23 ++++-
.../PoliceForceCachingKeyTests.swift | 19 ++++
...ceForceSeniorOfficersCachingKeyTests.swift | 19 ++++
.../PoliceForcesCachingKeyTests.swift | 19 ++++
.../Cache/PoliceForceDefaultCacheTests.swift | 19 ++++
.../Endpoints/PoliceForcesEndpointTests.swift | 19 ++++
.../Mocks/PoliceForceMockCache.swift | 19 ++++
.../Models/EngagementMethodTests.swift | 19 ++++
.../Models/PoliceForceReferenceTests.swift | 19 ++++
.../Models/PoliceForceTests.swift | 19 ++++
.../PoliceForceServiceTests.swift | 19 ++++
...AndSearchesAtLocationCachingKeyTests.swift | 19 ++++
...earchesForPoliceForceCachingKeyTests.swift | 19 ++++
...earchesWithNoLocationCachingKeyTests.swift | 19 ++++
.../StopAndSearchDefaultCacheTests.swift | 19 ++++
.../StopAndSearchesEndpointTests.swift | 21 +++-
.../Mocks/StopAndSearchMockCache.swift | 39 ++++++--
.../Models/StopAndSearchTests.swift | 19 ++++
.../Models/StopAndSearchTypeTests.swift | 19 ++++
.../StopAndSearchServiceTests.swift | 29 +++++-
225 files changed, 5049 insertions(+), 588 deletions(-)
create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md
create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md
create mode 100644 .github/codeql/codeql-config.yml
create mode 100644 .github/workflows/ci-documentation.yml
delete mode 100644 .github/workflows/code-scan.yml
create mode 100644 .github/workflows/codeql.yml
create mode 100644 .github/workflows/lint-markdown.yml
create mode 100644 .github/workflows/lint.yml
create mode 100644 .swift-version
create mode 100644 .swiftformat
create mode 100644 Makefile
delete mode 100644 Package.resolved
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000..45ab92c
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,29 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**To Reproduce**
+Steps to reproduce the behavior:
+1. ...
+2. ...
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
+
+**Platform (please complete the following information):**
+ - OS: [e.g. iOS 17.2, macOS 14.2]
+ - Device: [e.g. iPhone 15, MacBook Pro 16-inch 2021 M1 Pro]
+
+**Additional context**
+Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000..4ead480
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,20 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context about the feature request here.
diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml
new file mode 100644
index 0000000..5395fe5
--- /dev/null
+++ b/.github/codeql/codeql-config.yml
@@ -0,0 +1,3 @@
+paths:
+ - Sources
+ - Tests
diff --git a/.github/workflows/ci-documentation.yml b/.github/workflows/ci-documentation.yml
new file mode 100644
index 0000000..1562d30
--- /dev/null
+++ b/.github/workflows/ci-documentation.yml
@@ -0,0 +1,24 @@
+name: Documentation CI
+
+on:
+ pull_request:
+ branches:
+ - main
+ workflow_dispatch:
+
+concurrency:
+ group: "ci-documentation-${{ github.head_ref || github.run_id }}"
+ cancel-in-progress: true
+
+jobs:
+ build-documentation:
+ name: Build Documentation
+ runs-on: ubuntu-latest
+ env:
+ SWIFTCI_DOCC: 1
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Build
+ run: swift package generate-documentation --product PoliceDataKit
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a86b734..37b476f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,12 +1,15 @@
name: CI
on:
- push:
+ pull_request:
branches:
- main
- pull_request:
+ push:
branches:
- main
+ paths:
+ - ".github/workflows/ci.yml"
+ - "**/*.swift"
workflow_dispatch:
concurrency:
@@ -14,26 +17,15 @@ concurrency:
cancel-in-progress: true
env:
- DEVELOPER_DIR: /Applications/Xcode_14.3.app/Contents/Developer
+ DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
jobs:
build-test:
name: Build and Test
- runs-on: macos-13
+ runs-on: macos-14
steps:
- name: Checkout
- uses: actions/checkout@v3
-
- - name: Cache SPM
- uses: actions/cache@v3
- with:
- path: .build
- key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
- restore-keys: |
- ${{ runner.os }}-spm-
-
- - name: Lint
- run: swiftlint --strict --reporter github-actions-logging
+ uses: actions/checkout@v4
- name: Build
run: swift build -Xswiftc -warnings-as-errors --build-tests
@@ -43,27 +35,43 @@ jobs:
- name: Build for Release
run: swift build -c release -Xswiftc -warnings-as-errors
-
- build-documentation:
- name: Build Documentation
- runs-on: macos-13
+
+ build-and-test-platforms:
+ name: Build and Test (${{ matrix.name }})
+ runs-on: macos-14
+ continue-on-error: true
+ strategy:
+ matrix:
+ include:
+ - name: iOS
+ destination: platform=iOS Simulator,name=iPhone 15,OS=17.2
+ - name: watchOS
+ destination: platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.2
+ - name: tvOS
+ destination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.2
steps:
- name: Checkout
- uses: actions/checkout@v3
-
- - name: Cache SPM
- uses: actions/cache@v3
- with:
- path: .build
- key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
- restore-keys: |
- ${{ runner.os }}-spm-
-
- - name: Install markdownlint-cli
- run: brew install markdownlint-cli
+ uses: actions/checkout@v4
- - name: Lint DocC files
- run: markdownlint **/*.docc/**/*.md
+ - name: Build
+ run: set -o pipefail && env NSUnbufferedIO=YES && xcodebuild build-for-testing -scheme PoliceDataKit -only-testing PoliceDataKitTests -destination '${{ matrix.destination }}' | xcpretty
+
+ - name: Test
+ run: set -o pipefail && env NSUnbufferedIO=YES && xcodebuild test-without-building -scheme PoliceDataKit -only-testing PoliceDataKitTests -destination '${{ matrix.destination }}' | xcpretty
+
+ build-test-linux:
+ name: Build and Test (Linux)
+ runs-on: ubuntu-latest
+ container: swift:5.9.2-jammy
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
- name: Build
- run: swift package generate-documentation --product PoliceDataKit
+ run: swift build -Xswiftc -warnings-as-errors --build-tests
+
+ - name: Test
+ run: swift test --skip-build --parallel --filter PoliceDataKitTests
+
+ - name: Build for Release
+ run: swift build -c release -Xswiftc -warnings-as-errors
diff --git a/.github/workflows/code-scan.yml b/.github/workflows/code-scan.yml
deleted file mode 100644
index b794d7c..0000000
--- a/.github/workflows/code-scan.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-name: Code Scan
-
-on:
- push:
- branches:
- - main
- pull_request:
- branches:
- - main
- schedule:
- # Every day at 12am
- - cron: '0 0 * * *'
- workflow_dispatch:
-
-concurrency:
- group: "code-scan-${{ github.head_ref || github.run_id }}"
- cancel-in-progress: true
-
-env:
- DEVELOPER_DIR: /Applications/Xcode_14.3.app/Contents/Developer
-
-jobs:
- codeScan:
- name: Code Scan
- runs-on: ubuntu-latest
- permissions:
- security-events: write
- steps:
- - name: Checkout
- uses: actions/checkout@v3
-
- - name: Scan
- uses: MobSF/mobsfscan@main
- with:
- args: '. --sarif --output results.sarif || true'
-
- - name: Upload report
- uses: github/codeql-action/upload-sarif@v2
- with:
- sarif_file: results.sarif
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
new file mode 100644
index 0000000..2430ce1
--- /dev/null
+++ b/.github/workflows/codeql.yml
@@ -0,0 +1,47 @@
+name: CodeQL
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+ branches:
+ - main
+ schedule:
+ # Every Sunday at 12am
+ - cron: '0 0 * * 0'
+ workflow_dispatch:
+
+concurrency:
+ group: "codeql-${{ github.head_ref || github.run_id }}"
+ cancel-in-progress: true
+
+env:
+ DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
+
+jobs:
+ analyze:
+ name: Analyze
+ runs-on: macos-14
+ timeout-minutes: 120
+ permissions:
+ actions: read
+ contents: read
+ security-events: write
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v3
+ with:
+ languages: swift
+ config-file: ./.github/codeql/codeql-config.yml
+
+ - name: Build
+ run: swift build --build-tests
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v3
+ with:
+ category: "/language:swift"
\ No newline at end of file
diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml
index 770b879..4df6bba 100644
--- a/.github/workflows/documentation.yml
+++ b/.github/workflows/documentation.yml
@@ -4,6 +4,10 @@ on:
push:
branches:
- main
+ paths:
+ - ".github/workflows/documentation.yml"
+ - "**/*.swift"
+ - "**/*.docc/**/*.md"
workflow_dispatch:
permissions:
@@ -12,33 +16,20 @@ permissions:
id-token: write
concurrency:
- group: "documentation"
- cancel-in-progress: false
-
-env:
- DEVELOPER_DIR: /Applications/Xcode_14.3.app/Contents/Developer
+ group: "deploy-documentation"
+ cancel-in-progress: true
jobs:
- deploy:
- name: Deploy Documentation
- environment:
- name: github-pages
- url: ${{ steps.deployment.outputs.page_url }}documentation/policedatakit
- runs-on: macos-13
+ build:
+ name: Build
+ runs-on: ubuntu-latest
+ container: swift:5.9.2-jammy
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Setup Pages
- uses: actions/configure-pages@v3
-
- - name: Cache SPM
- uses: actions/cache@v3
- with:
- path: .build
- key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
- restore-keys: |
- ${{ runner.os }}-spm-
+ uses: actions/configure-pages@v4
- name: Build documentation
run: |
@@ -48,12 +39,22 @@ jobs:
--transform-for-static-hosting \
--hosting-base-path police-data-kit \
--output-path docs
+ env:
+ SWIFTCI_DOCC: 1
- name: Upload documentation
- uses: actions/upload-pages-artifact@v1
+ uses: actions/upload-pages-artifact@v3
with:
path: 'docs'
-
+
+ deploy:
+ name: Deploy
+ runs-on: ubuntu-latest
+ needs: build
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}documentation/policedatakit
+ steps:
- name: Deploy to GitHub Pages
id: deployment
- uses: actions/deploy-pages@main
+ uses: actions/deploy-pages@v4
diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
index 8ba04cd..cb104fa 100644
--- a/.github/workflows/integration.yml
+++ b/.github/workflows/integration.yml
@@ -4,9 +4,15 @@ on:
pull_request:
branches:
- main
+ push:
+ branches:
+ - main
+ paths:
+ - ".github/workflows/integration.yml"
+ - "**/*.swift"
schedule:
- # Every day at 12am
- - cron: '0 0 * * *'
+ # Every Sunday at 12am
+ - cron: '0 0 * * 0'
workflow_dispatch:
concurrency:
@@ -14,23 +20,15 @@ concurrency:
cancel-in-progress: true
env:
- DEVELOPER_DIR: /Applications/Xcode_14.3.app/Contents/Developer
+ DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
jobs:
integration-test:
name: Integration Test
- runs-on: macos-13
+ runs-on: macos-14
steps:
- name: Checkout
- uses: actions/checkout@v3
-
- - name: Cache SPM
- uses: actions/cache@v3
- with:
- path: .build
- key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
- restore-keys: |
- ${{ runner.os }}-spm-
+ uses: actions/checkout@v4
- name: Build
run: swift build --build-tests
diff --git a/.github/workflows/lint-markdown.yml b/.github/workflows/lint-markdown.yml
new file mode 100644
index 0000000..4a1b0b6
--- /dev/null
+++ b/.github/workflows/lint-markdown.yml
@@ -0,0 +1,33 @@
+name: Lint Markdown
+
+on:
+ pull_request:
+ branches:
+ - main
+ push:
+ branches:
+ - main
+ paths:
+ - ".github/workflows/lint-markdown.yml"
+ - "**/*.swift"
+ workflow_dispatch:
+
+concurrency:
+ group: "lint-markdown-${{ github.head_ref || github.run_id }}"
+ cancel-in-progress: true
+
+jobs:
+ markdownlint:
+ name: Markdownlint
+ runs-on: ubuntu-latest
+ container:
+ image: docker://ghcr.io/igorshubovych/markdownlint-cli:latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Lint README
+ run: markdownlint "README.md"
+
+ - name: Lint DocC files
+ run: markdownlint "**/*.docc/**/*.md"
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
new file mode 100644
index 0000000..d3ed8ae
--- /dev/null
+++ b/.github/workflows/lint.yml
@@ -0,0 +1,42 @@
+name: Lint
+
+on:
+ pull_request:
+ branches:
+ - main
+ push:
+ branches:
+ - main
+ paths:
+ - ".github/workflows/lint.yml"
+ - "**/*.swift"
+ workflow_dispatch:
+
+concurrency:
+ group: "lint-${{ github.head_ref || github.run_id }}"
+ cancel-in-progress: true
+
+jobs:
+ swiftlint:
+ name: Swiftlint
+ runs-on: ubuntu-latest
+ container:
+ image: docker://ghcr.io/realm/swiftlint:latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Swiftlint
+ run: swiftlint --strict --reporter github-actions-logging
+
+ swiftformat:
+ name: SwiftFormat
+ runs-on: ubuntu-latest
+ container:
+ image: docker://ghcr.io/nicklockwood/swiftformat:latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: SwiftFormat
+ run: swiftformat --lint .
diff --git a/.swift-version b/.swift-version
new file mode 100644
index 0000000..b883184
--- /dev/null
+++ b/.swift-version
@@ -0,0 +1 @@
+5.9
\ No newline at end of file
diff --git a/.swiftformat b/.swiftformat
new file mode 100644
index 0000000..baf37db
--- /dev/null
+++ b/.swiftformat
@@ -0,0 +1,11 @@
+--typeblanklines preserve
+--indent 4
+--commas inline
+--self init-only
+--wraparguments before-first
+--xcodeindentation enabled
+
+--disable wrapMultilineStatementBraces
+--disable redundantLetError
+
+--header \n {file}\n PoliceDataKit\n\n Copyright © 2024 Adam Young.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an "AS IS" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..b1c5e1c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,97 @@
+TARGET = PoliceDataKit
+TEST_TARGET = PoliceDataKitTests
+INTEGRATION_TEST_TARGET = IntegrationTests
+
+IOS_DESTINATION = 'platform=iOS Simulator,name=iPhone 15,OS=17.2'
+WATCHOS_DESINTATION = 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.2'
+TVOS_DESTINATION = 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.2'
+
+SWIFT_CONTAINER_IMAGE = swift:5.9.2-jammy
+
+all: build
+
+.PHONY: clean
+clean:
+ swift package clean
+ rm -rf docs
+
+.PHONY: format
+format:
+ swiftlint --fix
+ swiftformat .
+
+.PHONY: lint
+lint:
+ swiftlint --strict
+ swiftformat --lint .
+
+.PHONY: lint-markdown
+lint-markdown:
+ markdownlint "README.md"
+ markdownlint "**/*.docc/**/*.md"
+
+.PHONY: build
+build:
+ swift build
+
+.PHONY: build-linux
+build-linux:
+ docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -Xswiftc -warnings-as-errors"
+
+.PHONY: build-release
+build-release:
+ swift build -c release -Xswiftc -warnings-as-errors
+
+.PHONY: build-linux-release
+build-linux-release:
+ docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -c release -Xswiftc -warnings-as-errors"
+
+.PHONY: build-docs
+build-docs:
+ SWIFTCI_DOCC=1 swift package generate-documentation --product $(TARGET)
+ swift package resolve
+
+.PHONY: preview-docs
+preview-docs:
+ SWIFTCI_DOCC=1 swift package --disable-sandbox preview-documentation --target $(TARGET)
+
+.PHONY: generate-docs
+generate-docs:
+ SWIFTCI_DOCC=1 swift package --allow-writing-to-directory docs \
+ generate-documentation --target $(TARGET) \
+ --disable-indexing \
+ --transform-for-static-hosting \
+ --hosting-base-path $(TARGET) \
+ --output-path docs
+
+.PHONY: test
+test:
+ swift build -Xswiftc -warnings-as-errors --build-tests
+ swift test --skip-build --filter $(TEST_TARGET)
+
+.PHONY: test-ios
+test-ios:
+ xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION)
+ xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION)
+
+.PHONY: test-watchos
+test-watchos:
+ xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION)
+ xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION)
+
+.PHONY: test-tvos
+test-tvos:
+ xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION)
+ xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION)
+
+.PHONY: test-linux
+test-linux:
+ docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -Xswiftc -warnings-as-errors --build-tests && swift test --skip-build --filter $(TEST_TARGET)"
+
+.PHONY: integration-test
+integration-test: .check-env-vars
+ swift build --build-tests
+ swift test --skip-build --filter $(INTEGRATION_TEST_TARGET)
+
+.PHONY: ci
+ci: lint lint-markdown test test-ios test-watchos test-tvos test-linux integration-test build-release build-docs
diff --git a/Package.resolved b/Package.resolved
deleted file mode 100644
index 690014a..0000000
--- a/Package.resolved
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "pins" : [
- {
- "identity" : "swift-docc-plugin",
- "kind" : "remoteSourceControl",
- "location" : "https://github.com/apple/swift-docc-plugin.git",
- "state" : {
- "revision" : "9b1258905c21fc1b97bf03d1b4ca12c4ec4e5fda",
- "version" : "1.2.0"
- }
- },
- {
- "identity" : "swift-docc-symbolkit",
- "kind" : "remoteSourceControl",
- "location" : "https://github.com/apple/swift-docc-symbolkit",
- "state" : {
- "revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
- "version" : "1.0.0"
- }
- }
- ],
- "version" : 2
-}
diff --git a/Package.swift b/Package.swift
index c960e59..435071e 100644
--- a/Package.swift
+++ b/Package.swift
@@ -1,6 +1,7 @@
-// swift-tools-version:5.7
+// swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
+import class Foundation.ProcessInfo
import PackageDescription
let package = Package(
@@ -22,10 +23,6 @@ let package = Package(
)
],
- dependencies: [
- .package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.2.0")
- ],
-
targets: [
.target(
name: "PoliceDataKit",
@@ -46,3 +43,9 @@ let package = Package(
)
]
)
+
+if ProcessInfo.processInfo.environment["SWIFTCI_DOCC"] == "1" {
+ package.dependencies += [
+ .package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.3.0")
+ ]
+}
diff --git a/Sources/PoliceDataKit/Availability/AvailabilityError.swift b/Sources/PoliceDataKit/Availability/AvailabilityError.swift
index 94af886..413673e 100644
--- a/Sources/PoliceDataKit/Availability/AvailabilityError.swift
+++ b/Sources/PoliceDataKit/Availability/AvailabilityError.swift
@@ -1,3 +1,22 @@
+//
+// AvailabilityError.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
@@ -13,34 +32,34 @@ public enum AvailabilityError: LocalizedError, Equatable {
}
-extension AvailabilityError {
+public extension AvailabilityError {
/// A localized message describing what error occurred.
- public var errorDescription: String? {
+ var errorDescription: String? {
switch self {
case .network:
- return NSLocalizedString("NETWORK_ERROR", bundle: .module, comment: "Network error")
+ NSLocalizedString("NETWORK_ERROR", bundle: .module, comment: "Network error")
case .unknown:
- return NSLocalizedString("UNKNOWN_ERROR", bundle: .module, comment: "Unknown error")
+ NSLocalizedString("UNKNOWN_ERROR", bundle: .module, comment: "Unknown error")
}
}
}
-extension AvailabilityError {
+public extension AvailabilityError {
/// Returns a Boolean value indicating whether two `AvailabilityError`s are equal.
- public static func == (lhs: AvailabilityError, rhs: AvailabilityError) -> Bool {
+ static func == (lhs: AvailabilityError, rhs: AvailabilityError) -> Bool {
switch (lhs, rhs) {
case (.network, .network):
- return true
+ true
case (.unknown, .unknown):
- return true
+ true
default:
- return false
+ false
}
}
diff --git a/Sources/PoliceDataKit/Availability/AvailabilityService.swift b/Sources/PoliceDataKit/Availability/AvailabilityService.swift
index 9cc4d7a..7f0191a 100644
--- a/Sources/PoliceDataKit/Availability/AvailabilityService.swift
+++ b/Sources/PoliceDataKit/Availability/AvailabilityService.swift
@@ -1,3 +1,22 @@
+//
+// AvailabilityService.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
import os
diff --git a/Sources/PoliceDataKit/Availability/Cache/AvailabilityDefaultCache.swift b/Sources/PoliceDataKit/Availability/Cache/AvailabilityDefaultCache.swift
index 5910711..d4a4816 100644
--- a/Sources/PoliceDataKit/Availability/Cache/AvailabilityDefaultCache.swift
+++ b/Sources/PoliceDataKit/Availability/Cache/AvailabilityDefaultCache.swift
@@ -1,3 +1,22 @@
+//
+// AvailabilityDefaultCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
final class AvailabilityDefaultCache: AvailabilityCache {
diff --git a/Sources/PoliceDataKit/Availability/Cache/CachingKeys/AvailableDataSetsCachingKey.swift b/Sources/PoliceDataKit/Availability/Cache/CachingKeys/AvailableDataSetsCachingKey.swift
index 64c944e..9ddb238 100644
--- a/Sources/PoliceDataKit/Availability/Cache/CachingKeys/AvailableDataSetsCachingKey.swift
+++ b/Sources/PoliceDataKit/Availability/Cache/CachingKeys/AvailableDataSetsCachingKey.swift
@@ -1,9 +1,28 @@
+//
+// AvailableDataSetsCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct AvailableDataSetsCachingKey: CachingKey {
let keyValue = "available-data-sets"
- init() { }
+ init() {}
}
diff --git a/Sources/PoliceDataKit/Availability/Endpoints/AvailabilityEndpoint.swift b/Sources/PoliceDataKit/Availability/Endpoints/AvailabilityEndpoint.swift
index 74dd80a..d086b1f 100644
--- a/Sources/PoliceDataKit/Availability/Endpoints/AvailabilityEndpoint.swift
+++ b/Sources/PoliceDataKit/Availability/Endpoints/AvailabilityEndpoint.swift
@@ -1,3 +1,22 @@
+//
+// AvailabilityEndpoint.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
enum AvailabilityEndpoint {
@@ -13,7 +32,7 @@ extension AvailabilityEndpoint: Endpoint {
var path: URL {
switch self {
case .dataSets:
- return Self.dataSetsBasePath
+ Self.dataSetsBasePath
}
}
diff --git a/Sources/PoliceDataKit/Availability/Models/DataSet.swift b/Sources/PoliceDataKit/Availability/Models/DataSet.swift
index 24272a4..12ba8eb 100644
--- a/Sources/PoliceDataKit/Availability/Models/DataSet.swift
+++ b/Sources/PoliceDataKit/Availability/Models/DataSet.swift
@@ -1,3 +1,22 @@
+//
+// DataSet.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/Availability/Protocols/AvailabilityCache.swift b/Sources/PoliceDataKit/Availability/Protocols/AvailabilityCache.swift
index 11b9ed4..8f7b606 100644
--- a/Sources/PoliceDataKit/Availability/Protocols/AvailabilityCache.swift
+++ b/Sources/PoliceDataKit/Availability/Protocols/AvailabilityCache.swift
@@ -1,3 +1,22 @@
+//
+// AvailabilityCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
protocol AvailabilityCache {
diff --git a/Sources/PoliceDataKit/Cache/CacheItem.swift b/Sources/PoliceDataKit/Cache/CacheItem.swift
index 682af3d..20b5f83 100644
--- a/Sources/PoliceDataKit/Cache/CacheItem.swift
+++ b/Sources/PoliceDataKit/Cache/CacheItem.swift
@@ -1,3 +1,22 @@
+//
+// CacheItem.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
final class CacheItem {
diff --git a/Sources/PoliceDataKit/Cache/InMemoryCache.swift b/Sources/PoliceDataKit/Cache/InMemoryCache.swift
index 12feea0..aa7a95c 100644
--- a/Sources/PoliceDataKit/Cache/InMemoryCache.swift
+++ b/Sources/PoliceDataKit/Cache/InMemoryCache.swift
@@ -1,3 +1,22 @@
+//
+// InMemoryCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
import os
@@ -9,13 +28,13 @@ final actor InMemoryCache: Cache {
init(name: String, defaultExpiresIn: TimeInterval = 60 * 60 * 12, countLimit: Int = 0) {
self.cache = NSCache()
- self.cache.name = name
- self.cache.countLimit = countLimit
+ cache.name = name
+ cache.countLimit = countLimit
self.defaultExpiresIn = defaultExpiresIn
self.logger = Logger(subsystem: Logger.policeDataKit, category: "\(name)InMemoryCache")
}
- func object(for key: some CustomStringConvertible, type: ObjectType.Type) async -> ObjectType? {
+ func object(for key: some CustomStringConvertible, type _: ObjectType.Type) async -> ObjectType? {
let cacheKey = keyValue(for: key)
guard let item = cache.object(forKey: cacheKey) else {
diff --git a/Sources/PoliceDataKit/Crimes/Cache/CachingKeys/CrimeCategoriesCachingKey.swift b/Sources/PoliceDataKit/Crimes/Cache/CachingKeys/CrimeCategoriesCachingKey.swift
index 2a8c92d..73a15e1 100644
--- a/Sources/PoliceDataKit/Crimes/Cache/CachingKeys/CrimeCategoriesCachingKey.swift
+++ b/Sources/PoliceDataKit/Crimes/Cache/CachingKeys/CrimeCategoriesCachingKey.swift
@@ -1,3 +1,22 @@
+//
+// CrimeCategoriesCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct CrimeCategoriesCachingKey: CachingKey {
diff --git a/Sources/PoliceDataKit/Crimes/Cache/CachingKeys/CrimesForStreetCachingKey.swift b/Sources/PoliceDataKit/Crimes/Cache/CachingKeys/CrimesForStreetCachingKey.swift
index 1f194be..7326dbe 100644
--- a/Sources/PoliceDataKit/Crimes/Cache/CachingKeys/CrimesForStreetCachingKey.swift
+++ b/Sources/PoliceDataKit/Crimes/Cache/CachingKeys/CrimesForStreetCachingKey.swift
@@ -1,3 +1,22 @@
+//
+// CrimesForStreetCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct CrimesForStreetCachingKey: CachingKey {
diff --git a/Sources/PoliceDataKit/Crimes/Cache/CachingKeys/CrimesWithNoLocationForCategoryInPoliceForceCachingKey.swift b/Sources/PoliceDataKit/Crimes/Cache/CachingKeys/CrimesWithNoLocationForCategoryInPoliceForceCachingKey.swift
index 3f2431e..d5049b0 100644
--- a/Sources/PoliceDataKit/Crimes/Cache/CachingKeys/CrimesWithNoLocationForCategoryInPoliceForceCachingKey.swift
+++ b/Sources/PoliceDataKit/Crimes/Cache/CachingKeys/CrimesWithNoLocationForCategoryInPoliceForceCachingKey.swift
@@ -1,3 +1,22 @@
+//
+// CrimesWithNoLocationForCategoryInPoliceForceCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct CrimesWithNoLocationForCategoryInPoliceForceCachingKey: CachingKey {
diff --git a/Sources/PoliceDataKit/Crimes/Cache/CrimeDefaultCache.swift b/Sources/PoliceDataKit/Crimes/Cache/CrimeDefaultCache.swift
index 135a522..144fbcc 100644
--- a/Sources/PoliceDataKit/Crimes/Cache/CrimeDefaultCache.swift
+++ b/Sources/PoliceDataKit/Crimes/Cache/CrimeDefaultCache.swift
@@ -1,3 +1,22 @@
+//
+// CrimeDefaultCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@@ -22,19 +41,32 @@ final actor CrimeDefaultCache: CrimeCache {
await cacheStore.set(crimes, for: cacheKey)
}
- func crimesWithNoLocation(forCategory categoryID: CrimeCategory.ID, inPoliceForce policeForceID: PoliceForce.ID,
- date: Date) async -> [Crime]? {
- let cacheKey = CrimesWithNoLocationForCategoryInPoliceForceCachingKey(categoryID: categoryID,
- policeForceID: policeForceID, date: date)
+ func crimesWithNoLocation(
+ forCategory categoryID: CrimeCategory.ID,
+ inPoliceForce policeForceID: PoliceForce.ID,
+ date: Date
+ ) async -> [Crime]? {
+ let cacheKey = CrimesWithNoLocationForCategoryInPoliceForceCachingKey(
+ categoryID: categoryID,
+ policeForceID: policeForceID,
+ date: date
+ )
let cachedCrimes = await cacheStore.object(for: cacheKey, type: [Crime].self)
return cachedCrimes
}
- func setCrimesWithNoLocation(_ crimes: [Crime], forCategory categoryID: CrimeCategory.ID,
- inPoliceForce policeForceID: PoliceForce.ID, date: Date) async {
- let cacheKey = CrimesWithNoLocationForCategoryInPoliceForceCachingKey(categoryID: categoryID,
- policeForceID: policeForceID, date: date)
+ func setCrimesWithNoLocation(
+ _ crimes: [Crime],
+ forCategory categoryID: CrimeCategory.ID,
+ inPoliceForce policeForceID: PoliceForce.ID,
+ date: Date
+ ) async {
+ let cacheKey = CrimesWithNoLocationForCategoryInPoliceForceCachingKey(
+ categoryID: categoryID,
+ policeForceID: policeForceID,
+ date: date
+ )
await cacheStore.set(crimes, for: cacheKey)
}
diff --git a/Sources/PoliceDataKit/Crimes/CrimeError.swift b/Sources/PoliceDataKit/Crimes/CrimeError.swift
index 0cfeb96..2b9f3f9 100644
--- a/Sources/PoliceDataKit/Crimes/CrimeError.swift
+++ b/Sources/PoliceDataKit/Crimes/CrimeError.swift
@@ -1,3 +1,22 @@
+//
+// CrimeError.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
@@ -19,47 +38,50 @@ public enum CrimeError: LocalizedError, Equatable {
}
-extension CrimeError {
+public extension CrimeError {
/// A localized message describing what error occurred.
- public var errorDescription: String? {
+ var errorDescription: String? {
switch self {
case .notFound:
- return NSLocalizedString("NOT_FOUND", bundle: .module, comment: "Not found error")
+ NSLocalizedString("NOT_FOUND", bundle: .module, comment: "Not found error")
case .locationOutsideOfDataSetRegion:
- return NSLocalizedString("LOCATION_OUTSIDE_OF_DATA_SET_REGION", bundle: .module,
- comment: "Location outside of data set region")
+ NSLocalizedString(
+ "LOCATION_OUTSIDE_OF_DATA_SET_REGION",
+ bundle: .module,
+ comment: "Location outside of data set region"
+ )
case .network:
- return NSLocalizedString("NETWORK_ERROR", bundle: .module, comment: "Network error")
+ NSLocalizedString("NETWORK_ERROR", bundle: .module, comment: "Network error")
case .unknown:
- return NSLocalizedString("UNKNOWN_ERROR", bundle: .module, comment: "Unknown error")
+ NSLocalizedString("UNKNOWN_ERROR", bundle: .module, comment: "Unknown error")
}
}
}
-extension CrimeError {
+public extension CrimeError {
/// Returns a Boolean value indicating whether two `CrimeError`s are equal.
- public static func == (lhs: CrimeError, rhs: CrimeError) -> Bool {
+ static func == (lhs: CrimeError, rhs: CrimeError) -> Bool {
switch (lhs, rhs) {
case (.notFound, .notFound):
- return true
+ true
case (.locationOutsideOfDataSetRegion, .locationOutsideOfDataSetRegion):
- return true
+ true
case (.network, .network):
- return true
+ true
case (.unknown, .unknown):
- return true
+ true
default:
- return false
+ false
}
}
diff --git a/Sources/PoliceDataKit/Crimes/CrimeService.swift b/Sources/PoliceDataKit/Crimes/CrimeService.swift
index 804bb86..9b9fd51 100644
--- a/Sources/PoliceDataKit/Crimes/CrimeService.swift
+++ b/Sources/PoliceDataKit/Crimes/CrimeService.swift
@@ -1,3 +1,22 @@
+//
+// CrimeService.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Combine
import Foundation
import MapKit
@@ -99,8 +118,10 @@ public final class CrimeService {
///
/// - Returns: The street level crimes in a 1 mile radius of the specifed coordinate and date.
///
- public func streetLevelCrimesPublisher(at coordinate: CLLocationCoordinate2D,
- date: Date = Date()) -> AnyPublisher<[Crime], CrimeError> {
+ public func streetLevelCrimesPublisher(
+ at coordinate: CLLocationCoordinate2D,
+ date: Date = Date()
+ ) -> AnyPublisher<[Crime], CrimeError> {
Future { [weak self] promise in
guard let self else {
promise(.failure(.unknown))
@@ -139,8 +160,10 @@ public final class CrimeService {
///
/// - Returns: The street level crimes with the specified area and month..
///
- public func streetLevelCrimes(in coordinates: [CLLocationCoordinate2D],
- date: Date = Date()) async throws -> [Crime] {
+ public func streetLevelCrimes(
+ in coordinates: [CLLocationCoordinate2D],
+ date: Date = Date()
+ ) async throws -> [Crime] {
Self.logger.trace("fetching street level Crimes in area")
let crimes: [Crime]
@@ -176,8 +199,10 @@ public final class CrimeService {
///
/// - Returns: The street level crimes with the specified area and month..
///
- public func streetLevelCrimesPublisher(in coordinates: [CLLocationCoordinate2D],
- date: Date = Date()) -> AnyPublisher<[Crime], CrimeError> {
+ public func streetLevelCrimesPublisher(
+ in coordinates: [CLLocationCoordinate2D],
+ date: Date = Date()
+ ) -> AnyPublisher<[Crime], CrimeError> {
Future { [weak self] promise in
guard let self else {
promise(.failure(.unknown))
@@ -211,7 +236,7 @@ public final class CrimeService {
/// - Throws: Crime data error ``CrimeError``.
///
/// - Returns: The crimes at the specified street and date.
- ///
+ ///
public func crimes(forStreet streetID: Int, date: Date = Date()) async throws -> [Crime] {
Self.logger.trace("fetching Crimes for street \(streetID, privacy: .public)")
@@ -286,8 +311,10 @@ public final class CrimeService {
///
/// - Returns: The crimes for the street nearest to the specified coordinate and date.
///
- public func crimesPublisher(at coordinate: CLLocationCoordinate2D,
- date: Date = Date()) -> AnyPublisher<[Crime], CrimeError> {
+ public func crimesPublisher(
+ at coordinate: CLLocationCoordinate2D,
+ date: Date = Date()
+ ) -> AnyPublisher<[Crime], CrimeError> {
Future { [weak self] promise in
guard let self else {
promise(.failure(.unknown))
@@ -321,14 +348,19 @@ public final class CrimeService {
///
/// - Returns: The crimes not mapped to a location.
///
- public func crimesWithNoLocation(forCategory categoryID: CrimeCategory.ID = CrimeCategory.default.id,
- inPoliceForce policeForceID: PoliceForce.ID,
- date: Date = Date()) async throws -> [Crime] {
+ public func crimesWithNoLocation(
+ forCategory categoryID: CrimeCategory.ID = CrimeCategory.default.id,
+ inPoliceForce policeForceID: PoliceForce.ID,
+ date: Date = Date()
+ ) async throws -> [Crime] {
// swiftlint:disable:next line_length
Self.logger.trace("fetching Crimes with no location for category \(categoryID, privacy: .public) in Police Force \(policeForceID, privacy: .public)")
- if let cachedCrimes = await cache.crimesWithNoLocation(forCategory: categoryID, inPoliceForce: policeForceID,
- date: date) {
+ if let cachedCrimes = await cache.crimesWithNoLocation(
+ forCategory: categoryID,
+ inPoliceForce: policeForceID,
+ date: date
+ ) {
return cachedCrimes
}
diff --git a/Sources/PoliceDataKit/Crimes/Endpoints/CrimesEndpoint.swift b/Sources/PoliceDataKit/Crimes/Endpoints/CrimesEndpoint.swift
index 4afd9ba..7737501 100644
--- a/Sources/PoliceDataKit/Crimes/Endpoints/CrimesEndpoint.swift
+++ b/Sources/PoliceDataKit/Crimes/Endpoints/CrimesEndpoint.swift
@@ -1,3 +1,22 @@
+//
+// CrimesEndpoint.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@@ -21,38 +40,38 @@ extension CrimesEndpoint: Endpoint {
var path: URL {
switch self {
- case .streetLevelCrimesAtSpecificPoint(let coordinate, let date):
- return Self.streetLevelCrimesAtLocationBasePath
+ case let .streetLevelCrimesAtSpecificPoint(coordinate, date):
+ Self.streetLevelCrimesAtLocationBasePath
.appendingPathComponent("all-crime")
.appendingQueryItem(name: "lat", value: coordinate.latitude)
.appendingQueryItem(name: "lng", value: coordinate.longitude)
.appendingQueryItem(name: "date", date: date)
- case .streetLevelCrimesInArea(let coordinates, let date):
- return Self.streetLevelCrimesAtLocationBasePath
+ case let .streetLevelCrimesInArea(coordinates, date):
+ Self.streetLevelCrimesAtLocationBasePath
.appendingPathComponent("all-crime")
.appendingQueryItem(name: "poly", coordinates: coordinates)
.appendingQueryItem(name: "date", date: date)
- case .crimesAtLocationForStreet(let streetID, let date):
- return Self.crimesAtLocationBasePath
+ case let .crimesAtLocationForStreet(streetID, date):
+ Self.crimesAtLocationBasePath
.appendingQueryItem(name: "location_id", value: streetID)
.appendingQueryItem(name: "date", date: date)
- case .crimesAtLocationAtSpecificPoint(let coordinate, let date):
- return Self.crimesAtLocationBasePath
+ case let .crimesAtLocationAtSpecificPoint(coordinate, date):
+ Self.crimesAtLocationBasePath
.appendingQueryItem(name: "lat", value: coordinate.latitude)
.appendingQueryItem(name: "lng", value: coordinate.longitude)
.appendingQueryItem(name: "date", date: date)
- case .crimesWithNoLocation(let categoryID, let policeForceID, let date):
- return Self.crimesWithNoLocationBasePath
+ case let .crimesWithNoLocation(categoryID, policeForceID, date):
+ Self.crimesWithNoLocationBasePath
.appendingQueryItem(name: "category", value: categoryID)
.appendingQueryItem(name: "force", value: policeForceID)
.appendingQueryItem(name: "date", date: date)
- case .categories(let date):
- return Self.crimeCategoriesBasePath
+ case let .categories(date):
+ Self.crimeCategoriesBasePath
.appendingQueryItem(name: "date", date: date)
}
}
diff --git a/Sources/PoliceDataKit/Crimes/Models/Crime.swift b/Sources/PoliceDataKit/Crimes/Models/Crime.swift
index 9ddef2a..3187f80 100644
--- a/Sources/PoliceDataKit/Crimes/Models/Crime.swift
+++ b/Sources/PoliceDataKit/Crimes/Models/Crime.swift
@@ -1,3 +1,22 @@
+//
+// Crime.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/Crimes/Models/CrimeCategory.swift b/Sources/PoliceDataKit/Crimes/Models/CrimeCategory.swift
index 26d0b7e..64a72f3 100644
--- a/Sources/PoliceDataKit/Crimes/Models/CrimeCategory.swift
+++ b/Sources/PoliceDataKit/Crimes/Models/CrimeCategory.swift
@@ -1,3 +1,22 @@
+//
+// CrimeCategory.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/Crimes/Models/CrimeLocationType.swift b/Sources/PoliceDataKit/Crimes/Models/CrimeLocationType.swift
index 987f995..314f556 100644
--- a/Sources/PoliceDataKit/Crimes/Models/CrimeLocationType.swift
+++ b/Sources/PoliceDataKit/Crimes/Models/CrimeLocationType.swift
@@ -1,3 +1,22 @@
+//
+// CrimeLocationType.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
@@ -17,10 +36,10 @@ public enum CrimeLocationType: String, Equatable, CaseIterable, CustomStringConv
public var description: String {
switch self {
case .force:
- return NSLocalizedString("POLICE_FORCE", bundle: .module, comment: "Police Force")
+ NSLocalizedString("POLICE_FORCE", bundle: .module, comment: "Police Force")
case .britishTransportPolice:
- return NSLocalizedString("BRITISH_TRANSPORT_POLICE", bundle: .module, comment: "British Transport Police")
+ NSLocalizedString("BRITISH_TRANSPORT_POLICE", bundle: .module, comment: "British Transport Police")
}
}
diff --git a/Sources/PoliceDataKit/Crimes/Protocols/CrimeCache.swift b/Sources/PoliceDataKit/Crimes/Protocols/CrimeCache.swift
index a24ba67..06ad908 100644
--- a/Sources/PoliceDataKit/Crimes/Protocols/CrimeCache.swift
+++ b/Sources/PoliceDataKit/Crimes/Protocols/CrimeCache.swift
@@ -1,3 +1,22 @@
+//
+// CrimeCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@@ -7,11 +26,18 @@ protocol CrimeCache {
func setCrimes(_ crimes: [Crime], forStreet streetID: Int, date: Date) async
- func crimesWithNoLocation(forCategory categoryID: CrimeCategory.ID, inPoliceForce policeForceID: PoliceForce.ID,
- date: Date) async -> [Crime]?
-
- func setCrimesWithNoLocation(_ crimes: [Crime], forCategory categoryID: CrimeCategory.ID,
- inPoliceForce policeForceID: PoliceForce.ID, date: Date) async
+ func crimesWithNoLocation(
+ forCategory categoryID: CrimeCategory.ID,
+ inPoliceForce policeForceID: PoliceForce.ID,
+ date: Date
+ ) async -> [Crime]?
+
+ func setCrimesWithNoLocation(
+ _ crimes: [Crime],
+ forCategory categoryID: CrimeCategory.ID,
+ inPoliceForce policeForceID: PoliceForce.ID,
+ date: Date
+ ) async
func crimeCategories(forDate date: Date) async -> [CrimeCategory]?
diff --git a/Sources/PoliceDataKit/Extensions/DateFormatter+PoliceDataAPI.swift b/Sources/PoliceDataKit/Extensions/DateFormatter+PoliceDataAPI.swift
index 255947c..8cd5e6c 100644
--- a/Sources/PoliceDataKit/Extensions/DateFormatter+PoliceDataAPI.swift
+++ b/Sources/PoliceDataKit/Extensions/DateFormatter+PoliceDataAPI.swift
@@ -1,3 +1,22 @@
+//
+// DateFormatter+PoliceDataAPI.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
extension DateFormatter {
diff --git a/Sources/PoliceDataKit/Extensions/JSONDecoder+PoliceDataAPI.swift b/Sources/PoliceDataKit/Extensions/JSONDecoder+PoliceDataAPI.swift
index 250136b..9936fa7 100644
--- a/Sources/PoliceDataKit/Extensions/JSONDecoder+PoliceDataAPI.swift
+++ b/Sources/PoliceDataKit/Extensions/JSONDecoder+PoliceDataAPI.swift
@@ -1,3 +1,22 @@
+//
+// JSONDecoder+PoliceDataAPI.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
extension JSONDecoder {
diff --git a/Sources/PoliceDataKit/Extensions/JSONDecoderDateDecodingStrategy+PoliceDataAPI.swift b/Sources/PoliceDataKit/Extensions/JSONDecoderDateDecodingStrategy+PoliceDataAPI.swift
index 7ae5c20..d811f8e 100644
--- a/Sources/PoliceDataKit/Extensions/JSONDecoderDateDecodingStrategy+PoliceDataAPI.swift
+++ b/Sources/PoliceDataKit/Extensions/JSONDecoderDateDecodingStrategy+PoliceDataAPI.swift
@@ -1,3 +1,22 @@
+//
+// JSONDecoderDateDecodingStrategy+PoliceDataAPI.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
extension JSONDecoder.DateDecodingStrategy {
diff --git a/Sources/PoliceDataKit/Extensions/String+HTML.swift b/Sources/PoliceDataKit/Extensions/String+HTML.swift
index af8d5c3..8fcd60d 100644
--- a/Sources/PoliceDataKit/Extensions/String+HTML.swift
+++ b/Sources/PoliceDataKit/Extensions/String+HTML.swift
@@ -1,3 +1,22 @@
+//
+// String+HTML.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
extension String {
diff --git a/Sources/PoliceDataKit/Extensions/URL+QueryItem.swift b/Sources/PoliceDataKit/Extensions/URL+QueryItem.swift
index 82b060f..1191a64 100644
--- a/Sources/PoliceDataKit/Extensions/URL+QueryItem.swift
+++ b/Sources/PoliceDataKit/Extensions/URL+QueryItem.swift
@@ -1,3 +1,22 @@
+//
+// URL+QueryItem.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@@ -12,7 +31,7 @@ extension URL {
}
func appendingQueryItem(name: String, date: Date?, formatter: DateFormatter = .yearMonth) -> Self {
- guard let date = date else {
+ guard let date else {
return self
}
diff --git a/Sources/PoliceDataKit/General/Models/CLLocationCoordinate2D+Codable.swift b/Sources/PoliceDataKit/General/Models/CLLocationCoordinate2D+Codable.swift
index dcf6683..3097d06 100644
--- a/Sources/PoliceDataKit/General/Models/CLLocationCoordinate2D+Codable.swift
+++ b/Sources/PoliceDataKit/General/Models/CLLocationCoordinate2D+Codable.swift
@@ -1,3 +1,22 @@
+//
+// CLLocationCoordinate2D+Codable.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
diff --git a/Sources/PoliceDataKit/General/Models/CLLocationCoordinate2D+CustomStringConvertible.swift b/Sources/PoliceDataKit/General/Models/CLLocationCoordinate2D+CustomStringConvertible.swift
index a1b9187..29bd2a5 100644
--- a/Sources/PoliceDataKit/General/Models/CLLocationCoordinate2D+CustomStringConvertible.swift
+++ b/Sources/PoliceDataKit/General/Models/CLLocationCoordinate2D+CustomStringConvertible.swift
@@ -1,3 +1,22 @@
+//
+// CLLocationCoordinate2D+CustomStringConvertible.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
diff --git a/Sources/PoliceDataKit/General/Models/CLLocationCoordinate2D+Equatable.swift b/Sources/PoliceDataKit/General/Models/CLLocationCoordinate2D+Equatable.swift
index abe3105..c27e63b 100644
--- a/Sources/PoliceDataKit/General/Models/CLLocationCoordinate2D+Equatable.swift
+++ b/Sources/PoliceDataKit/General/Models/CLLocationCoordinate2D+Equatable.swift
@@ -1,3 +1,22 @@
+//
+// CLLocationCoordinate2D+Equatable.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
diff --git a/Sources/PoliceDataKit/General/Models/ContactDetails.swift b/Sources/PoliceDataKit/General/Models/ContactDetails.swift
index 3784511..3080f53 100644
--- a/Sources/PoliceDataKit/General/Models/ContactDetails.swift
+++ b/Sources/PoliceDataKit/General/Models/ContactDetails.swift
@@ -1,3 +1,22 @@
+//
+// ContactDetails.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/General/Models/Location.swift b/Sources/PoliceDataKit/General/Models/Location.swift
index 3d2bdd9..1f588ad 100644
--- a/Sources/PoliceDataKit/General/Models/Location.swift
+++ b/Sources/PoliceDataKit/General/Models/Location.swift
@@ -1,3 +1,22 @@
+//
+// Location.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@@ -28,7 +47,7 @@ public struct Location: Equatable, Codable {
}
-extension Location {
+public extension Location {
private enum CodingKeys: String, CodingKey {
case latitude
@@ -36,7 +55,7 @@ extension Location {
case street
}
- public init(from decoder: Decoder) throws {
+ init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let latitudeString = try container.decodeIfPresent(String.self, forKey: .latitude)
@@ -57,7 +76,7 @@ extension Location {
self.street = try container.decode(Street.self, forKey: .street)
}
- public func encode(to encoder: Encoder) throws {
+ func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
let latitudeString: String? = {
guard let coordinate else {
diff --git a/Sources/PoliceDataKit/General/Models/MKCoordinateRegion+ContainsCLLocationCoordinate2D.swift b/Sources/PoliceDataKit/General/Models/MKCoordinateRegion+ContainsCLLocationCoordinate2D.swift
index 4dbd962..a37eba3 100644
--- a/Sources/PoliceDataKit/General/Models/MKCoordinateRegion+ContainsCLLocationCoordinate2D.swift
+++ b/Sources/PoliceDataKit/General/Models/MKCoordinateRegion+ContainsCLLocationCoordinate2D.swift
@@ -1,11 +1,30 @@
+//
+// MKCoordinateRegion+ContainsCLLocationCoordinate2D.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
import MapKit
-extension MKCoordinateRegion {
+public extension MKCoordinateRegion {
- public func contains(coordinate: CLLocationCoordinate2D) -> Bool {
- let northWestCoordinate = self.northWestCoordinate
- let southEastRightCoordinate = self.southEastRightCoordinate
+ func contains(coordinate: CLLocationCoordinate2D) -> Bool {
+ let northWestCoordinate = northWestCoordinate
+ let southEastRightCoordinate = southEastRightCoordinate
return coordinate.latitude >= northWestCoordinate.latitude
&& coordinate.longitude >= northWestCoordinate.longitude
diff --git a/Sources/PoliceDataKit/General/Models/MKCoordinateRegion+Regions.swift b/Sources/PoliceDataKit/General/Models/MKCoordinateRegion+Regions.swift
index 95496b7..6a82c7f 100644
--- a/Sources/PoliceDataKit/General/Models/MKCoordinateRegion+Regions.swift
+++ b/Sources/PoliceDataKit/General/Models/MKCoordinateRegion+Regions.swift
@@ -1,3 +1,22 @@
+//
+// MKCoordinateRegion+Regions.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
import MapKit
diff --git a/Sources/PoliceDataKit/General/Models/PoliceOfficer.swift b/Sources/PoliceDataKit/General/Models/PoliceOfficer.swift
index 67947b2..0923ebf 100644
--- a/Sources/PoliceDataKit/General/Models/PoliceOfficer.swift
+++ b/Sources/PoliceDataKit/General/Models/PoliceOfficer.swift
@@ -1,3 +1,22 @@
+//
+// PoliceOfficer.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/General/Models/Street.swift b/Sources/PoliceDataKit/General/Models/Street.swift
index b2f8086..450edc4 100644
--- a/Sources/PoliceDataKit/General/Models/Street.swift
+++ b/Sources/PoliceDataKit/General/Models/Street.swift
@@ -1,3 +1,22 @@
+//
+// Street.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/General/Protocols/APIClient.swift b/Sources/PoliceDataKit/General/Protocols/APIClient.swift
index d0b154a..0fff731 100644
--- a/Sources/PoliceDataKit/General/Protocols/APIClient.swift
+++ b/Sources/PoliceDataKit/General/Protocols/APIClient.swift
@@ -1,3 +1,22 @@
+//
+// APIClient.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
protocol APIClient {
diff --git a/Sources/PoliceDataKit/General/Protocols/Cache.swift b/Sources/PoliceDataKit/General/Protocols/Cache.swift
index 39f92e4..8f469f2 100644
--- a/Sources/PoliceDataKit/General/Protocols/Cache.swift
+++ b/Sources/PoliceDataKit/General/Protocols/Cache.swift
@@ -1,3 +1,22 @@
+//
+// Cache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
protocol Cache {
diff --git a/Sources/PoliceDataKit/General/Protocols/CachingKey.swift b/Sources/PoliceDataKit/General/Protocols/CachingKey.swift
index 5a026c5..927c425 100644
--- a/Sources/PoliceDataKit/General/Protocols/CachingKey.swift
+++ b/Sources/PoliceDataKit/General/Protocols/CachingKey.swift
@@ -1,3 +1,22 @@
+//
+// CachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
protocol CachingKey: CustomStringConvertible {
diff --git a/Sources/PoliceDataKit/General/Protocols/Endpoint.swift b/Sources/PoliceDataKit/General/Protocols/Endpoint.swift
index 6c8649b..096d850 100644
--- a/Sources/PoliceDataKit/General/Protocols/Endpoint.swift
+++ b/Sources/PoliceDataKit/General/Protocols/Endpoint.swift
@@ -1,3 +1,22 @@
+//
+// Endpoint.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
protocol Endpoint {
diff --git a/Sources/PoliceDataKit/Logger+PoliceDataKit.swift b/Sources/PoliceDataKit/Logger+PoliceDataKit.swift
index 48cbca4..ea11151 100644
--- a/Sources/PoliceDataKit/Logger+PoliceDataKit.swift
+++ b/Sources/PoliceDataKit/Logger+PoliceDataKit.swift
@@ -1,3 +1,22 @@
+//
+// Logger+PoliceDataKit.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
import os
diff --git a/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodBoundaryCachingKey.swift b/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodBoundaryCachingKey.swift
index 63c587a..25a477d 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodBoundaryCachingKey.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodBoundaryCachingKey.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodBoundaryCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct NeighbourhoodBoundaryCachingKey: CachingKey {
diff --git a/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodCachingKey.swift b/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodCachingKey.swift
index 2121c67..2db0eca 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodCachingKey.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodCachingKey.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct NeighbourhoodCachingKey: CachingKey {
diff --git a/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPoliceOfficersCachingKey.swift b/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPoliceOfficersCachingKey.swift
index 507b1c2..86749da 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPoliceOfficersCachingKey.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPoliceOfficersCachingKey.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodPoliceOfficersCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct NeighbourhoodPoliceOfficersCachingKey: CachingKey {
diff --git a/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPrioritiesCachingKey.swift b/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPrioritiesCachingKey.swift
index 3d53a6f..80d69a6 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPrioritiesCachingKey.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPrioritiesCachingKey.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodPrioritiesCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct NeighbourhoodPrioritiesCachingKey: CachingKey {
diff --git a/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodsInPoliceForceCachingKey.swift b/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodsInPoliceForceCachingKey.swift
index 8ac1b8b..4624366 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodsInPoliceForceCachingKey.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/Cache/CachingKeys/NeighbourhoodsInPoliceForceCachingKey.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodsInPoliceForceCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct NeighbourhoodsInPoliceForceCachingKey: CachingKey {
diff --git a/Sources/PoliceDataKit/Neighbourhoods/Cache/NeighbourhoodDefaultCache.swift b/Sources/PoliceDataKit/Neighbourhoods/Cache/NeighbourhoodDefaultCache.swift
index 4dee95e..39d73a6 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/Cache/NeighbourhoodDefaultCache.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/Cache/NeighbourhoodDefaultCache.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodDefaultCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@@ -16,8 +35,10 @@ final class NeighbourhoodDefaultCache: NeighbourhoodCache {
return cachedNeighbourhoods
}
- func setNeighbourhoods(_ neighbourhoods: [NeighbourhoodReference],
- inPoliceForce policeForceID: PoliceForce.ID) async {
+ func setNeighbourhoods(
+ _ neighbourhoods: [NeighbourhoodReference],
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async {
let cacheKey = NeighbourhoodsInPoliceForceCachingKey(policeForceID: policeForceID)
await cacheStore.set(neighbourhoods, for: cacheKey)
@@ -30,55 +51,77 @@ final class NeighbourhoodDefaultCache: NeighbourhoodCache {
return cachedNeighbourhood
}
- func setNeighbourhood(_ neighbourhood: Neighbourhood, withID id: String,
- inPoliceForce policeForceID: PoliceForce.ID) async {
+ func setNeighbourhood(
+ _ neighbourhood: Neighbourhood,
+ withID id: String,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async {
let cacheKey = NeighbourhoodCachingKey(id: id, policeForceID: policeForceID)
await cacheStore.set(neighbourhood, for: cacheKey)
}
- func boundary(forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async -> [CLLocationCoordinate2D]? {
+ func boundary(
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async -> [CLLocationCoordinate2D]? {
let cacheKey = NeighbourhoodBoundaryCachingKey(neighbourhoodID: neighbourhoodID, policeForceID: policeForceID)
let cachedBoundary = await cacheStore.object(for: cacheKey, type: [CLLocationCoordinate2D].self)
return cachedBoundary
}
- func setBoundary(_ coordinates: [CLLocationCoordinate2D], forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async {
+ func setBoundary(
+ _ coordinates: [CLLocationCoordinate2D],
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async {
let cacheKey = NeighbourhoodBoundaryCachingKey(neighbourhoodID: neighbourhoodID, policeForceID: policeForceID)
await cacheStore.set(coordinates, for: cacheKey)
}
- func policeOfficers(forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async -> [PoliceOfficer]? {
- let cacheKey = NeighbourhoodPoliceOfficersCachingKey(neighbourhoodID: neighbourhoodID,
- policeForceID: policeForceID)
+ func policeOfficers(
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async -> [PoliceOfficer]? {
+ let cacheKey = NeighbourhoodPoliceOfficersCachingKey(
+ neighbourhoodID: neighbourhoodID,
+ policeForceID: policeForceID
+ )
let cachedPoliceOfficers = await cacheStore.object(for: cacheKey, type: [PoliceOfficer].self)
return cachedPoliceOfficers
}
- func setPoliceOfficers(_ policeOfficers: [PoliceOfficer], forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async {
- let cacheKey = NeighbourhoodPoliceOfficersCachingKey(neighbourhoodID: neighbourhoodID,
- policeForceID: policeForceID)
+ func setPoliceOfficers(
+ _ policeOfficers: [PoliceOfficer],
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async {
+ let cacheKey = NeighbourhoodPoliceOfficersCachingKey(
+ neighbourhoodID: neighbourhoodID,
+ policeForceID: policeForceID
+ )
await cacheStore.set(policeOfficers, for: cacheKey)
}
- func priorities(forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async -> [NeighbourhoodPriority]? {
+ func priorities(
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async -> [NeighbourhoodPriority]? {
let cacheKey = NeighbourhoodPrioritiesCachingKey(neighbourhoodID: neighbourhoodID, policeForceID: policeForceID)
let cachedPriorities = await cacheStore.object(for: cacheKey, type: [NeighbourhoodPriority].self)
return cachedPriorities
}
- func setPriorities(_ priorities: [NeighbourhoodPriority], forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async {
+ func setPriorities(
+ _ priorities: [NeighbourhoodPriority],
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async {
let cacheKey = NeighbourhoodPrioritiesCachingKey(neighbourhoodID: neighbourhoodID, policeForceID: policeForceID)
await cacheStore.set(priorities, for: cacheKey)
diff --git a/Sources/PoliceDataKit/Neighbourhoods/Endpoints/NeighbourhoodsEndpoint.swift b/Sources/PoliceDataKit/Neighbourhoods/Endpoints/NeighbourhoodsEndpoint.swift
index c00bef7..ec5e8f0 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/Endpoints/NeighbourhoodsEndpoint.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/Endpoints/NeighbourhoodsEndpoint.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodsEndpoint.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@@ -18,36 +37,36 @@ extension NeighbourhoodsEndpoint: Endpoint {
var path: URL {
switch self {
- case .list(let policeForceID):
- return Self.basePath
+ case let .list(policeForceID):
+ Self.basePath
.appendingPathComponent(policeForceID)
.appendingPathComponent("neighbourhoods")
- case .details(let id, let policeForceID):
- return Self.basePath
+ case let .details(id, policeForceID):
+ Self.basePath
.appendingPathComponent(policeForceID)
.appendingPathComponent(id)
- case .boundary(let neighbourhoodID, let policeForceID):
- return Self.basePath
+ case let .boundary(neighbourhoodID, policeForceID):
+ Self.basePath
.appendingPathComponent(policeForceID)
.appendingPathComponent(neighbourhoodID)
.appendingPathComponent("boundary")
- case .policeOfficers(let neighbourhoodID, let policeForceID):
- return Self.basePath
+ case let .policeOfficers(neighbourhoodID, policeForceID):
+ Self.basePath
.appendingPathComponent(policeForceID)
.appendingPathComponent(neighbourhoodID)
.appendingPathComponent("people")
- case .priorities(let neighbourhoodID, let policeForceID):
- return Self.basePath
+ case let .priorities(neighbourhoodID, policeForceID):
+ Self.basePath
.appendingPathComponent(policeForceID)
.appendingPathComponent(neighbourhoodID)
.appendingPathComponent("priorities")
- case .locateNeighbourhood(let coordinate):
- return Self.basePath
+ case let .locateNeighbourhood(coordinate):
+ Self.basePath
.appendingPathComponent("locate-neighbourhood")
.appendingQueryItem(name: "q", coordinate: coordinate)
}
diff --git a/Sources/PoliceDataKit/Neighbourhoods/Models/Link.swift b/Sources/PoliceDataKit/Neighbourhoods/Models/Link.swift
index 4154ea7..7bbb9a1 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/Models/Link.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/Models/Link.swift
@@ -1,3 +1,22 @@
+//
+// Link.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/Neighbourhoods/Models/Neighbourhood.swift b/Sources/PoliceDataKit/Neighbourhoods/Models/Neighbourhood.swift
index dd75e13..8830e6a 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/Models/Neighbourhood.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/Models/Neighbourhood.swift
@@ -1,3 +1,22 @@
+//
+// Neighbourhood.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@@ -81,7 +100,7 @@ public struct Neighbourhood: Identifiable, Equatable, Codable {
}
-extension Neighbourhood {
+public extension Neighbourhood {
private enum CodingKeys: String, CodingKey {
case id
@@ -96,7 +115,7 @@ extension Neighbourhood {
case links
}
- public init(from decoder: Decoder) throws {
+ init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.id = try container.decode(String.self, forKey: .id)
self.name = try container.decode(String.self, forKey: .name).htmlStripped
@@ -124,7 +143,7 @@ extension Neighbourhood {
self.links = try container.decode([Link].self, forKey: .links)
}
- public func encode(to encoder: Encoder) throws {
+ func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
diff --git a/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodLocation.swift b/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodLocation.swift
index 3e193c7..95c5760 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodLocation.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodLocation.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodLocation.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@@ -55,7 +74,7 @@ public struct NeighbourhoodLocation: Equatable, Codable {
}
-extension NeighbourhoodLocation {
+public extension NeighbourhoodLocation {
private enum CodingKeys: String, CodingKey {
case name
@@ -67,7 +86,7 @@ extension NeighbourhoodLocation {
case longitude
}
- public init(from decoder: Decoder) throws {
+ init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.name = try container.decodeIfPresent(String.self, forKey: .name)
self.type = try container.decodeIfPresent(String.self, forKey: .type)
@@ -90,7 +109,7 @@ extension NeighbourhoodLocation {
}()
}
- public func encode(to encoder: Encoder) throws {
+ func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(name, forKey: .name)
try container.encodeIfPresent(type, forKey: .type)
diff --git a/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodPolicingTeam.swift b/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodPolicingTeam.swift
index 9720788..fef4ba8 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodPolicingTeam.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodPolicingTeam.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodPolicingTeam.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodPriority.swift b/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodPriority.swift
index 2ed2e52..09112aa 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodPriority.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodPriority.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodPriority.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodReference.swift b/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodReference.swift
index 2850de6..7645f0e 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodReference.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/Models/NeighbourhoodReference.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodReference.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/Neighbourhoods/NeighbourhoodError.swift b/Sources/PoliceDataKit/Neighbourhoods/NeighbourhoodError.swift
index 824ccf4..85b328b 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/NeighbourhoodError.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/NeighbourhoodError.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodError.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
@@ -19,47 +38,50 @@ public enum NeighbourhoodError: LocalizedError, Equatable {
}
-extension NeighbourhoodError {
+public extension NeighbourhoodError {
/// A localized message describing what error occurred.
- public var errorDescription: String? {
+ var errorDescription: String? {
switch self {
case .notFound:
- return NSLocalizedString("NOT_FOUND", bundle: .module, comment: "Not found error")
+ NSLocalizedString("NOT_FOUND", bundle: .module, comment: "Not found error")
case .locationOutsideOfDataSetRegion:
- return NSLocalizedString("LOCATION_OUTSIDE_OF_DATA_SET_REGION", bundle: .module,
- comment: "Location outside of data set region")
+ NSLocalizedString(
+ "LOCATION_OUTSIDE_OF_DATA_SET_REGION",
+ bundle: .module,
+ comment: "Location outside of data set region"
+ )
case .network:
- return NSLocalizedString("NETWORK_ERROR", bundle: .module, comment: "Network error")
+ NSLocalizedString("NETWORK_ERROR", bundle: .module, comment: "Network error")
case .unknown:
- return NSLocalizedString("UNKNOWN_ERROR", bundle: .module, comment: "Unknown error")
+ NSLocalizedString("UNKNOWN_ERROR", bundle: .module, comment: "Unknown error")
}
}
}
-extension NeighbourhoodError {
+public extension NeighbourhoodError {
/// Returns a Boolean value indicating whether two `NeighbourhoodError`s are equal.
- public static func == (lhs: NeighbourhoodError, rhs: NeighbourhoodError) -> Bool {
+ static func == (lhs: NeighbourhoodError, rhs: NeighbourhoodError) -> Bool {
switch (lhs, rhs) {
case (.notFound, .notFound):
- return true
+ true
case (.locationOutsideOfDataSetRegion, .locationOutsideOfDataSetRegion):
- return true
+ true
case (.network, .network):
- return true
+ true
case (.unknown, .unknown):
- return true
+ true
default:
- return false
+ false
}
}
diff --git a/Sources/PoliceDataKit/Neighbourhoods/NeighbourhoodService.swift b/Sources/PoliceDataKit/Neighbourhoods/NeighbourhoodService.swift
index cb03671..f186fe4 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/NeighbourhoodService.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/NeighbourhoodService.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodService.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Combine
import Foundation
import MapKit
@@ -89,8 +108,10 @@ public final class NeighbourhoodService {
///
/// - Returns: The neighbourhood matching the specified ID and police force.
///
- public func neighbourhood(withID id: String,
- inPoliceForce policeForceID: PoliceForce.ID) async throws -> Neighbourhood {
+ public func neighbourhood(
+ withID id: String,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async throws -> Neighbourhood {
// swiftlint:disable:next line_length
Self.logger.trace("fetching Neighbourhood \(id, privacy: .public) in Police Force \(policeForceID, privacy: .public)")
@@ -179,8 +200,10 @@ public final class NeighbourhoodService {
///
/// - Returns: The coordinates that make up the boundary of the matching neighbourhood.
///
- public func boundary(forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async throws -> [CLLocationCoordinate2D] {
+ public func boundary(
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async throws -> [CLLocationCoordinate2D] {
// swiftlint:disable:next line_length
Self.logger.trace("fetching Boundary for Neighbourhood \(neighbourhoodID, privacy: .public) in Police Force \(policeForceID, privacy: .public)")
@@ -219,13 +242,17 @@ public final class NeighbourhoodService {
///
/// - Returns: Police officers who are members of the neighbourhood team for the specified neighbourhood and police force.
///
- public func policeOfficers(forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async throws -> [PoliceOfficer] {
+ public func policeOfficers(
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async throws -> [PoliceOfficer] {
// swiftlint:disable:next line_length
Self.logger.trace("fetching Police Officers for Neighbourhood \(neighbourhoodID, privacy: .public) in Police Force \(policeForceID, privacy: .public)")
- if let cachedPoliceOfficers = await cache.policeOfficers(forNeighbourhood: neighbourhoodID,
- inPoliceForce: policeForceID) {
+ if let cachedPoliceOfficers = await cache.policeOfficers(
+ forNeighbourhood: neighbourhoodID,
+ inPoliceForce: policeForceID
+ ) {
return cachedPoliceOfficers
}
@@ -259,14 +286,18 @@ public final class NeighbourhoodService {
/// - Throws: Neighbourhood data error ``NeighbourhoodError``.
///
/// - Returns: The neighbourhood priorities for the specified neighbourhood and police force.
- ///
- public func priorities(forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async throws -> [NeighbourhoodPriority] {
+ ///
+ public func priorities(
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async throws -> [NeighbourhoodPriority] {
// swiftlint:disable:next line_length
Self.logger.trace("fetching Priorities for Neighbourhood \(neighbourhoodID, privacy: .public) in Police Force \(policeForceID, privacy: .public)")
- if let cachedPriorities = await cache.priorities(forNeighbourhood: neighbourhoodID,
- inPoliceForce: policeForceID) {
+ if let cachedPriorities = await cache.priorities(
+ forNeighbourhood: neighbourhoodID,
+ inPoliceForce: policeForceID
+ ) {
return cachedPriorities
}
diff --git a/Sources/PoliceDataKit/Neighbourhoods/Protocols/NeighbourhoodCache.swift b/Sources/PoliceDataKit/Neighbourhoods/Protocols/NeighbourhoodCache.swift
index 62c942a..ba9b2c9 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/Protocols/NeighbourhoodCache.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/Protocols/NeighbourhoodCache.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@@ -5,30 +24,50 @@ protocol NeighbourhoodCache {
func neighbourhoods(inPoliceForce policeForceID: PoliceForce.ID) async -> [NeighbourhoodReference]?
- func setNeighbourhoods(_ neighbourhoods: [NeighbourhoodReference],
- inPoliceForce policeForceID: PoliceForce.ID) async
+ func setNeighbourhoods(
+ _ neighbourhoods: [NeighbourhoodReference],
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async
func neighbourhood(withID id: String, inPoliceForce policeForceID: PoliceForce.ID) async -> Neighbourhood?
- func setNeighbourhood(_ neighbourhood: Neighbourhood, withID id: String,
- inPoliceForce policeForceID: PoliceForce.ID) async
+ func setNeighbourhood(
+ _ neighbourhood: Neighbourhood,
+ withID id: String,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async
- func boundary(forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async -> [CLLocationCoordinate2D]?
+ func boundary(
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async -> [CLLocationCoordinate2D]?
- func setBoundary(_ coordinates: [CLLocationCoordinate2D], forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async
+ func setBoundary(
+ _ coordinates: [CLLocationCoordinate2D],
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async
- func policeOfficers(forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async -> [PoliceOfficer]?
+ func policeOfficers(
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async -> [PoliceOfficer]?
- func setPoliceOfficers(_ policeOfficers: [PoliceOfficer], forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async
+ func setPoliceOfficers(
+ _ policeOfficers: [PoliceOfficer],
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async
- func priorities(forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async -> [NeighbourhoodPriority]?
+ func priorities(
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async -> [NeighbourhoodPriority]?
- func setPriorities(_ priorities: [NeighbourhoodPriority], forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async
+ func setPriorities(
+ _ priorities: [NeighbourhoodPriority],
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async
}
diff --git a/Sources/PoliceDataKit/Networking/JSONSerialiser.swift b/Sources/PoliceDataKit/Networking/JSONSerialiser.swift
index 2031b8c..fc04639 100644
--- a/Sources/PoliceDataKit/Networking/JSONSerialiser.swift
+++ b/Sources/PoliceDataKit/Networking/JSONSerialiser.swift
@@ -1,3 +1,22 @@
+//
+// JSONSerialiser.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
actor JSONSerialiser: Serialiser {
@@ -8,7 +27,7 @@ actor JSONSerialiser: Serialiser {
self.decoder = decoder
}
- func decode(_ type: T.Type, from data: Data) async throws -> T {
+ func decode(_: T.Type, from data: Data) async throws -> T {
let result = try decoder.decode(T.self, from: data)
return result
}
diff --git a/Sources/PoliceDataKit/Networking/PoliceDataAPIClient.swift b/Sources/PoliceDataKit/Networking/PoliceDataAPIClient.swift
index ffa2195..a2f3589 100644
--- a/Sources/PoliceDataKit/Networking/PoliceDataAPIClient.swift
+++ b/Sources/PoliceDataKit/Networking/PoliceDataAPIClient.swift
@@ -1,3 +1,22 @@
+//
+// PoliceDataAPIClient.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
final actor PoliceDataAPIClient: APIClient {
diff --git a/Sources/PoliceDataKit/Networking/Serialiser.swift b/Sources/PoliceDataKit/Networking/Serialiser.swift
index 956c23a..0a2b936 100644
--- a/Sources/PoliceDataKit/Networking/Serialiser.swift
+++ b/Sources/PoliceDataKit/Networking/Serialiser.swift
@@ -1,3 +1,22 @@
+//
+// Serialiser.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
protocol Serialiser {
diff --git a/Sources/PoliceDataKit/Outcomes/Cache/CachingKeys/OutcomesAtStreetLevelForStreetCachingKey.swift b/Sources/PoliceDataKit/Outcomes/Cache/CachingKeys/OutcomesAtStreetLevelForStreetCachingKey.swift
index 24deb26..e25b7c9 100644
--- a/Sources/PoliceDataKit/Outcomes/Cache/CachingKeys/OutcomesAtStreetLevelForStreetCachingKey.swift
+++ b/Sources/PoliceDataKit/Outcomes/Cache/CachingKeys/OutcomesAtStreetLevelForStreetCachingKey.swift
@@ -1,3 +1,22 @@
+//
+// OutcomesAtStreetLevelForStreetCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct OutcomesAtStreetLevelForStreetCachingKey: CachingKey {
diff --git a/Sources/PoliceDataKit/Outcomes/Cache/CachingKeys/OutcomesForCrimeCachingKey.swift b/Sources/PoliceDataKit/Outcomes/Cache/CachingKeys/OutcomesForCrimeCachingKey.swift
index 9e3aac3..bc06612 100644
--- a/Sources/PoliceDataKit/Outcomes/Cache/CachingKeys/OutcomesForCrimeCachingKey.swift
+++ b/Sources/PoliceDataKit/Outcomes/Cache/CachingKeys/OutcomesForCrimeCachingKey.swift
@@ -1,3 +1,22 @@
+//
+// OutcomesForCrimeCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct OutcomesForCrimeCachingKey: CachingKey {
diff --git a/Sources/PoliceDataKit/Outcomes/Cache/OutcomeDefaultCache.swift b/Sources/PoliceDataKit/Outcomes/Cache/OutcomeDefaultCache.swift
index 9de18d3..37dedf8 100644
--- a/Sources/PoliceDataKit/Outcomes/Cache/OutcomeDefaultCache.swift
+++ b/Sources/PoliceDataKit/Outcomes/Cache/OutcomeDefaultCache.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeDefaultCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
final class OutcomeDefaultCache: OutcomeCache {
diff --git a/Sources/PoliceDataKit/Outcomes/Endpoints/OutcomesEndpoint.swift b/Sources/PoliceDataKit/Outcomes/Endpoints/OutcomesEndpoint.swift
index 16b6801..502e223 100644
--- a/Sources/PoliceDataKit/Outcomes/Endpoints/OutcomesEndpoint.swift
+++ b/Sources/PoliceDataKit/Outcomes/Endpoints/OutcomesEndpoint.swift
@@ -1,3 +1,22 @@
+//
+// OutcomesEndpoint.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@@ -17,24 +36,24 @@ extension OutcomesEndpoint: Endpoint {
var path: URL {
switch self {
- case .streetLevelOutcomesForStreet(let streetID, let date):
- return Self.outcomesAtLocationBasePath
+ case let .streetLevelOutcomesForStreet(streetID, date):
+ Self.outcomesAtLocationBasePath
.appendingQueryItem(name: "location_id", value: streetID)
.appendingQueryItem(name: "date", date: date)
- case .streetLevelOutcomesAtSpecificPoint(let coordinate, let date):
- return Self.outcomesAtLocationBasePath
+ case let .streetLevelOutcomesAtSpecificPoint(coordinate, date):
+ Self.outcomesAtLocationBasePath
.appendingQueryItem(name: "lat", value: coordinate.latitude)
.appendingQueryItem(name: "lng", value: coordinate.longitude)
.appendingQueryItem(name: "date", date: date)
- case .streetLevelOutcomesInArea(let coordinates, let date):
- return Self.outcomesAtLocationBasePath
+ case let .streetLevelOutcomesInArea(coordinates, date):
+ Self.outcomesAtLocationBasePath
.appendingQueryItem(name: "poly", coordinates: coordinates)
.appendingQueryItem(name: "date", date: date)
- case .caseHistory(let crimeID):
- return Self.outcomesForCrimeBasePath
+ case let .caseHistory(crimeID):
+ Self.outcomesForCrimeBasePath
.appendingPathComponent("\(crimeID)")
}
}
diff --git a/Sources/PoliceDataKit/Outcomes/Models/CaseHistory.swift b/Sources/PoliceDataKit/Outcomes/Models/CaseHistory.swift
index bb51e4d..f49ba75 100644
--- a/Sources/PoliceDataKit/Outcomes/Models/CaseHistory.swift
+++ b/Sources/PoliceDataKit/Outcomes/Models/CaseHistory.swift
@@ -1,3 +1,22 @@
+//
+// CaseHistory.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/Outcomes/Models/CaseHistoryCrime.swift b/Sources/PoliceDataKit/Outcomes/Models/CaseHistoryCrime.swift
index ff8e9b1..ebb7652 100644
--- a/Sources/PoliceDataKit/Outcomes/Models/CaseHistoryCrime.swift
+++ b/Sources/PoliceDataKit/Outcomes/Models/CaseHistoryCrime.swift
@@ -1,3 +1,22 @@
+//
+// CaseHistoryCrime.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/Outcomes/Models/CaseHistoryOutcome.swift b/Sources/PoliceDataKit/Outcomes/Models/CaseHistoryOutcome.swift
index 0bfeca3..2195643 100644
--- a/Sources/PoliceDataKit/Outcomes/Models/CaseHistoryOutcome.swift
+++ b/Sources/PoliceDataKit/Outcomes/Models/CaseHistoryOutcome.swift
@@ -1,3 +1,22 @@
+//
+// CaseHistoryOutcome.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/Outcomes/Models/Outcome.swift b/Sources/PoliceDataKit/Outcomes/Models/Outcome.swift
index 99e00e0..f807637 100644
--- a/Sources/PoliceDataKit/Outcomes/Models/Outcome.swift
+++ b/Sources/PoliceDataKit/Outcomes/Models/Outcome.swift
@@ -1,3 +1,22 @@
+//
+// Outcome.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/Outcomes/Models/OutcomeCategory.swift b/Sources/PoliceDataKit/Outcomes/Models/OutcomeCategory.swift
index 537cf76..6b60857 100644
--- a/Sources/PoliceDataKit/Outcomes/Models/OutcomeCategory.swift
+++ b/Sources/PoliceDataKit/Outcomes/Models/OutcomeCategory.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeCategory.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/Outcomes/Models/OutcomeCrime.swift b/Sources/PoliceDataKit/Outcomes/Models/OutcomeCrime.swift
index e17486a..c858b74 100644
--- a/Sources/PoliceDataKit/Outcomes/Models/OutcomeCrime.swift
+++ b/Sources/PoliceDataKit/Outcomes/Models/OutcomeCrime.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeCrime.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/Outcomes/Models/OutcomeStatus.swift b/Sources/PoliceDataKit/Outcomes/Models/OutcomeStatus.swift
index 3a30975..6e9e3b8 100644
--- a/Sources/PoliceDataKit/Outcomes/Models/OutcomeStatus.swift
+++ b/Sources/PoliceDataKit/Outcomes/Models/OutcomeStatus.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeStatus.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/Outcomes/OutcomeError.swift b/Sources/PoliceDataKit/Outcomes/OutcomeError.swift
index eac149d..d8cf248 100644
--- a/Sources/PoliceDataKit/Outcomes/OutcomeError.swift
+++ b/Sources/PoliceDataKit/Outcomes/OutcomeError.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeError.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
@@ -19,47 +38,50 @@ public enum OutcomeError: LocalizedError, Equatable {
}
-extension OutcomeError {
+public extension OutcomeError {
/// A localized message describing what error occurred.
- public var errorDescription: String? {
+ var errorDescription: String? {
switch self {
case .notFound:
- return NSLocalizedString("NOT_FOUND", bundle: .module, comment: "Not found error")
+ NSLocalizedString("NOT_FOUND", bundle: .module, comment: "Not found error")
case .locationOutsideOfDataSetRegion:
- return NSLocalizedString("LOCATION_OUTSIDE_OF_DATA_SET_REGION", bundle: .module,
- comment: "Location outside of data set region")
+ NSLocalizedString(
+ "LOCATION_OUTSIDE_OF_DATA_SET_REGION",
+ bundle: .module,
+ comment: "Location outside of data set region"
+ )
case .network:
- return NSLocalizedString("NETWORK_ERROR", bundle: .module, comment: "Network error")
+ NSLocalizedString("NETWORK_ERROR", bundle: .module, comment: "Network error")
case .unknown:
- return NSLocalizedString("UNKNOWN_ERROR", bundle: .module, comment: "Unknown error")
+ NSLocalizedString("UNKNOWN_ERROR", bundle: .module, comment: "Unknown error")
}
}
}
-extension OutcomeError {
+public extension OutcomeError {
/// Returns a Boolean value indicating whether two `OutcomeError`s are equal.
- public static func == (lhs: OutcomeError, rhs: OutcomeError) -> Bool {
+ static func == (lhs: OutcomeError, rhs: OutcomeError) -> Bool {
switch (lhs, rhs) {
case (.notFound, .notFound):
- return true
+ true
case (.locationOutsideOfDataSetRegion, .locationOutsideOfDataSetRegion):
- return true
+ true
case (.network, .network):
- return true
+ true
case (.unknown, .unknown):
- return true
+ true
default:
- return false
+ false
}
}
diff --git a/Sources/PoliceDataKit/Outcomes/OutcomeService.swift b/Sources/PoliceDataKit/Outcomes/OutcomeService.swift
index 55ce432..c5c4b32 100644
--- a/Sources/PoliceDataKit/Outcomes/OutcomeService.swift
+++ b/Sources/PoliceDataKit/Outcomes/OutcomeService.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeService.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Combine
import Foundation
import MapKit
@@ -94,9 +113,11 @@ public final class OutcomeService {
/// - Throws: Outcome data error ``OutcomeError``.
///
/// - Returns: The outcomes of crimes in a 1 mile radius of the specified coordinate and date.
- ///
- public func streetLevelOutcomes(at coordinate: CLLocationCoordinate2D,
- date: Date = Date()) async throws -> [Outcome] {
+ ///
+ public func streetLevelOutcomes(
+ at coordinate: CLLocationCoordinate2D,
+ date: Date = Date()
+ ) async throws -> [Outcome] {
Self.logger.trace("fetching street level Outcomes at coordinate \(coordinate, privacy: .public)")
guard availableDataRegion.contains(coordinate: coordinate) else {
@@ -129,9 +150,11 @@ public final class OutcomeService {
/// - date: Limit results to a specific month. The latest month will be shown by default.
///
/// - Returns: The outcomes of crimes in a 1 mile radius of the specified coordinate and date.
- ///
- public func streetLevelOutcomesPublisher(at coordinate: CLLocationCoordinate2D,
- date: Date = Date()) -> AnyPublisher<[Outcome], OutcomeError> {
+ ///
+ public func streetLevelOutcomesPublisher(
+ at coordinate: CLLocationCoordinate2D,
+ date: Date = Date()
+ ) -> AnyPublisher<[Outcome], OutcomeError> {
Future { [weak self] promise in
guard let self else {
promise(.failure(.unknown))
@@ -166,8 +189,10 @@ public final class OutcomeService {
///
/// - Returns: The outcomes of crimes within the specified area.
///
- public func streetLevelOutcomes(in coordinates: [CLLocationCoordinate2D],
- date: Date = Date()) async throws -> [Outcome] {
+ public func streetLevelOutcomes(
+ in coordinates: [CLLocationCoordinate2D],
+ date: Date = Date()
+ ) async throws -> [Outcome] {
Self.logger.trace("fetching street level Outcomes in area")
let outcomes: [Outcome]
@@ -197,8 +222,10 @@ public final class OutcomeService {
///
/// - Returns: The outcomes of crimes within the specified area.
///
- public func streetLevelOutcomesPublisher(in coordinates: [CLLocationCoordinate2D],
- date: Date = Date()) -> AnyPublisher<[Outcome], OutcomeError> {
+ public func streetLevelOutcomesPublisher(
+ in coordinates: [CLLocationCoordinate2D],
+ date: Date = Date()
+ ) -> AnyPublisher<[Outcome], OutcomeError> {
Future { [weak self] promise in
guard let self else {
promise(.failure(.unknown))
diff --git a/Sources/PoliceDataKit/Outcomes/Protocols/OutcomeCache.swift b/Sources/PoliceDataKit/Outcomes/Protocols/OutcomeCache.swift
index e2d1319..7d8a5d3 100644
--- a/Sources/PoliceDataKit/Outcomes/Protocols/OutcomeCache.swift
+++ b/Sources/PoliceDataKit/Outcomes/Protocols/OutcomeCache.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
protocol OutcomeCache {
diff --git a/Sources/PoliceDataKit/PoliceDataKitFactory.swift b/Sources/PoliceDataKit/PoliceDataKitFactory.swift
index 9f570ba..5abf5c6 100644
--- a/Sources/PoliceDataKit/PoliceDataKitFactory.swift
+++ b/Sources/PoliceDataKit/PoliceDataKitFactory.swift
@@ -1,20 +1,37 @@
+//
+// PoliceDataKitFactory.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
final class PoliceDataKitFactory {
- private init() { }
+ private init() {}
}
extension PoliceDataKitFactory {
- static let apiClient: some APIClient = {
- PoliceDataAPIClient(
- baseURL: policeDataBaseURL,
- urlSession: urlSession,
- serialiser: serialiser
- )
- }()
+ static let apiClient: some APIClient = PoliceDataAPIClient(
+ baseURL: policeDataBaseURL,
+ urlSession: urlSession,
+ serialiser: serialiser
+ )
static var availabilityCache: some AvailabilityCache {
AvailabilityDefaultCache(cacheStore: cacheStore)
@@ -48,8 +65,8 @@ extension PoliceDataKitFactory {
private static var urlSessionConfiguration: URLSessionConfiguration {
let configuration = URLSessionConfiguration.default
- #if !os(macOS)
- configuration.multipathServiceType = .handover
+ #if os(iOS)
+ configuration.multipathServiceType = .handover
#endif
configuration.waitsForConnectivity = true
@@ -58,9 +75,7 @@ extension PoliceDataKitFactory {
return configuration
}
- static let cacheStore: some Cache = {
- InMemoryCache(name: "PoliceDataKitCache")
- }()
+ static let cacheStore: some Cache = InMemoryCache(name: "PoliceDataKitCache")
private static var serialiser: some Serialiser {
JSONSerialiser(decoder: .policeDataAPI)
diff --git a/Sources/PoliceDataKit/PoliceForces/Cache/CachingKeys/PoliceForceCachingKey.swift b/Sources/PoliceDataKit/PoliceForces/Cache/CachingKeys/PoliceForceCachingKey.swift
index 869cb0d..51c2f00 100644
--- a/Sources/PoliceDataKit/PoliceForces/Cache/CachingKeys/PoliceForceCachingKey.swift
+++ b/Sources/PoliceDataKit/PoliceForces/Cache/CachingKeys/PoliceForceCachingKey.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct PoliceForceCachingKey: CachingKey {
diff --git a/Sources/PoliceDataKit/PoliceForces/Cache/CachingKeys/PoliceForceSeniorOfficersCachingKey.swift b/Sources/PoliceDataKit/PoliceForces/Cache/CachingKeys/PoliceForceSeniorOfficersCachingKey.swift
index 0826991..fc0d7b8 100644
--- a/Sources/PoliceDataKit/PoliceForces/Cache/CachingKeys/PoliceForceSeniorOfficersCachingKey.swift
+++ b/Sources/PoliceDataKit/PoliceForces/Cache/CachingKeys/PoliceForceSeniorOfficersCachingKey.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceSeniorOfficersCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct PoliceForceSeniorOfficersCachingKey: CachingKey {
diff --git a/Sources/PoliceDataKit/PoliceForces/Cache/CachingKeys/PoliceForcesCachingKey.swift b/Sources/PoliceDataKit/PoliceForces/Cache/CachingKeys/PoliceForcesCachingKey.swift
index 76cda42..76ff0a1 100644
--- a/Sources/PoliceDataKit/PoliceForces/Cache/CachingKeys/PoliceForcesCachingKey.swift
+++ b/Sources/PoliceDataKit/PoliceForces/Cache/CachingKeys/PoliceForcesCachingKey.swift
@@ -1,9 +1,28 @@
+//
+// PoliceForcesCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct PoliceForcesCachingKey: CachingKey {
let keyValue = "police-forces"
- init() { }
+ init() {}
}
diff --git a/Sources/PoliceDataKit/PoliceForces/Cache/PoliceForceDefaultCache.swift b/Sources/PoliceDataKit/PoliceForces/Cache/PoliceForceDefaultCache.swift
index 450cb7f..ad4ecce 100644
--- a/Sources/PoliceDataKit/PoliceForces/Cache/PoliceForceDefaultCache.swift
+++ b/Sources/PoliceDataKit/PoliceForces/Cache/PoliceForceDefaultCache.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceDefaultCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
final class PoliceForceDefaultCache: PoliceForceCache {
diff --git a/Sources/PoliceDataKit/PoliceForces/Endpoints/PoliceForcesEndpoint.swift b/Sources/PoliceDataKit/PoliceForces/Endpoints/PoliceForcesEndpoint.swift
index fbaefd5..098b156 100644
--- a/Sources/PoliceDataKit/PoliceForces/Endpoints/PoliceForcesEndpoint.swift
+++ b/Sources/PoliceDataKit/PoliceForces/Endpoints/PoliceForcesEndpoint.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForcesEndpoint.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
enum PoliceForcesEndpoint {
@@ -15,14 +34,14 @@ extension PoliceForcesEndpoint: Endpoint {
var path: URL {
switch self {
case .list:
- return Self.basePath
+ Self.basePath
- case .details(let id):
- return Self.basePath
+ case let .details(id):
+ Self.basePath
.appendingPathComponent(id)
- case .seniorOfficers(let policeForceID):
- return Self.basePath
+ case let .seniorOfficers(policeForceID):
+ Self.basePath
.appendingPathComponent(policeForceID)
.appendingPathComponent("people")
}
diff --git a/Sources/PoliceDataKit/PoliceForces/Models/EngagementMethod.swift b/Sources/PoliceDataKit/PoliceForces/Models/EngagementMethod.swift
index 4913bc9..dd50a82 100644
--- a/Sources/PoliceDataKit/PoliceForces/Models/EngagementMethod.swift
+++ b/Sources/PoliceDataKit/PoliceForces/Models/EngagementMethod.swift
@@ -1,3 +1,22 @@
+//
+// EngagementMethod.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
@@ -29,7 +48,7 @@ public struct EngagementMethod: Equatable, Codable {
}
-extension EngagementMethod {
+public extension EngagementMethod {
private enum CodingKeys: String, CodingKey {
case title
@@ -37,7 +56,7 @@ extension EngagementMethod {
case url
}
- public init(from decoder: Decoder) throws {
+ init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.title = try container.decode(String.self, forKey: .title)
self.description = try container.decodeIfPresent(String.self, forKey: .description)
@@ -50,7 +69,7 @@ extension EngagementMethod {
}()
}
- public func encode(to encoder: Encoder) throws {
+ func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(title, forKey: .title)
try container.encodeIfPresent(description, forKey: .description)
diff --git a/Sources/PoliceDataKit/PoliceForces/Models/PoliceForce.swift b/Sources/PoliceDataKit/PoliceForces/Models/PoliceForce.swift
index e3dd59c..410927c 100644
--- a/Sources/PoliceDataKit/PoliceForces/Models/PoliceForce.swift
+++ b/Sources/PoliceDataKit/PoliceForces/Models/PoliceForce.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForce.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/PoliceForces/Models/PoliceForceReference.swift b/Sources/PoliceDataKit/PoliceForces/Models/PoliceForceReference.swift
index d9713e3..2cb3531 100644
--- a/Sources/PoliceDataKit/PoliceForces/Models/PoliceForceReference.swift
+++ b/Sources/PoliceDataKit/PoliceForces/Models/PoliceForceReference.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceReference.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/PoliceForces/PoliceForceError.swift b/Sources/PoliceDataKit/PoliceForces/PoliceForceError.swift
index f162ca2..a859599 100644
--- a/Sources/PoliceDataKit/PoliceForces/PoliceForceError.swift
+++ b/Sources/PoliceDataKit/PoliceForces/PoliceForceError.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceError.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
@@ -16,40 +35,40 @@ public enum PoliceForceError: LocalizedError, Equatable {
}
-extension PoliceForceError {
+public extension PoliceForceError {
/// A localized message describing what error occurred.
- public var errorDescription: String? {
+ var errorDescription: String? {
switch self {
case .notFound:
- return NSLocalizedString("NOT_FOUND", bundle: .module, comment: "Not found error")
+ NSLocalizedString("NOT_FOUND", bundle: .module, comment: "Not found error")
case .network:
- return NSLocalizedString("NETWORK_ERROR", bundle: .module, comment: "Network error")
+ NSLocalizedString("NETWORK_ERROR", bundle: .module, comment: "Network error")
case .unknown:
- return NSLocalizedString("UNKNOWN_ERROR", bundle: .module, comment: "Unknown error")
+ NSLocalizedString("UNKNOWN_ERROR", bundle: .module, comment: "Unknown error")
}
}
}
-extension PoliceForceError {
+public extension PoliceForceError {
/// Returns a Boolean value indicating whether two `PoliceForceError`s are equal.
- public static func == (lhs: PoliceForceError, rhs: PoliceForceError) -> Bool {
+ static func == (lhs: PoliceForceError, rhs: PoliceForceError) -> Bool {
switch (lhs, rhs) {
case (.notFound, .notFound):
- return true
+ true
case (.network, .network):
- return true
+ true
case (.unknown, .unknown):
- return true
+ true
default:
- return false
+ false
}
}
diff --git a/Sources/PoliceDataKit/PoliceForces/PoliceForceService.swift b/Sources/PoliceDataKit/PoliceForces/PoliceForceService.swift
index d4f8327..9da55ed 100644
--- a/Sources/PoliceDataKit/PoliceForces/PoliceForceService.swift
+++ b/Sources/PoliceDataKit/PoliceForces/PoliceForceService.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceService.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
import os
diff --git a/Sources/PoliceDataKit/PoliceForces/Protocols/PoliceForceCache.swift b/Sources/PoliceDataKit/PoliceForces/Protocols/PoliceForceCache.swift
index 798c807..73009a8 100644
--- a/Sources/PoliceDataKit/PoliceForces/Protocols/PoliceForceCache.swift
+++ b/Sources/PoliceDataKit/PoliceForces/Protocols/PoliceForceCache.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
protocol PoliceForceCache {
diff --git a/Sources/PoliceDataKit/StopAndSearches/Cache/CachingKeys/StopAndSearchesAtLocationCachingKey.swift b/Sources/PoliceDataKit/StopAndSearches/Cache/CachingKeys/StopAndSearchesAtLocationCachingKey.swift
index 75ba2a4..37cd882 100644
--- a/Sources/PoliceDataKit/StopAndSearches/Cache/CachingKeys/StopAndSearchesAtLocationCachingKey.swift
+++ b/Sources/PoliceDataKit/StopAndSearches/Cache/CachingKeys/StopAndSearchesAtLocationCachingKey.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchesAtLocationCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct StopAndSearchesAtLocationCachingKey: CachingKey {
diff --git a/Sources/PoliceDataKit/StopAndSearches/Cache/CachingKeys/StopAndSearchesForPoliceForceCachingKey.swift b/Sources/PoliceDataKit/StopAndSearches/Cache/CachingKeys/StopAndSearchesForPoliceForceCachingKey.swift
index ad7992d..9b268d4 100644
--- a/Sources/PoliceDataKit/StopAndSearches/Cache/CachingKeys/StopAndSearchesForPoliceForceCachingKey.swift
+++ b/Sources/PoliceDataKit/StopAndSearches/Cache/CachingKeys/StopAndSearchesForPoliceForceCachingKey.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchesForPoliceForceCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct StopAndSearchesForPoliceForceCachingKey: CachingKey {
diff --git a/Sources/PoliceDataKit/StopAndSearches/Cache/CachingKeys/StopAndSearchesWithNoLocationCachingKey.swift b/Sources/PoliceDataKit/StopAndSearches/Cache/CachingKeys/StopAndSearchesWithNoLocationCachingKey.swift
index b9d967e..114a75d 100644
--- a/Sources/PoliceDataKit/StopAndSearches/Cache/CachingKeys/StopAndSearchesWithNoLocationCachingKey.swift
+++ b/Sources/PoliceDataKit/StopAndSearches/Cache/CachingKeys/StopAndSearchesWithNoLocationCachingKey.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchesWithNoLocationCachingKey.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct StopAndSearchesWithNoLocationCachingKey: CachingKey {
diff --git a/Sources/PoliceDataKit/StopAndSearches/Cache/StopAndSearchDefaultCache.swift b/Sources/PoliceDataKit/StopAndSearches/Cache/StopAndSearchDefaultCache.swift
index fc921fb..a554027 100644
--- a/Sources/PoliceDataKit/StopAndSearches/Cache/StopAndSearchDefaultCache.swift
+++ b/Sources/PoliceDataKit/StopAndSearches/Cache/StopAndSearchDefaultCache.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchDefaultCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
final class StopAndSearchDefaultCache: StopAndSearchCache {
@@ -15,23 +34,31 @@ final class StopAndSearchDefaultCache: StopAndSearchCache {
return cachedStopAndSearches
}
- func setStopAndSearches(_ stopAndSearches: [StopAndSearch], atLocation streetID: Int,
- date: Date) async {
+ func setStopAndSearches(
+ _ stopAndSearches: [StopAndSearch],
+ atLocation streetID: Int,
+ date: Date
+ ) async {
let cacheKey = StopAndSearchesAtLocationCachingKey(streetID: streetID, date: date)
await cacheStore.set(stopAndSearches, for: cacheKey)
}
- func stopAndSearchesWithNoLocation(forPoliceForce policeForceID: PoliceForce.ID,
- date: Date) async -> [StopAndSearch]? {
+ func stopAndSearchesWithNoLocation(
+ forPoliceForce policeForceID: PoliceForce.ID,
+ date: Date
+ ) async -> [StopAndSearch]? {
let cacheKey = StopAndSearchesWithNoLocationCachingKey(policeForceID: policeForceID, date: date)
let cachedStopAndSearches = await cacheStore.object(for: cacheKey, type: [StopAndSearch].self)
return cachedStopAndSearches
}
- func setStopAndSearchesWithNoLocation(_ stopAndSearches: [StopAndSearch],
- forPoliceForce policeForceID: PoliceForce.ID, date: Date) async {
+ func setStopAndSearchesWithNoLocation(
+ _ stopAndSearches: [StopAndSearch],
+ forPoliceForce policeForceID: PoliceForce.ID,
+ date: Date
+ ) async {
let cacheKey = StopAndSearchesWithNoLocationCachingKey(policeForceID: policeForceID, date: date)
await cacheStore.set(stopAndSearches, for: cacheKey)
@@ -44,8 +71,11 @@ final class StopAndSearchDefaultCache: StopAndSearchCache {
return cachedStopAndSearches
}
- func setStopAndSearches(_ stopAndSearches: [StopAndSearch], forPoliceForce policeForceID: PoliceForce.ID,
- date: Date) async {
+ func setStopAndSearches(
+ _ stopAndSearches: [StopAndSearch],
+ forPoliceForce policeForceID: PoliceForce.ID,
+ date: Date
+ ) async {
let cacheKey = StopAndSearchesForPoliceForceCachingKey(policeForceID: policeForceID, date: date)
await cacheStore.set(stopAndSearches, for: cacheKey)
diff --git a/Sources/PoliceDataKit/StopAndSearches/Endpoints/StopAndSearchesEndpoint.swift b/Sources/PoliceDataKit/StopAndSearches/Endpoints/StopAndSearchesEndpoint.swift
index ae4d92f..283b66e 100644
--- a/Sources/PoliceDataKit/StopAndSearches/Endpoints/StopAndSearchesEndpoint.swift
+++ b/Sources/PoliceDataKit/StopAndSearches/Endpoints/StopAndSearchesEndpoint.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchesEndpoint.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@@ -21,29 +40,29 @@ extension StopAndSearchesEndpoint: Endpoint {
var path: URL {
switch self {
- case .stopAndSearchesByAreaAtSpecificPoint(let coordinate, let date):
- return Self.stopsStreetBasePath
+ case let .stopAndSearchesByAreaAtSpecificPoint(coordinate, date):
+ Self.stopsStreetBasePath
.appendingQueryItem(name: "lat", value: coordinate.latitude)
.appendingQueryItem(name: "lng", value: coordinate.longitude)
.appendingQueryItem(name: "date", date: date)
- case .stopAndSearchesByAreaInArea(let coordinates, let date):
- return Self.stopsStreetBasePath
+ case let .stopAndSearchesByAreaInArea(coordinates, date):
+ Self.stopsStreetBasePath
.appendingQueryItem(name: "poly", coordinates: coordinates)
.appendingQueryItem(name: "date", date: date)
- case .stopAndSearchesAtLocation(let streetID, let date):
- return Self.stopsAtLocationBasePath
+ case let .stopAndSearchesAtLocation(streetID, date):
+ Self.stopsAtLocationBasePath
.appendingQueryItem(name: "location_id", value: streetID)
.appendingQueryItem(name: "date", date: date)
- case .stopAndSearchesWithNoLocation(let policeForceID, let date):
- return Self.stopsNoLocationBasePath
+ case let .stopAndSearchesWithNoLocation(policeForceID, date):
+ Self.stopsNoLocationBasePath
.appendingQueryItem(name: "force", value: policeForceID)
.appendingQueryItem(name: "date", date: date)
- case .stopAndSearchesByPoliceForce(let policeForceID, let date):
- return Self.stopsForceBasePath
+ case let .stopAndSearchesByPoliceForce(policeForceID, date):
+ Self.stopsForceBasePath
.appendingQueryItem(name: "force", value: policeForceID)
.appendingQueryItem(name: "date", date: date)
}
diff --git a/Sources/PoliceDataKit/StopAndSearches/Models/Gender.swift b/Sources/PoliceDataKit/StopAndSearches/Models/Gender.swift
index 2ef95e0..2af6c68 100644
--- a/Sources/PoliceDataKit/StopAndSearches/Models/Gender.swift
+++ b/Sources/PoliceDataKit/StopAndSearches/Models/Gender.swift
@@ -1,3 +1,22 @@
+//
+// Gender.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
@@ -18,13 +37,13 @@ public enum Gender: String, CaseIterable, CustomStringConvertible, Codable {
public var description: String {
switch self {
case .male:
- return NSLocalizedString("MALE", bundle: .module, comment: "Male")
+ NSLocalizedString("MALE", bundle: .module, comment: "Male")
case .female:
- return NSLocalizedString("FEMALE", bundle: .module, comment: "Female")
+ NSLocalizedString("FEMALE", bundle: .module, comment: "Female")
case .other:
- return NSLocalizedString("OTHER", bundle: .module, comment: "Other")
+ NSLocalizedString("OTHER", bundle: .module, comment: "Other")
}
}
}
diff --git a/Sources/PoliceDataKit/StopAndSearches/Models/StopAndSearch.swift b/Sources/PoliceDataKit/StopAndSearches/Models/StopAndSearch.swift
index 267fbe2..f123ca7 100644
--- a/Sources/PoliceDataKit/StopAndSearches/Models/StopAndSearch.swift
+++ b/Sources/PoliceDataKit/StopAndSearches/Models/StopAndSearch.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearch.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
diff --git a/Sources/PoliceDataKit/StopAndSearches/Models/StopAndSearchType.swift b/Sources/PoliceDataKit/StopAndSearches/Models/StopAndSearchType.swift
index 462c0ce..f757a9b 100644
--- a/Sources/PoliceDataKit/StopAndSearches/Models/StopAndSearchType.swift
+++ b/Sources/PoliceDataKit/StopAndSearches/Models/StopAndSearchType.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchType.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
@@ -18,13 +37,13 @@ public enum StopAndSearchType: String, Equatable, CaseIterable, Codable {
public var localizedName: String {
switch self {
case .personSearch:
- return NSLocalizedString("PERSON_SEARCH", bundle: .module, comment: "Person search")
+ NSLocalizedString("PERSON_SEARCH", bundle: .module, comment: "Person search")
case .vehicleSearch:
- return NSLocalizedString("VEHICLE_SEARCH", bundle: .module, comment: "Vehicle search")
+ NSLocalizedString("VEHICLE_SEARCH", bundle: .module, comment: "Vehicle search")
case .personAndVehicleSearch:
- return NSLocalizedString("PERSON_AND_VEHICLE_SEARCH", bundle: .module, comment: "Person and Vehicle search")
+ NSLocalizedString("PERSON_AND_VEHICLE_SEARCH", bundle: .module, comment: "Person and Vehicle search")
}
}
diff --git a/Sources/PoliceDataKit/StopAndSearches/Protocols/StopAndSearchCache.swift b/Sources/PoliceDataKit/StopAndSearches/Protocols/StopAndSearchCache.swift
index 52f81d7..73f8731 100644
--- a/Sources/PoliceDataKit/StopAndSearches/Protocols/StopAndSearchCache.swift
+++ b/Sources/PoliceDataKit/StopAndSearches/Protocols/StopAndSearchCache.swift
@@ -1,21 +1,51 @@
+//
+// StopAndSearchCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
protocol StopAndSearchCache {
func stopAndSearches(atLocation streetID: Int, date: Date) async -> [StopAndSearch]?
- func setStopAndSearches(_ stopAndSearches: [StopAndSearch], atLocation streetID: Int,
- date: Date) async
+ func setStopAndSearches(
+ _ stopAndSearches: [StopAndSearch],
+ atLocation streetID: Int,
+ date: Date
+ ) async
- func stopAndSearchesWithNoLocation(forPoliceForce policeForceID: PoliceForce.ID,
- date: Date) async -> [StopAndSearch]?
+ func stopAndSearchesWithNoLocation(
+ forPoliceForce policeForceID: PoliceForce.ID,
+ date: Date
+ ) async -> [StopAndSearch]?
- func setStopAndSearchesWithNoLocation(_ stopAndSearches: [StopAndSearch],
- forPoliceForce policeForceID: PoliceForce.ID, date: Date) async
+ func setStopAndSearchesWithNoLocation(
+ _ stopAndSearches: [StopAndSearch],
+ forPoliceForce policeForceID: PoliceForce.ID,
+ date: Date
+ ) async
func stopAndSearches(forPoliceForce policeForceID: PoliceForce.ID, date: Date) async -> [StopAndSearch]?
- func setStopAndSearches(_ stopAndSearches: [StopAndSearch], forPoliceForce policeForceID: PoliceForce.ID,
- date: Date) async
+ func setStopAndSearches(
+ _ stopAndSearches: [StopAndSearch],
+ forPoliceForce policeForceID: PoliceForce.ID,
+ date: Date
+ ) async
}
diff --git a/Sources/PoliceDataKit/StopAndSearches/StopAndSearchError.swift b/Sources/PoliceDataKit/StopAndSearches/StopAndSearchError.swift
index 55a0c95..1553e90 100644
--- a/Sources/PoliceDataKit/StopAndSearches/StopAndSearchError.swift
+++ b/Sources/PoliceDataKit/StopAndSearches/StopAndSearchError.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchError.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
///
@@ -19,47 +38,50 @@ public enum StopAndSearchError: LocalizedError, Equatable {
}
-extension StopAndSearchError {
+public extension StopAndSearchError {
/// A localized message describing what error occurred.
- public var errorDescription: String? {
+ var errorDescription: String? {
switch self {
case .notFound:
- return NSLocalizedString("NOT_FOUND", bundle: .module, comment: "Not found error")
+ NSLocalizedString("NOT_FOUND", bundle: .module, comment: "Not found error")
case .locationOutsideOfDataSetRegion:
- return NSLocalizedString("LOCATION_OUTSIDE_OF_DATA_SET_REGION", bundle: .module,
- comment: "Location outside of data set region")
+ NSLocalizedString(
+ "LOCATION_OUTSIDE_OF_DATA_SET_REGION",
+ bundle: .module,
+ comment: "Location outside of data set region"
+ )
case .network:
- return NSLocalizedString("NETWORK_ERROR", bundle: .module, comment: "Network error")
+ NSLocalizedString("NETWORK_ERROR", bundle: .module, comment: "Network error")
case .unknown:
- return NSLocalizedString("UNKNOWN_ERROR", bundle: .module, comment: "Unknown error")
+ NSLocalizedString("UNKNOWN_ERROR", bundle: .module, comment: "Unknown error")
}
}
}
-extension StopAndSearchError {
+public extension StopAndSearchError {
/// Returns a Boolean value indicating whether two `StopAndSearchError`s are equal.
- public static func == (lhs: StopAndSearchError, rhs: StopAndSearchError) -> Bool {
+ static func == (lhs: StopAndSearchError, rhs: StopAndSearchError) -> Bool {
switch (lhs, rhs) {
case (.notFound, .notFound):
- return true
+ true
case (.locationOutsideOfDataSetRegion, .locationOutsideOfDataSetRegion):
- return true
+ true
case (.network, .network):
- return true
+ true
case (.unknown, .unknown):
- return true
+ true
default:
- return false
+ false
}
}
diff --git a/Sources/PoliceDataKit/StopAndSearches/StopAndSearchService.swift b/Sources/PoliceDataKit/StopAndSearches/StopAndSearchService.swift
index aa5d935..50f3d74 100644
--- a/Sources/PoliceDataKit/StopAndSearches/StopAndSearchService.swift
+++ b/Sources/PoliceDataKit/StopAndSearches/StopAndSearchService.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchService.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Combine
import Foundation
import MapKit
@@ -63,8 +82,10 @@ public final class StopAndSearchService {
///
/// - Returns: A list of stop and searches.
///
- public func stopAndSearches(at coordinate: CLLocationCoordinate2D,
- date: Date = Date()) async throws -> [StopAndSearch] {
+ public func stopAndSearches(
+ at coordinate: CLLocationCoordinate2D,
+ date: Date = Date()
+ ) async throws -> [StopAndSearch] {
Self.logger.trace("fetching Stop and Searches at \(coordinate, privacy: .public)")
guard availableDataRegion.contains(coordinate: coordinate) else {
@@ -102,8 +123,10 @@ public final class StopAndSearchService {
///
/// - Returns: A list of stop and searches.
///
- public func stopAndSearchesPublisher(at coordinate: CLLocationCoordinate2D,
- date: Date = Date()) -> AnyPublisher<[StopAndSearch], StopAndSearchError> {
+ public func stopAndSearchesPublisher(
+ at coordinate: CLLocationCoordinate2D,
+ date: Date = Date()
+ ) -> AnyPublisher<[StopAndSearch], StopAndSearchError> {
Future { [weak self] promise in
guard let self else {
promise(.failure(.unknown))
@@ -140,8 +163,10 @@ public final class StopAndSearchService {
///
/// - Returns: A list of stop and searches.
///
- public func stopAndSearches(in coordinates: [CLLocationCoordinate2D],
- date: Date = Date()) async throws -> [StopAndSearch] {
+ public func stopAndSearches(
+ in coordinates: [CLLocationCoordinate2D],
+ date: Date = Date()
+ ) async throws -> [StopAndSearch] {
Self.logger.trace("fetching Stop and Searches in area")
let stopAndSearches: [StopAndSearch]
@@ -173,8 +198,10 @@ public final class StopAndSearchService {
///
/// - Returns: A list of stop and searches.
///
- public func stopAndSearchesPublisher(in coordinates: [CLLocationCoordinate2D],
- date: Date = Date()) -> AnyPublisher<[StopAndSearch], StopAndSearchError> {
+ public func stopAndSearchesPublisher(
+ in coordinates: [CLLocationCoordinate2D],
+ date: Date = Date()
+ ) -> AnyPublisher<[StopAndSearch], StopAndSearchError> {
Future { [weak self] promise in
guard let self else {
promise(.failure(.unknown))
@@ -251,13 +278,17 @@ public final class StopAndSearchService {
///
/// - Returns: A list of stop and searches.
///
- public func stopAndSearchesWithNoLocation(forPoliceForce policeForceID: PoliceForce.ID,
- date: Date = Date()) async throws -> [StopAndSearch] {
+ public func stopAndSearchesWithNoLocation(
+ forPoliceForce policeForceID: PoliceForce.ID,
+ date: Date = Date()
+ ) async throws -> [StopAndSearch] {
// swiftlint:disable:next line_length
Self.logger.trace("fetching Stop and Searches with no location for Police Force \(policeForceID, privacy: .public)")
- if let cachedStopAndSearches = await cache.stopAndSearchesWithNoLocation(forPoliceForce: policeForceID,
- date: date) {
+ if let cachedStopAndSearches = await cache.stopAndSearchesWithNoLocation(
+ forPoliceForce: policeForceID,
+ date: date
+ ) {
return cachedStopAndSearches
}
@@ -295,9 +326,11 @@ public final class StopAndSearchService {
/// - Throws: Stop and Search data error ``StopAndSearchError``.
///
/// - Returns: A list of stop and searches.
- ///
- public func stopAndSearches(forPoliceForce policeForceID: PoliceForce.ID,
- date: Date = Date()) async throws -> [StopAndSearch] {
+ ///
+ public func stopAndSearches(
+ forPoliceForce policeForceID: PoliceForce.ID,
+ date: Date = Date()
+ ) async throws -> [StopAndSearch] {
Self.logger.trace("fetching Stop and Searches for Police Force \(policeForceID, privacy: .public)")
if let cachedStopAndSearches = await cache.stopAndSearches(forPoliceForce: policeForceID, date: date) {
diff --git a/Tests/IntegrationTests/AvailabilityIntegrationTests.swift b/Tests/IntegrationTests/AvailabilityIntegrationTests.swift
index 5f4377e..3423968 100644
--- a/Tests/IntegrationTests/AvailabilityIntegrationTests.swift
+++ b/Tests/IntegrationTests/AvailabilityIntegrationTests.swift
@@ -1,3 +1,22 @@
+//
+// AvailabilityIntegrationTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import PoliceDataKit
import XCTest
diff --git a/Tests/IntegrationTests/CrimeIntegrationTests.swift b/Tests/IntegrationTests/CrimeIntegrationTests.swift
index 3386bd0..d0dbd49 100644
--- a/Tests/IntegrationTests/CrimeIntegrationTests.swift
+++ b/Tests/IntegrationTests/CrimeIntegrationTests.swift
@@ -1,3 +1,22 @@
+//
+// CrimeIntegrationTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Combine
import CoreLocation
import PoliceDataKit
@@ -33,7 +52,7 @@ final class CrimeIntegrationTests: XCTestCase {
let leedsCityCentreCoordinate = CLLocationCoordinate2D(latitude: 53.797927, longitude: -1.541522)
let date = try XCTUnwrap(Date(isoString: "2023-03-01T12:00:00Z"))
- let expectation = self.expectation(description: "StreetLevelCrimesPublisher")
+ let expectation = expectation(description: "StreetLevelCrimesPublisher")
var result: [Crime]?
crimeService.streetLevelCrimesPublisher(at: leedsCityCentreCoordinate, date: date)
.sink { _ in
@@ -72,7 +91,7 @@ final class CrimeIntegrationTests: XCTestCase {
]
let date = try XCTUnwrap(Date(isoString: "2023-03-01T12:00:00Z"))
- let expectation = self.expectation(description: "StreetLevelCrimesPublisher")
+ let expectation = expectation(description: "StreetLevelCrimesPublisher")
var result: [Crime]?
crimeService.streetLevelCrimesPublisher(in: boundary, date: date)
.sink { _ in
@@ -89,7 +108,7 @@ final class CrimeIntegrationTests: XCTestCase {
}
func testCrimesForStreetAtSaundersWayLondon() async throws {
- let saundersWayLondonStreetID = 1705005
+ let saundersWayLondonStreetID = 1_705_005
let date = try XCTUnwrap(Date(isoString: "2023-02-01T12:00:00Z"))
let crimes = try await crimeService.crimes(forStreet: saundersWayLondonStreetID, date: date)
@@ -119,7 +138,7 @@ final class CrimeIntegrationTests: XCTestCase {
let leedsCityCentreCoordinate = CLLocationCoordinate2D(latitude: 53.797927, longitude: -1.541522)
let date = try XCTUnwrap(Date(isoString: "2023-03-01T12:00:00Z"))
- let expectation = self.expectation(description: "StreetLevelCrimesPublisher")
+ let expectation = expectation(description: "StreetLevelCrimesPublisher")
var result: [Crime]?
crimeService.crimesPublisher(at: leedsCityCentreCoordinate, date: date)
.sink { _ in
diff --git a/Tests/IntegrationTests/Helpers/Date+ISO8601.swift b/Tests/IntegrationTests/Helpers/Date+ISO8601.swift
index a3df9fe..011f220 100644
--- a/Tests/IntegrationTests/Helpers/Date+ISO8601.swift
+++ b/Tests/IntegrationTests/Helpers/Date+ISO8601.swift
@@ -1,3 +1,22 @@
+//
+// Date+ISO8601.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
extension Date {
diff --git a/Tests/IntegrationTests/NeighbourhoodIntegrationTests.swift b/Tests/IntegrationTests/NeighbourhoodIntegrationTests.swift
index 54da4ea..ff27600 100644
--- a/Tests/IntegrationTests/NeighbourhoodIntegrationTests.swift
+++ b/Tests/IntegrationTests/NeighbourhoodIntegrationTests.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodIntegrationTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Combine
import CoreLocation
import PoliceDataKit
@@ -53,8 +72,10 @@ final class NeighbourhoodIntegrationTests: XCTestCase {
let neighbourhoodID = "NC04"
let policeForceID = "leicestershire"
- let neighbourhood = try await neighbourhoodService.neighbourhood(withID: neighbourhoodID,
- inPoliceForce: policeForceID)
+ let neighbourhood = try await neighbourhoodService.neighbourhood(
+ withID: neighbourhoodID,
+ inPoliceForce: policeForceID
+ )
XCTAssertEqual(neighbourhood.id, neighbourhoodID)
}
@@ -63,8 +84,10 @@ final class NeighbourhoodIntegrationTests: XCTestCase {
let neighbourhoodID = "NC09"
let policeForceID = "lincolnshire"
- let neighbourhood = try await neighbourhoodService.neighbourhood(withID: neighbourhoodID,
- inPoliceForce: policeForceID)
+ let neighbourhood = try await neighbourhoodService.neighbourhood(
+ withID: neighbourhoodID,
+ inPoliceForce: policeForceID
+ )
XCTAssertEqual(neighbourhood.id, neighbourhoodID)
}
@@ -122,7 +145,7 @@ final class NeighbourhoodIntegrationTests: XCTestCase {
func testNeighbourhoodPublisherAtCoordinateForLeedsCityCentre() {
let leedsCityCentreCoordinate = CLLocationCoordinate2D(latitude: 53.797927, longitude: -1.541522)
- let expectation = self.expectation(description: "NeighbourhoodPublisher")
+ let expectation = expectation(description: "NeighbourhoodPublisher")
var result: Neighbourhood?
neighbourhoodService.neighbourhoodPublisher(at: leedsCityCentreCoordinate)
.sink { _ in
@@ -142,8 +165,10 @@ final class NeighbourhoodIntegrationTests: XCTestCase {
let neighbourhoodID = "WDT_CEN"
let policeForceID = "west-yorkshire"
- let boundary = try await neighbourhoodService.boundary(forNeighbourhood: neighbourhoodID,
- inPoliceForce: policeForceID)
+ let boundary = try await neighbourhoodService.boundary(
+ forNeighbourhood: neighbourhoodID,
+ inPoliceForce: policeForceID
+ )
XCTAssertEqual(boundary.count, 993)
}
@@ -152,8 +177,10 @@ final class NeighbourhoodIntegrationTests: XCTestCase {
let neighbourhoodID = "WDT_CEN"
let policeForceID = "west-yorkshire"
- let policeOfficers = try await neighbourhoodService.policeOfficers(forNeighbourhood: neighbourhoodID,
- inPoliceForce: policeForceID)
+ let policeOfficers = try await neighbourhoodService.policeOfficers(
+ forNeighbourhood: neighbourhoodID,
+ inPoliceForce: policeForceID
+ )
XCTAssertGreaterThan(policeOfficers.count, 0)
}
@@ -162,8 +189,10 @@ final class NeighbourhoodIntegrationTests: XCTestCase {
let neighbourhoodID = "AB"
let policeForceID = "south-yorkshire"
- let policeOfficers = try await neighbourhoodService.policeOfficers(forNeighbourhood: neighbourhoodID,
- inPoliceForce: policeForceID)
+ let policeOfficers = try await neighbourhoodService.policeOfficers(
+ forNeighbourhood: neighbourhoodID,
+ inPoliceForce: policeForceID
+ )
XCTAssertGreaterThan(policeOfficers.count, 0)
}
@@ -172,8 +201,10 @@ final class NeighbourhoodIntegrationTests: XCTestCase {
let neighbourhoodID = "AB"
let policeForceID = "south-yorkshire"
- let priorties = try await neighbourhoodService.priorities(forNeighbourhood: neighbourhoodID,
- inPoliceForce: policeForceID)
+ let priorties = try await neighbourhoodService.priorities(
+ forNeighbourhood: neighbourhoodID,
+ inPoliceForce: policeForceID
+ )
XCTAssertGreaterThan(priorties.count, 0)
}
@@ -182,8 +213,10 @@ final class NeighbourhoodIntegrationTests: XCTestCase {
let neighbourhoodID = "BA1"
let policeForceID = "gloucestershire"
- let priorties = try await neighbourhoodService.priorities(forNeighbourhood: neighbourhoodID,
- inPoliceForce: policeForceID)
+ let priorties = try await neighbourhoodService.priorities(
+ forNeighbourhood: neighbourhoodID,
+ inPoliceForce: policeForceID
+ )
XCTAssertGreaterThan(priorties.count, 0)
}
@@ -200,7 +233,7 @@ final class NeighbourhoodIntegrationTests: XCTestCase {
func testNeighbourhoodPolicingTeamPublisherAtCoordinateForGloucesterCityCentreGloucestershire() {
let gloucesterCoordinate = CLLocationCoordinate2D(latitude: 51.86703, longitude: -2.2413)
- let expectation = self.expectation(description: "NeighbourhoodPublisher")
+ let expectation = expectation(description: "NeighbourhoodPublisher")
var result: NeighbourhoodPolicingTeam?
neighbourhoodService.neighbourhoodPolicingTeamPublisher(at: gloucesterCoordinate)
.sink { _ in
diff --git a/Tests/IntegrationTests/OutcomeIntegrationTests.swift b/Tests/IntegrationTests/OutcomeIntegrationTests.swift
index 2022c9b..c055209 100644
--- a/Tests/IntegrationTests/OutcomeIntegrationTests.swift
+++ b/Tests/IntegrationTests/OutcomeIntegrationTests.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeIntegrationTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Combine
import CoreLocation
import PoliceDataKit
@@ -21,7 +40,7 @@ final class OutcomeIntegrationTests: XCTestCase {
}
func testStreetLevelOutcomesForStreetForPrincesStreetLondon() async throws {
- let princesStreetLondonStreetID = 1675924
+ let princesStreetLondonStreetID = 1_675_924
let date = try XCTUnwrap(Date(isoString: "2022-08-01T12:00:00Z"))
let outcomes = try await outcomeService.streetLevelOutcomes(forStreet: princesStreetLondonStreetID, date: date)
@@ -48,7 +67,7 @@ final class OutcomeIntegrationTests: XCTestCase {
let leedsCityCentreCoordinate = CLLocationCoordinate2D(latitude: 53.797927, longitude: -1.541522)
let date = try XCTUnwrap(Date(isoString: "2022-03-01T12:00:00Z"))
- let expectation = self.expectation(description: "OutcomesPublisher")
+ let expectation = expectation(description: "OutcomesPublisher")
var result: [Outcome]?
outcomeService.streetLevelOutcomesPublisher(at: leedsCityCentreCoordinate, date: date)
.sink { _ in
@@ -87,7 +106,7 @@ final class OutcomeIntegrationTests: XCTestCase {
]
let date = try XCTUnwrap(Date(isoString: "2022-09-01T12:00:00Z"))
- let expectation = self.expectation(description: "OutcomesPublisher")
+ let expectation = expectation(description: "OutcomesPublisher")
var result: [Outcome]?
outcomeService.streetLevelOutcomesPublisher(in: boundary, date: date)
.sink { _ in
diff --git a/Tests/IntegrationTests/PoliceForceIntegrationTests.swift b/Tests/IntegrationTests/PoliceForceIntegrationTests.swift
index 66ce7e6..bbb63cb 100644
--- a/Tests/IntegrationTests/PoliceForceIntegrationTests.swift
+++ b/Tests/IntegrationTests/PoliceForceIntegrationTests.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceIntegrationTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import PoliceDataKit
import XCTest
diff --git a/Tests/IntegrationTests/StopAndSearchIntegrationTests.swift b/Tests/IntegrationTests/StopAndSearchIntegrationTests.swift
index f19736d..5d961ce 100644
--- a/Tests/IntegrationTests/StopAndSearchIntegrationTests.swift
+++ b/Tests/IntegrationTests/StopAndSearchIntegrationTests.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchIntegrationTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Combine
import CoreLocation
import PoliceDataKit
@@ -33,7 +52,7 @@ final class StopAndSearchIntegrationTests: XCTestCase {
let leedsCityCentreCoordinate = CLLocationCoordinate2D(latitude: 53.797927, longitude: -1.541522)
let date = try XCTUnwrap(Date(isoString: "2023-02-01T12:00:00Z"))
- let expectation = self.expectation(description: "StopAndSearchesPublisher")
+ let expectation = expectation(description: "StopAndSearchesPublisher")
var result: [StopAndSearch]?
stopAndSearchService.stopAndSearchesPublisher(at: leedsCityCentreCoordinate, date: date)
.sink { _ in
@@ -72,7 +91,7 @@ final class StopAndSearchIntegrationTests: XCTestCase {
]
let date = try XCTUnwrap(Date(isoString: "2022-12-01T12:00:00Z"))
- let expectation = self.expectation(description: "StopAndSearchesPublisher")
+ let expectation = expectation(description: "StopAndSearchesPublisher")
var result: [StopAndSearch]?
stopAndSearchService.stopAndSearchesPublisher(in: boundary, date: date)
.sink { _ in
@@ -89,11 +108,13 @@ final class StopAndSearchIntegrationTests: XCTestCase {
}
func testStopAndSearchesAtLocationForBondStreetLondon() async throws {
- let bondStreetLondonStreetID = 2342948
+ let bondStreetLondonStreetID = 2_342_948
let date = try XCTUnwrap(Date(isoString: "2023-03-01T12:00:00Z"))
- let stopAndSearches = try await stopAndSearchService.stopAndSearches(atLocation: bondStreetLondonStreetID,
- date: date)
+ let stopAndSearches = try await stopAndSearchService.stopAndSearches(
+ atLocation: bondStreetLondonStreetID,
+ date: date
+ )
XCTAssertGreaterThan(stopAndSearches.count, 0)
}
diff --git a/Tests/PoliceDataKitTests/Availability/AvailabilityServiceTests.swift b/Tests/PoliceDataKitTests/Availability/AvailabilityServiceTests.swift
index ee00a7b..fd8c79a 100644
--- a/Tests/PoliceDataKitTests/Availability/AvailabilityServiceTests.swift
+++ b/Tests/PoliceDataKitTests/Availability/AvailabilityServiceTests.swift
@@ -1,3 +1,22 @@
+//
+// AvailabilityServiceTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Availability/Cache/AvailabilityDefaultCacheTests.swift b/Tests/PoliceDataKitTests/Availability/Cache/AvailabilityDefaultCacheTests.swift
index 29455d6..4d96814 100644
--- a/Tests/PoliceDataKitTests/Availability/Cache/AvailabilityDefaultCacheTests.swift
+++ b/Tests/PoliceDataKitTests/Availability/Cache/AvailabilityDefaultCacheTests.swift
@@ -1,3 +1,22 @@
+//
+// AvailabilityDefaultCacheTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Availability/Cache/CachingKeys/AvailableDataSetsCachingKeyTests.swift b/Tests/PoliceDataKitTests/Availability/Cache/CachingKeys/AvailableDataSetsCachingKeyTests.swift
index 40a6559..dd047de 100644
--- a/Tests/PoliceDataKitTests/Availability/Cache/CachingKeys/AvailableDataSetsCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/Availability/Cache/CachingKeys/AvailableDataSetsCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// AvailableDataSetsCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Availability/Endpoints/AvailabilityEndpointTests.swift b/Tests/PoliceDataKitTests/Availability/Endpoints/AvailabilityEndpointTests.swift
index 3195cf3..725928e 100644
--- a/Tests/PoliceDataKitTests/Availability/Endpoints/AvailabilityEndpointTests.swift
+++ b/Tests/PoliceDataKitTests/Availability/Endpoints/AvailabilityEndpointTests.swift
@@ -1,3 +1,22 @@
+//
+// AvailabilityEndpointTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Availability/Mocks/AvailabilityMockCache.swift b/Tests/PoliceDataKitTests/Availability/Mocks/AvailabilityMockCache.swift
index ef4c11b..21efe96 100644
--- a/Tests/PoliceDataKitTests/Availability/Mocks/AvailabilityMockCache.swift
+++ b/Tests/PoliceDataKitTests/Availability/Mocks/AvailabilityMockCache.swift
@@ -1,3 +1,22 @@
+//
+// AvailabilityMockCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
@@ -10,7 +29,7 @@ final actor AvailabilityMockCache: AvailabilityCache {
}
func availableDataSets() async -> [DataSet]? {
- return cacheStore[CacheKey.availableDataSets] as? [DataSet]
+ cacheStore[CacheKey.availableDataSets] as? [DataSet]
}
func setAvailableDataSets(_ dataSets: [DataSet]) async {
diff --git a/Tests/PoliceDataKitTests/Availability/Models/DataSetTests.swift b/Tests/PoliceDataKitTests/Availability/Models/DataSetTests.swift
index d160193..c165a66 100644
--- a/Tests/PoliceDataKitTests/Availability/Models/DataSetTests.swift
+++ b/Tests/PoliceDataKitTests/Availability/Models/DataSetTests.swift
@@ -1,3 +1,22 @@
+//
+// DataSetTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Cache/CacheItemTests.swift b/Tests/PoliceDataKitTests/Cache/CacheItemTests.swift
index d919157..78b7e7d 100644
--- a/Tests/PoliceDataKitTests/Cache/CacheItemTests.swift
+++ b/Tests/PoliceDataKitTests/Cache/CacheItemTests.swift
@@ -1,3 +1,22 @@
+//
+// CacheItemTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Cache/InMemoryCacheTests.swift b/Tests/PoliceDataKitTests/Cache/InMemoryCacheTests.swift
index 2c4cec5..4266819 100644
--- a/Tests/PoliceDataKitTests/Cache/InMemoryCacheTests.swift
+++ b/Tests/PoliceDataKitTests/Cache/InMemoryCacheTests.swift
@@ -1,3 +1,22 @@
+//
+// InMemoryCacheTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Crimes/Cache/CachingKey/CrimeCategoriesCachingKeyTests.swift b/Tests/PoliceDataKitTests/Crimes/Cache/CachingKey/CrimeCategoriesCachingKeyTests.swift
index 244e4eb..eb3231e 100644
--- a/Tests/PoliceDataKitTests/Crimes/Cache/CachingKey/CrimeCategoriesCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/Crimes/Cache/CachingKey/CrimeCategoriesCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// CrimeCategoriesCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Crimes/Cache/CachingKey/CrimesForStreetCachingKeyTests.swift b/Tests/PoliceDataKitTests/Crimes/Cache/CachingKey/CrimesForStreetCachingKeyTests.swift
index c6daf9d..4df89a8 100644
--- a/Tests/PoliceDataKitTests/Crimes/Cache/CachingKey/CrimesForStreetCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/Crimes/Cache/CachingKey/CrimesForStreetCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// CrimesForStreetCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Crimes/Cache/CachingKey/CrimesWithNoLocationForCategoryInPoliceForceCachingKeyTests.swift b/Tests/PoliceDataKitTests/Crimes/Cache/CachingKey/CrimesWithNoLocationForCategoryInPoliceForceCachingKeyTests.swift
index 33d122a..e41b9d9 100644
--- a/Tests/PoliceDataKitTests/Crimes/Cache/CachingKey/CrimesWithNoLocationForCategoryInPoliceForceCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/Crimes/Cache/CachingKey/CrimesWithNoLocationForCategoryInPoliceForceCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// CrimesWithNoLocationForCategoryInPoliceForceCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
@@ -7,8 +26,11 @@ final class CrimesWithNoLocationForCategoryInPoliceForceCachingKeyTests: XCTestC
let categoryID = "ABC123"
let policeForceID = "leicestershire"
let date = Date(timeIntervalSince1970: 0)
- let cacheKey = CrimesWithNoLocationForCategoryInPoliceForceCachingKey(categoryID: categoryID,
- policeForceID: policeForceID, date: date)
+ let cacheKey = CrimesWithNoLocationForCategoryInPoliceForceCachingKey(
+ categoryID: categoryID,
+ policeForceID: policeForceID,
+ date: date
+ )
XCTAssertEqual(
cacheKey.keyValue,
diff --git a/Tests/PoliceDataKitTests/Crimes/Cache/CrimeDefaultCacheTests.swift b/Tests/PoliceDataKitTests/Crimes/Cache/CrimeDefaultCacheTests.swift
index c293a8d..baaa6d0 100644
--- a/Tests/PoliceDataKitTests/Crimes/Cache/CrimeDefaultCacheTests.swift
+++ b/Tests/PoliceDataKitTests/Crimes/Cache/CrimeDefaultCacheTests.swift
@@ -1,3 +1,22 @@
+//
+// CrimeDefaultCacheTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
@@ -65,8 +84,11 @@ final class CrimeDefaultCacheTests: XCTestCase {
let categoryID = "test-crime"
let policeForceID = "test-police-force"
let date = Date()
- let cacheKey = CrimesWithNoLocationForCategoryInPoliceForceCachingKey(categoryID: categoryID,
- policeForceID: policeForceID, date: date)
+ let cacheKey = CrimesWithNoLocationForCategoryInPoliceForceCachingKey(
+ categoryID: categoryID,
+ policeForceID: policeForceID,
+ date: date
+ )
let expectedResult = Crime.mocks
await cacheStore.set(expectedResult, for: cacheKey)
@@ -79,12 +101,19 @@ final class CrimeDefaultCacheTests: XCTestCase {
let categoryID = "test-crime"
let policeForceID = "test-police-force"
let date = Date()
- let cacheKey = CrimesWithNoLocationForCategoryInPoliceForceCachingKey(categoryID: categoryID,
- policeForceID: policeForceID, date: date)
+ let cacheKey = CrimesWithNoLocationForCategoryInPoliceForceCachingKey(
+ categoryID: categoryID,
+ policeForceID: policeForceID,
+ date: date
+ )
let expectedResult = Crime.mocks
- await cache.setCrimesWithNoLocation(expectedResult, forCategory: categoryID, inPoliceForce: policeForceID,
- date: date)
+ await cache.setCrimesWithNoLocation(
+ expectedResult,
+ forCategory: categoryID,
+ inPoliceForce: policeForceID,
+ date: date
+ )
let result = await cacheStore.object(for: cacheKey, type: [Crime].self)
XCTAssertEqual(result, expectedResult)
diff --git a/Tests/PoliceDataKitTests/Crimes/CrimeServiceTests.swift b/Tests/PoliceDataKitTests/Crimes/CrimeServiceTests.swift
index 5c48edb..b721d2c 100644
--- a/Tests/PoliceDataKitTests/Crimes/CrimeServiceTests.swift
+++ b/Tests/PoliceDataKitTests/Crimes/CrimeServiceTests.swift
@@ -1,8 +1,28 @@
+//
+// CrimeServiceTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Combine
import MapKit
@testable import PoliceDataKit
import XCTest
+// swiftlint:disable:next type_body_length
final class CrimeServiceTests: XCTestCase {
var service: CrimeService!
@@ -51,7 +71,7 @@ final class CrimeServiceTests: XCTestCase {
let expectedResult = Crime.mocks
apiClient.add(response: .success(Crime.mocks))
- let expectation = self.expectation(description: "StreetLevelCrimesPublisher")
+ let expectation = expectation(description: "StreetLevelCrimesPublisher")
var result: [Crime]?
service.streetLevelCrimesPublisher(at: coordinate, date: date)
.sink { _ in
@@ -109,7 +129,7 @@ final class CrimeServiceTests: XCTestCase {
let expectedResult = Crime.mocks
apiClient.add(response: .success(Crime.mocks))
- let expectation = self.expectation(description: "StreetLevelCrimesPublisher")
+ let expectation = expectation(description: "StreetLevelCrimesPublisher")
var result: [Crime]?
service.streetLevelCrimesPublisher(in: coordinates, date: date)
.sink { _ in
@@ -190,7 +210,7 @@ final class CrimeServiceTests: XCTestCase {
let expectedResult = Crime.mocks
apiClient.add(response: .success(Crime.mocks))
- let expectation = self.expectation(description: "StreetLevelCrimesPublisher")
+ let expectation = expectation(description: "StreetLevelCrimesPublisher")
var result: [Crime]?
service.crimesPublisher(at: coordinate, date: date)
.sink { _ in
@@ -234,8 +254,11 @@ final class CrimeServiceTests: XCTestCase {
let expectedResult = Crime.mocks
apiClient.add(response: .success(Crime.mocks))
- let result = try await service.crimesWithNoLocation(forCategory: categoryID, inPoliceForce: policeForceID,
- date: date)
+ let result = try await service.crimesWithNoLocation(
+ forCategory: categoryID,
+ inPoliceForce: policeForceID,
+ date: date
+ )
XCTAssertEqual(result, expectedResult)
XCTAssertEqual(
@@ -250,11 +273,18 @@ final class CrimeServiceTests: XCTestCase {
let policeForceID = PoliceForce.mock.id
let date = Date()
let expectedResult = Crime.mocks
- await cache.setCrimesWithNoLocation(expectedResult, forCategory: categoryID, inPoliceForce: policeForceID,
- date: date)
+ await cache.setCrimesWithNoLocation(
+ expectedResult,
+ forCategory: categoryID,
+ inPoliceForce: policeForceID,
+ date: date
+ )
- let result = try await service.crimesWithNoLocation(forCategory: categoryID, inPoliceForce: policeForceID,
- date: date)
+ let result = try await service.crimesWithNoLocation(
+ forCategory: categoryID,
+ inPoliceForce: policeForceID,
+ date: date
+ )
XCTAssertEqual(result, expectedResult)
XCTAssertEqual(apiClient.requestedURLs.count, 0)
@@ -269,8 +299,11 @@ final class CrimeServiceTests: XCTestCase {
apiClient.add(response: .success(Crime.mocks))
_ = try await service.crimesWithNoLocation(forCategory: categoryID, inPoliceForce: policeForceID, date: date)
- let cachedResult = await cache.crimesWithNoLocation(forCategory: categoryID, inPoliceForce: policeForceID,
- date: date)
+ let cachedResult = await cache.crimesWithNoLocation(
+ forCategory: categoryID,
+ inPoliceForce: policeForceID,
+ date: date
+ )
XCTAssertEqual(cachedResult, expectedResult)
}
diff --git a/Tests/PoliceDataKitTests/Crimes/Endpoints/CrimesEndpointTests.swift b/Tests/PoliceDataKitTests/Crimes/Endpoints/CrimesEndpointTests.swift
index 748d4e6..9574369 100644
--- a/Tests/PoliceDataKitTests/Crimes/Endpoints/CrimesEndpointTests.swift
+++ b/Tests/PoliceDataKitTests/Crimes/Endpoints/CrimesEndpointTests.swift
@@ -1,3 +1,22 @@
+//
+// CrimesEndpointTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
@testable import PoliceDataKit
import XCTest
@@ -57,8 +76,11 @@ final class CrimesEndpointTests: XCTestCase {
string: "/crimes-no-location?category=\(categoryID)&force=\(policeForceID)&date=1970-01"
))
- let path = CrimesEndpoint.crimesWithNoLocation(categoryID: categoryID, policeForceID: policeForceID,
- date: date).path
+ let path = CrimesEndpoint.crimesWithNoLocation(
+ categoryID: categoryID,
+ policeForceID: policeForceID,
+ date: date
+ ).path
XCTAssertEqual(path, expectedPath)
}
diff --git a/Tests/PoliceDataKitTests/Crimes/Mocks/CrimeMockCache.swift b/Tests/PoliceDataKitTests/Crimes/Mocks/CrimeMockCache.swift
index ea1d6b8..08db241 100644
--- a/Tests/PoliceDataKitTests/Crimes/Mocks/CrimeMockCache.swift
+++ b/Tests/PoliceDataKitTests/Crimes/Mocks/CrimeMockCache.swift
@@ -1,3 +1,22 @@
+//
+// CrimeMockCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
@@ -11,10 +30,14 @@ final class CrimeMockCache: CrimeCache {
"crimes-for-street-\(streetID)-\(date)"
}
- static func crimesWithNoLocation(categoryID: CrimeCategory.ID, policeForceID: PoliceForce.ID,
- date: Date) -> String {
+ static func crimesWithNoLocation(
+ categoryID: CrimeCategory.ID,
+ policeForceID: PoliceForce.ID,
+ date: Date
+ ) -> String {
"crimes-with-no-location-\(categoryID)-\(policeForceID)-\(date)"
}
+
static func crimeCategories(date: Date) -> String {
"crime-categories-\(date)"
}
@@ -29,14 +52,21 @@ final class CrimeMockCache: CrimeCache {
cacheStore[CacheKey.crimesForStreet(streetID: streetID, date: date)] = crimes
}
- func crimesWithNoLocation(forCategory categoryID: CrimeCategory.ID, inPoliceForce policeForceID: PoliceForce.ID,
- date: Date) async -> [Crime]? {
+ func crimesWithNoLocation(
+ forCategory categoryID: CrimeCategory.ID,
+ inPoliceForce policeForceID: PoliceForce.ID,
+ date: Date
+ ) async -> [Crime]? {
let key = CacheKey.crimesWithNoLocation(categoryID: categoryID, policeForceID: policeForceID, date: date)
return cacheStore[key] as? [Crime]
}
- func setCrimesWithNoLocation(_ crimes: [Crime], forCategory categoryID: CrimeCategory.ID,
- inPoliceForce policeForceID: PoliceForce.ID, date: Date) async {
+ func setCrimesWithNoLocation(
+ _ crimes: [Crime],
+ forCategory categoryID: CrimeCategory.ID,
+ inPoliceForce policeForceID: PoliceForce.ID,
+ date: Date
+ ) async {
let key = CacheKey.crimesWithNoLocation(categoryID: categoryID, policeForceID: policeForceID, date: date)
cacheStore[key] = crimes
}
diff --git a/Tests/PoliceDataKitTests/Crimes/Models/CrimeCategoryTests.swift b/Tests/PoliceDataKitTests/Crimes/Models/CrimeCategoryTests.swift
index 1f614ad..b1027a4 100644
--- a/Tests/PoliceDataKitTests/Crimes/Models/CrimeCategoryTests.swift
+++ b/Tests/PoliceDataKitTests/Crimes/Models/CrimeCategoryTests.swift
@@ -1,3 +1,22 @@
+//
+// CrimeCategoryTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Crimes/Models/CrimeLocationTypeTests.swift b/Tests/PoliceDataKitTests/Crimes/Models/CrimeLocationTypeTests.swift
index 36b2c46..11b26a9 100644
--- a/Tests/PoliceDataKitTests/Crimes/Models/CrimeLocationTypeTests.swift
+++ b/Tests/PoliceDataKitTests/Crimes/Models/CrimeLocationTypeTests.swift
@@ -1,3 +1,22 @@
+//
+// CrimeLocationTypeTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Crimes/Models/CrimeTests.swift b/Tests/PoliceDataKitTests/Crimes/Models/CrimeTests.swift
index fbcb50f..ae8f813 100644
--- a/Tests/PoliceDataKitTests/Crimes/Models/CrimeTests.swift
+++ b/Tests/PoliceDataKitTests/Crimes/Models/CrimeTests.swift
@@ -1,3 +1,22 @@
+//
+// CrimeTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Extensions/DateFormatter+PoliceDataAPITests.swift b/Tests/PoliceDataKitTests/Extensions/DateFormatter+PoliceDataAPITests.swift
index 1b7c43f..505d74a 100644
--- a/Tests/PoliceDataKitTests/Extensions/DateFormatter+PoliceDataAPITests.swift
+++ b/Tests/PoliceDataKitTests/Extensions/DateFormatter+PoliceDataAPITests.swift
@@ -1,3 +1,22 @@
+//
+// DateFormatter+PoliceDataAPITests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Extensions/JSONDecoderDateDecodingStrategy+PoliceDataAPITests.swift b/Tests/PoliceDataKitTests/Extensions/JSONDecoderDateDecodingStrategy+PoliceDataAPITests.swift
index c30c39a..f302dcf 100644
--- a/Tests/PoliceDataKitTests/Extensions/JSONDecoderDateDecodingStrategy+PoliceDataAPITests.swift
+++ b/Tests/PoliceDataKitTests/Extensions/JSONDecoderDateDecodingStrategy+PoliceDataAPITests.swift
@@ -1,3 +1,22 @@
+//
+// JSONDecoderDateDecodingStrategy+PoliceDataAPITests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
@@ -22,7 +41,7 @@ final class JSONDecoderDateDecodingStrategyPoliceDataAPITestsTests: XCTestCase {
"date": "2021-05-24T11:28:00"
}
""".data(using: .utf8))
- let expectedResult = Date(timeIntervalSince1970: 1621855680)
+ let expectedResult = Date(timeIntervalSince1970: 1_621_855_680)
let container = try decoder.decode(Container.self, from: data)
let result = container.date
@@ -36,7 +55,7 @@ final class JSONDecoderDateDecodingStrategyPoliceDataAPITestsTests: XCTestCase {
"date": "2021-05-24T11:28:00-07:00"
}
""".data(using: .utf8))
- let expectedResult = Date(timeIntervalSince1970: 1621880880)
+ let expectedResult = Date(timeIntervalSince1970: 1_621_880_880)
let container = try decoder.decode(Container.self, from: data)
let result = container.date
@@ -50,7 +69,7 @@ final class JSONDecoderDateDecodingStrategyPoliceDataAPITestsTests: XCTestCase {
"date": "2021-05"
}
""".data(using: .utf8))
- let expectedResult = Date(timeIntervalSince1970: 1619827200)
+ let expectedResult = Date(timeIntervalSince1970: 1_619_827_200)
let container = try decoder.decode(Container.self, from: data)
let result = container.date
diff --git a/Tests/PoliceDataKitTests/Extensions/StringHTMLTests.swift b/Tests/PoliceDataKitTests/Extensions/StringHTMLTests.swift
index d0d6633..facb7ce 100644
--- a/Tests/PoliceDataKitTests/Extensions/StringHTMLTests.swift
+++ b/Tests/PoliceDataKitTests/Extensions/StringHTMLTests.swift
@@ -1,3 +1,22 @@
+//
+// StringHTMLTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
@@ -22,13 +41,13 @@ final class StringHTMLTests: XCTestCase {
func testHTMLStrippedWhenContainsHTMLTagReturnsSelfWithoutHTML() {
let value = "The Castle neighbourhood is a diverse covering all of the City Centre. In addition it covers "
- + "De Montfort University, the University of Leicester, Leicester Royal Infirmary, the Leicester Tigers "
- + "rugby ground and the Clarendon Park and Riverside communities.
\nThe Highcross and Haymarket "
- + "shopping centres and Leicester's famous Market are all covered by this neighbourhood.
"
+ + "De Montfort University, the University of Leicester, Leicester Royal Infirmary, the Leicester Tigers "
+ + "rugby ground and the Clarendon Park and Riverside communities.
\nThe Highcross and Haymarket "
+ + "shopping centres and Leicester's famous Market are all covered by this neighbourhood.
"
let expectedResult = "The Castle neighbourhood is a diverse covering all of the City Centre. In addition it "
- + "covers De Montfort University, the University of Leicester, Leicester Royal Infirmary, the Leicester Tigers "
- + "rugby ground and the Clarendon Park and Riverside communities. The Highcross and Haymarket shopping "
- + "centres and Leicester's famous Market are all covered by this neighbourhood."
+ + "covers De Montfort University, the University of Leicester, Leicester Royal Infirmary, the Leicester "
+ + "Tigers rugby ground and the Clarendon Park and Riverside communities. The Highcross and Haymarket "
+ + "shopping centres and Leicester's famous Market are all covered by this neighbourhood."
let result = value.htmlStripped
diff --git a/Tests/PoliceDataKitTests/Extensions/URL+QueryItemTests.swift b/Tests/PoliceDataKitTests/Extensions/URL+QueryItemTests.swift
index 5d43fd8..3512f32 100644
--- a/Tests/PoliceDataKitTests/Extensions/URL+QueryItemTests.swift
+++ b/Tests/PoliceDataKitTests/Extensions/URL+QueryItemTests.swift
@@ -1,3 +1,22 @@
+//
+// URL+QueryItemTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
@testable import PoliceDataKit
import XCTest
@@ -29,7 +48,7 @@ final class URLQueryItemTests: XCTestCase {
func testAppendingQueryItemWithDateWhenURLContainsNoQueryItemsAndNoDateFormatterReturnsURLWithYearMonthDate() {
let baseURL = URL(string: "https://some.domain.com")
let queryItemName = "date"
- let date = Date(timeIntervalSince1970: 1621850198) // 2021-05-24 09:56:38 +0000
+ let date = Date(timeIntervalSince1970: 1_621_850_198) // 2021-05-24 09:56:38 +0000
let expectedResult = URL(string: "https://some.domain.com?\(queryItemName)=2021-05")
let result = baseURL?.appendingQueryItem(name: queryItemName, date: date)
@@ -40,7 +59,7 @@ final class URLQueryItemTests: XCTestCase {
func testAppendingQueryItemWithDateWhenURLContainsQueryItemsAndNoDateFormatterReturnsURLWithYearMonthDate() {
let baseURL = URL(string: "https://some.domain.com?id=987")
let queryItemName = "date"
- let date = Date(timeIntervalSince1970: 1621850198) // 2021-05-24 09:56:38 +0000
+ let date = Date(timeIntervalSince1970: 1_621_850_198) // 2021-05-24 09:56:38 +0000
let expectedResult = URL(string: "https://some.domain.com?id=987&\(queryItemName)=2021-05")
let result = baseURL?.appendingQueryItem(name: queryItemName, date: date)
@@ -51,7 +70,7 @@ final class URLQueryItemTests: XCTestCase {
func testAppendingQueryItemWithDateWhenURLContainsNoQueryItemsAndWithDateFormatterReturnsURLWithFormattedDate() {
let baseURL = URL(string: "https://some.domain.com")
let queryItemName = "date"
- let date = Date(timeIntervalSince1970: 1621850198) // 2021-05-24 09:56:38 +0000
+ let date = Date(timeIntervalSince1970: 1_621_850_198) // 2021-05-24 09:56:38 +0000
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
let expectedResult = URL(string: "https://some.domain.com?\(queryItemName)=2021-05-24")
diff --git a/Tests/PoliceDataKitTests/General/Models/ContactDetailsTests.swift b/Tests/PoliceDataKitTests/General/Models/ContactDetailsTests.swift
index 1044630..6c7a8a2 100644
--- a/Tests/PoliceDataKitTests/General/Models/ContactDetailsTests.swift
+++ b/Tests/PoliceDataKitTests/General/Models/ContactDetailsTests.swift
@@ -1,3 +1,22 @@
+//
+// ContactDetailsTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/General/Models/GenderTests.swift b/Tests/PoliceDataKitTests/General/Models/GenderTests.swift
index f784687..d682ca5 100644
--- a/Tests/PoliceDataKitTests/General/Models/GenderTests.swift
+++ b/Tests/PoliceDataKitTests/General/Models/GenderTests.swift
@@ -1,3 +1,22 @@
+//
+// GenderTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/General/Models/LocationTests.swift b/Tests/PoliceDataKitTests/General/Models/LocationTests.swift
index d165ed5..e51c39c 100644
--- a/Tests/PoliceDataKitTests/General/Models/LocationTests.swift
+++ b/Tests/PoliceDataKitTests/General/Models/LocationTests.swift
@@ -1,3 +1,22 @@
+//
+// LocationTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/General/Models/MKCoordinateRegionContainsCoordinateTests.swift b/Tests/PoliceDataKitTests/General/Models/MKCoordinateRegionContainsCoordinateTests.swift
index f3061ed..0f55e4d 100644
--- a/Tests/PoliceDataKitTests/General/Models/MKCoordinateRegionContainsCoordinateTests.swift
+++ b/Tests/PoliceDataKitTests/General/Models/MKCoordinateRegionContainsCoordinateTests.swift
@@ -1,3 +1,22 @@
+//
+// MKCoordinateRegionContainsCoordinateTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import MapKit
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/General/Models/PoliceOfficerTests.swift b/Tests/PoliceDataKitTests/General/Models/PoliceOfficerTests.swift
index c2b9ff1..eab2b2e 100644
--- a/Tests/PoliceDataKitTests/General/Models/PoliceOfficerTests.swift
+++ b/Tests/PoliceDataKitTests/General/Models/PoliceOfficerTests.swift
@@ -1,3 +1,22 @@
+//
+// PoliceOfficerTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Helpers/Data+LoadFromFile.swift b/Tests/PoliceDataKitTests/Helpers/Data+LoadFromFile.swift
index b8817ba..68e124d 100644
--- a/Tests/PoliceDataKitTests/Helpers/Data+LoadFromFile.swift
+++ b/Tests/PoliceDataKitTests/Helpers/Data+LoadFromFile.swift
@@ -1,3 +1,22 @@
+//
+// Data+LoadFromFile.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
extension Data {
@@ -12,8 +31,4 @@ extension Data {
}
-struct LoadDataError: Error {
-
- init() { }
-
-}
+struct LoadDataError: Error {}
diff --git a/Tests/PoliceDataKitTests/Helpers/JSONDecoder+DecodeFromFile.swift b/Tests/PoliceDataKitTests/Helpers/JSONDecoder+DecodeFromFile.swift
index 125f37d..711d00b 100644
--- a/Tests/PoliceDataKitTests/Helpers/JSONDecoder+DecodeFromFile.swift
+++ b/Tests/PoliceDataKitTests/Helpers/JSONDecoder+DecodeFromFile.swift
@@ -1,9 +1,31 @@
+//
+// JSONDecoder+DecodeFromFile.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
extension JSONDecoder {
- func decode(_ type: T.Type, fromResource fileName: String,
- withExtension fileType: String = "json") throws -> T where T: Decodable {
+ func decode(
+ _: T.Type,
+ fromResource fileName: String,
+ withExtension fileType: String = "json"
+ ) throws -> T where T: Decodable {
let data = try Data(fromResource: fileName, withExtension: fileType)
return try decode(T.self, from: data)
}
diff --git a/Tests/PoliceDataKitTests/Helpers/MockError.swift b/Tests/PoliceDataKitTests/Helpers/MockError.swift
index 78f59b5..b8203ea 100644
--- a/Tests/PoliceDataKitTests/Helpers/MockError.swift
+++ b/Tests/PoliceDataKitTests/Helpers/MockError.swift
@@ -1,3 +1,22 @@
+//
+// MockError.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
struct MockError: LocalizedError {
diff --git a/Tests/PoliceDataKitTests/Helpers/URLProtocolMock.swift b/Tests/PoliceDataKitTests/Helpers/URLProtocolMock.swift
index af9c317..591ee8c 100644
--- a/Tests/PoliceDataKitTests/Helpers/URLProtocolMock.swift
+++ b/Tests/PoliceDataKitTests/Helpers/URLProtocolMock.swift
@@ -1,3 +1,22 @@
+//
+// URLProtocolMock.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
final class URLProtocolMock: URLProtocol {
@@ -10,12 +29,12 @@ final class URLProtocolMock: URLProtocol {
requests = []
}
- override class func canInit(with request: URLRequest) -> Bool {
- return true
+ override class func canInit(with _: URLRequest) -> Bool {
+ true
}
override class func canonicalRequest(for request: URLRequest) -> URLRequest {
- return request
+ request
}
override func startLoading() {
@@ -42,6 +61,6 @@ final class URLProtocolMock: URLProtocol {
}
}
- override func stopLoading() { }
+ override func stopLoading() {}
}
diff --git a/Tests/PoliceDataKitTests/Helpers/URLSessionConfiguration+Mock.swift b/Tests/PoliceDataKitTests/Helpers/URLSessionConfiguration+Mock.swift
index 4186cca..726e478 100644
--- a/Tests/PoliceDataKitTests/Helpers/URLSessionConfiguration+Mock.swift
+++ b/Tests/PoliceDataKitTests/Helpers/URLSessionConfiguration+Mock.swift
@@ -1,3 +1,22 @@
+//
+// URLSessionConfiguration+Mock.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
extension URLSessionConfiguration {
diff --git a/Tests/PoliceDataKitTests/Helpers/XCTestCase+URLProtocolMock.swift b/Tests/PoliceDataKitTests/Helpers/XCTestCase+URLProtocolMock.swift
index 99e5b6b..04579ef 100644
--- a/Tests/PoliceDataKitTests/Helpers/XCTestCase+URLProtocolMock.swift
+++ b/Tests/PoliceDataKitTests/Helpers/XCTestCase+URLProtocolMock.swift
@@ -1,3 +1,22 @@
+//
+// XCTestCase+URLProtocolMock.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
import XCTest
diff --git a/Tests/PoliceDataKitTests/Mocks/Cache/MockCache.swift b/Tests/PoliceDataKitTests/Mocks/Cache/MockCache.swift
index 42fc493..e05a3db 100644
--- a/Tests/PoliceDataKitTests/Mocks/Cache/MockCache.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Cache/MockCache.swift
@@ -1,3 +1,22 @@
+//
+// MockCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
@@ -9,11 +28,11 @@ final actor MockCache: Cache {
self.cacheStore = initialCacheStore
}
- func object(for key: some CustomStringConvertible, type: ObjectType.Type) async -> ObjectType? {
+ func object(for key: some CustomStringConvertible, type _: ObjectType.Type) async -> ObjectType? {
cacheStore[key.description] as? ObjectType
}
- func set(_ object: Any?, for key: some CustomStringConvertible, expiresIn: TimeInterval? = nil) async {
+ func set(_ object: Any?, for key: some CustomStringConvertible, expiresIn _: TimeInterval? = nil) async {
guard let object else {
cacheStore.removeValue(forKey: key.description)
return
diff --git a/Tests/PoliceDataKitTests/Mocks/Client/MockAPIClient.swift b/Tests/PoliceDataKitTests/Mocks/Client/MockAPIClient.swift
index 841e8ca..7ac7612 100644
--- a/Tests/PoliceDataKitTests/Mocks/Client/MockAPIClient.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Client/MockAPIClient.swift
@@ -1,3 +1,22 @@
+//
+// MockAPIClient.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Mocks/CoreLocation/CLLocationCoordinate2D+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/CoreLocation/CLLocationCoordinate2D+Mocks.swift
index 88c5420..d18ae93 100644
--- a/Tests/PoliceDataKitTests/Mocks/CoreLocation/CLLocationCoordinate2D+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/CoreLocation/CLLocationCoordinate2D+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// CLLocationCoordinate2D+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
diff --git a/Tests/PoliceDataKitTests/Mocks/MapKit/MKCoordinateRegion+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/MapKit/MKCoordinateRegion+Mocks.swift
index 32c2421..b9e73e5 100644
--- a/Tests/PoliceDataKitTests/Mocks/MapKit/MKCoordinateRegion+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/MapKit/MKCoordinateRegion+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// MKCoordinateRegion+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
import MapKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/CaseHistory+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/CaseHistory+Mocks.swift
index 8624d01..99ea00d 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/CaseHistory+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/CaseHistory+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// CaseHistory+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
@@ -6,7 +25,7 @@ extension CaseHistory {
static var mock: Self {
CaseHistory(
crime: CaseHistoryCrime(
- id: 82067369,
+ id: 82_067_369,
crimeID: "46688f40815e3a4cb7fcf69550492d8bffa4ed267652e676e49e23d00955c486",
context: "",
categoryID: "bicycle-theft",
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/ContactDetails+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/ContactDetails+Mocks.swift
index cb9461f..81494d5 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/ContactDetails+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/ContactDetails+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// ContactDetails+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/Crime+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/Crime+Mocks.swift
index 8a515e0..35f7de2 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/Crime+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/Crime+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// Crime+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@testable import PoliceDataKit
@@ -6,13 +25,13 @@ extension Crime {
static var mock: Self {
Crime(
- id: 81012437,
+ id: 81_012_437,
crimeID: "0e51b9ceb4aedef3f9679481aa11262a6c5ea90a68d0dd0e0002a0b521c445e0",
context: "",
categoryID: "violent-crime",
location: Location(
street: Street(
- id: 883345,
+ id: 883_345,
name: "On or near Marquis Street"
),
coordinate: CLLocationCoordinate2D(latitude: 52.629909, longitude: -1.132073)
@@ -31,13 +50,13 @@ extension Crime {
[
.mock,
Crime(
- id: 90362519,
+ id: 90_362_519,
crimeID: "5d512591e5dc9dd264a08c8dc133c3dde5c843d329928d1e6124bfe8fc9216a5",
context: "",
categoryID: "criminal-damage-arson",
location: Location(
street: Street(
- id: 886204,
+ id: 886_204,
name: "On or near Ostlers Drive"
),
coordinate: CLLocationCoordinate2D(latitude: 52.679277, longitude: -0.740683)
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/CrimeCategory+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/CrimeCategory+Mocks.swift
index 7b69eaf..58a84b0 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/CrimeCategory+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/CrimeCategory+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// CrimeCategory+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/CrimeLocationType+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/CrimeLocationType+Mocks.swift
index 6bd77b4..8f3d367 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/CrimeLocationType+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/CrimeLocationType+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// CrimeLocationType+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/DataSet+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/DataSet+Mocks.swift
index 1b428b5..2097afa 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/DataSet+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/DataSet+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// DataSet+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/EngagementMethod+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/EngagementMethod+Mocks.swift
index 79dd5d5..270749b 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/EngagementMethod+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/EngagementMethod+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// EngagementMethod+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/Link+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/Link+Mocks.swift
index 324bf86..0c94dc7 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/Link+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/Link+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// Link+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/Location+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/Location+Mocks.swift
index 59fc3ec..dc78790 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/Location+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/Location+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// Location+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@testable import PoliceDataKit
@@ -7,11 +26,10 @@ extension Location {
static var mock: Self {
Location(
street: Street(
- id: 883425,
+ id: 883_425,
name: "On or near Peacock Lane"
),
coordinate: CLLocationCoordinate2D(latitude: 52.633888, longitude: -1.138924)
-
)
}
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/Neighbourhood+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/Neighbourhood+Mocks.swift
index f1924a8..26be019 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/Neighbourhood+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/Neighbourhood+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// Neighbourhood+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodLocation+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodLocation+Mocks.swift
index 7cabd1b..394209d 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodLocation+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodLocation+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodLocation+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodPolicingTeam+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodPolicingTeam+Mocks.swift
index e9535f8..cb841ca 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodPolicingTeam+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodPolicingTeam+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodPolicingTeam+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodPriority+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodPriority+Mocks.swift
index b6f8eae..c9305ce 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodPriority+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodPriority+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodPriority+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodReference+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodReference+Mocks.swift
index facdea5..cf56551 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodReference+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/NeighbourhoodReference+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodReference+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/Outcome+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/Outcome+Mocks.swift
index 5e98acc..3b0e270 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/Outcome+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/Outcome+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// Outcome+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@testable import PoliceDataKit
@@ -13,13 +32,13 @@ extension Outcome {
name: "Investigation complete; no suspect identified"
),
crime: OutcomeCrime(
- id: 86783916,
+ id: 86_783_916,
crimeID: "c69de56fd2fcd523ab65b588811caf53e7ff3a577b2bfd2f731173f5f95af99d",
context: "",
categoryID: "burglary",
location: Location(
street: Street(
- id: 884330,
+ id: 884_330,
name: "On or near Christow Street"
),
coordinate: CLLocationCoordinate2D(latitude: 52.640374, longitude: -1.122319)
@@ -42,13 +61,13 @@ extension Outcome {
name: "Investigation incomplete"
),
crime: OutcomeCrime(
- id: 86783932232,
+ id: 86_783_932_232,
crimeID: "hfd78fd89s078f9ds789fds789fdfdjnmlnm4432",
context: "",
categoryID: "theft",
location: Location(
street: Street(
- id: 884330,
+ id: 884_330,
name: "On or near Christow Street"
),
coordinate: CLLocationCoordinate2D(latitude: 52.640374, longitude: -1.122319)
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/OutcomeCategory+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/OutcomeCategory+Mocks.swift
index 238052b..b31352d 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/OutcomeCategory+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/OutcomeCategory+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeCategory+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/OutcomeCrime+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/OutcomeCrime+Mocks.swift
index b201f23..c51d4c5 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/OutcomeCrime+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/OutcomeCrime+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeCrime+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@testable import PoliceDataKit
@@ -6,13 +25,13 @@ extension OutcomeCrime {
static var mock: Self {
OutcomeCrime(
- id: 86783916,
+ id: 86_783_916,
crimeID: "c69de56fd2fcd523ab65b588811caf53e7ff3a577b2bfd2f731173f5f95af99d",
context: "",
categoryID: "burglary",
location: Location(
street: Street(
- id: 884330,
+ id: 884_330,
name: "On or near Christow Street"
),
coordinate: CLLocationCoordinate2D(latitude: 52.640374, longitude: -1.122319)
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/OutcomeStatus+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/OutcomeStatus+Mocks.swift
index b250189..1070247 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/OutcomeStatus+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/OutcomeStatus+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeStatus+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/PoliceForce+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/PoliceForce+Mocks.swift
index 289c569..d4cf042 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/PoliceForce+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/PoliceForce+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForce+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/PoliceForceReference+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/PoliceForceReference+Mocks.swift
index f1cd5d1..26c2b42 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/PoliceForceReference+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/PoliceForceReference+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceReference+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/PoliceOfficer+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/PoliceOfficer+Mocks.swift
index 91dc759..94b706a 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/PoliceOfficer+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/PoliceOfficer+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// PoliceOfficer+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Mocks/Models/StopAndSearch+Mocks.swift b/Tests/PoliceDataKitTests/Mocks/Models/StopAndSearch+Mocks.swift
index bfeff90..f6f9558 100644
--- a/Tests/PoliceDataKitTests/Mocks/Models/StopAndSearch+Mocks.swift
+++ b/Tests/PoliceDataKitTests/Mocks/Models/StopAndSearch+Mocks.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearch+Mocks.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@testable import PoliceDataKit
@@ -18,7 +37,7 @@ extension StopAndSearch {
operationName: nil,
location: Location(
street: Street(
- id: 883415,
+ id: 883_415,
name: "On or near Shopping Area"
),
coordinate: CLLocationCoordinate2D(latitude: 52.63625, longitude: -1.133691)
@@ -45,7 +64,7 @@ extension StopAndSearch {
operationName: nil,
location: Location(
street: Street(
- id: 883415,
+ id: 883_415,
name: "On or near Shopping Area"
),
coordinate: CLLocationCoordinate2D(latitude: 52.63625, longitude: -1.133691)
diff --git a/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodBoundaryCachingKeyTests.swift b/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodBoundaryCachingKeyTests.swift
index 44ca020..cd00b37 100644
--- a/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodBoundaryCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodBoundaryCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodBoundaryCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodCachingKeyTests.swift b/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodCachingKeyTests.swift
index 406b058..ad7c421 100644
--- a/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPoliceOfficersCachingKeyTests.swift b/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPoliceOfficersCachingKeyTests.swift
index 34ab5db..1dfc8ea 100644
--- a/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPoliceOfficersCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPoliceOfficersCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodPoliceOfficersCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPrioritiesCachingKeyTests.swift b/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPrioritiesCachingKeyTests.swift
index ada79fd..4cd3d11 100644
--- a/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPrioritiesCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodPrioritiesCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodPrioritiesCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodsInPoliceForceCachingKeyTests.swift b/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodsInPoliceForceCachingKeyTests.swift
index 9eb1fb9..2e859da 100644
--- a/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodsInPoliceForceCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/Neighbourhoods/Cache/CachingKeys/NeighbourhoodsInPoliceForceCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodsInPoliceForceCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Neighbourhoods/Cache/NeighbourhoodDefaultCacheTests.swift b/Tests/PoliceDataKitTests/Neighbourhoods/Cache/NeighbourhoodDefaultCacheTests.swift
index b2bed0a..a7ff277 100644
--- a/Tests/PoliceDataKitTests/Neighbourhoods/Cache/NeighbourhoodDefaultCacheTests.swift
+++ b/Tests/PoliceDataKitTests/Neighbourhoods/Cache/NeighbourhoodDefaultCacheTests.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodDefaultCacheTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
@testable import PoliceDataKit
import XCTest
@@ -123,8 +142,10 @@ final class NeighbourhoodDefaultCacheTests: XCTestCase {
func testPoliceOfficersForNeighbourhoodWhenHitReturnsPoliceOfficers() async {
let neighbourhoodID = "test-neighbourhood"
let policeForceID = "test-police-force"
- let cacheKey = NeighbourhoodPoliceOfficersCachingKey(neighbourhoodID: neighbourhoodID,
- policeForceID: policeForceID)
+ let cacheKey = NeighbourhoodPoliceOfficersCachingKey(
+ neighbourhoodID: neighbourhoodID,
+ policeForceID: policeForceID
+ )
let expectedResult = PoliceOfficer.mocks
await cacheStore.set(expectedResult, for: cacheKey)
@@ -136,8 +157,10 @@ final class NeighbourhoodDefaultCacheTests: XCTestCase {
func testSetPoliceOfficersForNeighbourhoodSetsPoliceOfficers() async {
let neighbourhoodID = "test-neighbourhood"
let policeForceID = "test-police-force"
- let cacheKey = NeighbourhoodPoliceOfficersCachingKey(neighbourhoodID: neighbourhoodID,
- policeForceID: policeForceID)
+ let cacheKey = NeighbourhoodPoliceOfficersCachingKey(
+ neighbourhoodID: neighbourhoodID,
+ policeForceID: policeForceID
+ )
let expectedResult = PoliceOfficer.mocks
await cache.setPoliceOfficers(expectedResult, forNeighbourhood: neighbourhoodID, inPoliceForce: policeForceID)
diff --git a/Tests/PoliceDataKitTests/Neighbourhoods/Endpoints/NeighbourhoodsEndpointTests.swift b/Tests/PoliceDataKitTests/Neighbourhoods/Endpoints/NeighbourhoodsEndpointTests.swift
index 7fdb129..6b2efbc 100644
--- a/Tests/PoliceDataKitTests/Neighbourhoods/Endpoints/NeighbourhoodsEndpointTests.swift
+++ b/Tests/PoliceDataKitTests/Neighbourhoods/Endpoints/NeighbourhoodsEndpointTests.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodsEndpointTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Neighbourhoods/Mocks/NeighbourhoodMockCache.swift b/Tests/PoliceDataKitTests/Neighbourhoods/Mocks/NeighbourhoodMockCache.swift
index d6d5286..60e7a1b 100644
--- a/Tests/PoliceDataKitTests/Neighbourhoods/Mocks/NeighbourhoodMockCache.swift
+++ b/Tests/PoliceDataKitTests/Neighbourhoods/Mocks/NeighbourhoodMockCache.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodMockCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
import Foundation
@testable import PoliceDataKit
@@ -12,7 +31,7 @@ final class NeighbourhoodMockCache: NeighbourhoodCache {
"neighbourhoods-police-force-\(policeForceID)"
}
- static func neighbourhood(id: String, policeForceID: PoliceForce.ID) -> String {
+ static func neighbourhood(id: String, policeForceID _: PoliceForce.ID) -> String {
"neighbourhood-\(id)"
}
@@ -34,8 +53,10 @@ final class NeighbourhoodMockCache: NeighbourhoodCache {
cacheStore[CacheKey.neighbourhoods(policeForceID: policeForceID)] as? [NeighbourhoodReference]
}
- func setNeighbourhoods(_ neighbourhoods: [NeighbourhoodReference],
- inPoliceForce policeForceID: PoliceForce.ID) async {
+ func setNeighbourhoods(
+ _ neighbourhoods: [NeighbourhoodReference],
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async {
cacheStore[CacheKey.neighbourhoods(policeForceID: policeForceID)] = neighbourhoods
}
@@ -43,43 +64,61 @@ final class NeighbourhoodMockCache: NeighbourhoodCache {
cacheStore[CacheKey.neighbourhood(id: id, policeForceID: policeForceID)] as? Neighbourhood
}
- func setNeighbourhood(_ neighbourhood: Neighbourhood, withID id: String,
- inPoliceForce policeForceID: PoliceForce.ID) async {
+ func setNeighbourhood(
+ _ neighbourhood: Neighbourhood,
+ withID id: String,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async {
cacheStore[CacheKey.neighbourhood(id: id, policeForceID: policeForceID)] = neighbourhood
}
- func boundary(forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async -> [CLLocationCoordinate2D]? {
+ func boundary(
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async -> [CLLocationCoordinate2D]? {
let key = CacheKey.boundary(neighbourhoodID: neighbourhoodID, policeForceID: policeForceID)
return cacheStore[key] as? [CLLocationCoordinate2D]
}
- func setBoundary(_ coordinates: [CLLocationCoordinate2D], forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async {
+ func setBoundary(
+ _ coordinates: [CLLocationCoordinate2D],
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async {
let key = CacheKey.boundary(neighbourhoodID: neighbourhoodID, policeForceID: policeForceID)
cacheStore[key] = coordinates
}
- func policeOfficers(forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async -> [PoliceOfficer]? {
+ func policeOfficers(
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async -> [PoliceOfficer]? {
let key = CacheKey.policeOfficers(neighbourhoodID: neighbourhoodID, policeForceID: policeForceID)
return cacheStore[key] as? [PoliceOfficer]
}
- func setPoliceOfficers(_ policeOfficers: [PoliceOfficer], forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async {
+ func setPoliceOfficers(
+ _ policeOfficers: [PoliceOfficer],
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async {
let key = CacheKey.policeOfficers(neighbourhoodID: neighbourhoodID, policeForceID: policeForceID)
cacheStore[key] = policeOfficers
}
- func priorities(forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async -> [NeighbourhoodPriority]? {
+ func priorities(
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async -> [NeighbourhoodPriority]? {
let key = CacheKey.priorities(neighbourhoodID: neighbourhoodID, policeForceID: policeForceID)
return cacheStore[key] as? [NeighbourhoodPriority]
}
- func setPriorities(_ priorities: [NeighbourhoodPriority], forNeighbourhood neighbourhoodID: Neighbourhood.ID,
- inPoliceForce policeForceID: PoliceForce.ID) async {
+ func setPriorities(
+ _ priorities: [NeighbourhoodPriority],
+ forNeighbourhood neighbourhoodID: Neighbourhood.ID,
+ inPoliceForce policeForceID: PoliceForce.ID
+ ) async {
let key = CacheKey.priorities(neighbourhoodID: neighbourhoodID, policeForceID: policeForceID)
cacheStore[key] = priorities
}
diff --git a/Tests/PoliceDataKitTests/Neighbourhoods/Models/LinkTests.swift b/Tests/PoliceDataKitTests/Neighbourhoods/Models/LinkTests.swift
index fc775c6..29e8a38 100644
--- a/Tests/PoliceDataKitTests/Neighbourhoods/Models/LinkTests.swift
+++ b/Tests/PoliceDataKitTests/Neighbourhoods/Models/LinkTests.swift
@@ -1,3 +1,22 @@
+//
+// LinkTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodLocationTests.swift b/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodLocationTests.swift
index 2b42cd0..5ef5df6 100644
--- a/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodLocationTests.swift
+++ b/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodLocationTests.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodLocationTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodPolicingTeamTests.swift b/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodPolicingTeamTests.swift
index 4a55629..55d3f40 100644
--- a/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodPolicingTeamTests.swift
+++ b/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodPolicingTeamTests.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodPolicingTeamTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodPriorityTests.swift b/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodPriorityTests.swift
index be47f3d..bc7264d 100644
--- a/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodPriorityTests.swift
+++ b/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodPriorityTests.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodPriorityTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodReferenceTests.swift b/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodReferenceTests.swift
index ecf45d6..22d0405 100644
--- a/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodReferenceTests.swift
+++ b/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodReferenceTests.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodReferenceTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodTests.swift b/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodTests.swift
index 8fab24b..e7ab4de 100644
--- a/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodTests.swift
+++ b/Tests/PoliceDataKitTests/Neighbourhoods/Models/NeighbourhoodTests.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Neighbourhoods/NeighbourhoodServiceTests.swift b/Tests/PoliceDataKitTests/Neighbourhoods/NeighbourhoodServiceTests.swift
index 1f5f610..6e9d62c 100644
--- a/Tests/PoliceDataKitTests/Neighbourhoods/NeighbourhoodServiceTests.swift
+++ b/Tests/PoliceDataKitTests/Neighbourhoods/NeighbourhoodServiceTests.swift
@@ -1,3 +1,22 @@
+//
+// NeighbourhoodServiceTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Combine
import MapKit
@testable import PoliceDataKit
@@ -159,7 +178,7 @@ extension NeighbourhoodServiceTests {
apiClient.add(response: .success(neighbourhoodPolicingTeam))
apiClient.add(response: .success(expectedResult))
- let expectation = self.expectation(description: "NeighbourhoodPublisher")
+ let expectation = expectation(description: "NeighbourhoodPublisher")
var result: Neighbourhood?
service.neighbourhoodPublisher(at: coordinate)
.sink { _ in
@@ -255,8 +274,10 @@ extension NeighbourhoodServiceTests {
let expectedResult = PoliceOfficer.mocks
apiClient.add(response: .success(PoliceOfficer.mocks))
- let result = try await service.policeOfficers(forNeighbourhood: neighbourhoodID,
- inPoliceForce: policeForceID)
+ let result = try await service.policeOfficers(
+ forNeighbourhood: neighbourhoodID,
+ inPoliceForce: policeForceID
+ )
XCTAssertEqual(result, expectedResult)
XCTAssertEqual(apiClient.requestedURLs.count, 1)
@@ -388,7 +409,7 @@ extension NeighbourhoodServiceTests {
let expectedResult = NeighbourhoodPolicingTeam.mock
apiClient.add(response: .success(NeighbourhoodPolicingTeam.mock))
- let expectation = self.expectation(description: "NeighbourhoodPolicingTeamPublisher")
+ let expectation = expectation(description: "NeighbourhoodPolicingTeamPublisher")
var result: NeighbourhoodPolicingTeam?
service.neighbourhoodPolicingTeamPublisher(at: coordinate)
.sink { _ in
diff --git a/Tests/PoliceDataKitTests/Networking/JSONSerialiserTests.swift b/Tests/PoliceDataKitTests/Networking/JSONSerialiserTests.swift
index ed7f8a7..6dda2fd 100644
--- a/Tests/PoliceDataKitTests/Networking/JSONSerialiserTests.swift
+++ b/Tests/PoliceDataKitTests/Networking/JSONSerialiserTests.swift
@@ -1,3 +1,22 @@
+//
+// JSONSerialiserTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Networking/MockURLProtocol.swift b/Tests/PoliceDataKitTests/Networking/MockURLProtocol.swift
index 3e608d3..3d79530 100644
--- a/Tests/PoliceDataKitTests/Networking/MockURLProtocol.swift
+++ b/Tests/PoliceDataKitTests/Networking/MockURLProtocol.swift
@@ -1,3 +1,22 @@
+//
+// MockURLProtocol.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
final class MockURLProtocol: URLProtocol {
@@ -5,9 +24,9 @@ final class MockURLProtocol: URLProtocol {
static var data: Data?
static var failError: Error?
static var responseStatusCode: Int = 200
- static private(set) var lastRequest: URLRequest?
+ private(set) static var lastRequest: URLRequest?
- override class func canInit(with request: URLRequest) -> Bool {
+ override class func canInit(with _: URLRequest) -> Bool {
true
}
@@ -18,7 +37,7 @@ final class MockURLProtocol: URLProtocol {
override func startLoading() {
if let failError = Self.failError {
- self.client?.urlProtocol(self, didFailWithError: failError)
+ client?.urlProtocol(self, didFailWithError: failError)
return
}
@@ -27,16 +46,20 @@ final class MockURLProtocol: URLProtocol {
}
if let data = Self.data {
- self.client?.urlProtocol(self, didLoad: data)
+ client?.urlProtocol(self, didLoad: data)
}
- let response = HTTPURLResponse(url: url, statusCode: Self.responseStatusCode, httpVersion: "2.0",
- headerFields: nil)!
- self.client?.urlProtocol(self, didReceive: response, cacheStoragePolicy: .notAllowed)
- self.client?.urlProtocolDidFinishLoading(self)
+ let response = HTTPURLResponse(
+ url: url,
+ statusCode: Self.responseStatusCode,
+ httpVersion: "2.0",
+ headerFields: nil
+ )!
+ client?.urlProtocol(self, didReceive: response, cacheStoragePolicy: .notAllowed)
+ client?.urlProtocolDidFinishLoading(self)
}
- override func stopLoading() { }
+ override func stopLoading() {}
static func reset() {
data = nil
diff --git a/Tests/PoliceDataKitTests/Networking/PoliceDataAPIClientTests.swift b/Tests/PoliceDataKitTests/Networking/PoliceDataAPIClientTests.swift
index 7801134..a5d514d 100644
--- a/Tests/PoliceDataKitTests/Networking/PoliceDataAPIClientTests.swift
+++ b/Tests/PoliceDataKitTests/Networking/PoliceDataAPIClientTests.swift
@@ -1,3 +1,22 @@
+//
+// PoliceDataAPIClientTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
@@ -27,32 +46,34 @@ final class PoliceDataAPIClientTests: XCTestCase {
super.tearDown()
}
- func testGetWhenRequestFailsThrowsNetworkError() async throws {
- let expectedError = NSError(domain: NSURLErrorDomain, code: URLError.badServerResponse.rawValue)
- MockURLProtocol.failError = expectedError
- let path = try XCTUnwrap(URL(string: "/error"))
-
- do {
- _ = try await apiClient.get(path: path) as String
- } catch let error as APIClientError {
- switch error {
- case .network(let error as NSError):
- XCTAssertEqual(error.code, expectedError.code)
- return
- default:
- break
+ #if !os(watchOS)
+ func testGetWhenRequestFailsThrowsNetworkError() async throws {
+ let expectedError = NSError(domain: NSURLErrorDomain, code: URLError.badServerResponse.rawValue)
+ MockURLProtocol.failError = expectedError
+ let path = try XCTUnwrap(URL(string: "/error"))
+
+ do {
+ _ = try await apiClient.get(path: path) as String
+ } catch let error as APIClientError {
+ switch error {
+ case let .network(error as NSError):
+ XCTAssertEqual(error.code, expectedError.code)
+ return
+ default:
+ break
+ }
}
- }
- XCTFail("Expected error to be thrown")
- }
+ XCTFail("Expected error to be thrown")
+ }
+ #endif
func testGetWhenResponseStatusCodeIs404ReturnsNotFoundError() async throws {
MockURLProtocol.responseStatusCode = 404
let path = try XCTUnwrap(URL(string: "/error"))
do {
- _ = try await apiClient.get(path: path) as String
+ _ = try await apiClient.get(path: path) as String
} catch let error as APIClientError {
switch error {
case .notFound:
@@ -71,7 +92,7 @@ final class PoliceDataAPIClientTests: XCTestCase {
let path = try XCTUnwrap(URL(string: "/error"))
do {
- _ = try await apiClient.get(path: path) as String
+ _ = try await apiClient.get(path: path) as String
} catch let error as APIClientError {
switch error {
case .unknown:
diff --git a/Tests/PoliceDataKitTests/Outcomes/Cache/CachingKeys/OutcomesAtStreetLevelForStreetCachingKeyTests.swift b/Tests/PoliceDataKitTests/Outcomes/Cache/CachingKeys/OutcomesAtStreetLevelForStreetCachingKeyTests.swift
index 6b103b6..c1347e7 100644
--- a/Tests/PoliceDataKitTests/Outcomes/Cache/CachingKeys/OutcomesAtStreetLevelForStreetCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/Outcomes/Cache/CachingKeys/OutcomesAtStreetLevelForStreetCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// OutcomesAtStreetLevelForStreetCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Outcomes/Cache/CachingKeys/OutcomesForCrimeCachingKeyTests.swift b/Tests/PoliceDataKitTests/Outcomes/Cache/CachingKeys/OutcomesForCrimeCachingKeyTests.swift
index c16dcb3..4e27ed2 100644
--- a/Tests/PoliceDataKitTests/Outcomes/Cache/CachingKeys/OutcomesForCrimeCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/Outcomes/Cache/CachingKeys/OutcomesForCrimeCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// OutcomesForCrimeCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Outcomes/Cache/OutcomeDefaultCacheTests.swift b/Tests/PoliceDataKitTests/Outcomes/Cache/OutcomeDefaultCacheTests.swift
index 004aa61..7f58306 100644
--- a/Tests/PoliceDataKitTests/Outcomes/Cache/OutcomeDefaultCacheTests.swift
+++ b/Tests/PoliceDataKitTests/Outcomes/Cache/OutcomeDefaultCacheTests.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeDefaultCacheTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Outcomes/Endpoints/OutcomesEndpointTests.swift b/Tests/PoliceDataKitTests/Outcomes/Endpoints/OutcomesEndpointTests.swift
index 3a79cbd..6d8dcc4 100644
--- a/Tests/PoliceDataKitTests/Outcomes/Endpoints/OutcomesEndpointTests.swift
+++ b/Tests/PoliceDataKitTests/Outcomes/Endpoints/OutcomesEndpointTests.swift
@@ -1,3 +1,22 @@
+//
+// OutcomesEndpointTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Outcomes/Mocks/OutcomeMockCache.swift b/Tests/PoliceDataKitTests/Outcomes/Mocks/OutcomeMockCache.swift
index 28e5e6e..0a19139 100644
--- a/Tests/PoliceDataKitTests/Outcomes/Mocks/OutcomeMockCache.swift
+++ b/Tests/PoliceDataKitTests/Outcomes/Mocks/OutcomeMockCache.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeMockCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/Outcomes/Models/CaseHistoryTests.swift b/Tests/PoliceDataKitTests/Outcomes/Models/CaseHistoryTests.swift
index bec9ade..fc92fe0 100644
--- a/Tests/PoliceDataKitTests/Outcomes/Models/CaseHistoryTests.swift
+++ b/Tests/PoliceDataKitTests/Outcomes/Models/CaseHistoryTests.swift
@@ -1,3 +1,22 @@
+//
+// CaseHistoryTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeCategoryTests.swift b/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeCategoryTests.swift
index ab159eb..a121181 100644
--- a/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeCategoryTests.swift
+++ b/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeCategoryTests.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeCategoryTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeCrimeTests.swift b/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeCrimeTests.swift
index 37ab0ec..248b54f 100644
--- a/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeCrimeTests.swift
+++ b/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeCrimeTests.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeCrimeTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeStatusDataModelTests.swift b/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeStatusDataModelTests.swift
index 4c51dbc..5a52674 100644
--- a/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeStatusDataModelTests.swift
+++ b/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeStatusDataModelTests.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeStatusDataModelTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeTests.swift b/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeTests.swift
index 58809ff..d89d96d 100644
--- a/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeTests.swift
+++ b/Tests/PoliceDataKitTests/Outcomes/Models/OutcomeTests.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/Outcomes/OutcomeServiceTests.swift b/Tests/PoliceDataKitTests/Outcomes/OutcomeServiceTests.swift
index 7ad9fe9..b109904 100644
--- a/Tests/PoliceDataKitTests/Outcomes/OutcomeServiceTests.swift
+++ b/Tests/PoliceDataKitTests/Outcomes/OutcomeServiceTests.swift
@@ -1,3 +1,22 @@
+//
+// OutcomeServiceTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Combine
import MapKit
@testable import PoliceDataKit
@@ -91,7 +110,7 @@ final class OutcomeServiceTests: XCTestCase {
let date = Date()
apiClient.add(response: .success(Outcome.mocks))
- let expectation = self.expectation(description: "StreetLevelOutcomesPublisher")
+ let expectation = expectation(description: "StreetLevelOutcomesPublisher")
var result: [Outcome]?
service.streetLevelOutcomesPublisher(at: coordinate)
.sink { _ in
@@ -149,7 +168,7 @@ final class OutcomeServiceTests: XCTestCase {
let date = Date()
apiClient.add(response: .success(Outcome.mocks))
- let expectation = self.expectation(description: "StreetLevelOutcomesPublisher")
+ let expectation = expectation(description: "StreetLevelOutcomesPublisher")
var result: [Outcome]?
service.streetLevelOutcomesPublisher(in: boundary)
.sink { _ in
diff --git a/Tests/PoliceDataKitTests/PoliceForces/Cache/CachingKeys/PoliceForceCachingKeyTests.swift b/Tests/PoliceDataKitTests/PoliceForces/Cache/CachingKeys/PoliceForceCachingKeyTests.swift
index 60f130d..cfdf283 100644
--- a/Tests/PoliceDataKitTests/PoliceForces/Cache/CachingKeys/PoliceForceCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/PoliceForces/Cache/CachingKeys/PoliceForceCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/PoliceForces/Cache/CachingKeys/PoliceForceSeniorOfficersCachingKeyTests.swift b/Tests/PoliceDataKitTests/PoliceForces/Cache/CachingKeys/PoliceForceSeniorOfficersCachingKeyTests.swift
index 7d25c50..a0996d7 100644
--- a/Tests/PoliceDataKitTests/PoliceForces/Cache/CachingKeys/PoliceForceSeniorOfficersCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/PoliceForces/Cache/CachingKeys/PoliceForceSeniorOfficersCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceSeniorOfficersCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/PoliceForces/Cache/CachingKeys/PoliceForcesCachingKeyTests.swift b/Tests/PoliceDataKitTests/PoliceForces/Cache/CachingKeys/PoliceForcesCachingKeyTests.swift
index b9a8716..b37d812 100644
--- a/Tests/PoliceDataKitTests/PoliceForces/Cache/CachingKeys/PoliceForcesCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/PoliceForces/Cache/CachingKeys/PoliceForcesCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForcesCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/PoliceForces/Cache/PoliceForceDefaultCacheTests.swift b/Tests/PoliceDataKitTests/PoliceForces/Cache/PoliceForceDefaultCacheTests.swift
index 02dce8c..927e0c9 100644
--- a/Tests/PoliceDataKitTests/PoliceForces/Cache/PoliceForceDefaultCacheTests.swift
+++ b/Tests/PoliceDataKitTests/PoliceForces/Cache/PoliceForceDefaultCacheTests.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceDefaultCacheTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/PoliceForces/Endpoints/PoliceForcesEndpointTests.swift b/Tests/PoliceDataKitTests/PoliceForces/Endpoints/PoliceForcesEndpointTests.swift
index 5a56dc8..d76adf0 100644
--- a/Tests/PoliceDataKitTests/PoliceForces/Endpoints/PoliceForcesEndpointTests.swift
+++ b/Tests/PoliceDataKitTests/PoliceForces/Endpoints/PoliceForcesEndpointTests.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForcesEndpointTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/PoliceForces/Mocks/PoliceForceMockCache.swift b/Tests/PoliceDataKitTests/PoliceForces/Mocks/PoliceForceMockCache.swift
index 31a0331..6f8cb27 100644
--- a/Tests/PoliceDataKitTests/PoliceForces/Mocks/PoliceForceMockCache.swift
+++ b/Tests/PoliceDataKitTests/PoliceForces/Mocks/PoliceForceMockCache.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceMockCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
diff --git a/Tests/PoliceDataKitTests/PoliceForces/Models/EngagementMethodTests.swift b/Tests/PoliceDataKitTests/PoliceForces/Models/EngagementMethodTests.swift
index 44d03e5..53834e0 100644
--- a/Tests/PoliceDataKitTests/PoliceForces/Models/EngagementMethodTests.swift
+++ b/Tests/PoliceDataKitTests/PoliceForces/Models/EngagementMethodTests.swift
@@ -1,3 +1,22 @@
+//
+// EngagementMethodTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/PoliceForces/Models/PoliceForceReferenceTests.swift b/Tests/PoliceDataKitTests/PoliceForces/Models/PoliceForceReferenceTests.swift
index 8883b5c..e45bb18 100644
--- a/Tests/PoliceDataKitTests/PoliceForces/Models/PoliceForceReferenceTests.swift
+++ b/Tests/PoliceDataKitTests/PoliceForces/Models/PoliceForceReferenceTests.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceReferenceTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/PoliceForces/Models/PoliceForceTests.swift b/Tests/PoliceDataKitTests/PoliceForces/Models/PoliceForceTests.swift
index f28723f..f277073 100644
--- a/Tests/PoliceDataKitTests/PoliceForces/Models/PoliceForceTests.swift
+++ b/Tests/PoliceDataKitTests/PoliceForces/Models/PoliceForceTests.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/PoliceForces/PoliceForceServiceTests.swift b/Tests/PoliceDataKitTests/PoliceForces/PoliceForceServiceTests.swift
index 2f0362d..458b0c2 100644
--- a/Tests/PoliceDataKitTests/PoliceForces/PoliceForceServiceTests.swift
+++ b/Tests/PoliceDataKitTests/PoliceForces/PoliceForceServiceTests.swift
@@ -1,3 +1,22 @@
+//
+// PoliceForceServiceTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/StopsAndSearches/Cache/CachingKeys/StopAndSearchesAtLocationCachingKeyTests.swift b/Tests/PoliceDataKitTests/StopsAndSearches/Cache/CachingKeys/StopAndSearchesAtLocationCachingKeyTests.swift
index 9f0220e..bab0d77 100644
--- a/Tests/PoliceDataKitTests/StopsAndSearches/Cache/CachingKeys/StopAndSearchesAtLocationCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/StopsAndSearches/Cache/CachingKeys/StopAndSearchesAtLocationCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchesAtLocationCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/StopsAndSearches/Cache/CachingKeys/StopAndSearchesForPoliceForceCachingKeyTests.swift b/Tests/PoliceDataKitTests/StopsAndSearches/Cache/CachingKeys/StopAndSearchesForPoliceForceCachingKeyTests.swift
index fb2cc2b..ed9bcde 100644
--- a/Tests/PoliceDataKitTests/StopsAndSearches/Cache/CachingKeys/StopAndSearchesForPoliceForceCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/StopsAndSearches/Cache/CachingKeys/StopAndSearchesForPoliceForceCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchesForPoliceForceCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/StopsAndSearches/Cache/CachingKeys/StopAndSearchesWithNoLocationCachingKeyTests.swift b/Tests/PoliceDataKitTests/StopsAndSearches/Cache/CachingKeys/StopAndSearchesWithNoLocationCachingKeyTests.swift
index c7fc4f3..1cdc678 100644
--- a/Tests/PoliceDataKitTests/StopsAndSearches/Cache/CachingKeys/StopAndSearchesWithNoLocationCachingKeyTests.swift
+++ b/Tests/PoliceDataKitTests/StopsAndSearches/Cache/CachingKeys/StopAndSearchesWithNoLocationCachingKeyTests.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchesWithNoLocationCachingKeyTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/StopsAndSearches/Cache/StopAndSearchDefaultCacheTests.swift b/Tests/PoliceDataKitTests/StopsAndSearches/Cache/StopAndSearchDefaultCacheTests.swift
index 02e20b6..c33f835 100644
--- a/Tests/PoliceDataKitTests/StopsAndSearches/Cache/StopAndSearchDefaultCacheTests.swift
+++ b/Tests/PoliceDataKitTests/StopsAndSearches/Cache/StopAndSearchDefaultCacheTests.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchDefaultCacheTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/StopsAndSearches/Endpoints/StopAndSearchesEndpointTests.swift b/Tests/PoliceDataKitTests/StopsAndSearches/Endpoints/StopAndSearchesEndpointTests.swift
index 0abac1e..a6d3135 100644
--- a/Tests/PoliceDataKitTests/StopsAndSearches/Endpoints/StopAndSearchesEndpointTests.swift
+++ b/Tests/PoliceDataKitTests/StopsAndSearches/Endpoints/StopAndSearchesEndpointTests.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchesEndpointTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import CoreLocation
@testable import PoliceDataKit
import XCTest
@@ -28,7 +47,7 @@ final class StopAndSearchesEndpointTests: XCTestCase {
}
func testStopAndSearchesAtLocationEndpointReturnsURL() throws {
- let streetID = 883407
+ let streetID = 883_407
let date = Date(timeIntervalSince1970: 0)
let expectedPath = try XCTUnwrap(URL(string: "/stops-at-location?location_id=\(streetID)&date=1970-01"))
diff --git a/Tests/PoliceDataKitTests/StopsAndSearches/Mocks/StopAndSearchMockCache.swift b/Tests/PoliceDataKitTests/StopsAndSearches/Mocks/StopAndSearchMockCache.swift
index aca5441..89e44ad 100644
--- a/Tests/PoliceDataKitTests/StopsAndSearches/Mocks/StopAndSearchMockCache.swift
+++ b/Tests/PoliceDataKitTests/StopsAndSearches/Mocks/StopAndSearchMockCache.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchMockCache.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Foundation
@testable import PoliceDataKit
@@ -29,13 +48,18 @@ final class StopAndSearchMockCache: StopAndSearchCache {
cacheStore[CacheKey.stopAndSearches(streetID: streetID, date: date)] = stopAndSearches
}
- func stopAndSearchesWithNoLocation(forPoliceForce policeForceID: PoliceForce.ID,
- date: Date) async -> [StopAndSearch]? {
+ func stopAndSearchesWithNoLocation(
+ forPoliceForce policeForceID: PoliceForce.ID,
+ date: Date
+ ) async -> [StopAndSearch]? {
cacheStore[CacheKey.stopAndSearchesWithNoLocation(policeForceID: policeForceID, date: date)] as? [StopAndSearch]
}
- func setStopAndSearchesWithNoLocation(_ stopAndSearches: [StopAndSearch],
- forPoliceForce policeForceID: PoliceForce.ID, date: Date) async {
+ func setStopAndSearchesWithNoLocation(
+ _ stopAndSearches: [StopAndSearch],
+ forPoliceForce policeForceID: PoliceForce.ID,
+ date: Date
+ ) async {
cacheStore[CacheKey.stopAndSearchesWithNoLocation(policeForceID: policeForceID, date: date)] = stopAndSearches
}
@@ -43,8 +67,11 @@ final class StopAndSearchMockCache: StopAndSearchCache {
cacheStore[CacheKey.stopAndSearches(policeForceID: policeForceID, date: date)] as? [StopAndSearch]
}
- func setStopAndSearches(_ stopAndSearches: [StopAndSearch], forPoliceForce policeForceID: PoliceForce.ID,
- date: Date) async {
+ func setStopAndSearches(
+ _ stopAndSearches: [StopAndSearch],
+ forPoliceForce policeForceID: PoliceForce.ID,
+ date: Date
+ ) async {
cacheStore[CacheKey.stopAndSearches(policeForceID: policeForceID, date: date)] = stopAndSearches
}
diff --git a/Tests/PoliceDataKitTests/StopsAndSearches/Models/StopAndSearchTests.swift b/Tests/PoliceDataKitTests/StopsAndSearches/Models/StopAndSearchTests.swift
index 687df11..9d38b67 100644
--- a/Tests/PoliceDataKitTests/StopsAndSearches/Models/StopAndSearchTests.swift
+++ b/Tests/PoliceDataKitTests/StopsAndSearches/Models/StopAndSearchTests.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/StopsAndSearches/Models/StopAndSearchTypeTests.swift b/Tests/PoliceDataKitTests/StopsAndSearches/Models/StopAndSearchTypeTests.swift
index 9715fe2..94f8576 100644
--- a/Tests/PoliceDataKitTests/StopsAndSearches/Models/StopAndSearchTypeTests.swift
+++ b/Tests/PoliceDataKitTests/StopsAndSearches/Models/StopAndSearchTypeTests.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchTypeTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
@testable import PoliceDataKit
import XCTest
diff --git a/Tests/PoliceDataKitTests/StopsAndSearches/StopAndSearchServiceTests.swift b/Tests/PoliceDataKitTests/StopsAndSearches/StopAndSearchServiceTests.swift
index 7877875..1082889 100644
--- a/Tests/PoliceDataKitTests/StopsAndSearches/StopAndSearchServiceTests.swift
+++ b/Tests/PoliceDataKitTests/StopsAndSearches/StopAndSearchServiceTests.swift
@@ -1,3 +1,22 @@
+//
+// StopAndSearchServiceTests.swift
+// PoliceDataKit
+//
+// Copyright © 2024 Adam Young.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
import Combine
import MapKit
@testable import PoliceDataKit
@@ -55,7 +74,7 @@ final class StopAndSearchServiceTests: XCTestCase {
let expectedResult = StopAndSearch.mocks
apiClient.add(response: .success(StopAndSearch.mocks))
- let expectation = self.expectation(description: "StopAndSearchPublisher")
+ let expectation = expectation(description: "StopAndSearchPublisher")
var result: [StopAndSearch]?
service.stopAndSearchesPublisher(at: coordinate, date: date)
.sink { _ in
@@ -113,7 +132,7 @@ final class StopAndSearchServiceTests: XCTestCase {
let expectedResult = StopAndSearch.mocks
apiClient.add(response: .success(StopAndSearch.mocks))
- let expectation = self.expectation(description: "StopAndSearchPublisher")
+ let expectation = expectation(description: "StopAndSearchPublisher")
var result: [StopAndSearch]?
service.stopAndSearchesPublisher(in: coordinates, date: date)
.sink { _ in
@@ -134,7 +153,7 @@ final class StopAndSearchServiceTests: XCTestCase {
}
func testStopAndSearchesAtLocationWhenNotCachedReturnsStopAndSearches() async throws {
- let streetID = 123456
+ let streetID = 123_456
let date = Date()
let expectedResult = StopAndSearch.mocks
apiClient.add(response: .success(StopAndSearch.mocks))
@@ -150,7 +169,7 @@ final class StopAndSearchServiceTests: XCTestCase {
}
func testStopAndSearchesAtLocationWhenCachedReturnsCachedStopAndSearches() async throws {
- let streetID = 123456
+ let streetID = 123_456
let date = Date()
let expectedResult = StopAndSearch.mocks
await cache.setStopAndSearches(expectedResult, atLocation: streetID, date: date)
@@ -162,7 +181,7 @@ final class StopAndSearchServiceTests: XCTestCase {
}
func testStopAndSearchesAtLocationWhenNotCachedAndReturnsStopAndSearchesShouldCacheResult() async throws {
- let streetID = 123456
+ let streetID = 123_456
let date = Date()
let expectedResult = StopAndSearch.mocks
apiClient.add(response: .success(StopAndSearch.mocks))
From 98c0e722af0007bcbc32b559d0a145a80ea6f2ce Mon Sep 17 00:00:00 2001
From: Adam Young
Date: Mon, 26 Feb 2024 19:41:16 +0000
Subject: [PATCH 2/5] Fix lint errors
---
...DateDecodingStrategy+PoliceDataAPITests.swift | 16 ++++++++--------
.../Networking/JSONSerialiserTests.swift | 2 +-
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/Tests/PoliceDataKitTests/Extensions/JSONDecoderDateDecodingStrategy+PoliceDataAPITests.swift b/Tests/PoliceDataKitTests/Extensions/JSONDecoderDateDecodingStrategy+PoliceDataAPITests.swift
index f302dcf..9212ec8 100644
--- a/Tests/PoliceDataKitTests/Extensions/JSONDecoderDateDecodingStrategy+PoliceDataAPITests.swift
+++ b/Tests/PoliceDataKitTests/Extensions/JSONDecoderDateDecodingStrategy+PoliceDataAPITests.swift
@@ -36,11 +36,11 @@ final class JSONDecoderDateDecodingStrategyPoliceDataAPITestsTests: XCTestCase {
}
func testDecodingDateTimeDateReturnsDate() throws {
- let data = try XCTUnwrap("""
+ let data = Data("""
{
"date": "2021-05-24T11:28:00"
}
- """.data(using: .utf8))
+ """.utf8)
let expectedResult = Date(timeIntervalSince1970: 1_621_855_680)
let container = try decoder.decode(Container.self, from: data)
@@ -50,11 +50,11 @@ final class JSONDecoderDateDecodingStrategyPoliceDataAPITestsTests: XCTestCase {
}
func testDecodingDateTimeWithTimeZoneOffsetDateReturnsDate() throws {
- let data = try XCTUnwrap("""
+ let data = Data("""
{
"date": "2021-05-24T11:28:00-07:00"
}
- """.data(using: .utf8))
+ """.utf8)
let expectedResult = Date(timeIntervalSince1970: 1_621_880_880)
let container = try decoder.decode(Container.self, from: data)
@@ -64,11 +64,11 @@ final class JSONDecoderDateDecodingStrategyPoliceDataAPITestsTests: XCTestCase {
}
func testDecodingYearMonthDateReturnsDate() throws {
- let data = try XCTUnwrap("""
+ let data = Data("""
{
"date": "2021-05"
}
- """.data(using: .utf8))
+ """.utf8)
let expectedResult = Date(timeIntervalSince1970: 1_619_827_200)
let container = try decoder.decode(Container.self, from: data)
@@ -78,11 +78,11 @@ final class JSONDecoderDateDecodingStrategyPoliceDataAPITestsTests: XCTestCase {
}
func testDecodingWhenInvalidDateThrowsDecodingError() throws {
- let data = try XCTUnwrap("""
+ let data = Data("""
{
"date": "11111"
}
- """.data(using: .utf8))
+ """.utf8)
XCTAssertThrowsError(try decoder.decode(Container.self, from: data))
}
diff --git a/Tests/PoliceDataKitTests/Networking/JSONSerialiserTests.swift b/Tests/PoliceDataKitTests/Networking/JSONSerialiserTests.swift
index 6dda2fd..362e984 100644
--- a/Tests/PoliceDataKitTests/Networking/JSONSerialiserTests.swift
+++ b/Tests/PoliceDataKitTests/Networking/JSONSerialiserTests.swift
@@ -35,7 +35,7 @@ final class JSONSerialiserTests: XCTestCase {
}
func testDecodeWhenDataCannotBeDecodedThrowsDecodeError() async throws {
- let data = try XCTUnwrap("aaa".data(using: .utf8))
+ let data = Data("aaa".utf8)
do {
_ = try await serialiser.decode(MockObject.self, from: data)
From 48facbf0ffa8e0f2ee6e576a5525e6a7804e8a5d Mon Sep 17 00:00:00 2001
From: Adam Young
Date: Mon, 26 Feb 2024 19:58:19 +0000
Subject: [PATCH 3/5] Remove Linux builds
---
.github/workflows/ci-documentation.yml | 5 ++-
.github/workflows/ci.yml | 17 ----------
README.md | 6 ++--
.../Availability/AvailabilityService.swift | 6 ----
.../PoliceDataKit/Cache/InMemoryCache.swift | 8 -----
.../PoliceDataKit/Crimes/CrimeService.swift | 27 ---------------
.../PoliceDataKit/Logger+PoliceDataKit.swift | 27 ---------------
.../Neighbourhoods/NeighbourhoodService.swift | 33 -------------------
.../Outcomes/OutcomeService.swift | 19 -----------
.../PoliceForces/PoliceForceService.swift | 14 --------
.../StopAndSearchService.swift | 24 --------------
11 files changed, 7 insertions(+), 179 deletions(-)
delete mode 100644 Sources/PoliceDataKit/Logger+PoliceDataKit.swift
diff --git a/.github/workflows/ci-documentation.yml b/.github/workflows/ci-documentation.yml
index 1562d30..82a8dd7 100644
--- a/.github/workflows/ci-documentation.yml
+++ b/.github/workflows/ci-documentation.yml
@@ -10,10 +10,13 @@ concurrency:
group: "ci-documentation-${{ github.head_ref || github.run_id }}"
cancel-in-progress: true
+env:
+ DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
+
jobs:
build-documentation:
name: Build Documentation
- runs-on: ubuntu-latest
+ runs-on: macos-14
env:
SWIFTCI_DOCC: 1
steps:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 37b476f..620885b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -58,20 +58,3 @@ jobs:
- name: Test
run: set -o pipefail && env NSUnbufferedIO=YES && xcodebuild test-without-building -scheme PoliceDataKit -only-testing PoliceDataKitTests -destination '${{ matrix.destination }}' | xcpretty
-
- build-test-linux:
- name: Build and Test (Linux)
- runs-on: ubuntu-latest
- container: swift:5.9.2-jammy
- steps:
- - name: Checkout
- uses: actions/checkout@v4
-
- - name: Build
- run: swift build -Xswiftc -warnings-as-errors --build-tests
-
- - name: Test
- run: swift test --skip-build --parallel --filter PoliceDataKitTests
-
- - name: Build for Release
- run: swift build -c release -Xswiftc -warnings-as-errors
diff --git a/README.md b/README.md
index f63d69c..521bb70 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ Wales and Northern Ireland.
## Requirements
-* Swift 5.7+
+* Swift 5.9+
## Installation
@@ -19,7 +19,7 @@ Add the PoliceDataKit package as a dependency to your `Package.swift` file, and
add it as a dependency to your target.
```swift
-// swift-tools-version:5.7
+// swift-tools-version:5.9
import PackageDescription
@@ -27,7 +27,7 @@ let package = Package(
name: "MyProject",
dependencies: [
- .package(url: "https://github.com/adamayoung/police-data-kit.git", from: "3.0.0")
+ .package(url: "https://github.com/adamayoung/police-data-kit.git", from: "4.0.0")
],
targets: [
diff --git a/Sources/PoliceDataKit/Availability/AvailabilityService.swift b/Sources/PoliceDataKit/Availability/AvailabilityService.swift
index 7f0191a..8d2ef9c 100644
--- a/Sources/PoliceDataKit/Availability/AvailabilityService.swift
+++ b/Sources/PoliceDataKit/Availability/AvailabilityService.swift
@@ -18,7 +18,6 @@
//
import Foundation
-import os
///
/// Provides an interface for obtaining availability data sets from the UK Police API.
@@ -33,8 +32,6 @@ public final class AvailabilityService {
///
public static let shared = AvailabilityService()
- private static let logger = Logger(subsystem: Logger.policeDataKit, category: "AvailabilityService")
-
private let apiClient: any APIClient
private let cache: any AvailabilityCache
@@ -66,8 +63,6 @@ public final class AvailabilityService {
/// - Returns: The available data sets.
///
public func availableDataSets() async throws -> [DataSet] {
- Self.logger.trace("fetching available data sets")
-
if let cachedDataSets = await cache.availableDataSets() {
return cachedDataSets
}
@@ -76,7 +71,6 @@ public final class AvailabilityService {
do {
dataSets = try await apiClient.get(endpoint: AvailabilityEndpoint.dataSets)
} catch let error {
- Self.logger.error("failed fetching available data sets: \(error.localizedDescription)")
throw Self.mapToAvailabilityError(error)
}
diff --git a/Sources/PoliceDataKit/Cache/InMemoryCache.swift b/Sources/PoliceDataKit/Cache/InMemoryCache.swift
index aa7a95c..4e167bf 100644
--- a/Sources/PoliceDataKit/Cache/InMemoryCache.swift
+++ b/Sources/PoliceDataKit/Cache/InMemoryCache.swift
@@ -18,37 +18,31 @@
//
import Foundation
-import os
final actor InMemoryCache: Cache {
private let cache: NSCache
private let defaultExpiresIn: TimeInterval
- private let logger: Logger
init(name: String, defaultExpiresIn: TimeInterval = 60 * 60 * 12, countLimit: Int = 0) {
self.cache = NSCache()
cache.name = name
cache.countLimit = countLimit
self.defaultExpiresIn = defaultExpiresIn
- self.logger = Logger(subsystem: Logger.policeDataKit, category: "\(name)InMemoryCache")
}
func object(for key: some CustomStringConvertible, type _: ObjectType.Type) async -> ObjectType? {
let cacheKey = keyValue(for: key)
guard let item = cache.object(forKey: cacheKey) else {
- logger.trace("MISS \(key.description)")
return nil
}
guard !item.isExpired else {
- logger.trace("EXPIRED \(key.description)")
cache.removeObject(forKey: cacheKey)
return nil
}
- logger.trace("HIT \(key.description)")
return item.object as? ObjectType
}
@@ -57,13 +51,11 @@ final actor InMemoryCache: Cache {
guard let object else {
cache.removeObject(forKey: cacheKey)
- logger.trace("REMOVE \(key.description)")
return
}
let item = CacheItem(key: key.description, object: object, expiresIn: expiresIn ?? defaultExpiresIn)
cache.setObject(item, forKey: cacheKey)
- logger.trace("ADD \(key.description)")
}
func removeAll() async {
diff --git a/Sources/PoliceDataKit/Crimes/CrimeService.swift b/Sources/PoliceDataKit/Crimes/CrimeService.swift
index 9b9fd51..597de88 100644
--- a/Sources/PoliceDataKit/Crimes/CrimeService.swift
+++ b/Sources/PoliceDataKit/Crimes/CrimeService.swift
@@ -20,7 +20,6 @@
import Combine
import Foundation
import MapKit
-import os
///
/// Provides an interface for obtaining crime data from the UK Police API.
@@ -35,8 +34,6 @@ public final class CrimeService {
///
public static let shared = CrimeService()
- private static let logger = Logger(subsystem: Logger.policeDataKit, category: "CrimeService")
-
private let apiClient: any APIClient
private let cache: any CrimeCache
private let availableDataRegion: MKCoordinateRegion
@@ -81,8 +78,6 @@ public final class CrimeService {
/// - Returns: The street level crimes in a 1 mile radius of the specifed coordinate and date.
///
public func streetLevelCrimes(at coordinate: CLLocationCoordinate2D, date: Date = Date()) async throws -> [Crime] {
- Self.logger.trace("fetching street level Crimes at coordinate \(coordinate, privacy: .public)")
-
guard availableDataRegion.contains(coordinate: coordinate) else {
throw CrimeError.locationOutsideOfDataSetRegion
}
@@ -93,8 +88,6 @@ public final class CrimeService {
endpoint: CrimesEndpoint.streetLevelCrimesAtSpecificPoint(coordinate: coordinate, date: date)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching street level Crimes at coordinate \(coordinate, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToCrimeError(error)
}
@@ -164,7 +157,6 @@ public final class CrimeService {
in coordinates: [CLLocationCoordinate2D],
date: Date = Date()
) async throws -> [Crime] {
- Self.logger.trace("fetching street level Crimes in area")
let crimes: [Crime]
do {
@@ -172,8 +164,6 @@ public final class CrimeService {
endpoint: CrimesEndpoint.streetLevelCrimesInArea(coordinates: coordinates, date: date)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching street level Crimes in area: \(error.localizedDescription, privacy: .public)")
throw Self.mapToCrimeError(error)
}
@@ -238,8 +228,6 @@ public final class CrimeService {
/// - Returns: The crimes at the specified street and date.
///
public func crimes(forStreet streetID: Int, date: Date = Date()) async throws -> [Crime] {
- Self.logger.trace("fetching Crimes for street \(streetID, privacy: .public)")
-
if let cachedCrimes = await cache.crimes(forStreet: streetID, date: date) {
return cachedCrimes
}
@@ -250,8 +238,6 @@ public final class CrimeService {
endpoint: CrimesEndpoint.crimesAtLocationForStreet(streetID: streetID, date: date)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Crimes for street \(streetID, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToCrimeError(error)
}
@@ -277,8 +263,6 @@ public final class CrimeService {
/// - Returns: The crimes for the street nearest to the specified coordinate and date.
///
public func crimes(at coordinate: CLLocationCoordinate2D, date: Date = Date()) async throws -> [Crime] {
- Self.logger.trace("fetching Crimes at coordinate \(coordinate, privacy: .public)")
-
guard availableDataRegion.contains(coordinate: coordinate) else {
throw CrimeError.locationOutsideOfDataSetRegion
}
@@ -289,8 +273,6 @@ public final class CrimeService {
endpoint: CrimesEndpoint.crimesAtLocationAtSpecificPoint(coordinate: coordinate, date: date)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Crimes at coordinate \(coordinate, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToCrimeError(error)
}
@@ -353,9 +335,6 @@ public final class CrimeService {
inPoliceForce policeForceID: PoliceForce.ID,
date: Date = Date()
) async throws -> [Crime] {
- // swiftlint:disable:next line_length
- Self.logger.trace("fetching Crimes with no location for category \(categoryID, privacy: .public) in Police Force \(policeForceID, privacy: .public)")
-
if let cachedCrimes = await cache.crimesWithNoLocation(
forCategory: categoryID,
inPoliceForce: policeForceID,
@@ -372,8 +351,6 @@ public final class CrimeService {
)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Crimes with no location for category \(categoryID, privacy: .public) in Police Force \(policeForceID, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToCrimeError(error)
}
@@ -394,8 +371,6 @@ public final class CrimeService {
/// - Returns: The crime categories for the specified month.
///
public func crimeCategories(forDate date: Date = Date()) async throws -> [CrimeCategory] {
- Self.logger.trace("fetching Crime categories for date \(date, privacy: .public)")
-
if let cachedCategories = await cache.crimeCategories(forDate: date) {
return cachedCategories
}
@@ -404,8 +379,6 @@ public final class CrimeService {
do {
crimeCategories = try await apiClient.get(endpoint: CrimesEndpoint.categories(date: date))
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Crime categories for date \(date, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToCrimeError(error)
}
diff --git a/Sources/PoliceDataKit/Logger+PoliceDataKit.swift b/Sources/PoliceDataKit/Logger+PoliceDataKit.swift
deleted file mode 100644
index ea11151..0000000
--- a/Sources/PoliceDataKit/Logger+PoliceDataKit.swift
+++ /dev/null
@@ -1,27 +0,0 @@
-//
-// Logger+PoliceDataKit.swift
-// PoliceDataKit
-//
-// Copyright © 2024 Adam Young.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-import Foundation
-import os
-
-extension Logger {
-
- static let policeDataKit = "uk.co.adam-young.PoliceDataKit"
-
-}
diff --git a/Sources/PoliceDataKit/Neighbourhoods/NeighbourhoodService.swift b/Sources/PoliceDataKit/Neighbourhoods/NeighbourhoodService.swift
index f186fe4..5e76920 100644
--- a/Sources/PoliceDataKit/Neighbourhoods/NeighbourhoodService.swift
+++ b/Sources/PoliceDataKit/Neighbourhoods/NeighbourhoodService.swift
@@ -20,7 +20,6 @@
import Combine
import Foundation
import MapKit
-import os
///
/// Provides an interface for obtaining neighbourhood data from the UK Police API.
@@ -35,8 +34,6 @@ public final class NeighbourhoodService {
///
public static let shared = NeighbourhoodService()
- private static let logger = Logger(subsystem: Logger.policeDataKit, category: "NeighbourhoodService")
-
private let apiClient: any APIClient
private let cache: any NeighbourhoodCache
private let availableDataRegion: MKCoordinateRegion
@@ -73,8 +70,6 @@ public final class NeighbourhoodService {
/// - Returns: The neighbourhoods in the specified police force.
///
public func neighbourhoods(inPoliceForce policeForceID: PoliceForce.ID) async throws -> [NeighbourhoodReference] {
- Self.logger.trace("fetching Neighbourhoods in Police Force \(policeForceID, privacy: .public)")
-
if let cachedNeighbourhoodReferences = await cache.neighbourhoods(inPoliceForce: policeForceID) {
return cachedNeighbourhoodReferences
}
@@ -85,8 +80,6 @@ public final class NeighbourhoodService {
endpoint: NeighbourhoodsEndpoint.list(policeForceID: policeForceID)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Neighbourhoods in Police Force \(policeForceID, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToNeighbourhoodError(error)
}
@@ -112,9 +105,6 @@ public final class NeighbourhoodService {
withID id: String,
inPoliceForce policeForceID: PoliceForce.ID
) async throws -> Neighbourhood {
- // swiftlint:disable:next line_length
- Self.logger.trace("fetching Neighbourhood \(id, privacy: .public) in Police Force \(policeForceID, privacy: .public)")
-
if let cachedNeighbourhood = await cache.neighbourhood(withID: id, inPoliceForce: policeForceID) {
return cachedNeighbourhood
}
@@ -125,8 +115,6 @@ public final class NeighbourhoodService {
endpoint: NeighbourhoodsEndpoint.details(id: id, policeForceID: policeForceID)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Neighbourhood \(id, privacy: .public) in Police Force \(policeForceID, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToNeighbourhoodError(error)
}
@@ -146,8 +134,6 @@ public final class NeighbourhoodService {
/// - Returns: The neighbourhood at the specified coordinate.
///
public func neighbourhood(at coordinate: CLLocationCoordinate2D) async throws -> Neighbourhood {
- Self.logger.trace("fetching Neighbourhood at coordinate \(coordinate, privacy: .public)")
-
let neighbourhoodPolicingTeam = try await neighbourhoodPolicingTeam(at: coordinate)
let neighbourhood = try await neighbourhood(
withID: neighbourhoodPolicingTeam.neighbourhood,
@@ -204,9 +190,6 @@ public final class NeighbourhoodService {
forNeighbourhood neighbourhoodID: Neighbourhood.ID,
inPoliceForce policeForceID: PoliceForce.ID
) async throws -> [CLLocationCoordinate2D] {
- // swiftlint:disable:next line_length
- Self.logger.trace("fetching Boundary for Neighbourhood \(neighbourhoodID, privacy: .public) in Police Force \(policeForceID, privacy: .public)")
-
if let cachedBoundary = await cache.boundary(forNeighbourhood: neighbourhoodID, inPoliceForce: policeForceID) {
return cachedBoundary
}
@@ -219,8 +202,6 @@ public final class NeighbourhoodService {
)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Boundary for Neighbourhood \(neighbourhoodID, privacy: .public) in Police Force \(policeForceID, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToNeighbourhoodError(error)
}
@@ -246,9 +227,6 @@ public final class NeighbourhoodService {
forNeighbourhood neighbourhoodID: Neighbourhood.ID,
inPoliceForce policeForceID: PoliceForce.ID
) async throws -> [PoliceOfficer] {
- // swiftlint:disable:next line_length
- Self.logger.trace("fetching Police Officers for Neighbourhood \(neighbourhoodID, privacy: .public) in Police Force \(policeForceID, privacy: .public)")
-
if let cachedPoliceOfficers = await cache.policeOfficers(
forNeighbourhood: neighbourhoodID,
inPoliceForce: policeForceID
@@ -264,8 +242,6 @@ public final class NeighbourhoodService {
)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Police Officers for Neighbourhood \(neighbourhoodID, privacy: .public) in Police Force \(policeForceID, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToNeighbourhoodError(error)
}
@@ -291,9 +267,6 @@ public final class NeighbourhoodService {
forNeighbourhood neighbourhoodID: Neighbourhood.ID,
inPoliceForce policeForceID: PoliceForce.ID
) async throws -> [NeighbourhoodPriority] {
- // swiftlint:disable:next line_length
- Self.logger.trace("fetching Priorities for Neighbourhood \(neighbourhoodID, privacy: .public) in Police Force \(policeForceID, privacy: .public)")
-
if let cachedPriorities = await cache.priorities(
forNeighbourhood: neighbourhoodID,
inPoliceForce: policeForceID
@@ -309,8 +282,6 @@ public final class NeighbourhoodService {
)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Priorities for Neighbourhood \(neighbourhoodID, privacy: .public) in Police Force \(policeForceID, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToNeighbourhoodError(error)
}
@@ -333,8 +304,6 @@ public final class NeighbourhoodService {
public func neighbourhoodPolicingTeam(
at coordinate: CLLocationCoordinate2D
) async throws -> NeighbourhoodPolicingTeam {
- Self.logger.trace("fetching Neighbourhood Policing Team at coordinate \(coordinate, privacy: .public)")
-
guard availableDataRegion.contains(coordinate: coordinate) else {
throw NeighbourhoodError.locationOutsideOfDataSetRegion
}
@@ -345,8 +314,6 @@ public final class NeighbourhoodService {
endpoint: NeighbourhoodsEndpoint.locateNeighbourhood(coordinate: coordinate)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Neighbourhood Policing Team at coordinate \(coordinate, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToNeighbourhoodError(error)
}
diff --git a/Sources/PoliceDataKit/Outcomes/OutcomeService.swift b/Sources/PoliceDataKit/Outcomes/OutcomeService.swift
index c5c4b32..4714f5d 100644
--- a/Sources/PoliceDataKit/Outcomes/OutcomeService.swift
+++ b/Sources/PoliceDataKit/Outcomes/OutcomeService.swift
@@ -20,7 +20,6 @@
import Combine
import Foundation
import MapKit
-import os
///
/// Provides an interface for obtaining outcome data from the UK Police API.
@@ -35,8 +34,6 @@ public final class OutcomeService {
///
public static let shared = OutcomeService()
- private static let logger = Logger(subsystem: Logger.policeDataKit, category: "OutcomeService")
-
private let apiClient: any APIClient
private let cache: any OutcomeCache
private let availableDataRegion: MKCoordinateRegion
@@ -77,8 +74,6 @@ public final class OutcomeService {
/// - Returns: The outcomes of crimes for the specified street and date..
///
public func streetLevelOutcomes(forStreet streetID: Int, date: Date = Date()) async throws -> [Outcome] {
- Self.logger.trace("fetching street level Outcomes for Street \(streetID, privacy: .public)")
-
if let cachedOutcomes = await cache.streetLevelOutcomes(forStreet: streetID, date: date) {
return cachedOutcomes
}
@@ -89,8 +84,6 @@ public final class OutcomeService {
endpoint: OutcomesEndpoint.streetLevelOutcomesForStreet(streetID: streetID, date: date)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching street level Outcomes for Street \(streetID, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToOutcomeError(error)
}
@@ -118,8 +111,6 @@ public final class OutcomeService {
at coordinate: CLLocationCoordinate2D,
date: Date = Date()
) async throws -> [Outcome] {
- Self.logger.trace("fetching street level Outcomes at coordinate \(coordinate, privacy: .public)")
-
guard availableDataRegion.contains(coordinate: coordinate) else {
throw OutcomeError.locationOutsideOfDataSetRegion
}
@@ -130,8 +121,6 @@ public final class OutcomeService {
endpoint: OutcomesEndpoint.streetLevelOutcomesAtSpecificPoint(coordinate: coordinate, date: date)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching street level Outcomes at coordinate \(coordinate, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToOutcomeError(error)
}
@@ -193,16 +182,12 @@ public final class OutcomeService {
in coordinates: [CLLocationCoordinate2D],
date: Date = Date()
) async throws -> [Outcome] {
- Self.logger.trace("fetching street level Outcomes in area")
-
let outcomes: [Outcome]
do {
outcomes = try await apiClient.get(
endpoint: OutcomesEndpoint.streetLevelOutcomesInArea(coordinates: coordinates, date: date)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching street level Outcomes in area: \(error.localizedDescription, privacy: .public)")
throw Self.mapToOutcomeError(error)
}
@@ -259,8 +244,6 @@ public final class OutcomeService {
/// - Returns: The case history for the specified crime.
///
public func caseHistory(forCrime crimeID: String) async throws -> CaseHistory {
- Self.logger.trace("fetching Case History for crime \(crimeID, privacy: .public)")
-
if let cachedCaseHistory = await cache.caseHistory(forCrime: crimeID) {
return cachedCaseHistory
}
@@ -269,8 +252,6 @@ public final class OutcomeService {
do {
caseHistory = try await apiClient.get(endpoint: OutcomesEndpoint.caseHistory(crimeID: crimeID))
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Case History for crime \(crimeID, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToOutcomeError(error)
}
diff --git a/Sources/PoliceDataKit/PoliceForces/PoliceForceService.swift b/Sources/PoliceDataKit/PoliceForces/PoliceForceService.swift
index 9da55ed..473ffac 100644
--- a/Sources/PoliceDataKit/PoliceForces/PoliceForceService.swift
+++ b/Sources/PoliceDataKit/PoliceForces/PoliceForceService.swift
@@ -18,7 +18,6 @@
//
import Foundation
-import os
///
/// Provides an interface for obtaining police force data from the UK Police API.
@@ -33,8 +32,6 @@ public final class PoliceForceService {
///
public static let shared = PoliceForceService()
- private static let logger = Logger(subsystem: Logger.policeDataKit, category: "PoliceForceService")
-
private let apiClient: any APIClient
private let cache: any PoliceForceCache
@@ -69,8 +66,6 @@ public final class PoliceForceService {
/// - Returns: All Police Forces.
///
public func policeForces() async throws -> [PoliceForceReference] {
- Self.logger.trace("fetching Police Forces")
-
if let cachedPoliceForces = await cache.policeForces() {
return cachedPoliceForces
}
@@ -79,7 +74,6 @@ public final class PoliceForceService {
do {
policeForces = try await apiClient.get(endpoint: PoliceForcesEndpoint.list)
} catch let error {
- Self.logger.error("failed fetching Police Forces: \(error.localizedDescription, privacy: .public)")
throw Self.mapToPoliceForceError(error)
}
@@ -100,8 +94,6 @@ public final class PoliceForceService {
/// - Returns: The Police Force specified.
///
public func policeForce(withID id: PoliceForce.ID) async throws -> PoliceForce {
- Self.logger.trace("fetching Police Force \(id, privacy: .public)")
-
if let cachedPoliceForce = await cache.policeForce(withID: id) {
return cachedPoliceForce
}
@@ -110,8 +102,6 @@ public final class PoliceForceService {
do {
policeForce = try await apiClient.get(endpoint: PoliceForcesEndpoint.details(id: id))
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Police Force \(id, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToPoliceForceError(error)
}
@@ -132,8 +122,6 @@ public final class PoliceForceService {
/// - Returns: Senior Police Officers for the specified Police Force.
///
public func seniorOfficers(inPoliceForce policeForceID: PoliceForce.ID) async throws -> [PoliceOfficer] {
- Self.logger.trace("fetching Senior Officers in Police Force \(policeForceID, privacy: .public)")
-
if let cachedPeopleOfficers = await cache.seniorOfficers(inPoliceForce: policeForceID) {
return cachedPeopleOfficers
}
@@ -144,8 +132,6 @@ public final class PoliceForceService {
endpoint: PoliceForcesEndpoint.seniorOfficers(policeForceID: policeForceID)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Senior Officers in Police Force \(policeForceID, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToPoliceForceError(error)
}
diff --git a/Sources/PoliceDataKit/StopAndSearches/StopAndSearchService.swift b/Sources/PoliceDataKit/StopAndSearches/StopAndSearchService.swift
index 50f3d74..e0d8f55 100644
--- a/Sources/PoliceDataKit/StopAndSearches/StopAndSearchService.swift
+++ b/Sources/PoliceDataKit/StopAndSearches/StopAndSearchService.swift
@@ -20,7 +20,6 @@
import Combine
import Foundation
import MapKit
-import os
///
/// Provides an interface for obtaining stop and search data from the UK Police API.
@@ -39,8 +38,6 @@ public final class StopAndSearchService {
///
public static let shared = StopAndSearchService()
- private static let logger = Logger(subsystem: Logger.policeDataKit, category: "StopAndSearchService")
-
private let apiClient: any APIClient
private let cache: any StopAndSearchCache
private let availableDataRegion: MKCoordinateRegion
@@ -86,8 +83,6 @@ public final class StopAndSearchService {
at coordinate: CLLocationCoordinate2D,
date: Date = Date()
) async throws -> [StopAndSearch] {
- Self.logger.trace("fetching Stop and Searches at \(coordinate, privacy: .public)")
-
guard availableDataRegion.contains(coordinate: coordinate) else {
throw StopAndSearchError.locationOutsideOfDataSetRegion
}
@@ -100,8 +95,6 @@ public final class StopAndSearchService {
)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Stop and Searches at \(coordinate, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToStopAndSearchError(error)
}
@@ -167,16 +160,12 @@ public final class StopAndSearchService {
in coordinates: [CLLocationCoordinate2D],
date: Date = Date()
) async throws -> [StopAndSearch] {
- Self.logger.trace("fetching Stop and Searches in area")
-
let stopAndSearches: [StopAndSearch]
do {
stopAndSearches = try await apiClient.get(
endpoint: StopAndSearchesEndpoint.stopAndSearchesByAreaInArea(coordinates: coordinates, date: date)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Stop and Searches in area: \(error.localizedDescription, privacy: .public)")
throw Self.mapToStopAndSearchError(error)
}
@@ -239,8 +228,6 @@ public final class StopAndSearchService {
/// - Returns: A list of stop and searches.
///
public func stopAndSearches(atLocation streetID: Int, date: Date = Date()) async throws -> [StopAndSearch] {
- Self.logger.trace("fetching Stop and Searches at location \(streetID, privacy: .public)")
-
if let cachedStopAndSearches = await cache.stopAndSearches(atLocation: streetID, date: date) {
return cachedStopAndSearches
}
@@ -251,8 +238,6 @@ public final class StopAndSearchService {
endpoint: StopAndSearchesEndpoint.stopAndSearchesAtLocation(streetID: streetID, date: date)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Stop and Searches at location \(streetID, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToStopAndSearchError(error)
}
@@ -282,9 +267,6 @@ public final class StopAndSearchService {
forPoliceForce policeForceID: PoliceForce.ID,
date: Date = Date()
) async throws -> [StopAndSearch] {
- // swiftlint:disable:next line_length
- Self.logger.trace("fetching Stop and Searches with no location for Police Force \(policeForceID, privacy: .public)")
-
if let cachedStopAndSearches = await cache.stopAndSearchesWithNoLocation(
forPoliceForce: policeForceID,
date: date
@@ -300,8 +282,6 @@ public final class StopAndSearchService {
)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Stop and Searches with no location for Police Force \(policeForceID, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToStopAndSearchError(error)
}
@@ -331,8 +311,6 @@ public final class StopAndSearchService {
forPoliceForce policeForceID: PoliceForce.ID,
date: Date = Date()
) async throws -> [StopAndSearch] {
- Self.logger.trace("fetching Stop and Searches for Police Force \(policeForceID, privacy: .public)")
-
if let cachedStopAndSearches = await cache.stopAndSearches(forPoliceForce: policeForceID, date: date) {
return cachedStopAndSearches
}
@@ -343,8 +321,6 @@ public final class StopAndSearchService {
endpoint: StopAndSearchesEndpoint.stopAndSearchesByPoliceForce(policeForceID: policeForceID, date: date)
)
} catch let error {
- // swiftlint:disable:next line_length
- Self.logger.error("failed fetching Stop and Searches for Police Force \(policeForceID, privacy: .public): \(error.localizedDescription, privacy: .public)")
throw Self.mapToStopAndSearchError(error)
}
From b6dd1323200839699e211d16399afb09e514c702 Mon Sep 17 00:00:00 2001
From: Adam Young
Date: Mon, 26 Feb 2024 20:01:02 +0000
Subject: [PATCH 4/5] Fix lint errors
---
Sources/PoliceDataKit/Crimes/CrimeService.swift | 1 -
1 file changed, 1 deletion(-)
diff --git a/Sources/PoliceDataKit/Crimes/CrimeService.swift b/Sources/PoliceDataKit/Crimes/CrimeService.swift
index 597de88..607247c 100644
--- a/Sources/PoliceDataKit/Crimes/CrimeService.swift
+++ b/Sources/PoliceDataKit/Crimes/CrimeService.swift
@@ -157,7 +157,6 @@ public final class CrimeService {
in coordinates: [CLLocationCoordinate2D],
date: Date = Date()
) async throws -> [Crime] {
-
let crimes: [Crime]
do {
crimes = try await apiClient.get(
From a635b26a711ac6f571816a0980c1bdceb7130a1c Mon Sep 17 00:00:00 2001
From: Adam Young
Date: Mon, 26 Feb 2024 20:09:32 +0000
Subject: [PATCH 5/5] Fix failing integration test
---
Tests/IntegrationTests/NeighbourhoodIntegrationTests.swift | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Tests/IntegrationTests/NeighbourhoodIntegrationTests.swift b/Tests/IntegrationTests/NeighbourhoodIntegrationTests.swift
index ff27600..2a2c325 100644
--- a/Tests/IntegrationTests/NeighbourhoodIntegrationTests.swift
+++ b/Tests/IntegrationTests/NeighbourhoodIntegrationTests.swift
@@ -170,7 +170,7 @@ final class NeighbourhoodIntegrationTests: XCTestCase {
inPoliceForce: policeForceID
)
- XCTAssertEqual(boundary.count, 993)
+ XCTAssertEqual(boundary.count, 961)
}
func testPoliceOfficersForNeighbourhoodInPoliceForceForWakefieldCentralWestYorkshire() async throws {