Skip to content

Commit

Permalink
Fix lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
4np committed Dec 4, 2024
1 parent bb224ee commit 61e97e6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 33 deletions.
25 changes: 12 additions & 13 deletions OctoKit/PullRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public extension PullRequest {
public let createdAt: Date
public let updatedAt: Date
public let reactions: Reactions?

/// The SHA of the commit this comment is associated with.
public private(set) var commitId: String?
/// The line of the blob in the pull request diff that the comment applies to. For a multi-line comment, the last line of the range that your comment applies to.
Expand All @@ -203,13 +203,13 @@ public extension PullRequest {
public private(set) var subjectType: SubjectType?
/// The ID of the review comment this comment replied to.
public private(set) var inReplyToId: Int?

enum CodingKeys: String, CodingKey {
case id, url, body, user, reactions
case htmlURL = "html_url"
case createdAt = "created_at"
case updatedAt = "updated_at"

case line, side
case commitId = "commit_id"
case startLine = "start_line"
Expand Down Expand Up @@ -460,7 +460,6 @@ public extension Octokit {
decoder.dateDecodingStrategy = .formatted(Time.rfc3339DateFormatter)
return try await router.post(session, decoder: decoder, expectedResultType: PullRequest.self)
}

#endif

func listPullRequestsFiles(owner: String,
Expand Down Expand Up @@ -490,7 +489,7 @@ public extension Octokit {
return try await router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [PullRequest.File].self)
}
#endif

/// Fetches all review comments for a pull request.
/// - Parameters:
/// - owner: The user or organization that owns the repository.
Expand All @@ -515,7 +514,7 @@ public extension Octokit {
}
}
}

#if compiler(>=5.5.2) && canImport(_Concurrency)
/// Fetches all review comments for a pull request.
/// - Parameters:
Expand All @@ -534,7 +533,7 @@ public extension Octokit {
return try await router.load(session, dateDecodingStrategy: .formatted(Time.rfc3339DateFormatter), expectedResultType: [PullRequest.Comment].self)
}
#endif

/// Posts a review comment on a pull request using the given body.
/// - Parameters:
/// - owner: The user or organization that owns the repository.
Expand Down Expand Up @@ -565,7 +564,7 @@ public extension Octokit {
}
}
}

#if compiler(>=5.5.2) && canImport(_Concurrency)
/// Posts a review comment on a pull request using the given body.
/// - Parameters:
Expand All @@ -590,7 +589,7 @@ public extension Octokit {
return try await router.post(session, decoder: decoder, expectedResultType: PullRequest.Comment.self)
}
#endif

/// Posts a review comment on a pull request using the given body.
/// - Parameters:
/// - owner: The user or organization that owns the repository.
Expand All @@ -611,7 +610,7 @@ public extension Octokit {
number: number, body: body,
completion: completion)
}

#if compiler(>=5.5.2) && canImport(_Concurrency)
/// Posts a review comment on a pull request using the given body.
/// - Parameters:
Expand All @@ -629,7 +628,7 @@ public extension Octokit {
try await commentIssue(owner: owner, repository: repository, number: number, body: body)
}
#endif

/// Fetches all reviewers for a pull request.
/// - Parameters:
/// - owner: The user or organization that owns the repository.
Expand All @@ -654,7 +653,7 @@ public extension Octokit {
}
}
}

#if compiler(>=5.5.2) && canImport(_Concurrency)
/// Fetches all reviewers for a pull request.
/// - Parameters:
Expand Down Expand Up @@ -697,7 +696,7 @@ enum PullRequestRouter: JSONPostRouter {
var method: HTTPMethod {
switch self {
case .createPullRequest,
.createPullRequestReviewComment:
.createPullRequestReviewComment:
return .POST
case .readPullRequest,
.readPullRequests,
Expand Down
4 changes: 2 additions & 2 deletions OctoKit/Team.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import FoundationNetworking
// MARK: model

open class Team: Codable {
open internal(set) var id: Int
open internal(set) var id: Int
open var nodeID: String
open var name: String
open var slug: String
Expand Down Expand Up @@ -49,7 +49,7 @@ open class Team: Codable {
self.membersURL = membersURL
self.repositoriesURL = repositoriesURL
}

enum CodingKeys: String, CodingKey {
case id, name, slug, description, privacy, url
case nodeID = "node_id"
Expand Down
28 changes: 10 additions & 18 deletions Tests/OctoKitTests/PullRequestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,12 @@ class PullRequestTests: XCTestCase {
XCTAssertTrue(session.wasCalled)
}
#endif

func testReadPullRequestReviewComments() {
let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octokat/Hello-World/pulls/1347/comments?",
expectedHTTPMethod: "GET",
jsonFile: "pull_request_comments",
statusCode: 200)

let task = Octokit(session: session).readPullRequestReviewComments(owner: "octokat",
repository: "Hello-World",
number: 1347) { response in
Expand All @@ -452,15 +451,14 @@ class PullRequestTests: XCTestCase {
XCTAssertNotNil(task)
XCTAssertTrue(session.wasCalled)
}

#if compiler(>=5.5.2) && canImport(_Concurrency)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func testReadPullRequestReviewCommentsAsync() async throws {
let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octokat/Hello-World/pulls/1347/comments?",
expectedHTTPMethod: "GET",
jsonFile: "pull_request_comments",
statusCode: 200)

let comments = try await Octokit(session: session).readPullRequestReviewComments(owner: "octokat",
repository: "Hello-World",
number: 1347)
Expand All @@ -471,13 +469,12 @@ class PullRequestTests: XCTestCase {
XCTAssertTrue(session.wasCalled)
}
#endif

func testCreatePullRequestReviewComment() {
let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octokat/Hello-World/pulls/1347/comments",
expectedHTTPMethod: "POST",
jsonFile: "pull_request_comment",
statusCode: 200)

let task = Octokit(session: session).createPullRequestReviewComment(owner: "octokat",
repository: "Hello-World",
number: 1347,
Expand All @@ -498,19 +495,18 @@ class PullRequestTests: XCTestCase {
XCTAssertNil(error)
}
}

XCTAssertNotNil(task)
XCTAssertTrue(session.wasCalled)
}

#if compiler(>=5.5.2) && canImport(_Concurrency)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func testCreatePullRequestReviewCommentAsync() async throws {
let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octokat/Hello-World/pulls/1347/comments",
expectedHTTPMethod: "POST",
jsonFile: "pull_request_comment",
statusCode: 200)

let comment = try await Octokit(session: session).createPullRequestReviewComment(owner: "octokat",
repository: "Hello-World",
number: 1347,
Expand All @@ -528,13 +524,12 @@ class PullRequestTests: XCTestCase {
XCTAssertTrue(session.wasCalled)
}
#endif

func testCreatePullRequestRegularComment() {
let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octokat/Hello-World/issues/1347/comments",
expectedHTTPMethod: "POST",
jsonFile: "pull_request_comment",
statusCode: 200)

let task = Octokit(session: session).createPullRequestReviewComment(owner: "octokat",
repository: "Hello-World",
number: 1347,
Expand All @@ -546,19 +541,18 @@ class PullRequestTests: XCTestCase {
XCTAssertNil(error)
}
}

XCTAssertNotNil(task)
XCTAssertTrue(session.wasCalled)
}

#if compiler(>=5.5.2) && canImport(_Concurrency)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func testCreatePullRequestRegularCommentAsync() async throws {
let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octokat/Hello-World/issues/1347/comments",
expectedHTTPMethod: "POST",
jsonFile: "pull_request_comment",
statusCode: 200)

let comment = try await Octokit(session: session).createPullRequestReviewComment(owner: "octokat",
repository: "Hello-World",
number: 1347,
Expand All @@ -567,13 +561,12 @@ class PullRequestTests: XCTestCase {
XCTAssertTrue(session.wasCalled)
}
#endif

func testReadPullRequestRequestedReviewers() {
let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octokat/Hello-World/pulls/1347/requested_reviewers?",
expectedHTTPMethod: "GET",
jsonFile: "pull_request_requested_reviewers",
statusCode: 200)

let task = Octokit(session: session).readPullRequestRequestedReviewers(owner: "octokat",
repository: "Hello-World",
number: 1347) { response in
Expand All @@ -590,15 +583,14 @@ class PullRequestTests: XCTestCase {
XCTAssertNotNil(task)
XCTAssertTrue(session.wasCalled)
}

#if compiler(>=5.5.2) && canImport(_Concurrency)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func testReadPullRequestRequestedReviewersAsync() async throws {
let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octokat/Hello-World/pulls/1347/requested_reviewers?",
expectedHTTPMethod: "GET",
jsonFile: "pull_request_requested_reviewers",
statusCode: 200)

let requestedReviewers = try await Octokit(session: session).readPullRequestRequestedReviewers(owner: "octokat",
repository: "Hello-World",
number: 1347)
Expand Down

0 comments on commit 61e97e6

Please sign in to comment.