Skip to content

Commit

Permalink
Address source code warnings (#1807)
Browse files Browse the repository at this point in the history
* Address a few warnings in unit tests

* Address Sendable-related warning

* Skip "Xcode upgrade" warning
  • Loading branch information
OdNairy authored Sep 13, 2023
1 parent 5682ddd commit 2444553
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import Dispatch
// depending on this protocol instead of on DispatchQueue directly
// allow mocking the main queue in tests which avoids the need for waits
protocol DispatchQueueProtocol: AnyObject {
func async(
@preconcurrency func async(
group: DispatchGroup?,
qos: DispatchQoS,
flags: DispatchWorkItemFlags,
execute work: @escaping @convention(block) () -> Void
execute work: @Sendable @escaping @convention(block) () -> Void
)
func async(execute workItem: DispatchWorkItem)
}

extension DispatchQueueProtocol {
func async(execute work: @escaping @convention(block) () -> Void) {
@preconcurrency func async(execute work: @escaping @convention(block) () -> Void) {
async(group: nil, qos: .unspecified, flags: [], execute: work)
}

func async(
@preconcurrency func async(
qos: DispatchQoS,
execute work: @escaping @convention(block) () -> Void
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import XCTest
final class ViewAnnotationPositionsUpdateListenerImplTests: XCTestCase {

func testOnViewAnnotationPositionsUpdate() {
var stub = Stub<[ViewAnnotationPositionDescriptor], Void>()
var me = ViewAnnotationPositionsUpdateListenerImpl(callback: stub.call(with:))
let stub = Stub<[ViewAnnotationPositionDescriptor], Void>()
let me = ViewAnnotationPositionsUpdateListenerImpl(callback: stub.call(with:))

let descriptor = ViewAnnotationPositionDescriptor(
identifier: "test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2992,10 +2992,10 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega
style.addPersistentLayerStub.reset()
// given
let clusterOptions = ClusterOptions()
var annotations = (0..<500).map { _ in
let annotations = (0..<500).map { _ in
PointAnnotation(coordinate: .random(), isSelected: false, isDraggable: false)
}
var newAnnotations = (0..<100).map { _ in
let newAnnotations = (0..<100).map { _ in
PointAnnotation(coordinate: .random(), isSelected: false, isDraggable: false)
}

Expand All @@ -3011,16 +3011,16 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega
)
pointAnnotationManager.annotations = annotations
$displayLink.send()
var parameters = try XCTUnwrap(style.addGeoJSONSourceFeaturesStub.invocations.last).parameters
let parameters = try XCTUnwrap(style.addGeoJSONSourceFeaturesStub.invocations.last).parameters
XCTAssertEqual(parameters.features, annotations.map(\.feature))

// then
pointAnnotationManager.annotations = newAnnotations
$displayLink.send()
var addParameters = try XCTUnwrap(style.addGeoJSONSourceFeaturesStub.invocations.last).parameters
let addParameters = try XCTUnwrap(style.addGeoJSONSourceFeaturesStub.invocations.last).parameters
XCTAssertEqual(addParameters.features, newAnnotations.map(\.feature))

var removeParameters = try XCTUnwrap(style.removeGeoJSONSourceFeaturesStub.invocations.last).parameters
let removeParameters = try XCTUnwrap(style.removeGeoJSONSourceFeaturesStub.invocations.last).parameters
XCTAssertEqual(removeParameters.featureIds, annotations.map(\.id))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,9 @@ final class StyleSourceManagerTests: XCTestCase {
feature.identifier = .number(featureIdentifier)

sourceManager.updateGeoJSONSource(withId: sourceId, data: .emptyFeatureCollection(), dataId: nil)
try sourceManager.addGeoJSONSourceFeatures(forSourceId: sourceId, features: [feature], dataId: nil)
try sourceManager.updateGeoJSONSourceFeatures(forSourceId: sourceId, features: [feature], dataId: nil)
try sourceManager.removeGeoJSONSourceFeatures(forSourceId: sourceId,
sourceManager.addGeoJSONSourceFeatures(forSourceId: sourceId, features: [feature], dataId: nil)
sourceManager.updateGeoJSONSourceFeatures(forSourceId: sourceId, features: [feature], dataId: nil)
sourceManager.removeGeoJSONSourceFeatures(forSourceId: sourceId,
featureIds: [featureIdentifier.description],
dataId: nil)

Expand All @@ -539,7 +539,7 @@ final class StyleSourceManagerTests: XCTestCase {
backgroundQueue.asyncWorkItemStub.defaultSideEffect = { $0.parameters.perform() }

// when
try sourceManager.removeGeoJSONSourceFeatures(forSourceId: sourceId, featureIds: featureIdentifiers, dataId: dataId)
sourceManager.removeGeoJSONSourceFeatures(forSourceId: sourceId, featureIds: featureIdentifiers, dataId: dataId)

// then
XCTAssertEqual(styleManager.removeGeoJSONSourceFeaturesStub.invocations.count, 1)
Expand Down
1 change: 0 additions & 1 deletion Tests/MapboxMapsTests/SwiftUI/MapContentBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ final class MapContentBuilderTests: XCTestCase {

func testForEvery() throws {
var visitorIds: [AnyHashable] = []
var condition = true
let data = Array.random(withLength: 5, generator: { UUID().uuidString })

@MapContentBuilder func content() -> MapContent {
Expand Down
1 change: 1 addition & 0 deletions project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ configFiles:
options:
bundleIdPrefix: com.mapbox
defaultConfig: Release
xcodeVersion: "15.0"
parallelizeBuild: false
groupOrdering:
- order:
Expand Down

0 comments on commit 2444553

Please sign in to comment.