Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      15 Essential Skills to Look for When Hiring Node.js Developers for Enterprise Projects (2025-2026)

      August 4, 2025

      African training program creates developers with cloud-native skills

      August 4, 2025

      React.js for SaaS Platforms: How Top Development Teams Help Startups Launch Faster

      August 3, 2025

      Upwork Freelancers vs Dedicated React.js Teams: What’s Better for Your Project in 2025?

      August 1, 2025

      Automate your project with GitHub Models in Actions

      August 4, 2025

      Thinking Deeply About Theming and Color Naming

      August 4, 2025

      Wish You Were Here – Win a Free Ticket to Penpot Fest 2025!

      August 4, 2025

      CodeSOD: Concatenated Validation

      August 4, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Billing System using PHP and MySQL

      August 4, 2025
      Recent

      Billing System using PHP and MySQL

      August 4, 2025

      The details of TC39’s last meeting

      August 4, 2025

      July report 2025

      August 4, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft’s record stock run collides with Nadella’s admission that 15,000 layoffs still ‘hurt’

      August 4, 2025
      Recent

      Microsoft’s record stock run collides with Nadella’s admission that 15,000 layoffs still ‘hurt’

      August 4, 2025

      Microsoft and Adobe Power Up Fantasy Premier League Fans with AI – Here’s How

      August 4, 2025

      Google Quietly Tests Opal, a “Vibe-Coding” App That Turns Text into Mini Web Apps

      August 4, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»How to improve your code quality with SonarQube

    How to improve your code quality with SonarQube

    May 2, 2025

    SonarQube is a powerful open-source tool that helps you maintain code quality and security by analyzing your codebase for bugs and vulnerabilities. And it can play a major role when integrated into your CI/CD pipeline.

    In this tutorial, we will cover:

    1. What is SonarQube?

    2. How SonarQube Improves Code Quality

    3. Step-by-step Installation and Configuration

    4. How to Run Your First Code Analysis

    What is SonarQube?

    SonarQube is an open-source tool that checks for code quality continuously. It analyzes code to find issues like duplication, bad practices, test coverage gaps, bugs, and vulnerabilities, giving detailed reports. It works with many programming languages like Java, C#, JavaScript, Python, TypeScript, and Kotlin.

    You can add SonarQube to your CI/CD pipelines, IDEs, and version control systems like GitHub, GitLab, or Bitbucket. It provides detailed dashboards that show metrics, trends, and issues in your code.

    You can use custom rules to enforce coding standards and reduce technical debt. SonarQube also supports code coverage analysis to help teams improve their tests. With the Quality Gate feature, teams can ensure only clean, maintainable code goes into production.

    SonarQube offers both free and paid versions to suit any team size. Overall, it helps improve software quality and encourages good coding practices.

    How Does SonarQube Improve Code Quality?

    Here’s how SonarQube helps improve code quality:

    1. Early bug detection: Identifies bugs before they reach production

    2. Improved maintainability: Highlights code and design issues

    3. Security insights: Identifies vulnerabilities and security risks

    4. Code coverage: Integration with testing tools to monitor unit test coverage

    5. Customizable rules: Allows teams to set coding standards and policies

    6. Team collaboration: Ensures consistent code quality across development teams

    Step-by-Step Installation and Configuration

    Prerequisites:

    Here are the prerequisites that you will need before installing SonarQube

    1. Java Runtime Environment(JRE): Java 11 or above installed in your system.

    2. System Requirements: 2GB RAM minimum (Recommended: 4GB+).

    3. MacOS: You can use HomeBrew, which is the package manager for MacOS that simplifies the installation of software.

    Below are the steps to install SonarQube in your local machine:

    Download SonarQube

    Download the software from sonarsource downloads and choose the Community Edition for open-source projects.

    Extract and Configure

    To install SonarQube, you need to run the below command to unzip the file:

    unzip sonarqube-<version>.zip
    cd sonarqube-<version>/bin/<your-OS-folder>
    

    Start SonarQube

    On Linux/Mac, you need to run the below command:

    ./sonar.sh start
    

    On Windows, you need to run this one:

    StartSonar.bat
    

    Access SonarQube

    To access SonarQube, you need to open browser and go to: http://localhost:9000

    Enter the default credentials:

    • Username: admin

    • Password: admin (you’ll be prompted to change it)

    The page will look similar to below:

    SonarQube project creation page

    Set Up SonarQube in Your Project

    To set up SonarQube in your project, start by opening the Java project on your machine. In the project root, create a sonar-project.properties file.

    Add the below key value pairs in the file:

    sonar.projectKey=spring-myproject
    sonar.projectName=My Project
    sonar.projectVersion=1.0
    sonar.sources=.
    sonar.host.url=http://localhost:9000
    

    How to Run Your First Code Analysis

    Configure and Run SonarScanner

    SonarScanner is the tool that actually sends your code to SonarQube for analysis. Below are the detailed steps to follow to use it:

    Install SonarScanner:

    On Windows/Linux, download the software from SonarSource and unzip it:

    unzip sonar-scanner-cli-<version>.zip
    

    On MacOS, run the below command:

    >brew install sonar-scanner
    

    For both Windows/Linux and MacOS, verify the install by running the below command:

    >sonar-scanner -v
    

    Configure SonarScanner

    After installing SonarScanner, you’ll need to configure it by setting the SonarQube server URL and authentication token. Then go to your SonarQube profile (top-right corner > My Account > Security) and generate a token.

    Generate tokens in SolarQube

    Provide a name for the token and click ‘Generate’:

    Name token and then generate

    In the sonar-project.properties file in your project, add ‘sonar.login’ property and save.

    sonar.projectKey=test-project
    sonar.projectName=Test Project
    sonar.host.url=http://localhost:9000
    sonar.login=<YOUR_TOKEN_HERE>
    

    Run the Analysis

    Once the SonarScanner is configured, you can start scanning your project.

    In a terminal or command prompt, go to the root of your project (where sonar-project.properties is located).

    Run the following command:

    >sonar-scanner
    

    SonarScanner will analyze your code and push the results to your local SonarQube server. Visit http://localhost:9000, and you’ll see your project listed on the dashboard.

    • Scanner results dashboard

    To view the analysis report, go to http://localhost:9000/dashboard?id=java-sonar-demo:

    Analysis results

    If you go to the ‘Issues’ tab at top left corner, you can view different categories of Software Quality, Severity of the Issues, and various other attributes in your code.

    Detailed results

    Conclusion

    Now you have installed and configured SonarQube and learned how to scan your code using SonarScanner. You can easily configure it in your projects for continuous code quality analysis.

    This is a fantastic tool for keeping your code base clean and maintainable. As the next steps, you can consider adding test coverage reports, enforcing quality gates in your pipeline, and exploring SonarCloud for cloud-based analysis.

    ##

    Source: freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleAPI Documentation: The Importance of Clear and Concise API Documentation
    Next Article Learn Kubernetes – Full Handbook for Developers, Startups, and Businesses

    Related Posts

    Development

    PlayPraetor Android Trojan Infects 11,000+ Devices via Fake Google Play Pages and Meta Ads

    August 4, 2025
    Development

    The Wild West of Shadow IT

    August 4, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    AV1 @ Scale: Film Grain Synthesis, The Awakening

    News & Updates

    With iOS 26, Apple finally makes your iPhone’s Photos app usable again

    News & Updates

    TEKEVER becomes the latest unicorn in Europe’s defencetech industry

    News & Updates

    Streamline code conversion and testing from Microsoft SQL Server and Oracle to PostgreSQL with Amazon Bedrock

    Databases

    Highlights

    CVE-2025-25207 – Red Hat Connectivity Link Authorino Denial of Service

    June 9, 2025

    CVE ID : CVE-2025-25207

    Published : June 9, 2025, 6:15 a.m. | 3 hours, 23 minutes ago

    Description : The Authorino service in the Red Hat Connectivity Link is the authorization service for zero trust API security. Authorino allows the users with developer persona to add callbacks to be executed to HTTP endpoints once the authorization process is completed. It was found that an attacker with developer persona access can add a large number of those callbacks to be executed by Authorino and as the authentication policy is enforced by a single instance of the service, this leada to a Denial of Service in Authorino while processing the post-authorization callbacks.

    Severity: 5.7 | MEDIUM

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    CVE-2025-54447 – Samsung Electronics MagicINFO 9 Server Unrestricted File Upload Code Injection Vulnerability

    July 23, 2025

    I missed out on the Clair Obscur: Expedition 33 Collector’s Edition but thankfully, the developers are launching something special

    May 22, 2025

    Google upgrades AI Mode with Canvas and 3 other new features – how to try them

    July 30, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.