![github-actions[bot]](/assets/img/avatar_default.png)
You can preview this rule [here](https://sonarsource.github.io/rspec/#/rspec/S6629/kotlin) (updated a few minutes after each push). --------- Co-authored-by: kaufco <kaufco@users.noreply.github.com> Co-authored-by: Marco Kaufmann <marco.kaufmann@sonarsource.com>
59 lines
1.6 KiB
Plaintext
59 lines
1.6 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Dependencies should be grouped by their destination, otherwise,
|
|
it becomes hard for the reader to see which destination has what dependencies.
|
|
|
|
=== What is the potential impact?
|
|
|
|
==== Readability
|
|
|
|
This change improves readability by making it easier to see which destination has what dependencies.
|
|
|
|
== How to fix it
|
|
|
|
Reorder your dependencies so that they are grouped by destination.
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,kotlin,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
dependencies {
|
|
implementation("org.jetbrains.kotlin:kotlin-stdlib")
|
|
implementation("com.google.guava:guava:30.1.1-jre")
|
|
implementation("org.apache.commons:commons-lang3:3.9")
|
|
|
|
testImplementation(testLibs.junit.api)
|
|
testRuntimeOnly(testLibs.junit.engine)
|
|
|
|
testImplementation(testLibs.assertj.core)
|
|
testImplementation(libs.sonar.plugin.api)
|
|
|
|
implementation("log4j:log4j:1.2.17")
|
|
}
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,kotlin,diff-id=1,diff-type=compliant]
|
|
----
|
|
dependencies {
|
|
implementation("org.jetbrains.kotlin:kotlin-stdlib")
|
|
implementation("com.google.guava:guava:30.1.1-jre")
|
|
implementation("org.apache.commons:commons-lang3:3.9")
|
|
implementation("log4j:log4j:1.2.17")
|
|
|
|
testImplementation(testLibs.junit.api)
|
|
testImplementation(testLibs.assertj.core)
|
|
testImplementation(libs.sonar.plugin.api)
|
|
|
|
testRuntimeOnly(testLibs.junit.engine)
|
|
}
|
|
----
|
|
|
|
== Resources
|
|
|
|
=== Documentation
|
|
|
|
* https://github.com/liutikas/gradle-best-practices#keep-your-dependencies-clustered[Best Practices when using Gradle - Keep your dependencies clustered (Liutikas)] |