Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TECH DEBT: Tidy models #178

Merged
merged 4 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ jobs:
--disable-indexing \
--transform-for-static-hosting \
--hosting-base-path TMDb \
--output-path docs
--output-path docs \
--warnings-as-errors
env:
SWIFTCI_DOCC: 1

Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ concurrency:
jobs:
swiftLint:
name: SwiftLint
runs-on: ubuntu-latest
container:
image: docker://ghcr.io/realm/swiftlint:0.53.0
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install swiftlint
run: brew install swiftlint

- name: Swiftlint
run: swiftlint --strict --reporter github-actions-logging

Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ TARGET = TMDb
TEST_TARGET = TMDbTests
INTEGRATION_TEST_TARGET = TMDbIntegrationTests

IOS_DESTINATION = 'platform=iOS Simulator,name=iPhone 15,OS=17.4'
WATCHOS_DESINTATION = 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.4'
TVOS_DESTINATION = 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.4'
VISIONOS_DESTINATION = 'platform=visionOS Simulator,name=Apple Vision Pro,OS=1.1'
IOS_DESTINATION = 'platform=iOS Simulator,name=iPhone 15,OS=17.5'
WATCHOS_DESINTATION = 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.5'
TVOS_DESTINATION = 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.5'
VISIONOS_DESTINATION = 'platform=visionOS Simulator,name=Apple Vision Pro,OS=1.2'

SWIFT_CONTAINER_IMAGE = swift:5.9.2-jammy

Expand Down Expand Up @@ -47,7 +47,7 @@ build-linux-release:

.PHONY: build-docs
build-docs:
SWIFTCI_DOCC=1 swift package generate-documentation --product $(TARGET)
SWIFTCI_DOCC=1 swift package generate-documentation --product $(TARGET) --warnings-as-errors
swift package resolve

.PHONY: preview-docs
Expand Down Expand Up @@ -90,7 +90,7 @@ test-visionos:

.PHONY: test-linux
test-linux:
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build --build-tests -Xswiftc -warnings-as-errors && swift test --skip-build --filter $(TEST_TARGET)"
docker run -i --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build --build-tests -Xswiftc -warnings-as-errors && swift test --skip-build --filter $(TEST_TARGET)"

.PHONY: integration-test
integration-test: .check-env-vars
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Add the TMDb package as a dependency to your `Package.swift` file, and add it
as a dependency to your target.

```swift
// swift-tools-version:5.10
// swift-tools-version:5.9

import PackageDescription

Expand Down
18 changes: 0 additions & 18 deletions Sources/TMDb/Domain/Models/MovieExternalLinksCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,6 @@ public struct MovieExternalLinksCollection: Identifiable, Codable, Equatable, Ha
self.twitter = twitter
}

public func hash(into hasher: inout Hasher) {
hasher.combine(id)
hasher.combine(imdb?.id)
hasher.combine(wikiData?.id)
hasher.combine(facebook?.id)
hasher.combine(instagram?.id)
hasher.combine(twitter?.id)
}

public static func == (lhs: MovieExternalLinksCollection, rhs: MovieExternalLinksCollection) -> Bool {
lhs.id == rhs.id
&& lhs.imdb == rhs.imdb
&& lhs.wikiData == rhs.wikiData
&& lhs.facebook == rhs.facebook
&& lhs.instagram == rhs.instagram
&& lhs.twitter == rhs.twitter
}

}

public extension MovieExternalLinksCollection {
Expand Down
20 changes: 0 additions & 20 deletions Sources/TMDb/Domain/Models/PersonExternalLinksCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,6 @@ public struct PersonExternalLinksCollection: Identifiable, Codable, Equatable, H
self.tikTok = tikTok
}

public func hash(into hasher: inout Hasher) {
hasher.combine(id)
hasher.combine(imdb?.id)
hasher.combine(wikiData?.id)
hasher.combine(facebook?.id)
hasher.combine(instagram?.id)
hasher.combine(twitter?.id)
hasher.combine(tikTok?.id)
}

public static func == (lhs: PersonExternalLinksCollection, rhs: PersonExternalLinksCollection) -> Bool {
lhs.id == rhs.id
&& lhs.imdb == rhs.imdb
&& lhs.wikiData == rhs.wikiData
&& lhs.facebook == rhs.facebook
&& lhs.instagram == rhs.instagram
&& lhs.twitter == rhs.twitter
&& lhs.tikTok == rhs.tikTok
}

}

public extension PersonExternalLinksCollection {
Expand Down
2 changes: 2 additions & 0 deletions Sources/TMDb/Domain/Models/TMDbError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public enum TMDbError: Equatable, LocalizedError, Sendable {

public extension TMDbError {

///
/// A localized message describing what error occurred.
///
var errorDescription: String? {
switch self {
case .notFound:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,6 @@ public struct TVSeriesExternalLinksCollection: Identifiable, Codable, Equatable,
self.twitter = twitter
}

public func hash(into hasher: inout Hasher) {
hasher.combine(id)
hasher.combine(imdb?.id)
hasher.combine(wikiData?.id)
hasher.combine(facebook?.id)
hasher.combine(instagram?.id)
hasher.combine(twitter?.id)
}

public static func == (lhs: TVSeriesExternalLinksCollection, rhs: TVSeriesExternalLinksCollection) -> Bool {
lhs.id == rhs.id
&& lhs.imdb == rhs.imdb
&& lhs.wikiData == rhs.wikiData
&& lhs.facebook == rhs.facebook
&& lhs.instagram == rhs.instagram
&& lhs.twitter == rhs.twitter
}

}

public extension TVSeriesExternalLinksCollection {
Expand Down
2 changes: 1 addition & 1 deletion Sources/TMDb/TMDb.docc/Extensions/DiscoverService.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

### Discover Movies

- ``movies(sortedBy:withPeople:page:language:)``
- ``movies(filter:sortedBy:page:language:)``

### Discover TV Series

Expand Down
30 changes: 30 additions & 0 deletions Tests/TMDbTests/Domain/Models/PersonCombinedCreditsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,36 @@ final class PersonCombinedCreditsTests: XCTestCase {
XCTAssertEqual(result.crew, personCombinedCredits.crew)
}

func testAllShows() {
let credits = PersonCombinedCredits(
id: 1,
cast: [
.movie(Movie(id: 1, title: "Movie 1")),
.movie(Movie(id: 2, title: "Movie 2")),
.tvSeries(TVSeries(id: 11, name: "TV 1")),
.tvSeries(TVSeries(id: 12, name: "TV 2"))
],
crew: [
.movie(Movie(id: 1, title: "Movie 1")),
.movie(Movie(id: 3, title: "Movie 3")),
.tvSeries(TVSeries(id: 11, name: "TV 1")),
.tvSeries(TVSeries(id: 13, name: "TV 3"))
]
)
let expectedResult: [Show] = [
.movie(Movie(id: 1, title: "Movie 1")),
.movie(Movie(id: 2, title: "Movie 2")),
.movie(Movie(id: 3, title: "Movie 3")),
.tvSeries(TVSeries(id: 11, name: "TV 1")),
.tvSeries(TVSeries(id: 12, name: "TV 2")),
.tvSeries(TVSeries(id: 13, name: "TV 3"))
].sorted { $0.id < $1.id }

let result = credits.allShows.sorted { $0.id < $1.id }

XCTAssertEqual(result, expectedResult)
}

// swiftlint:disable line_length
private let personCombinedCredits = PersonCombinedCredits(
id: 287,
Expand Down
Loading