Sonar practices [open source code quality management platform]

Source: Internet
Author: User

As the project expands,CodeIn addition to code review, it is important to use tools for regular inspection specifications. Sonar is such a platform.


Sonar is an openSource codeQuality management platform.Its main features are as follows:

    • Code coverage: the unit test shows the lines of code selected.
    • Improved Coding rules
    • Search encoding rules: query by name, plug-in, activation level, and category
    • Project search: query by project name
    • Comparison data: Compare the trend of any measurement in the same table


Download the installation file from the, decompress it to any directory, execute startsonar. Bat corresponding to 32/64, a service is started on port 9000 by default

Java Project Practice

Http:// has detailed documentation, the fastest way is the form below


It is easier to use Maven for project management.

1,Download the sonar runner from the and decompress it, add the decompressed directory to path [to find the sonar-runner.bat run file]

2,Put the following files in the project

# Required metadata

Sonar. projectkey =Com. Demo: mydemo

Sonar. projectname =Demo

Sonar. projectversion =1.0

# Path to source directories (required)

Sources =Src/main/Java

# Path to test source directories (optional)

# Tests = testdir1, testdir2

# Path to project binaries (optional), for example directory of Java bytecode

# Binaries = bindir

# Path to project libraries (optional)

Libraries = JUnit. Jar

# Uncomment those lines if some features of Java 5 or Java 6 like annotations, Enum ,...

# Are Used in the source code to be analyzed

# Maid. java. Source = 1.5

Export get = 1.5

# Uncomment this line to analyze a project which is not a Java project.

# The value of the property must be the key of the language.

# Sonar. Language = COBOL

# Advanced Parameters

# My. Property = Value

The above is a simple configuration, more detailed configuration can refer to the


3,Run sonar-runner in the project directory.

4. Go to http: // localhost: 9000 to view the result, which is similar to the following:

The project's code volume, class distribution, and other indicators can be seen. This software integrates many open-source Java tools such as analysis and testing, so the specific functions are rich.


If you use it in eclipse, you can install it by referring to the following content.


Update site


Eclipse marketplace




Eclipse enhancements include local analysis



As a platform, sonar can run on the server and record the quality of each time. Therefore, it can track the code quality of the project.

If it's just a local analysis codepro analytix this open source tool is also very useful [Reference]


This tool also provides support for other languages, the official site of a lot of,

For example, CSHARP analysis integrates various tools such as fxcop stylecop. However, compared with Java, there are still fewer tools. Compared with vs team Foundation, it has many advantages in code management, the actual project can be used as a supplement to this TFs [You can quantitatively see the evolution history of the Code]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.