Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False-positve UnusedImports when there are mutiple functions of the same name #7224

Open
sschuberth opened this issue Apr 24, 2024 · 0 comments

Comments

@sschuberth
Copy link
Contributor

Expected Behavior

Detekt should not report UnusedImports for imports that are actually required.

Observed Behavior

Detekt flags an import that is required as UnusedImports.

Steps to Reproduce

In this code

import org.eclipse.apoapsis.ortserver.dao.createDataSource

private fun Application.createDataSource(): DataSource {
    val configManager: ConfigManager by inject()

    val dataSourceConfig = DatabaseConfig.create(configManager)

    return createDataSource(dataSourceConfig)
}

there is both the imported createDataSource (non-extension) function, and a function of the same name in the same file. Needless to say that createDataSource(dataSourceConfig) cannot call Application.createDataSource() as the former has an argument provided, but the latter takes none. So it's clear that only org.eclipse.apoapsis.ortserver.dao.createDataSource can be meant, and has to be imported.

Context

I'm trying to resolve all Detekt hints in my code base, using type resolution.

Your Environment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants