Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat warnings as errors across the codebase #1249

Merged
merged 3 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Ably.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3220,6 +3220,7 @@
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -3230,6 +3231,7 @@
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -3275,6 +3277,7 @@
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -3286,6 +3289,7 @@
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand Down
44 changes: 22 additions & 22 deletions Spec/Tests/CryptoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class CryptoTests: XCTestCase {
case should_decrypt_messages_as_expected_in_the_fixtures
}

func reusableTestsTestFixture(_ cryptoFixture: (fileName: String, expectedEncryptedEncoding: String, keyLength: UInt), testCase: TestCase_ReusableTestsTestFixture, beforeEach contextBeforeEach: (() -> Void)? = nil, afterEach contextAfterEach: (() -> Void)? = nil) {
func reusableTestsTestFixture(_ cryptoFixture: (fileName: String, expectedEncryptedEncoding: String, keyLength: UInt), testCase: TestCase_ReusableTestsTestFixture, beforeEach contextBeforeEach: (() -> Void)? = nil, afterEach contextAfterEach: (() -> Void)? = nil) throws {
let (key, iv, items) = AblyTests.loadCryptoTestData(cryptoFixture.fileName)
let decoder = ARTDataEncoder(cipherParams: nil, error: nil)
let cipherParams = ARTCipherParams(algorithm: "aes", key: key as ARTCipherKeyCompatible, iv: iv)
Expand All @@ -140,7 +140,7 @@ class CryptoTests: XCTestCase {
return msg
}

func test__should_encrypt_messages_as_expected_in_the_fixtures() {
func test__should_encrypt_messages_as_expected_in_the_fixtures() throws {
contextBeforeEach?()

for item in items {
Expand All @@ -153,17 +153,17 @@ class CryptoTests: XCTestCase {
expect(error).to(beNil())
expect(decoded).notTo(beNil())

let encrypted = decoded.encode(with: encrypter, error: &error)
let encrypted = try XCTUnwrap(decoded.encode(with: encrypter, error: &error) as? ARTMessage)
expect(error).to(beNil())
expect(encrypted).notTo(beNil())

expect(encrypted as! ARTMessage).to(equal(encryptedFixture))
expect(encrypted).to(equal(encryptedFixture))
}

contextAfterEach?()
}

func test__should_decrypt_messages_as_expected_in_the_fixtures() {
func test__should_decrypt_messages_as_expected_in_the_fixtures() throws {
contextBeforeEach?()

for item in items {
Expand All @@ -176,45 +176,45 @@ class CryptoTests: XCTestCase {
expect(error).to(beNil())
expect(decoded).notTo(beNil())

let decrypted = encryptedFixture.decode(with: encrypter, error: &error)
let decrypted = try XCTUnwrap(encryptedFixture.decode(with: encrypter, error: &error) as? ARTMessage)
expect(error).to(beNil())
expect(decrypted).notTo(beNil())

expect(decrypted as! ARTMessage).to(equal(decoded))
expect(decrypted).to(equal(decoded))
}

contextAfterEach?()
}

switch testCase {
case .should_encrypt_messages_as_expected_in_the_fixtures:
test__should_encrypt_messages_as_expected_in_the_fixtures()
try test__should_encrypt_messages_as_expected_in_the_fixtures()
case .should_decrypt_messages_as_expected_in_the_fixtures:
test__should_decrypt_messages_as_expected_in_the_fixtures()
try test__should_decrypt_messages_as_expected_in_the_fixtures()
}
}

func reusableTestsWrapper__Crypto__with_fixtures_from_crypto_data_128_json__reusableTestsTestFixture(testCase: TestCase_ReusableTestsTestFixture) {
reusableTestsTestFixture(("crypto-data-128", "cipher+aes-128-cbc", 128), testCase: testCase)
func reusableTestsWrapper__Crypto__with_fixtures_from_crypto_data_128_json__reusableTestsTestFixture(testCase: TestCase_ReusableTestsTestFixture) throws {
try reusableTestsTestFixture(("crypto-data-128", "cipher+aes-128-cbc", 128), testCase: testCase)
}

func test__011__Crypto__with_fixtures_from_crypto_data_128_json__should_encrypt_messages_as_expected_in_the_fixtures() {
reusableTestsWrapper__Crypto__with_fixtures_from_crypto_data_128_json__reusableTestsTestFixture(testCase: .should_encrypt_messages_as_expected_in_the_fixtures)
func test__011__Crypto__with_fixtures_from_crypto_data_128_json__should_encrypt_messages_as_expected_in_the_fixtures() throws {
try reusableTestsWrapper__Crypto__with_fixtures_from_crypto_data_128_json__reusableTestsTestFixture(testCase: .should_encrypt_messages_as_expected_in_the_fixtures)
}

func test__012__Crypto__with_fixtures_from_crypto_data_128_json__should_decrypt_messages_as_expected_in_the_fixtures() {
reusableTestsWrapper__Crypto__with_fixtures_from_crypto_data_128_json__reusableTestsTestFixture(testCase: .should_decrypt_messages_as_expected_in_the_fixtures)
func test__012__Crypto__with_fixtures_from_crypto_data_128_json__should_decrypt_messages_as_expected_in_the_fixtures() throws {
try reusableTestsWrapper__Crypto__with_fixtures_from_crypto_data_128_json__reusableTestsTestFixture(testCase: .should_decrypt_messages_as_expected_in_the_fixtures)
}

func reusableTestsWrapper__Crypto__with_fixtures_from_crypto_data_256_json__reusableTestsTestFixture(testCase: TestCase_ReusableTestsTestFixture) {
reusableTestsTestFixture(("crypto-data-256", "cipher+aes-256-cbc", 256), testCase: testCase)
func reusableTestsWrapper__Crypto__with_fixtures_from_crypto_data_256_json__reusableTestsTestFixture(testCase: TestCase_ReusableTestsTestFixture) throws {
try reusableTestsTestFixture(("crypto-data-256", "cipher+aes-256-cbc", 256), testCase: testCase)
}

func test__013__Crypto__with_fixtures_from_crypto_data_256_json__should_encrypt_messages_as_expected_in_the_fixtures() {
reusableTestsWrapper__Crypto__with_fixtures_from_crypto_data_256_json__reusableTestsTestFixture(testCase: .should_encrypt_messages_as_expected_in_the_fixtures)
func test__013__Crypto__with_fixtures_from_crypto_data_256_json__should_encrypt_messages_as_expected_in_the_fixtures() throws {
try reusableTestsWrapper__Crypto__with_fixtures_from_crypto_data_256_json__reusableTestsTestFixture(testCase: .should_encrypt_messages_as_expected_in_the_fixtures)
}

func test__014__Crypto__with_fixtures_from_crypto_data_256_json__should_decrypt_messages_as_expected_in_the_fixtures() {
reusableTestsWrapper__Crypto__with_fixtures_from_crypto_data_256_json__reusableTestsTestFixture(testCase: .should_decrypt_messages_as_expected_in_the_fixtures)
func test__014__Crypto__with_fixtures_from_crypto_data_256_json__should_decrypt_messages_as_expected_in_the_fixtures() throws {
try reusableTestsWrapper__Crypto__with_fixtures_from_crypto_data_256_json__reusableTestsTestFixture(testCase: .should_decrypt_messages_as_expected_in_the_fixtures)
}
}
2 changes: 2 additions & 0 deletions Spec/Tests/RealtimeClientConnectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3326,6 +3326,7 @@ class RealtimeClientConnectionTests: XCTestCase {
}

// RTN17b
@available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.")
func test__086__Connection__Host_Fallback__failing_connections_with_custom_endpoint_should_result_in_an_error_immediately() {
beforeEach__Connection__Host_Fallback()

Expand Down Expand Up @@ -3380,6 +3381,7 @@ class RealtimeClientConnectionTests: XCTestCase {
}

// RTN17b
@available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.")
func test__087__Connection__Host_Fallback__failing_connections_with_custom_endpoint_should_result_in_time_outs() {
beforeEach__Connection__Host_Fallback()

Expand Down
1 change: 1 addition & 0 deletions Spec/Tests/RestClientChannelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ class RestClientChannelTests: XCTestCase {
}

// RSL1k4
@available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.")
func test__025__publish__idempotent_publishing__should_have_only_one_published_message() {
client.internal.options.idempotentRestPublishing = true
client.internal.httpExecutor = testHTTPExecutor
Expand Down
6 changes: 6 additions & 0 deletions Spec/Tests/RestClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ class RestClientTests: XCTestCase {

// TO3k7

@available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.")
func test__051__RestClient__Host_Fallback__fallbackHostsUseDefault_option__allows_the_default_fallback_hosts_to_be_used_when__environment__is_not_production() {
let options = ARTClientOptions(key: "xxxx:xxxx")
options.environment = "not-production"
Expand All @@ -785,6 +786,7 @@ class RestClientTests: XCTestCase {
}
}

@available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.")
func test__052__RestClient__Host_Fallback__fallbackHostsUseDefault_option__allows_the_default_fallback_hosts_to_be_used_when_a_custom_Realtime_or_REST_host_endpoint_is_being_used() {
let options = ARTClientOptions(key: "xxxx:xxxx")
options.restHost = "fake1.ably.io"
Expand All @@ -806,11 +808,13 @@ class RestClientTests: XCTestCase {
}
}

@available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.")
func test__053__RestClient__Host_Fallback__fallbackHostsUseDefault_option__should_be_inactive_by_default() {
let options = ARTClientOptions(key: "xxxx:xxxx")
expect(options.fallbackHostsUseDefault).to(beFalse())
}

@available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.")
func test__054__RestClient__Host_Fallback__fallbackHostsUseDefault_option__should_never_accept_to_configure__fallbackHost__and_set__fallbackHostsUseDefault__to__true_() {
let options = ARTClientOptions(key: "xxxx:xxxx")
expect(options.fallbackHosts).to(beNil())
Expand Down Expand Up @@ -953,6 +957,7 @@ class RestClientTests: XCTestCase {
}

// RSC15b3, RSC15g4
@available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.")
func test__060__RestClient__Host_Fallback__Fallback_behavior__should_be_applied_when_ClientOptions_fallbackHosts_is_not_provided_and_deprecated_fallbackHostsUseDefault_is_on() {
let options = ARTClientOptions(key: "xxxx:xxxx")
options.fallbackHostsUseDefault = true
Expand Down Expand Up @@ -1100,6 +1105,7 @@ class RestClientTests: XCTestCase {
}

// RSC15g4
@available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.")
func test__046__RestClient__Host_Fallback__applies_when_ClientOptions_fallbackHostsUseDefault_is_true() {
let options = ARTClientOptions(key: "xxxx:xxxx")
options.environment = "test"
Expand Down