1

How can I exclude the sample folder from the following rules? with this configuration it is not working and detekt keeps parsing the sample folder

UndocumentedPublicClass:
  active: true
  excludes: &samples
    - '**/rd/compose/samples/**'
  includes: &composeComponent
    - '**/rd/compose/**'
UndocumentedPublicFunction:
  active: true
  excludes: *samples
  includes: *composeComponent
OutdatedDocumentation:
  active: true
  excludes: *samples
  includes: *composeComponent
  allowParamOnConstructorProperties: true
Rulogarcillan
  • 1,130
  • 2
  • 13
  • 23

1 Answers1

1

Problem:

There is a bug in Detekt that prevents configurations like yours from working: the excludes path filters are not evaluated if includes are present. The fix has just been implemented and is currently in the 1.23.0 milestone. Let's hope for a release soon. Unfortunately, the logic seems to have been in place for years so reverting to a previous release is probably not an option.

Workaround:

While we wait for that fix, consider implicitly excluding samples/ by explicitly including all other direct subfolders and files within compose/. For example:

UndocumentedPublicClass:
  active: true
  includes: &composeComponentNotSamples
    - '**/rd/compose/folderA/**'
    - '**/rd/compose/folderB/**'
    - '**/rd/compose/fileC.kt'
    - '**/rd/compose/fileD.kt'
UndocumentedPublicFunction:
  active: true
  includes: *composeComponentNotSamples
OutdatedDocumentation:
  active: true
  includes: *composeComponentNotSamples
  allowParamOnConstructorProperties: true

This should do the trick but should only be considered as a temporary solution because it would require manual effort to update that list as you add, rename, or remove files & folders.

Just The Highlights
  • 1,555
  • 19
  • 31