Pull a sonarqube
docker image from DockerHub and run it.
docker pull sonarqube
docker run -d --name sonarqube -p 9000:9000 sonarqube
Get the latest sonar-clojure-plugin.jar from github and add it to sonarqube as a plugin.
wget https://github.com/fsantiag/sonar-clojure/releases/download/v2.0.0/sonar-clojure-plugin-2.0.0.jar
docker cp sonar-clojure-plugin-2.0.0.jar sonarqube:/opt/sonarqube/extensions/plugins/
Restart the docker container to rerun it with sonar-clojure plugin enabled.
docker restart sonarqube
Open localhost:9090 and login with {:user admin :pw admin}. Now add a new project and remember the Project Key for later. Generate a token (you won't actually need it, when running local), select language Other -> OS and add the scanner:
Get sonar-scanner and put it on your $PATH
.
altered from sonar-clojure
-
Change your project.clj file and add the required plugins:
:plugins [[jonase/eastwood "0.3.6"] [lein-kibit "0.1.8"] [lein-ancient "0.6.15"] [lein-cloverage "1.1.2"] [lein-nvd "1.4.0"]]
-
Create a sonar-project.properties file in the root folder of your app:
sonar.projectKey=your-project-key sonar.projectName=YourProjectName sonar.projectVersion=1.0 sonar.sources=.
-
Run sonar-scanner on your project. You may also run the plugins by themselves to make sure they actually run (e.g.
lein kibit
orlein nvd check
), or if you want an altered output.