11

I need to perform some static analysis of java classes from command line To extract basic metrics and I was thinking I could use sonar-cli, but that required a fully working SonarQube.

How can I perform those inspections?

Edmondo
  • 19,559
  • 13
  • 62
  • 115

1 Answers1

7

If you want to get the metrics on your code, then there's no other choice than installing a SonarQube server and indeed run an analysis using a SonarQube scanner.

By the way, installing a SQ server for such a simple use case is as simple as extracting the binaries from the ZIP archive and double-click on the sonar.sh or sonar.bat scripts. See "Get Started in Two Minutes" documentation page.

  • 2
    Another option would be to use the [SonarQube Docker container](https://hub.docker.com/_/sonarqube/). – deamon May 26 '17 at 12:03
  • 1
    I went the SonarQube docker container route. Took about 30 min to get it up and running. – Black Frog Mar 30 '18 at 03:29
  • Hello! Thank you for the information. I am thinking to purchase SonarQube for our usage. Basically we have quite a large number of C code (small programs; within 200 LOC) and I want to quantify each C code regarding complexity, code smells, etc. Can SQ be launched via command line? Or I will have to use mouse/browser to do all the tasks which seem quite tedious? – lllllllllllll Jun 26 '20 at 08:01
  • Docker way: run `docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latest` go to `localhost:9000` in browser login with admin:admin and go to My Account -> Security -> Tokens and generate new one use it in your build - e.g.: mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar -Dsonar.login=... – chipiik Mar 23 '21 at 08:49