Skip to content

Commit

Permalink
Fix new Xcode and SwiftLint warnings (#21)
Browse files Browse the repository at this point in the history
* Fix new SwiftLint warnings

* Add a note about Xcode 14.3

* Update Tests/PexipVideoFiltersTests/Internal/ImageFilterTests.swift
  • Loading branch information
vadymmarkov authored Apr 20, 2023
1 parent 843c48d commit 78382ad
Show file tree
Hide file tree
Showing 37 changed files with 96 additions and 46 deletions.
3 changes: 3 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ identifier_name:
excluded:
- id
- to
attributes:
always_on_same_line:
["@AppStorage", "@NSApplicationDelegateAdaptor"]
file_header:
severity: error
required_pattern: |
Expand Down
5 changes: 2 additions & 3 deletions Examples/Conference/App/Shared/App/AppCoordinator.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2022 Pexip AS
// Copyright 2022-2023 Pexip AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -46,8 +46,7 @@ struct AppCoordinator: View {
#endif
}

@ViewBuilder
private var currentScreen: some View {
@ViewBuilder private var currentScreen: some View {
switch screen {
case .displayName:
viewFactory.displayNameView(onComplete: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2022 Pexip AS
// Copyright 2022-2023 Pexip AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,4 +28,5 @@ struct LargeTextFieldStyle: TextFieldStyle {
.fill(Material.ultraThin)
)
}
// swiftlint:enable identifier_name
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2022 Pexip AS
// Copyright 2022-2023 Pexip AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -192,8 +192,7 @@ private extension CallView {
}
}

@ViewBuilder
var presenterNameLabel: some View {
@ViewBuilder var presenterNameLabel: some View {
presenterName.map { name in
Text("\(name) presenting")
.padding(.horizontal, 10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ struct ConferenceView: View {
)
}

@ViewBuilder
private var connectedView: some View {
@ViewBuilder private var connectedView: some View {
GeometryReader { geometry in
let callViewSize = callViewSize(geometry: geometry)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ private extension ConferenceViewModel {
}
.store(in: &cancellables)
}
// swiftlint:enable cyclomatic_complexity
}

// MARK: - Private
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2022 Pexip AS
// Copyright 2022-2023 Pexip AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,8 +29,7 @@ struct PinChallengeView: View {
}
}

@ViewBuilder
private var pinInput: some View {
@ViewBuilder private var pinInput: some View {
Text("Welcome to the meeting, \(viewModel.displayName)!")
.font(.title)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2022 Pexip AS
// Copyright 2022-2023 Pexip AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -109,6 +109,7 @@ final class CameraViewModel: ObservableObject {
)
}
}
// swiftlint:enable cyclomatic_complexity function_body_length

private func segmenter(
for segmentationSettings: Settings.Segmentation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2022 Pexip AS
// Copyright 2022-2023 Pexip AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -98,6 +98,7 @@ final class MLKitPersonSegmenter: PersonSegmenter {
{
deviceOrientation = currentOrientation
}
// swiftlint:enable opening_brace

switch deviceOrientation {
case .portrait:
Expand Down
3 changes: 0 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ let package = Package(
dependencies: [
"PexipMedia",
.product(name: "WebRTC", package: "webrtc-objc")
],
cSettings: [
.unsafeFlags(["-w"])
]
),
.testTarget(
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ media signaling technologies in the future, or Infinity might be interchanged wi
- Swift 5.5 with structured concurrency support
- Xcode 13

:warning: **The project doesn't compile on Xcode 14.3 because of incorrect availability attributes CGDisplayStream.h file (introduced: is 13.0 instead of 10.8). Let's hope it's fixed in future Xcode versions.**

## Installation

### Swift Package Manager
Expand Down
2 changes: 2 additions & 0 deletions Sources/PexipInfinityClient/Conference/Conference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ final class DefaultConference: Conference {
notify(outputEvent)
}
}
// swiftlint:enable cyclomatic_complexity
// swiftlint:enable function_body_length

@MainActor
private func notify(_ event: ConferenceClientEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,4 @@ struct DefaultConferenceService: ConferenceService {
}
}
}
// swiftlint:enable line_length
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public struct ConferenceToken: InfinityToken, Codable, Hashable {
case _analyticsEnabled = "analytics_enabled"
case _directMedia = "direct_media"
}
// swiftlint:enable identifier_name

/// A textual representation of this type, suitable for debugging.
public static let name = "Conference token"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,5 @@ struct ConferenceEventParser: InfinityEventParser {
return .clientDisconnected(event)
}
}
// swiftlint:enable cyclomatic_complexity
}
3 changes: 2 additions & 1 deletion Sources/PexipInfinityClient/InfinityService.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2022 Pexip AS
// Copyright 2022-2023 Pexip AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -46,6 +46,7 @@ public extension InfinityService {
return url
}
}
// swiftlint: enable for_where

return nil
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2022 Pexip AS
// Copyright 2022-2023 Pexip AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -122,6 +122,7 @@ final class DNSLookupClient: DNSLookupClientProtocol {
context.records.append(Data(bytes: bytes, count: Int(length)))
}
}
// swiftlint:enable closure_parameter_position
}

// MARK: - Private extensions
Expand Down
3 changes: 2 additions & 1 deletion Sources/PexipInfinityClient/Node/NodeService.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2022 Pexip AS
// Copyright 2022-2023 Pexip AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -106,3 +106,4 @@ struct DefaultNodeService: NodeService {
)
}
}
// swiftlint:enable line_length
1 change: 1 addition & 0 deletions Sources/PexipInfinityClient/Participants/Participant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,4 @@ public struct Participant: Codable, Hashable, Identifiable {
case deny = "DENY"
}
}
// swiftlint:enable identifier_name
1 change: 1 addition & 0 deletions Sources/PexipRTC/Internal/WebRTCMediaConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -594,3 +594,4 @@ extension WebRTCMediaConnection: RTCDataChannelDelegate {
}
}
}
// swiftlint:enable file_length
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ final class BroadcastNotificationCenter {
observation.handler()
}
}
// swiftlint:enable prefer_self_in_static_references

CFNotificationCenterAddObserver(
center,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ import ScreenCaptureKit
*/
@available(macOS 12.3, *)
final class NewScreenMediaCapturer<Factory: ScreenCaptureStreamFactory>: NSObject,
ScreenMediaCapturer,
SCStreamOutput,
SCStreamDelegate
{
ScreenMediaCapturer,
SCStreamOutput,
SCStreamDelegate {
let source: ScreenMediaSource
weak var delegate: ScreenMediaCapturerDelegate?
private(set) var isCapturing = false
Expand Down Expand Up @@ -121,6 +120,7 @@ final class NewScreenMediaCapturer<Factory: ScreenCaptureStreamFactory>: NSObjec
else {
return
}
// swiftlint:enable force_cast

let transform = CGAffineTransform(scaleX: scaleFactor, y: scaleFactor)
contentRect = contentRect.applying(transform)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2022 Pexip AS
// Copyright 2022-2023 Pexip AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,7 @@ import ScreenCaptureKit
// MARK: - ShareableContent

// swiftlint:disable type_name

@available(macOS 12.3, *)
protocol ShareableContent {
associatedtype Content: ShareableContent
Expand Down Expand Up @@ -92,4 +93,6 @@ extension SCDisplay: Display {}
@available(macOS 12.3, *)
extension SCRunningApplication: RunningApplication {}

// swiftlint:enable type_name

#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2022 Pexip AS
// Copyright 2022-2023 Pexip AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -52,8 +52,13 @@ final class ConferenceServiceTests: APITestCase {
responseJSON: responseJSON,
assertHTTPErrors: false,
execute: { [weak self] in
var token = try await service.requestToken(fields: fields, pin: pin)
XCTAssertEqual(self?.lastRequest?.value(forHTTPHeaderField: "pin"), pin)
guard let self else {
XCTFail("Test case was deallocated")
return
}

var token = try await self.service.requestToken(fields: fields, pin: pin)
XCTAssertEqual(self.lastRequest?.value(forHTTPHeaderField: "pin"), pin)
XCTAssertEqual(token.value, expectedToken.value)
XCTAssertEqual(token.expires, expectedToken.expires)
// Update token to have the same `updatedAt` date as in expected token
Expand Down Expand Up @@ -82,12 +87,17 @@ final class ConferenceServiceTests: APITestCase {
responseJSON: responseJSON,
assertHTTPErrors: false,
execute: { [weak self] in
var token = try await service.requestToken(
guard let self else {
XCTFail("Test case was deallocated")
return
}

var token = try await self.service.requestToken(
fields: fields,
incomingToken: incomingToken
)
XCTAssertEqual(
self?.lastRequest?.value(forHTTPHeaderField: "token"),
self.lastRequest?.value(forHTTPHeaderField: "token"),
incomingToken
)
XCTAssertEqual(token.value, expectedToken.value)
Expand Down Expand Up @@ -366,6 +376,7 @@ final class ConferenceServiceTests: APITestCase {
)
}
}
// swiftlint:enable type_body_length

// MARK: - Private types

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import PexipCore
import TestHelpers
@testable import PexipInfinityClient

// swiftlint:disable file_length
// swiftlint:disable type_body_length
// swiftlint:disable file_length type_body_length function_body_length
final class ConferenceTests: XCTestCase {
private var conference: DefaultConference!
private var tokenStore: TokenStore<ConferenceToken>!
Expand All @@ -39,7 +38,6 @@ final class ConferenceTests: XCTestCase {

// MARK: - Setup

// swiftlint:disable function_body_length
override func setUp() async throws {
try await super.setUp()

Expand Down Expand Up @@ -764,6 +762,7 @@ final class ConferenceTests: XCTestCase {
wait(for: [assertExpectation], timeout: 0.1)
}
}
// swiftlint:enable type_body_length

// MARK: - Mocks

Expand Down Expand Up @@ -869,3 +868,5 @@ private extension ConferenceStatus {
)
}
}
// swiftlint:enable function_body_length
// swiftlint:enable file_length
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ final class ConferenceTokenTests: XCTestCase {
)
)
}
// swiftlint:enable function_body_length

func testUpdating() throws {
let date = Date()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,12 @@ final class ConferenceSignalingChannelTests: XCTestCase {
)
}
}
// swiftlint:enable type_body_length

// MARK: - Mocks

// swiftlint:disable unavailable_function
// swiftlint:disable fatal_error_message

private final class ParticipantServiceMock: ParticipantService {
enum Action {
case calls
Expand Down Expand Up @@ -581,3 +581,6 @@ private final class CallServiceMock: CallService {
return try XCTUnwrap(results[action]?.get() as? T)
}
}
// swiftlint:enable unavailable_function
// swiftlint:enable fatal_error_message
// swiftlint:enable file_length
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ final class RosterTests: XCTestCase {
XCTAssertEqual(publishCount, 3)
}
}
// swiftlint:enable type_body_length

// MARK: - Mocks

Expand Down
Loading

0 comments on commit 78382ad

Please sign in to comment.