No input file found MyFile.kt. No detekt issues will be imported on this file

Hello,

SonarQube plugin version : 2.7.1

I am trying to attach a Detekt generated reports and getting this type of error error for all files:

No input file found for PolyUtil.kt. No detekt issues will be imported on this file.

However, I can see on SonarQube that detekt report is applied correctly:

This is what I have in gradle:
property "sonar.kotlin.detekt.reportPaths", ["MY_PATH/build/reports/detekt.xml"].

So why am I getting the error (No input file found for PolyUtil.kt. No detekt issues will be imported on this file.) ?

Thanks.

Hi,

First let me clarify, the file you shared is <project dir>/PolyUtil.kt, right?
Could you share full logs of Detekt sensor as well as the report itself?
I suspect that we are keeping some state when parsing this report, so fortunately you are getting your issue in the right place.

Hi Elena,

Logs:
detektlogs.txt (11.8 KB)

detekt report in txt format (was not possible to upload .xml):

detektTxt.txt (12.7 KB)

Thanks

Hi,

In your logs I see that each file is reported 5 times. Did you copy paste or it’s like that in original logs?

I checked and I don’t see how having these logs you can have any detekt issues in SQ UI. Are you sure that this screenshot corresponds to the analysis for which you provided logs?

Hello,

This is the output which I get when I run the gradle task for sonarqube :no_mouth:. (in logs which I provided I changed a package name for security).

This error does not break the build and uploads the detekt reports so they are visible (as on a screenshot)

The question is what could trigger this error? :

No input file found for/Users/user/Soft/project/tollgate/src/commonMain/kotlin/com/company/tollgate/maputils/PolyUtil.kt. No detekt issues will be imported on this file.

Thanks

Hi Sergey,

My hypothesis is: “sonar.sources” configuration is not exhaustive, not all kotlin source directories are described.
For example, if there’s kotlin files in “src/main/kotlin” and “src/commonMain/kotlin”, but only “src/main/kotlin” is present in “sonar.sources”, then you would see this problem.
The error message comes from CheckstyleFormatImporter.java#L125
When a detekt report is imported, the logic is:

  • The file path is read from the name attribute.
    <file name="/Users/user/Soft/project/tollgate/src/commonMain/kotlin/com/company/tollgate/maputils/PolyUtil.kt">
  • The file is resolved as an absolute or relative path in the sonar scanner filtered filesystem view.

It’s possible to not find the file if:

  • It has no ancestor directory in “sonar.sources” or it has one in “sonar.exclusions”
  • detekt report was generated on a computer and imported on another with a different directory structure

I hope it helps,
Alban

And to understand why the report is imported several times, could you share your value of sonar.kotlin.detekt.reportPaths?
And how many INFO log lines do you have starting with "Importing " before “No input file found for”?

property “sonar.kotlin.detekt.reportPaths”, “$rootDir/build/reports/detekt/detekt.xml”

Regarding this: And how many INFO log lines do you have starting with "Importing " before “No input file found for”? There is no logs starting with Importing.

Hello @Sergey_Ivaskhin,

Sorry for not replying you for the long time. As mentioned before, there are several possible reasons of your error.

First of all, Could you please check that the property “sonar.sources” is pointing to the right directory and “…src/commonMain/kotlin/” is located under it. The please note that in Kotlin the directory structure may not correspond to the package name. Make sure that your file is indeed located at the mentioned path.

To check which report files where actually imported, please run sonarqube command with --info.

Anyway, I see no point in keeping this conversation opened, so I’m closing it. Please, open another thread if you see any problems with the analysis.

Kind regards,
Margarita