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

Baseline generation w/ type resolution produces UnusedImports false negative #3123

Closed
tyvsmith opened this issue Oct 3, 2020 · 7 comments
Closed
Labels

Comments

@tyvsmith
Copy link
Contributor

tyvsmith commented Oct 3, 2020

1.12.0 was fine for us.

When generating the baseline 1.13.1 and above flag every import as UnusedImports.
It does not flag them when running in standard mode.

Potentially related to Issue #3079

@BraisGabin
Copy link
Member

Can you elaborate a bit more? A snippet of code that reproduces the false positive would be nice.

@cortinico
Copy link
Member

Also would be relevant to understand if you have Type Resolution enabled or not. We noticed several false positives in the past weeks related to UnusedImports with mixed behavior based on TR.

@tyvsmith
Copy link
Contributor Author

tyvsmith commented Oct 4, 2020

Type resolution is enabled. It seems EVERY import statement is now flagged as unused in the baseline generation. In normal mode, it works as expected. I'll try to get a sample repro case this week.

@cortinico
Copy link
Member

Type resolution is enabled. It seems EVERY import statement is now flagged as unused in the baseline generation.

I believe we addressed this in #3079 that is included in 1.14.x.
Have you tried bumping to that version (or is there a reason is holding you back on 1.13.1)?

@tyvsmith
Copy link
Contributor Author

tyvsmith commented Oct 4, 2020

Type resolution is enabled. It seems EVERY import statement is now flagged as unused in the baseline generation.

I believe we addressed this in #3079 that is included in 1.14.x.
Have you tried bumping to that version (or is there a reason is holding you back on 1.13.1)?

The issue exists in all versions above 1.13.1 (including 1.14.0 and 1.14.1). 1.12.0 was the last working version.

I also tried a build of the 1.14.1 tag with a revert on #3079 and it still occurred.

Note that we're using the CLI through a wrapper in Buck (no gradle plugin).

@tyvsmith
Copy link
Contributor Author

tyvsmith commented Oct 6, 2020

We narrowed it down to a change in parsing CLI arguments. In previous versions (1.12 and below), we were able to delimit classpath jars using a semicolon. We were doing that using the detekt-cli through an args file.

--build-upon-default-config
--jvm-target
1.8
-c
config.yml
-i
Sample.kt
-cp
sample.jar;sample2.jar
-b
baseline.xml
-cb

In the newer versions, it seems a comma or colon is required.

--build-upon-default-config
--jvm-target
1.8
-c
config.yml
-i
Sample.kt
-cp
sample.jar:sample2.jar
-b
baseline.xml
-cb

The UnusedImport seemed to be a side effect, not exactly sure why that one was firing, but when resolving it in our args file generation, the problem dissapears. So going to mark this as closed.

@tyvsmith tyvsmith closed this as completed Oct 6, 2020
@arturbosch
Copy link
Member

Linking #3084 for further information.

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

No branches or pull requests

4 participants