To make things clear, I’ve created a fresh .NET project which has the same folder structure as my corporate project that I’ve run into issue. Here is it.
So the steps I follow are like that:
- I install my plugin to a local SonarQube instance which runs on docker
- I run mutation tests on my project (I run it in
/tests folder) which generates a JSON report file in
tests/StrykerOutput directory. (Thats what the plugin I’ve been developing does. It parses that JSON file and creates issues on Sonar.)
- I run
sonar.sh script that runs dotnet-sonarscanner. (Which means, I run dotnet-sonarscanner in the root directory where .sln file places)
After dotnet-sonarscanner runs, it runs my plugin which is installed in my local sonar instance that runs on Docker.
Then I start debugging my plugin.
The problem starts here. All of the Sonar plugins’ entrypoint is “execute” method which takes
SonarContext as a parameter. This
SonarContext object returns some project related info from dotnet-sonarscanner. But
context.fs.baseDir directory returns
/Users/mustafa.yumurtaci/workspace/Example/src which is wrong, because i didn’t run dotnet-sonarscanner in this directory, I’ve run it in
/Users/mustafa.yumurtaci/workspace/Example which is root directory. So the
context.fs.baseDir (which is an info that dotnet-sonarscanner returns to the plugin) should be the root directory.
The detailed info can bee seen in the screenshot below:
I’ve also tried general purpose sonar-scanner, and it returns
context.fs.baseDir as root directory which is correct.
So this is the bug I’ve been talking about. I hope it’s more clear now.
Thank you for your time