# Kotlin code not detected

**URL:** <https://community.sonarsource.com/t/kotlin-code-not-detected/98961>\
**Category:** SonarQube Server / Community Build\
**Tags:** maven, kotlin\
**Created:** [September 8, 2023, 2:06pm UTC](https://community.sonarsource.com/t/kotlin-code-not-detected/98961 "2023-09-08T14:06:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomki991](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tomki991/32/15742_2.png) [@tomki991](https://community.sonarsource.com/u/tomki991)\
**Post date:** [September 8, 2023, 2:06pm UTC](https://community.sonarsource.com/t/kotlin-code-not-detected/98961/1 "2023-09-08T14:06:35Z")

</div>

Hi,  
I cannot analyze Kotlin code correctly, as a sensor is not detecting it. I’m executing

```auto
mvn clean install sonar:sonar -Dsonar.login=xxx -Dsonar.projectKey=123 -Dsonar.projectName="123"
...
output
...
[INFO] Project configuration:
[INFO] 26 files indexed
[INFO] 0 files ignored because of scm ignore settings
[INFO] ------------- Run sensors on module DEVOPS / dsl-microservice-pipelines
[INFO] Load metrics repository
[INFO] Load metrics repository (done) | time=34685ms
[INFO] Sonargraph Integration: Created 55 predefined and 0 custom metric(s)
[INFO] Sensor C# Project Type Information [csharp]
[INFO] Sensor C# Project Type Information [csharp] (done) | time=3ms
[INFO] Sensor C# Analysis Log [csharp]
[INFO] Sensor C# Analysis Log [csharp] (done) | time=12ms
[INFO] Sensor C# Properties [csharp]
[INFO] Sensor C# Properties [csharp] (done) | time=0ms
[INFO] Sensor HTML [web]
[INFO] Sensor HTML [web] (done) | time=3ms
[INFO] Sensor Text Sensor [text]
[INFO] 0 source files to be analyzed
[INFO] 0/0 source files have been analyzed
[INFO] Sensor Text Sensor [text] (done) | time=4ms
[INFO] Sensor VB.NET Project Type Information [vbnet]
[INFO] Sensor VB.NET Project Type Information [vbnet] (done) | time=1ms
[INFO] Sensor VB.NET Analysis Log [vbnet]
[INFO] Sensor VB.NET Analysis Log [vbnet] (done) | time=13ms
[INFO] Sensor VB.NET Properties [vbnet]
[INFO] Sensor VB.NET Properties [vbnet] (done) | time=0ms

```

26 files indexed and 0 files analyzed.  
On the UI of sonarqube I see only pom.xml scrapped, the .kt files are not detected. Any idea hot to run the analysis successfully?

Thanks,

---

<div class="post-metadata">

**Author:** ![tomki991](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tomki991/32/15742_2.png) [@tomki991](https://community.sonarsource.com/u/tomki991)\
**Post date:** [September 8, 2023, 2:07pm UTC](https://community.sonarsource.com/t/kotlin-code-not-detected/98961/2 "2023-09-08T14:07:56Z")

</div>

Of cors I’ve tried to add to the command

```auto
-Dsonar.sources=.

```

or

```auto
-Dsonar.sources=src

```

the same result.

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [September 11, 2023, 4:45pm UTC](https://community.sonarsource.com/t/kotlin-code-not-detected/98961/3 "2023-09-11T16:45:42Z")

</div>

Hi,

The source files the Maven scanner provides to analysis are Java files. Specifically, `.java` files in `src/main/java`. If your Kotlin sources aren’t filed there, then I don’t believe setting `-Dsonar.sources=src` is going to help.

Alternately, you could switch to Gradle, which I suppose is the default expectation for Kotlin analysis.

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [September 12, 2023, 6:34am UTC](https://community.sonarsource.com/t/kotlin-code-not-detected/98961/4 "2023-09-12T06:34:36Z")

</div>

Hi,

maybe this thread helps

> [@Mvn sonar:sonar doesn't scan angular files](https://community.sonarsource.com/t/mvn-sonar-sonar-doesnt-scan-angular-files/73767):
>
> Hi, Sonarqube Enterprise 9.5, sonar-maven-plugin:3.9.1.2184, Maven 3.8.1 The Maven build uses the [frontend-maven-plugin](https://github.com/eirslett/frontend-maven-plugin) to build frontend and backend. Source tree +---src +---main | +---java | [...] | +---liberty | | \---config | +---ngapp | [...] | | +---resources | | \---example | \---webapp | \---WEB-INF \---test +---java [...] \---resources Plugin config \<groupId\>com.github.eirslett\</groupId\> \<artifactId\>frontend-maven-plugin\</artifactId\> \<ver…

The mentioned Jira ticket [[MSONAR-190] - Jira](https://sonarsource.atlassian.net/browse/MSONAR-190) is closed on 30 August 2023, so i guess there will be a new version of the Sonarqube Maven plugin soon.

Gilbert

---

<div class="post-metadata">

**Author:** ![tomki991](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tomki991/32/15742_2.png) [@tomki991](https://community.sonarsource.com/u/tomki991)\
**Post date:** [September 12, 2023, 11:44am UTC](https://community.sonarsource.com/t/kotlin-code-not-detected/98961/5 "2023-09-12T11:44:09Z")

</div>

Hi,  
I’ve tried the

```auto
-Dsonar.sources=src 

```

but the same result. As our kotlin code is actually the teamcity pipelines code it have to be maven. I’ll try other plugins like detekt or so. Maybe it will help.  
And @anon67236913 - maybe new version of the scanner will change something.

Thanks,

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [September 12, 2023, 11:55am UTC](https://community.sonarsource.com/t/kotlin-code-not-detected/98961/6 "2023-09-12T11:55:07Z")

</div>

Moving your kotlin files to src/main/somefolder combined with `-Dsonar.source=src/main` may help,  
it worked for our angular files.  
It seems that src alone or ‘.’ is ignored by the Sonarqube Maven plugin !?

---

<div class="post-metadata">

**Author:** ![tomki991](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tomki991/32/15742_2.png) [@tomki991](https://community.sonarsource.com/u/tomki991)\
**Post date:** [September 12, 2023, 12:27pm UTC](https://community.sonarsource.com/t/kotlin-code-not-detected/98961/7 "2023-09-12T12:27:36Z")

</div>

Indeed the DSL code (written in kotlin) for the teamcity pipelines should be placed into ./teamcity folder and originally I’s sure only the `.` is an issue with detecting the kotlin files but now I’m trying other repo, where code is “traditionally” in ./src  
[mvn-execution.log](https://community.sonarsource.com/uploads/short-url/s0amM6BEtXM01gVXrZQWhPoyYwj.log) (44.6 KB)  
Files are indexed but not analyzed 😑 … The only file detected by sonar (visible on its UI in appropriate project is pom.xml)

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [September 12, 2023, 2:41pm UTC](https://community.sonarsource.com/t/kotlin-code-not-detected/98961/8 "2023-09-12T14:41:26Z")

</div>

You may try with the latest version of the Sonarqube Maven Plugin `sonar-maven-plugin:3.9.1.2184`  
From the logs i see you use `sonar-maven-plugin:3.8.0.2131` which is rather old.

---

<div class="post-metadata">

**Author:** ![tomki991](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tomki991/32/15742_2.png) [@tomki991](https://community.sonarsource.com/u/tomki991)\
**Post date:** [September 13, 2023, 8:11am UTC](https://community.sonarsource.com/t/kotlin-code-not-detected/98961/9 "2023-09-13T08:11:41Z")

</div>

I’ve also tried the newest maven but - hey - I’ve solved the issue. The reason was … trivial.  
On the UI Administration / Configuration / Languages / Kotlin there is only one parameter to set: “File suffixes” and it’s described as:

```auto
List of suffixes for files to analyze.

```

I’ve read this as comma separated list … and put there value

```auto
.kt,.kts

```

After changing it to two separate items of the list it started working 🙂

Thanks for your assistance!

Case closed 🙂

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [September 13, 2023, 10:29am UTC](https://community.sonarsource.com/t/kotlin-code-not-detected/98961/10 "2023-09-13T10:29:49Z")

</div>

Gotcha 🙂 One could use the settings of other languages as example, but an additional entry, i.e. ‘One entry per line’ or similar won’t hurt, as there are also comma-separated values.

 ![2023-09-13_12h19_15](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/3/2/3211f8cb1815b205309dad63e0367f0340fca324.png)
