saveourtool/diktat

[`USE_DATA_CLASS`] Actual and expected classes

Open

#1,656 创建于 2023年4月5日

在 GitHub 查看
 (0 评论) (0 反应) (0 负责人)Kotlin (40 fork)github user discovery
buggood first issue

仓库指标

Star
 (571 star)
PR 合并指标
 (PR 指标待抓取)

描述

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

贡献者指南