Skip to content

Fix Request: Kotlin AvoidRecreatingDateTimeFormatter false positive #669

Description

@jborgers

The rule doesn't recognize object as being a singleton and val for a constant.

object DateUtil {
    private const val ISO8601_PATTERN = "yyyyMMdd'T'HHmmss'Z'"
    private val DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(ISO8601_PATTERN) // <-- false positive

    fun formatISO8601(dateTime: ZonedDateTime): String =
        dateTime.withZoneSameInstant(ZoneOffset.UTC)
            .format(DATE_TIME_FORMATTER)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions