nebula-plugins / gradle-lint-plugin

A pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts.
Apache License 2.0
761 stars 88 forks source link

Rule `all-dependency` fails when applied on Kotlin module with no `stdlib` usages #385

Open fondesa opened 1 year ago

fondesa commented 1 year ago

Currently, the Kotlin plugin adds the dependency org.jetbrains.kotlin:kotlin-stdlib:$version automatically to Kotlin modules. This dependency is added in the configurations $DependenciesMetadata (e.g. implementationDependenciesMetadata, apiDependenciesMetadata) and not in implementation and api. Running ./gradlew generateGradleLintReport with the rule all-dependency, fails on Kotlin modules which are not using directly standard library APIs.

The violations on those modules are the following:

Violation: Rule=unused-dependency P=1 Line=null Msg=[one or more classes in org.jetbrains.kotlin:kotlin-stdlib:1.8.0 are required by your code directly]
Violation: Rule=undeclared-dependency P=1 Line=null Msg=[one or more classes in org.jetbrains.kotlin:kotlin-stdlib:1.8.0 are required by your code directly]

Proposals which would probably fix this:

  1. query the $DependenciesMetadata configs internally
  2. expose an API in GradleLintExtension to exclude dependencies from all-dependency checks (e.g. gradleLint.skipDependencies = "org.jetbrains.kotlin:kotlin-stdlib")