It is fair to say that setting up and maintaining a source code quality management is not on the top of priorities list of developers and managers alike. Despite all the good intentions, costs and/or time to market relegate the tasks of setting up a code analyzer for instances and enforcing coding best practices to the back burner. Unfortunately, those tools have gotten the reputation to be difficult to maintain and costly to license. This is not the case anymore.
Sonar is an open source Platform used by development teams to manage
source code quality. The main purpose of the project is to simplify code quality management.
As such, Sonar supports analysis of Java in the core,
but also up to 10 different programming languages through plug-ins. The automation process associated to code quality management can be broken down along two distinct objectives:
- Continuous integration: Build automation, static code analysis & code coverage reports
- Continuous reviews: Best practices violations, code improvement and refactoring, stability and maintainability
Cyclomatic complexity originally developed by Thomas McCabe,directly measures the number of linearly independent paths through a program's source code.
Readability of source code is quite often evaluated using Fresch-Kincaid test that was originally developed for measuring the readability of academic English. The method scores the "complexity" of any document from 100 (11th grade student) to 0 domain-experts and scholars, with 50 for articles in "Time Magazine".
Dashboard
![]() |
|
Best Practices Violation
One of a "side" benefit of any static code analyzer is to force the engineering to define and maintain a set of best practices. Sonar uses a severity ranking similar to most common defect database of classify violation of coding standards. The following table display the severity and type of violation of best practice rule.
By default, the current version of Sonar, 3.0, contains 600 coding off-the-shelf rules. The user can create custom rules or override existing ones using XPath expressions.
Inner Assignment
checkstyle : com.puppycrawl.tools.checkstyle.checks.coding.InnerAssignmentCheck
Checks for assignments in subexpressions, such as in String s = Integer.toString(i = 2);
Avoid Throwing Raw Exception Types
Avoid throwing certain exception types. Rather than throw a raw RuntimeException, Throwable, Exception, or Error, use a subclassed exception or error instead.
checkstyle : com.puppycrawl.tools.checkstyle.checks.coding.InnerAssignmentCheck
Checks for assignments in subexpressions, such as in String s = Integer.toString(i = 2);
Avoid Throwing Raw Exception Types
Avoid throwing certain exception types. Rather than throw a raw RuntimeException, Throwable, Exception, or Error, use a subclassed exception or error instead.
Sonar allows the developers to take a snapshot of the overall quality of an application and view the evolution of quality measures across snapshots with the TimeMachine service. But this was not sufficient to provide at quick answers to the fundamental question: What changed over the past X days?
Recently, Sonar added the differential dashboard that allows developers to visualize the difference between two quality snapshots. Those quality snapshots can be assigned a version, and purged according to a
configurable policy.
Getting Started
Sonar is made of 3 components:
- Database that stores the configuration and results of quality analyses
- Web Server that is used to navigate the results of the analyzes and make configuration
- Client that runs source code analyzers to compute data on projects
Installation of Sonar
Here are the set-up to install Sonar
1. Download the latest version of Sonar from Sonar Downloads
2. Unzip the installation package
3. In the directory sonar-xx/conf open and edit the Sonar property file
4. Override the credentials
sonar.jdbc.username: sonar
sonar.jdbc.password: sonar
5. By default, Sonar is bundled with Apache Derby databasesonar.jdbc.password: sonar
sonar.jdbc.url: jdbc:derby://localhost:1527/sonar;create=true
sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
6. If you want to use your own database you need to create the database and relevant tables
7. Then specify the JDBC drivers URL and name of your database
sonar.jdbc.url: jdbc:oracle:thin:@localhost:1521/instance-name
sonar.jdbc.driverClassName: oracle.jdbc.driver.OracleDriver
or
sonar.jdbc.url:jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8 sonar.jdbc.driverClassName:com.mysql.jdbc.Driver
sonar.jdbc.driverClassName: oracle.jdbc.driver.OracleDriver
or
sonar.jdbc.url:jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8 sonar.jdbc.driverClassName:com.mysql.jdbc.Driver
Assuming Eclipse version 3.7 or later is installed...
- Go to Help > Install New Software... This should display the Install dialog box.
- Paste the Update Site URL (http://dist.sonar-ide.codehaus.org/eclipse/) into the field Work with and press Enter. This should display the list of available plugins and components:
- Check the component you wish to install.
- Click Next. Eclipse will then check to see if there is any issue which would prevent a successful installation
- Click Finish to begin the installation process. Eclipse will then download and install the necessary components.
- Once the installation process is finished, Eclipse will ask if you want to restart the IDE. It is strongly recommended that you restart the IDE.
Integration with Jenkins
Assuming that Jenkins continuous integration server is already installed, you need to
- login into the Jenkins installation 's management screen
- click on Manage Plugins menu
- select the Available tab. If the list of plug-ins is empty, then select Advanced tab and force to check for new updates by clicking Check now.
- select the check box corresponding to the Sonar plug-in for a particular language
- select the Install without restart option. The installation will complete
References
Sonar Official Web Site
Improving Code Quality with Sonar and Jenkins
The development of artificial intelligence (AI) has propelled more programming architects, information scientists, and different experts to investigate the plausibility of a vocation in machine learning. Notwithstanding, a few newcomers will in general spotlight a lot on hypothesis and insufficient on commonsense application. machine learning projects for final year In case you will succeed, you have to begin building machine learning projects in the near future.
ReplyDeleteProjects assist you with improving your applied ML skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include projects into your portfolio, making it simpler to get a vocation, discover cool profession openings, and Final Year Project Centers in Chennai even arrange a more significant compensation.
Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account.
The Nodejs Training Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training