Search Tutorials


Top SonarQube frequently asked interview questions | JavaInUse



Top SonarQube frequently asked interview questions.

In this post we will look at SonarQube Interview questions. Examples are provided with explanations.


What is SonarQube
A:
Sonar is a web based code quality analysis tool for Maven based Java projects. It covers a wide area of code quality check points which include: Architecture & Design, Complexity, Duplications, Coding Rules, Potential Bugs, Unit Test etc.

Q: Why use SonarQube ?
A:
Sonar covers the 7 sections of code quality
  • Architecture and Design
  • Unit tests
  • Duplicated code
  • Potential bugs
  • Complex code
  • Coding standards
  • Comments

Q: What are the advantages of using SonarQube?
A:
  • SonarQube is open source
  • SonarQube supports for various languages like Java, C#
  • SonarQube reports for duplicate code, unit testing, code coverage, code complexity historical
  • We can integrate SonarQube with build tools like ant, gradle
  • SonarQube has Eclipse plugin like Sonarlint
  • SonarQube supports external plugins like plugin for ldap

Q: What are Quality Profiles in SonarQube?
A:
The Quality Profiles service is central to SonarQube, since it is where you define your requirements by defining sets of rules (ex: Methods should not have a Cognitive Complexity greater than 15).
Ideally, all projects will be measured with the same profile for any given language, but that's not always practical. For instance, you may find that:
The technological implementation differs from one application to another (for example, different coding rules may apply when building threaded or non-threaded Java applications). You want to ensure stronger requirements on some of your applications (internal frameworks for example).
Q: What are Quality Gates in SonarQube?
A:
A quality gate is the best way to enforce a quality policy in your organization. It's there to answer ONE question: can I deliver my project to production today or not? In order to answer this question, you define a set of Boolean conditions based on measure thresholds against which projects are measured. For example:
No new blocker issues Code coverage on new code greater than 80% Etc. Ideally, all projects will be verified against the same quality gate, but that's not always practical. For instance, you may find that: Technological implementation differs from one application to another (you might not require the same code coverage on new code for Web or Java applications). You want to ensure stronger requirements on some of your applications (internal frameworks for example). Etc.
Which is why you can define as many quality gates as you wish. Quality Gates are defined and managed in the Quality Gates page found in the top menu.

Q: What is role of database in SonarQube?
A:
Sonar uses a Derby or H2 as default database. When running Sonar, it says that these databases may only be used for evaluation. We can change this default database and use our custom DB.

Q: Explain architecture of SonarQube?
A:

SonarQube Architecture

Q: How to create reports in SonarQube?
A:
To create reports using SonarQube
mvn clean install
mvn sonar:sonar -Dsonar.issuesreport.html.enable=true

See Also

Spring Boot Interview Questions Apache Camel Interview Questions Drools Interview Questions Java 8 Interview Questions Enterprise Service Bus- ESB Interview Questions. JBoss Fuse Interview Questions Angular 2 Interview Questions