aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes SonarQube in Action:Is Sonar too heavy for small projects? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "SonarQube in Action:Is Sonar too heavy for small projects?" Watch "SonarQube in Action:Is Sonar too heavy for small projects?" New topic
Author

SonarQube in Action:Is Sonar too heavy for small projects?

Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 433
The management likes reports, all kinds of reports. I first heard Sonar due to the fact that my manager likes to have a report of our code quality. Then he will have some WORK to do. Finally I choose FindBugs instead of Sonar. I find Sonar is too heavy. I have to install it on a server, and then configure FindBugs or CheckStyle etc. It's too complicated compare with making FindBugs an ant task of my build script. What's your opinion of Sonar on small projects?

Thanks,
Qunfeng


To be or not to be. It's a question.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Why do you need to install it on a server? You could run Sonar on Tomcat on your own machine. (Or standalone - I believe there is a version with it's own server built in.)

Or is it that your manager can't connect to a URL on your machine?

Sonar is so much more than FindBugs. It shows code quality over time. It identifies hot spots.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
sudhakar sankara
Greenhorn

Joined: Oct 14, 2010
Posts: 2

SonarQube
Steps to install/start the SonarQube server
1. Download the latest SONAR[3.6] Distribution from SONARQUBE site.
2. Unzip the SONAR Distribution.
3. Open the [SONAR_HOME]\bin folder.
4. In the bin folder open the respective OS folder [if your machine is windows 32 bit then open windows-x86-32 folder, for 64 bit machine open windows-x86-64 folder]
5. In the respective OS[windows] folder run the StartSonar.bat by double clicking on it.
6. The Sonar Server will start on in the local machine on port 9000[9000 is default port for SONARQUBE. This is configurable ]
7. Access the server by hitting the URL http://localhost:9000

Sonar will run.

Prerequisite

The Only prerequisite to run the SONARQUBE is JAVA[ JDK 6 ONWARDS] have installed in your machine.


Supported Platforms

JAVA
It supports only Oracle JRE.
It doesnt support IBM, GCG, Oracle JRockit JRE.

DataBase

ORACLE: ORACLE 10G onwrds
MySQL MySQL 5.0 onwards
PostGre PostGre 8.1 onwards

Browsers

GoogleChrome, Mozilla, Safari and IE8 onwards
It doesnt support Opera.






To analysis your project
Sonar-Runner

Analyzing with SonarQube Runner
1. Download SONAR RUNNER Distribution from SONAEQUBE site
2. Unzip the distribution
3. Open [SONAR_HOME]/bin distribution
4. Open sonar-runner.cmd file and set your project ROOT path[PROJECT_HOME]
5. Create a configuration file [sonar-project.properties]in the ROOT folder[PROJECT_HOME] of the project. Below are the sample props in sonar-project.properties.
sonar.projectKey=SampleProj
sonar.projectName=SampleProj
sonar.projectVersion=1.0

sonar.sources=src
sonar.binaries=classes
sonar.language=java
sonar.sourceEncoding=UTF-8

sonar.jacoco.itReportPath=reports/jacoco.exec

6. Open a command window and change the dir to [SONAR_HOME]/bin folder
7. Execute below command at the command prompt.
sonar-runner
8. Sonar Runner will execute and analyze
9. The report we can see on the SONAR CONSOLE[http://localhost:9000] by accessing your project.
10. SONAR displays the statistics of your project.



Prerequisite

The Only prerequisite for sonar-runner is SONARQUBE must run.










[Thumbnail for FolderStruct.GIF]

sudhakar sankara
Greenhorn

Joined: Oct 14, 2010
Posts: 2
Sonar is very useful tool
It provides below features

1.Code Review
2.Code Coverage
3.Junit

By using Maven or ANT script we can work with SONAR.
It really a wonderful tool and it has so many plugins. This has commercial/ non commercial versions.
Based on your requirements you can choose.
Patroklos Papapetrou
Author
Ranch Hand

Joined: Aug 06, 2013
Posts: 32
    
    5

SonarQube is suitable for tiny, small, medium, large or titanic projects.
You can take a look at nemo.sonarsource.org (a public SonarQube instance) where you can find tiny plugins such as SCM Activity plugin with 1000 lines of code or huge projects as JDK 7 with millions of lines of code.

SonarQube installation is really straightforward and you can have a running instance in less than 15 minutes. We've included SonarQube in action an appendix that guides you step-by-step through the installation process in Linux and Windows environments.
Finally I'd like to point out that SonarQube is not just an alternative of PMD or FindBugs. It's true that SonarQube includes all rules of PMD, FindBugs and Checkstyle but it has a lot more to offer. Here's a not exhaustive list of what SonarQube can do for you.

  • Issues is just one of the seven axes of quality. With SonarQube you can get reports about test coverage, duplications, design,. architecture, complexity etc.
    Code reviews also are made easy with SonarQube and you can integrate it with CI environments such as Jenkins to adopt Continuous Inspection.
    Differential views is also a start feature : You can get historical data of your projects, see how things are going ( better, worse , steady ) and see trends of your source code quality
    SonarQube is not just for Java.... More than twenty languages are supported via open source or commercial plugins



  • Follow me on twitter ( @ppapapetrou76 ) or see my linked profile and connect with me
    You can slso subscribe to my technical blog
    G. Ann Campbell
    Author
    Ranch Hand

    Joined: Aug 06, 2013
    Posts: 33
        
        5
    Qunfeng,

    I get what you're saying about the initial overhead, but I think you're missing a trick to go with Findbugs instead of SonarQube. Yes, you'll want a server - just so you can point the boss to it and so restarting your machine won't disrupt his viewing pleasure. But once you've got the server allocated and SonarQube installed as a service, there's really very little ongoing maintenance. Set the Sonar Way with Findbugs profile as the default profile, integrate SonarQube analysis into your build and you're done. Just ship your boss the URL to the project dashboard and walk away satisfied.


    Ann
    Burk Hufnagel
    Ranch Hand

    Joined: Oct 01, 2001
    Posts: 814
        
        3
    G. Ann Campbell wrote:Qunfeng,

    I get what you're saying about the initial overhead, but I think you're missing a trick to go with Findbugs instead of SonarQube. Yes, you'll want a server - just so you can point the boss to it and so restarting your machine won't disrupt his viewing pleasure. But once you've got the server allocated and SonarQube installed as a service, there's really very little ongoing maintenance. Set the Sonar Way with Findbugs profile as the default profile, integrate SonarQube analysis into your build and you're done. Just ship your boss the URL to the project dashboard and walk away satisfied.


    Ann


    Ann makes a great point. There's another goodie though. Once it's set up, you can add other projects pretty easily so the initial cost pays off for multiple projects - no matter how big or small.

    Burk


    SCJP, SCJD, SCEA 5 "Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
    Burk Hufnagel
    Ranch Hand

    Joined: Oct 01, 2001
    Posts: 814
        
        3
    sudhakar sankara wrote:To analysis your project
    Sonar-Runner

    Analyzing with SonarQube Runner
    1. Download SONAR RUNNER Distribution from SONAEQUBE site
    2. Unzip the distribution
    3. Open [SONAR_HOME]/bin distribution
    4. Open sonar-runner.cmd file and set your project ROOT path[PROJECT_HOME]
    5. Create a configuration file [sonar-project.properties]in the ROOT folder[PROJECT_HOME] of the project. Below are the sample props in sonar-project.properties.
    sonar.projectKey=SampleProj
    sonar.projectName=SampleProj
    sonar.projectVersion=1.0

    sonar.sources=src
    sonar.binaries=classes
    sonar.language=java
    sonar.sourceEncoding=UTF-8

    sonar.jacoco.itReportPath=reports/jacoco.exec

    6. Open a command window and change the dir to [SONAR_HOME]/bin folder
    7. Execute below command at the command prompt.
    sonar-runner
    8. Sonar Runner will execute and analyze
    9. The report we can see on the SONAR CONSOLE[http://localhost:9000] by accessing your project.
    10. SONAR displays the statistics of your project.

    Interesting, but concerning. In steps 4 and 5 you configure SonarRunner for a single project. How do you configure it for multiple projects that may have different analysis needs?
    Thanks,
    Burk
    G. Ann Campbell
    Author
    Ranch Hand

    Joined: Aug 06, 2013
    Posts: 33
        
        5
    You should actually consult the docs for how to run an analysis.
    Burk Hufnagel
    Ranch Hand

    Joined: Oct 01, 2001
    Posts: 814
        
        3
    G. Ann Campbell wrote:You should actually consult the docs for how to run an analysis.

    Ah. Looks like multiple sonar-project.property files (one per project) with inheritance from the parent to reduce duplication. That seems very reasonable.

    It also brings up a question - if they had to change the name from Sonar to SonarQube for legal reasons, shouldn't the sonar-project.property file also need to be renamed? I'm guessing you're not a lawyer, but perhaps you know why that hasn't happened?

    Thanks, Ann.

    Burk
    G. Ann Campbell
    Author
    Ranch Hand

    Joined: Aug 06, 2013
    Posts: 33
        
        5
    Off-hand I'd say it's because there are a lot of pieces. I'm pretty sure that too will change eventually.
    Burk Hufnagel
    Ranch Hand

    Joined: Oct 01, 2001
    Posts: 814
        
        3
    You're probably right - and if that's the case, then I'm hoping someone will write a nice migration script that will update filenames, and config file contents, etc. automagically. Otherwise it's going to be a pain for people - especially those using SonarQube the most.

    Burk
    G. Ann Campbell
    Author
    Ranch Hand

    Joined: Aug 06, 2013
    Posts: 33
        
        5
    I have no inside line on this, but I would trust that there would be a very long migration period - if the old methods ever stop working.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: SonarQube in Action:Is Sonar too heavy for small projects?