saveourtool/diktat

[`USE_DATA_CLASS`] Actual and expected classes

Open

#1656 aperta il 5 apr 2023

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)Kotlin (40 fork)github user discovery
buggood first issue

Metriche repository

Star
 (571 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Describe the bug

Diktat suggests to use data class for actual or expected classes.

Expected behavior

Diktat doesn't detect it as error

Observed behavior

Steps to Reproduce

/**
 *  Class that holds value and shares atomic reference to the value
 *
 *  @param valueToStore value to store
 */
@Suppress("USE_DATA_CLASS")
expect class GenericAtomicReference<T>(valueToStore: T) {
    /**
     * @return stored value
     */
    fun get(): T

    /**
     * @param newValue new value to store
     */
    fun set(newValue: T)
}

@Suppress("USE_DATA_CLASS")
actual class GenericAtomicReference<T> actual constructor(valueToStore: T) {
    private val holder: kotlin.native.concurrent.AtomicReference<T> = kotlin.native.concurrent.AtomicReference(valueToStore)
    actual fun get(): T = holder.value
    actual fun set(newValue: T) {
        holder.value = newValue
    }
}

Environment information

  • diktat version: 1.2.5
  • build tool (maven/gradle): gralde
  • how is diktat run (CLI, plugin, etc.): plugin
  • kotlin version: 1.8.20
  • operating system: Linux
  • link to a project (if your project is public): saveourtool/save-cloud

Guida contributor