I am having an issue when trying to run SonarCloud where it indicates there is no code, even though it is clearly visible in BitBucket Cloud. It actually passes successfully, but upon further review, it indicates “The main branch has no lines of code.” and “the main branch of this project is empty” – so it’s not actually scanning anything.
I don’t have admin over the original code repo, so I am mirroring the repository into my personal workspace to run SonarCloud on the mirrored repo.
To replicate the codebase I am doing:
git clone --mirror https://username@bitbucket.org/original-project/repo.git
cd repo.git
git push --mirror https://username@bitbucket.org/personal-project/repo.git
When I browse the newly mirrored personal-project repo in BitBucket, it shows code in the master branch – as expected. So that should be fine…
I am not using a pipeline, so just running the scan manually. From Windows command line, it runs and shows no errors. Using this command:
sonar-scanner.bat -D"sonar.organization=org-name" -D"sonar.projectKey=project-key" -D"sonar.sources=." -D"sonar.host.url=https://sonarcloud.io" -D"sonar.login=XXX"
It runs fine, I get an execution success. I’m running that command from the directly parallel with the folder of the project. When running it from within the repo directory I get errors regarding a Bare repo. So the scan appears to work fine.
Any idea why the scan works but reports no code?