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

unreachable if condition #9

Open
ObjectPlayer opened this issue Mar 13, 2022 · 0 comments
Open

unreachable if condition #9

ObjectPlayer opened this issue Mar 13, 2022 · 0 comments

Comments

@ObjectPlayer
Copy link

Hey folks,
I just noticed that, there is an if-else condition in the Edition init method, where it is checking that if maxMintSize is 0 or not, in case of 0, it is initializing self.maxMintSize to nil otherwise self.maxMintSize to given maxMintSize, here is the code of that condition

 // If an edition size is not set, it has unlimited minting potential
            if maxMintSize == 0 {
                self.maxMintSize = nil
            } else {
                self.maxMintSize = maxMintSize
            }

But in my views, code under if block, never execute or you can say it is unreachable code due to the pre block of the Edition init method, where we already checking that maxMintSize should not equal to 0

pre {
                maxMintSize != 0: "max mint size is zero, must either be null or greater than 0"
                AllDay.seriesByID.containsKey(seriesID): "seriesID does not exist"
                AllDay.setByID.containsKey(setID): "setID does not exist"
                AllDay.playByID.containsKey(playID): "playID does not exist"
                SeriesData(id: seriesID).active == true: "cannot create an Edition with a closed Series"
                SetData(id: setID).setPlayExistsInEdition(playID: playID) != true: "set play combination already exists in an edition"
            } 

Here you can check, there is already a condition to check if maxMintSize is 0 or not, in case of 0, it will be return from this block, as it is pre-block of the method.

So we can remove if condition inside the init method as we already checked in pre-block and directly assign self.maxMintSize to given maxMintSize. But if it is deployed than I don't think so you can update that code, but you can check

Thanks

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

1 participant