https://kotlinlang.org logo
#detekt
Title
# detekt
t

thuytrinh

11/22/2019, 10:23 AM
Hi folks. I’m trying to use
Duration
type https://okkotlin.com/duration/ but it got flagged by the
MagicNumber
rule. Just wondering whether anyone knows how to configure the
MagicNumber
to exclude if I extract the whole
Duration
into a constant like below?
Copy code
@ExperimentalTime
class Operation {
    companion object {
        val DEFAULT_TIMEOUT = 3.seconds
    }

    @ExperimentalTime
    fun read(timeout: Duration = DEFAULT_TIMEOUT) {
    }
}
So w/ that example, detekt still complains that
3
should be constant.
s

schalkms

11/22/2019, 2:29 PM
How does your config for MagicNumber look like? Did you set
ignoreConstantDeclaration
to
true
?
5 Views