Skip to content

Commit

Permalink
#45: Fixed things that SwiftLint complained about.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrtibbetts committed Jan 11, 2020
1 parent fda8065 commit 7b0b823
Show file tree
Hide file tree
Showing 58 changed files with 300 additions and 264 deletions.
12 changes: 6 additions & 6 deletions Source/Collection/CollectionCustomField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ import Foundation

/// A user-defined column in the collection database.
public struct CollectionCustomField: Codable {

/// Determines what type of editing/display component to use when
/// entering data on Discogs.com.
public enum FieldType: String {
case dropdown
case textarea
}

/// The field's unique ID within the set of fields.
public var id: Int

/// If this is a text-area field, this is the number of lines that
/// should be displayed.
public var lines: Int?

/// The name of the field.
public var name: String

/// For dropdown fields, these are the option strings to display. They
/// will appear in the order they're specified.
public var options: [String]?

/// The index of this field among all fields.
public var position: Int

Expand All @@ -41,7 +41,7 @@ public struct CollectionCustomField: Codable {

/// A collection of the custom fields that a user has defined.
public struct CollectionCustomFields: Codable {

/// The custom fields that the user has defined, if any.
public var fields: [CollectionCustomField]?

Expand Down
8 changes: 4 additions & 4 deletions Source/Collection/CollectionFolder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import Foundation

/// A JSON element that contains the folders array.
public struct CollectionFolders: Codable {

public var folders: [CollectionFolder]

}

/// Information about a folder in a user's collection.
public struct CollectionFolder: Codable, Unique {

public var id: Int
public var count: Int
public var name: String
public var resourceUrl: String

}
2 changes: 1 addition & 1 deletion Source/Collection/CollectionFolderItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public struct CollectionFolderItems: Codable, Pageable {
}

public struct CollectionFolderItem: Codable {

public var folderId: Int
public var id: Int
public var basicInformation: Info?
Expand Down
4 changes: 2 additions & 2 deletions Source/Collection/CollectionItemInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import Foundation

public struct CollectionItemInfo: Codable {

public var instanceId: Int
public var resourceUrl: String

}
2 changes: 1 addition & 1 deletion Source/Collection/CollectionRelease.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Foundation

public struct CollectionRelease: Codable {

public var basicInformation: [Information]?
public var folderId: Int
public var id: Int
Expand Down
4 changes: 2 additions & 2 deletions Source/Collection/CollectionValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import Foundation

public struct CollectionValue: Codable {

public var maximum: String
public var median: String
public var minimum: String

}
4 changes: 2 additions & 2 deletions Source/Database/ArtistSummary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Foundation

public struct ArtistSummary: Codable, Unique {

public var artistNameVariation: String?
public var id: Int
public var join: String?
Expand All @@ -21,5 +21,5 @@ public struct ArtistSummary: Codable, Unique {
case role
case tracks
}

}
2 changes: 1 addition & 1 deletion Source/Database/Community.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Foundation

public struct Community: Codable {

public var have: Int
public var want: Int

Expand Down
2 changes: 1 addition & 1 deletion Source/Database/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public struct Image: Codable {
public var uri: String
public var uri150: String
public var width: Int

}
4 changes: 4 additions & 0 deletions Source/Database/MasterRelease.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import Foundation

// swiftlint:disable identifier_name

public struct MasterRelease: Codable, Unique {

public var artists: [ArtistSummary]
Expand Down Expand Up @@ -43,3 +45,5 @@ public struct MasterRelease: Codable, Unique {
}

}

// swiftlint:enable identifier_name
10 changes: 7 additions & 3 deletions Source/Database/MasterReleaseVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import Foundation

// swiftlint:disable identifier_name

public struct MasterReleaseVersion: Codable, Unique {

public var catalogNumber: String?
Expand All @@ -27,7 +29,7 @@ public struct MasterReleaseVersion: Codable, Unique {
return nil
}
}

public var majorFormat: String? {
return majorFormats?.first
}
Expand All @@ -49,8 +51,10 @@ public struct MasterReleaseVersion: Codable, Unique {
}

public struct MasterReleaseVersions: Codable, Pageable {

public var pagination: Pagination?
public var versions: [MasterReleaseVersion]

}

// swiftlint:enable identifier_name
2 changes: 1 addition & 1 deletion Source/Database/ReleaseRating.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Foundation

public struct ReleaseRating: Codable {

public var average: Float
public var count: Int

Expand Down
14 changes: 7 additions & 7 deletions Source/Database/ReleaseSummary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Foundation

public struct ReleaseSummary: Codable, Unique {

public var artist: String
public var catno: String?
public var catalogNumber: String? { return catno }
Expand All @@ -18,20 +18,20 @@ public struct ReleaseSummary: Codable, Unique {
public var title: String
public var type: String?
public var year: Int?

public var formats: [String]? {
return format?.components(separatedBy: ",").map { (substringChars) -> String in
let substring = String(substringChars)

return substring.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
}
}
}

}

public struct ReleaseSummaries: Codable, Pageable {

public var pagination: Pagination?
public var releases: [ReleaseSummary]?

}
10 changes: 7 additions & 3 deletions Source/Database/SearchResults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import Foundation

// swiftlint:disable identifier_name

public struct SearchResult: Codable, Unique {

public var catalogNumber: String?
Expand Down Expand Up @@ -35,11 +37,13 @@ public struct SearchResult: Codable, Unique {
case uri
case year
}

}

public struct SearchResults: Codable {

public var results: [SearchResult]?

}

// swiftlint:enable identifier_name
2 changes: 1 addition & 1 deletion Source/Database/Track.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Foundation

public struct Track: Codable {

public var duration: String
public var position: String
public var type: String
Expand Down
30 changes: 15 additions & 15 deletions Source/Discogs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ import PromiseKit

/// Error types for problems retrieving data from Discogs.
public enum DiscogsError: Error {

/// Thrown when no artist was found when searching by its ID.
case artistNotFoundById(Int)

case discogsResponse(ErrorResponse)

case labelNotFoundById(Int)

/// Thrown when no artist was found when searching by its name.
case masterReleaseNotFoundById(Int)
case releaseNotFoundById(Int)
case unauthenticatedUser
case unknownUser(username: String)
case unknown(Error?)

}

/// Implemented by clients of a Discogs API server.
Expand All @@ -29,18 +29,18 @@ public protocol Discogs {
// MARK: - User Identify

var isSignedIn: Bool { get }

func authorize(presentingViewController: UIViewController,
callbackUrlString: String) -> Promise<OAuthSwiftCredential>

func signOut()

func userIdentity() -> Promise<UserIdentity>

func userProfile(userName: String) -> Promise<UserProfile>

// MARK: - Database

/// Look up the artist with the specified ID and invoke the completion on
/// it.
///
Expand All @@ -55,45 +55,45 @@ public protocol Discogs {
/// - parameter completion: The completion block that will be applied to
/// all of the artist's releases, or to the error, if one was thrown.
func releases(forArtist artistId: Int) -> Promise<ReleaseSummaries>

/// Look up the record label by its ID.
///
/// - parameter identifier: The label's unique ID.
/// - parameter completion: The completion block that will be applied to
/// the label, or to the error, if one was thrown.
func label(identifier: Int) -> Promise<RecordLabel>

/// Look up the record label's releases by the label's name.
///
/// - parameter labelId: The label's unique ID.
/// - parameter completion: The completion block that will be applied to
/// all of the label's releases, or to the error, if one was thrown.
func releases(forLabel labelId: Int) -> Promise<ReleaseSummaries>

/// Process a master release with a specified ID.
///
/// - parameter identifier: The unique ID of the master release.
/// - parameter completion: The completion block that will be applied to
/// the master release, or to the error, if one was thrown.
func masterRelease(identifier: Int) -> Promise<MasterRelease>

/// Process all of the release versions that belong to a master release.
///
/// - parameter identifier: The unique ID of the master release.
/// - parameter pageNumber: The number of the page (i.e. batch).
func releasesForMasterRelease(_ identifier: Int,
pageNumber: Int,
resultsPerPage: Int) -> Promise<MasterReleaseVersions>

/// Process a release with a specified ID.
///
/// - parameter identifier: The unique ID of the release.
/// - parameter completion: The completion block that will be applied to
/// the release, or to the error, if one was thrown.
func release(identifier: Int) -> Promise<Release>

// MARK: - Collections

func customCollectionFields(forUserName: String) -> Promise<CollectionCustomFields>
func collectionValue(forUserName: String) -> Promise<CollectionValue>
func collectionFolders(forUserName: String) -> Promise<CollectionFolders>
Expand Down
Loading

0 comments on commit 7b0b823

Please sign in to comment.