detekt/detekt

Allow to suppress properties same as functions

Aperta

#4930 aperta il 7 giu 2022

 (8 commenti) (0 reazioni) (0 assegnatari)Kotlin (834 fork)batch import
featurehelp wantednever gets stalesuppressors

Metriche repository

Star
 (6942 stelle)
Metriche merge PR
 (Merge medio 4g 9h) (65 PR mergiate in 30 g)

Descrizione

Context

I'm trying to configure Detekt using suppressors to allow lateinit for only specific names. For example in all my tests, I use private lateinit var sut: SystemUnderTest, so I would like to allow lateinit usage on this specific name: sut.

Current Behavior

I tried the following

potential-bugs:
  LateinitUsage:
    excludes: [ ] # Enforce this for production and test code.
    ignoreFunction:
      - 'sut'
      - 'getSut'

but it didn't work.

Expected Behavior

A way to do this.


Note: next step I would like to also allow patterns ^mock.* and ^fixt.* which are also properties in test code. Although they're also annotated so I have a way.

Guida contributor