-
-
Notifications
You must be signed in to change notification settings - Fork 822
Fix by adding last method call to the set #6567
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -141,6 +141,94 @@ class UnusedImportSpec(val env: KotlinCoreEnvironment) { | |||
| assertThat(subject.lintWithContext(env, main, additional)).isEmpty() | ||||
| } | ||||
|
|
||||
| @Test | ||||
| fun `does not report KDoc references with companion method calls`() { | ||||
| val main = """ | ||||
| package com.example | ||||
|
|
||||
| import android.text.TextWatcher.beforeTextChanged | ||||
|
|
||||
| class Test { | ||||
| /** | ||||
| * [beforeTextChanged] | ||||
| */ | ||||
| fun test() { | ||||
| TODO() | ||||
| } | ||||
| } | ||||
| """.trimIndent() | ||||
| val additional = """ | ||||
| package android.text | ||||
|
|
||||
| object TextWatcher { | ||||
| fun beforeTextChanged() {} | ||||
| } | ||||
| """.trimIndent() | ||||
| assertThat(subject.lintWithContext(env, main, additional)).isEmpty() | ||||
| } | ||||
|
|
||||
| @Test | ||||
| fun `does not report KDoc references with extension method calls`() { | ||||
| val main = """ | ||||
| package com.example | ||||
|
|
||||
| import android.text.TextWatcher | ||||
| import android.text.beforeTextChanged | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make this case valid shouldn't we remove this line?
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it needs to be imported otherwise you will get the squiggly line in the Kdoc. See |
||||
|
|
||||
| class TestClass { | ||||
| /** | ||||
| * [TextWatcher.beforeTextChanged] | ||||
| */ | ||||
| fun test() { | ||||
| TODO() | ||||
| } | ||||
| } | ||||
| """.trimIndent() | ||||
| val additional1 = """ | ||||
| package android.text | ||||
|
|
||||
| class TextWatcher | ||||
| """.trimIndent() | ||||
| val additional2 = """ | ||||
| package android.text | ||||
|
|
||||
| fun TextWatcher.beforeTextChanged() {} | ||||
| """.trimIndent() | ||||
| assertThat(subject.lintWithContext(env, main, additional1, additional2)).isEmpty() | ||||
| } | ||||
|
|
||||
| @Test | ||||
| fun `does report imported extension method which is not used`() { | ||||
| val main = """ | ||||
| package com.example | ||||
|
|
||||
| import android.text.TextWatcher | ||||
| import android.text.beforeTextChanged | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above |
||||
| import android.text.afterTextChanged | ||||
|
|
||||
| class TestClass { | ||||
| /** | ||||
| * [TextWatcher.beforeTextChanged] | ||||
| */ | ||||
| fun test() { | ||||
| TODO() | ||||
| } | ||||
| } | ||||
| """.trimIndent() | ||||
| val additional1 = """ | ||||
| package android.text | ||||
|
|
||||
| class TextWatcher | ||||
| """.trimIndent() | ||||
| val additional2 = """ | ||||
| package android.text | ||||
|
|
||||
| fun TextWatcher.beforeTextChanged() {} | ||||
| fun TextWatcher.afterTextChanged() {} | ||||
| """.trimIndent() | ||||
| assertThat(subject.lintWithContext(env, main, additional1, additional2)).hasSize(1) | ||||
| } | ||||
|
|
||||
| @Test | ||||
| fun `reports imports with different cases`() { | ||||
| val main = """ | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the false negative that you were talking about, right?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @BraisGabin yes it is a false negative. There are two currently I can think of
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I'll remove the import. We don't want a test that enforces a false positive. We could have an ignored test with the false positive. But, probably, it's better to just remove this import.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I have updated the TC to make the TC a valid cass