https://docs.sonarqube.org/9.6/try-out-sonarqube/
を参照して、ローカルにソナーキューブを構築・実行した。
Execute the Scanner
Running a SonarQube analiysis is straighforward. You just need to execute the following commands in your project's folder.
sonar-scanner.bat -D"sonar.projectKey=My_Trial" -D"sonar.sources=." -D"sonar.host.url=http://localhost:9000" -D"sonar.login=xxxxx"
とのことだったので、表示されているコマンドをプロジェクトのディレクトリ配下から実行したところ下記のエラーが発生。
ERROR: Error during SonarScanner execution
org.sonar.java.AnalysisException: Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property.
classファイルよこせや。ということの様なので、classファイルが出力されているディレクトリ直下に移動してから再実行。
コマンド自体は成功したものの、結果を確認すると何も出力されていなかった。
The main branch has no lines of code.
classファイルが出力されているディレクトリに移動して実行ではなく、
classファイルが出力されているディレクトリ「sonar.java.binaries」で指定し実行して解決。
以下の様な感じで、引数に追加
sonar-scanner.bat -D"sonar.projectKey=My_Trial" -D"sonar.sources=." -D"sonar.host.url=http://localhost:9000" -D"sonar.login=xxxxx" -D"sonar.java.binaries=bin"