Skip to content

Commit

Permalink
Fix swiftlint
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo Carvalho <ricardo.abc@gmail.com>
  • Loading branch information
rabc committed Apr 7, 2024
1 parent f5ac6e3 commit 64a5516
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
35 changes: 20 additions & 15 deletions Sources/XCLogParser/activityparser/ActivityParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public class ActivityParser {
uniqueIdentifier: try parseAsString(token: iterator.next()),
localizedResultString: try parseAsString(token: iterator.next()),
xcbuildSignature: try parseAsString(token: iterator.next()),
// swiftlint:disable:next line_length
attachments: try parseIDEActivityLogSectionAttachments(iterator: &iterator),
// swiftlint:disable:next line_length
unknown: isCommandLineLog ? Int(try parseAsInt(token: iterator.next())) : 0,
Expand Down Expand Up @@ -363,20 +364,24 @@ public class ActivityParser {
}
throw XCLogParserError.parseError("Unexpected className found parsing IDEActivityLogMessage \(className)")
}

private func parseLogSectionAttachment(iterator: inout IndexingIterator<[Token]>) throws -> IDEActivityLogSectionAttachment {
let classRefToken = try getClassRefToken(iterator: &iterator)
guard case Token.classNameRef(let className) = classRefToken else {
throw XCLogParserError.parseError("Unexpected token found parsing IDEActivityLogSectionAttachment \(classRefToken)")
}

if className == "IDEFoundation.\(String(describing: IDEActivityLogSectionAttachment.self))" {
return try IDEActivityLogSectionAttachment(identifier: try parseAsString(token: iterator.next()),
majorVersion: try parseAsInt(token: iterator.next()),
minorVersion: try parseAsInt(token: iterator.next()),
metrics: try parseAsJson(token: iterator.next(), type: IDEActivityLogSectionAttachment.BuildOperationTaskMetrics.self))
}
throw XCLogParserError.parseError("Unexpected className found parsing IDEConsoleItem \(className)")
private func parseLogSectionAttachment(iterator: inout IndexingIterator<[Token]>)
throws -> IDEActivityLogSectionAttachment {
let classRefToken = try getClassRefToken(iterator: &iterator)
guard case Token.classNameRef(let className) = classRefToken else {
throw XCLogParserError.parseError("Unexpected token found parsing " +
"IDEActivityLogSectionAttachment \(classRefToken)")
}

if className == "IDEFoundation.\(String(describing: IDEActivityLogSectionAttachment.self))" {
let jsonType = IDEActivityLogSectionAttachment.BuildOperationTaskMetrics.self
return try IDEActivityLogSectionAttachment(identifier: try parseAsString(token: iterator.next()),
majorVersion: try parseAsInt(token: iterator.next()),
minorVersion: try parseAsInt(token: iterator.next()),
metrics: try parseAsJson(token: iterator.next(),
type: jsonType))
}
throw XCLogParserError.parseError("Unexpected className found parsing IDEConsoleItem \(className)")
}

private func parseLogSection(iterator: inout IndexingIterator<[Token]>)
Expand Down Expand Up @@ -450,7 +455,7 @@ public class ActivityParser {
"IDEActivityLogSection: \(listToken)")
}
}

private func parseIDEActivityLogSectionAttachments(iterator: inout IndexingIterator<[Token]>)
throws -> [IDEActivityLogSectionAttachment] {
guard let listToken = iterator.next() else {
Expand Down Expand Up @@ -593,7 +598,7 @@ public class ActivityParser {
throw XCLogParserError.parseError("Unexpected token parsing String: \(token)")
}
}

private func parseAsJson<T: Decodable>(token: Token?, type: T.Type) throws -> T? {
guard let token = token else {
throw XCLogParserError.parseError("Unexpected EOF parsing JSON String")
Expand Down
12 changes: 8 additions & 4 deletions Sources/XCLogParser/activityparser/IDEActivityModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -653,17 +653,21 @@ public class IDEActivityLogSectionAttachment: Encodable {
public let wcStartTime: UInt64
public let wcDuration: UInt64
}

public let identifier: String
public let majorVersion: UInt64
public let minorVersion: UInt64
public let metrics: BuildOperationTaskMetrics?

public init(identifier: String, majorVersion: UInt64, minorVersion: UInt64, metrics: BuildOperationTaskMetrics?) throws {

public init(
identifier: String,
majorVersion: UInt64,
minorVersion: UInt64,
metrics: BuildOperationTaskMetrics?
) throws {
self.identifier = identifier
self.majorVersion = majorVersion
self.minorVersion = minorVersion
self.metrics = metrics
}
}

2 changes: 1 addition & 1 deletion Sources/XCLogParser/lexer/Lexer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public final class Lexer {
}
return .string(content)
}

private func handleJSONTokenTypeCase(scanner: Scanner,
payload: String,
redacted: Bool,
Expand Down

0 comments on commit 64a5516

Please sign in to comment.