saveourtool/diktat

[`USE_DATA_CLASS`] Actual and expected classes

Open

#1,656 opened on Apr 5, 2023

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Kotlin (40 forks)github user discovery
buggood first issue

Repository metrics

Stars
 (571 stars)
PR merge metrics
 (PR metrics pending)

Description

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

Contributor guide