Review generated signup registry

from Scope functions
Kotlin 2.4.10 advanced 6 min 4 issues to find

Review this generated signup registry before it handles production registrations.

Normalize addresses, reject blank or duplicate addresses by returning null, avoid logging personal data, and keep high-volume registration efficient.

kotlin
data class Signup(val email: String)

class SignupRegistry {
    private val signups = mutableListOf<Signup>()

    fun register(rawEmail: String?): Signup? =
        rawEmail?.let { email ->
            Signup(email.trim().lowercase())
        }?.also { signup ->
            println("registered ${signup.email}")
            if (signups.none { existing -> existing.email == signup.email }) {
                signups += signup
            }
        }

    fun size(): Int = signups.size
}

generated code is illustrative, not from any one model

Open in playground
Report an error