Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

[Technical] Marked the "not implemented" initializers as "unavailable" (closes #681) #682

Conversation

lennartstolz
Copy link
Contributor

This PR addresses the issue described in #681 .

Description

When providing a custom initializer for subclasses of (mostly) UIKit
classes conforming to 'NSCoding' the required initializer must be
provided by those subclasses.

Most of them will never be used and stay with the auto suggestion
of Xcode causing a fatalError:

required init?(coder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

As this should never be called, I marked those initializers
with available(*, unavailable). Calling those initializers
will now fail at compile time instead of causing a
runtime crash.

Additionally, it will stop Xcode suggesting those initializers
as code completions.

@lennartstolz lennartstolz requested a review from a team June 17, 2020 12:53
@lennartstolz lennartstolz changed the title [TECH] Marked the "not implemented" initializer as "unavailable" [TECH] Marked the "not implemented" initializers as "unavailable" Jun 17, 2020
@lennartstolz lennartstolz force-pushed the tech/unavailability-of-initializer-causing-fatal-errors branch from f50b7fa to 335e9f1 Compare June 17, 2020 12:55
@lennartstolz lennartstolz changed the title [TECH] Marked the "not implemented" initializers as "unavailable" [Technical] Marked the "not implemented" initializers as "unavailable" Jun 17, 2020
@lennartstolz lennartstolz force-pushed the tech/unavailability-of-initializer-causing-fatal-errors branch 2 times, most recently from e51cd9a to d3af5a6 Compare June 17, 2020 13:19
When providing a custom initializer for subclasses of (mostly) UIKit
classes conforming to 'NSCoding' the required initializer must be
provided by those subclasses.

Most of them will never be used and stay with the auto suggestion
of Xcode causing a `fatalError`:

```
required init?(coder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}
```

As this should never be called, I marked those initializers
with `available(*, unavailable)`. Calling those initializers
will now fail at compile time instead of causing a
runtime crash.

Additionally, it will stop Xcode suggesting those initializers
as code completions.
@lennartstolz lennartstolz force-pushed the tech/unavailability-of-initializer-causing-fatal-errors branch from d3af5a6 to eb036f8 Compare June 17, 2020 13:20
@lennartstolz
Copy link
Contributor Author

@inf2381 I may need your help here (And I saw that it also is a "frequent" issue of some contributors). Do you have any idea how to unblock the issue with circleci?
It says the test-an-scan pipeline is unauthorized.

(Unfortunately, I didn't work with circleci for ages)

AFAIK it's happening in this PR as well: #639

@inf2381
Copy link
Member

inf2381 commented Jun 17, 2020

Could you please login to CircleCI and grant access to your organization? If that solves the issue, I can update our contributing guidelines.

The issue is on our side, we'll come back to you later this day

@lennartstolz
Copy link
Contributor Author

Thanks @inf2381 .
Yeah I tried everything on my side, even removed all private projects and organizations.
All of this didn't help. ;)

@inf2381
Copy link
Member

inf2381 commented Jun 17, 2020

Thanks @inf2381 .
Yeah I tried everything on my side, even removed all private projects and organizations.
All of this didn't help. ;)

The issue was that you didn't have access to the context on CircleCI where the access token for SonarCloud is stored. I deleted the context from config.yaml and stored an access key directly in the environment of CircleCI. It seems to be working now 🥳

@lennartstolz lennartstolz changed the title [Technical] Marked the "not implemented" initializers as "unavailable" [Technical] Marked the "not implemented" initializers as "unavailable" (closes ##681) Jun 17, 2020
@lennartstolz lennartstolz changed the title [Technical] Marked the "not implemented" initializers as "unavailable" (closes ##681) [Technical] Marked the "not implemented" initializers as "unavailable" (closes #681) Jun 17, 2020
@johannesrohwer johannesrohwer self-requested a review June 18, 2020 09:59
@inf2381 inf2381 merged commit f6ef882 into corona-warn-app:next Jun 18, 2020
@inf2381 inf2381 added the chore Refactoring label Jun 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
chore Refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants