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

UnusedPrivateProperty: Fix false postive by ignoring data classes #6151

Merged
merged 1 commit into from May 27, 2023

Conversation

atulgpt
Copy link
Contributor

@atulgpt atulgpt commented May 25, 2023

Fixes: #6142

@atulgpt atulgpt changed the title Ignore data classes UnusedPrivateProperty: Fix false postive by ignoring data classes May 25, 2023
@codecov
Copy link

codecov bot commented May 25, 2023

Codecov Report

Merging #6151 (2444100) into main (dcfb841) will decrease coverage by 0.01%.
The diff coverage is 50.00%.

@@             Coverage Diff              @@
##               main    #6151      +/-   ##
============================================
- Coverage     84.94%   84.94%   -0.01%     
  Complexity     4026     4026              
============================================
  Files           569      569              
  Lines         13498    13501       +3     
  Branches       2381     2384       +3     
============================================
+ Hits          11466    11468       +2     
  Misses          869      869              
- Partials       1163     1164       +1     
Impacted Files Coverage Δ
...rbosch/detekt/rules/style/UnusedPrivateProperty.kt 92.30% <50.00%> (-1.25%) ⬇️

@@ -108,7 +109,8 @@ private class UnusedPrivatePropertyVisitor(private val allowedNames: Regex) : De
constructor.valueParameters
.filter {
(it.isPrivate() || (!it.hasValOrVar() && !constructor.isActual())) &&
it.containingClassOrObject?.isExpect() == false
it.containingClassOrObject?.isExpect() == false &&
(constructor.parent as? KtClass)?.isData() != true
Copy link
Contributor

Choose a reason for hiding this comment

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

The same goes for value classes.

@JvmInline value class Foo(private val value: String)

inline class Bar(private val value: String)

Copy link
Member

Choose a reason for hiding this comment

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

Fair point 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@BraisGabin BraisGabin added this to the 2.0.0 milestone May 27, 2023
@cortinico cortinico merged commit 466c5af into detekt:main May 27, 2023
22 of 23 checks passed
@atulgpt atulgpt deleted the fixes/6142 branch May 27, 2023 19:14
@cortinico cortinico added the pick request Marker for PRs that should be ported to the 1.0 release branch label Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pick request Marker for PRs that should be ported to the 1.0 release branch rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive in UnusedPrivateProperty for private data class fields
6 participants