diktat
diktat copied to clipboard
`srcDirectories` logs an error for Android's `debug`/`release` source sets
Describe the bug
DiKTat is logging an error when the configured srcDirectories do not all end with [Mm]ain:
https://github.com/saveourtool/diktat/blob/2ae350021a562c2a2ae24d3d906ef0e123b843bb/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/rules/RulesConfigReader.kt#L167
Expected behavior
Configuring such source sets should not result in a logged error.
On Android, the available source sets include debug and release by default (as a "build type source set"):
https://developer.android.com/studio/build/build-variants#sourceset-build
Observed behavior
The Gradle diktatCheck task run is still successful, but it would be great if the error log would not log. Especially since it pops up once per thread that uses the RulesConfigReader (which seems to be matching my machine's CPU thread count).
Steps to Reproduce
In diktat-analysis.yml, set the srcDirectories to include debug and release:
- name: DIKTAT_COMMON
configuration:
...
testDirs: test, androidTest
...
srcDirectories: main, debug, release
...
Environment information
- diktat version:
org.cqfn.diktat.diktat-gradle-plugin:1.2.3 - build tool (maven/gradle): Gradle
- how is diktat run (CLI, plugin, etc.): CLI -
./gradlew diktatCheck - kotlin version: 1.7
- operating system: Windows
- link to a project (if your project is public): NA
BTW: The reason I've updated srcDirectories is simply to not get an error from PACKAGE_NAME_INCORRECT_PATH for my package statements in the debug source set files.
Hi! Thank you for this report, very interesting. As fullstack-developers we always miss those Andorid/IOS cases 😢 We can add an exception for this case. Do you have any examples of such hierarchy in opensource? We will support this hierarchy
@Cheshiriks can you help us? You know this rule

Do you have any examples of such hierarchy in opensource?
I actually haven't come across any yet!
My team uses it for a private project to add a broadcast receiver for debug purposes only, i.e. it only gets built and included in debug builds (and product flavors that we run some manual tests with). It basically allows us to debug the app without shipping that functionality to customers.
I actually haven't come across any yet!
Got it. The above picture with directories is fine as an exceptional case for this inspection?
Yup. That said, since both build types and flavors are user-customizable, i.e. replace demo in the screenshot with anything the user comes up with. I might be wrong, but it seems like the log statement (and accompanying check) needs to be removed altogether because of this.
Just to note: The testDirs setting also has a similar check. This one seems to be working fine for Android users, though, as I'm only aware of that supporting test and androidTest.
https://github.com/saveourtool/diktat/blob/2ae350021a562c2a2ae24d3d906ef0e123b843bb/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/rules/RulesConfigReader.kt#L130