Skip to content

UnusedPrivateProperty: Fix false postive by ignoring data classes#6151

Merged
cortinico merged 1 commit into
detekt:mainfrom
atulgpt:fixes/6142
May 27, 2023
Merged

UnusedPrivateProperty: Fix false postive by ignoring data classes#6151
cortinico merged 1 commit into
detekt:mainfrom
atulgpt:fixes/6142

Conversation

@atulgpt

@atulgpt atulgpt commented May 25, 2023

Copy link
Copy Markdown
Contributor

Fixes: #6142

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

codecov Bot commented May 25, 2023

Copy link
Copy Markdown

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%) ⬇️

(it.isPrivate() || (!it.hasValOrVar() && !constructor.isActual())) &&
it.containingClassOrObject?.isExpect() == false
it.containingClassOrObject?.isExpect() == false &&
(constructor.parent as? KtClass)?.isData() != true

@t-kameyama t-kameyama May 26, 2023

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@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