I’ve always been fan of tools for automation of development and testing. I’ve used SonarQube for a long time, and even connect it to my IDE (usually Eclipse), so that I can act on any warnings for code as I’m working on it.
SonarLint takes that to a new level, as it gives notifications before the code is even commited for SonarQube to analyze.
While the instructions here are for Eclipse, SonarLint is also available for IntelliJ IDEA, VisualStudio, and as a command line tool for download from the website.
Eclipse Update Site:
I noticed this while updating to SonarQube 4.5. The documentation and references to this parameter lead me to believe that it is a useful shortcut to optimizing server resources.
NOTE: In some instances you may need to escape the ampersands!
I’ll change this on a few projects and watch for any issues changes.
If you have already embraced Continuous Inspection with Sonar/SonarQube, you may find it advantageous to do analysis of new or modified code within the IDE without having to wait for a new build/compile/analyze cycle. Additionally, it’s often faster to keep all of your required information within the IDE without having to also open a web browser.
You can easily add this capability:
- Help > Install New Software… > Add… > then enter:
- Restart Eclipse
- RightClick on project – Configure > Associate with SonarQube > chose project
Installation of Sonar requires but a few simple steps, though they can be rather obscure to many developers.
Connect to MySQL:
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
grant all privileges on sonar.* to 'sonar@localhost' identified by 'sonar';
Easiest method, if you are on Ubuntu:
sudo vi /etc/apt/sources.list
- Then add the following line:
deb http://downloads.sourceforge.net/project/sonar-pkg/deb binary/
sudo apt-get update
sudo apt-get install sonar
- You will then have to stop/start as above to edit the configuration, generally to change database config:
sudo vi /opt/sonar/conf/sonar.properties
Manual installation (and upgrade?) if you prefer to do things the hard way 🙂
- Download and unzip the release:
sudo mv sonar-3.6.1 /opt/sonar
sudo rm -r /opt/sonar (to remove old link)
sudo ln -s /opt/sonar-3.6.1/ /opt/sonar
(uncomment lines for MySQL, comment out H2)
sudo cp /opt/sonar/bin/linux-x86-64/sonar.sh /etc/init.d/sonar
sudo vi /etc/init.d/sonar
add the following 2 lines:
sudo update-rc.d -f sonar remove
sudo chmod 755 /etc/init.d/sonar
sudo update-rc.d sonar defaults
Upgrades can be a little odd, if you see the maintenance page at http://localhost:9000/maintenance, go to http://localhost:9000/setup and do the required steps.