Sonar helps Gradle users to adopt Kotlin DSL

Dear Gradle users,

We are excited to announce a new feature that will make your build process even smoother. As you may have heard, Kotlin DSL is now the default for new Gradle builds.

To help you take advantage of this new default, we have added a feature to Sonar that will assist you in correctly configuring your build script. With this feature, you can save time and focus on writing your code, rather than fixing your build scripts.

Here is the list of rules dedicated to Kotlin DSL:

  • S6626: Tasks should define “description” and “group”
  • S6623: “tasks.register()” should be preferred over “tasks.create()”
  • S6624: Dependency versions shouldn’t be hard-coded
  • S6629: Dependencies should be grouped by destination
  • S6631: Gradle settings file should always be present
  • S6625: “” should always be present in Gradle settings
  • S6634: Core plugins IDs should be replaced by their shortcuts

If you are facing trouble migrating from the Groovy DSL to the Kotlin DSL and want to share your experience, that would be great. We may find ways to transform these pains into rules to help other Gradle users.

To benefit from this feature, you will need to upgrade your Scanner for Gradle to version 4.3.
This is available now for SonarCloud users and will come with version 10.2 for SonarQube users.