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

Guard issue #82

Closed
manuelgon47 opened this issue Nov 5, 2018 · 1 comment
Closed

Guard issue #82

manuelgon47 opened this issue Nov 5, 2018 · 1 comment

Comments

@manuelgon47
Copy link

Swift code:

guard let match = self.interactor.match,
            (interactor.userIsOwner || interactor.userIsPlayer) else {
                self.view?.updateResultStatus(MatchResultStatusItem.viewOnly(title: R.string.localizable.match_edit_result_view_only_title()))
                return
        }

Transformed code:

val match = this.interactor.match
if (match == null || !(interactor.userIsOwner && !interactor.userIsPlayer)) {
    this.view?.updateResultStatus(MatchResultStatusItem.viewOnly(title = R.string.localizable.match_edit_result_view_only_title()))
    return
}

Correct transformation:

        val match = this.interactor.match
        if (match == null || (!interactor.userIsOwner && !interactor.userIsPlayer)) {
            this.view?.updateResultStatus(MatchResultStatusItem.viewOnly(title = Context.getString(R.string.match_edit_result_view_only_title)))
            return
        }

angelolloqui added a commit that referenced this issue Nov 8, 2019
@angelolloqui
Copy link
Owner

Simplified to

val match = this.interactor.match
if (match == null || !(interactor.userIsOwner || interactor.userIsPlayer)) {
    this.view?.updateResultStatus(MatchResultStatusItem.viewOnly(title = R.string.localizable.match_edit_result_view_only_title()))
    return
}

And fixed with #106

angelolloqui added a commit that referenced this issue Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants