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

Split UnusedPrivateMember #5722

Merged
merged 29 commits into from
Feb 5, 2023
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
968683f
Run ktlint --format on files about to be touched
drawers Jan 23, 2023
7cb6c0f
Make UnusedPrivateMember focus on private functions
drawers Jan 23, 2023
806a415
Extract UnusedParameter
drawers Jan 23, 2023
429142c
Extract UnusedParameter
drawers Jan 23, 2023
09a7c6b
Extract UnusedPrivateProperty
drawers Jan 23, 2023
7c50787
Move first batch of property tests from inside UnusedPrivateMemberSpec
drawers Jan 23, 2023
eb11585
Move second batch of property tests from inside UnusedPrivateMemberSpec
drawers Jan 23, 2023
a86e950
Readjust expectations in test now that subject only detects unused pr…
drawers Jan 23, 2023
7ff9c21
Move over next batch of property tests from UnusedPrivateMemberSpec
drawers Jan 23, 2023
39491ae
Move one test from "unused class declarations which are allowed"
drawers Jan 23, 2023
49df7cb
Move "nested class declarations" from UnusedPrivateMemberSpec
drawers Jan 23, 2023
939c679
Split "error messages"
drawers Jan 23, 2023
f6ffe46
Move "suppress unused property warning annotations"
drawers Jan 23, 2023
2406a24
Move "main methods" inner test class
drawers Jan 23, 2023
8048a00
Move "backtick identifiers" inner test class
drawers Jan 23, 2023
4376627
Move "backtick identifiers" inner test class for unused private param…
drawers Jan 23, 2023
93f090d
Split "highlights declaration name"
drawers Jan 23, 2023
99a350b
Move "parameter with the same name as named argument"
drawers Jan 23, 2023
636b3ad
Split "actual functions and classes"
drawers Jan 23, 2023
18830f8
Move "properties in primary constructors"
drawers Jan 23, 2023
5227986
Fix typo
drawers Jan 23, 2023
9241ae4
Fix disabled tests
drawers Jan 23, 2023
8c4c509
Add alias "UnusedPrivateMember" to UnusedParameter and UnusedPrivateP…
drawers Jan 23, 2023
b563ece
Rename "UnusedPrivateParameterSpec" to "UnusedParameterSpec"
drawers Jan 25, 2023
5a3a901
Adjust KDoc to say "source file" instead of "class etc." for clarity
drawers Jan 25, 2023
5897a31
Adjust KDoc to explain how UnusedPrivateProperty can detect unused co…
drawers Jan 25, 2023
1e4bcb8
inline method
chao2zhang Jan 28, 2023
8f9a9e5
Merge branch 'main' into fix-3418-split
schalkms Feb 5, 2023
ddd19eb
Remove duplicate `main methods` inner class after merge
drawers Feb 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,35 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) {
}

@Nested
inner class `operators` {
inner class `main methods` {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @schalkms thank you for performing the merge 🙏 but I think this main methods now needs to be in UnusedParameterSpec.kt rather than in UnusedPrivateMemberSpec.kt. That was how it was in the original patch I submitted since those test cases now cover UnusedParameter.kt

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schalkms would you prefer me to add a commit to address this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Btw, sorry for messing around with the merge.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drawers you were a few seconds faster. 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schalkms I added a commit ddd19eb to address this. If I take Chao's last commit before the merge as authoritative (1e4bcb8) then I do:

git diff --name-only 1e4bcb8 | grep Unused

I get:

detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMemberSpec.kt

Then if I do:

git diff 1e4bcb8 detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMemberSpec.kt

I get:

diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMemberSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMemberSpec.kt
index 2dbf7673d3..237df91e75 100644
--- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMemberSpec.kt
+++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMemberSpec.kt
@@ -383,7 +383,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) {
     }
 
     @Nested
-    inner class `operators` {
+    inner class Operators {
 
         @Test
         fun `does not report used plus operator - #1354`() {

So we end up with only the change from renaming inner class operators to inner class Operators and nothing else. Which I think is what we want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inner class operators {
to
inner class Operators {

Yes 🙏

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also rollback the merge and do a rebase. That might be easier to grasp.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schalkms yes if you would prefer me to rebase then I don't mind doing it just let me know 👍
(sorry about leaving the branch to go stale, I didn't anticipate another PR touching that test)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drawers if we are good to go after the merge, we are fine, no need to do another rebase then, IMHO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schalkms looks okay to me now!


@Test
fun `does not report the args parameter of the main function inside an object`() {
val code = """
object O {

@JvmStatic
fun main(args: Array<String>) {
println("b")
}
}
""".trimIndent()
assertThat(subject.lint(code)).isEmpty()
}

@Test
fun `does not report the args parameter of the main function as top level function`() {
val code = """
fun main(args: Array<String>) {
println("b")
}
""".trimIndent()
assertThat(subject.lint(code)).isEmpty()
}
}

@Nested
inner class Operators {

@Test
fun `does not report used plus operator - #1354`() {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.