Skip to content

UnusedImports false positive for enums in annotation attributes (with type resolution) #3131

Description

@vladimirfx

Expected Behavior

When enum constants used in annotation attributes the enum import should not marked as unused.

Steps to Reproduce

In such code BatchFetch import statement marked as unused:

...
import org.eclipse.persistence.annotations.FetchType
...
@Entity
class Sale(
    @Id
    val id: Long,
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    var client: Client,
...
)

Context

We use Gradle plugin with type resolution mode (detektMain task). Bug is introduced after 1.12.0 (witch works as expected).

Your Environment

  • Version of detekt used: 1.14.1
  • Version of Gradle used (if applicable): 6.6.1
  • Operating System and version: MacOS 10.15.7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions