Skip to content

unreachable if condition #9

@ObjectPlayer

Description

@ObjectPlayer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions