Convert Figma logo to code with AI

SonarSource logosonarqube

Continuous Inspection

8,901
1,956
8,901
0

Top Related Projects

SpotBugs is FindBugs' successor. A tool for static analysis to look for bugs in Java code.

4,797

An extensible multilanguage static code analyzer.

Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. By default it supports the Google Java Style Guide and Sun Code Conventions, but is highly configurable. It can be invoked with an ANT task and a command line program.

6,200

Static code analysis for Kotlin

Quick Overview

SonarQube is an open-source platform developed by SonarSource for continuous inspection of code quality. It performs automatic reviews with static analysis of code to detect bugs, code smells, and security vulnerabilities on 20+ programming languages. SonarQube provides detailed reports and dashboards to help developers maintain and improve their code quality over time.

Pros

  • Supports a wide range of programming languages and integrates with various CI/CD tools
  • Offers comprehensive code analysis, including security vulnerabilities, bugs, and code smells
  • Provides clear visualizations and metrics for easy interpretation of code quality
  • Allows for customizable quality gates and rules to fit specific project needs

Cons

  • Can be resource-intensive, especially for large codebases
  • Initial setup and configuration can be complex for beginners
  • Some advanced features are only available in paid versions
  • False positives in analysis results may require manual review and filtering

Getting Started

To get started with SonarQube:

  1. Download and install SonarQube from the official website
  2. Start the SonarQube server
  3. Access the web interface (default: http://localhost:9000)
  4. Create a new project and generate a token
  5. Install SonarScanner on your development machine
  6. Run the scanner on your project with the following command:
sonar-scanner \
  -Dsonar.projectKey=my_project \
  -Dsonar.sources=. \
  -Dsonar.host.url=http://localhost:9000 \
  -Dsonar.login=YOUR_GENERATED_TOKEN
  1. View the analysis results in the SonarQube web interface

For more detailed instructions and advanced configurations, refer to the official SonarQube documentation.

Competitor Comparisons

SpotBugs is FindBugs' successor. A tool for static analysis to look for bugs in Java code.

Pros of SpotBugs

  • Lightweight and focused specifically on Java bytecode analysis
  • Can be easily integrated into build processes and IDEs
  • Free and open-source with a large community of contributors

Cons of SpotBugs

  • Limited to Java language analysis only
  • Less comprehensive in terms of overall code quality metrics
  • Requires more manual configuration compared to SonarQube's out-of-the-box setup

Code Comparison

SpotBugs configuration (in Maven pom.xml):

<plugin>
  <groupId>com.github.spotbugs</groupId>
  <artifactId>spotbugs-maven-plugin</artifactId>
  <version>4.5.0.0</version>
</plugin>

SonarQube configuration (in Maven pom.xml):

<plugin>
  <groupId>org.sonarsource.scanner.maven</groupId>
  <artifactId>sonar-maven-plugin</artifactId>
  <version>3.9.1.2184</version>
</plugin>

Both tools can be integrated into Maven builds, but SonarQube offers a more comprehensive analysis across multiple languages and metrics, while SpotBugs focuses specifically on Java bytecode analysis for finding bugs.

4,797

An extensible multilanguage static code analyzer.

Pros of PMD

  • Lightweight and easy to integrate into existing build processes
  • Supports multiple programming languages beyond Java
  • Highly customizable with user-defined rules

Cons of PMD

  • Less comprehensive analysis compared to SonarQube
  • Limited reporting and visualization capabilities
  • Requires more manual configuration for advanced use cases

Code Comparison

PMD rule definition:

<rule name="AvoidUsingHardCodedIP"
      language="java"
      message="Avoid using hardcoded IP addresses"
      class="net.sourceforge.pmd.lang.rule.XPathRule">
    <description>
        Avoid using hardcoded IP addresses in code.
    </description>
    <priority>3</priority>
    <properties>
        <property name="xpath">
            <value>
                //Literal[matches(@Image, "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")]
            </value>
        </property>
    </properties>
</rule>

SonarQube rule definition:

@Rule(key = "S1313")
public class HardcodedIpAddressCheck extends IssuableSubscriptionVisitor {
    private static final String MESSAGE = "Make this IP '%s' address configurable.";
    private static final Pattern IP = Pattern.compile("^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$");

    @Override
    public List<Tree.Kind> nodesToVisit() {
        return ImmutableList.of(Tree.Kind.STRING_LITERAL);
    }

    @Override
    public void visitNode(Tree tree) {
        LiteralTree literal = (LiteralTree) tree;
        if (IP.matcher(LiteralUtils.trimQuotes(literal.value())).matches()) {
            reportIssue(literal, String.format(MESSAGE, literal.value()));
        }
    }
}

Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. By default it supports the Google Java Style Guide and Sun Code Conventions, but is highly configurable. It can be invoked with an ANT task and a command line program.

Pros of Checkstyle

  • Lightweight and focused solely on Java code style checking
  • Highly customizable with extensive rule sets
  • Easy integration with build tools like Maven and Gradle

Cons of Checkstyle

  • Limited to Java language only
  • Lacks advanced static code analysis features
  • No built-in reporting or visualization tools

Code Comparison

Checkstyle configuration example:

<module name="Checker">
  <module name="TreeWalker">
    <module name="AvoidStarImport"/>
    <module name="ConstantName"/>
  </module>
</module>

SonarQube configuration example:

sonar.projectKey=my:project
sonar.projectName=My project
sonar.projectVersion=1.0
sonar.sources=src
sonar.java.binaries=target/classes

Summary

Checkstyle is a lightweight, Java-specific code style checker that excels in customization and easy integration with build tools. It's ideal for projects focused solely on Java code style enforcement. However, it lacks the comprehensive static code analysis and multi-language support offered by SonarQube.

SonarQube, on the other hand, provides a more robust solution for code quality management across multiple languages, with advanced static analysis features and built-in reporting tools. It's better suited for larger projects or organizations requiring a more comprehensive code quality platform.

6,200

Static code analysis for Kotlin

Pros of detekt

  • Lightweight and focused specifically on Kotlin static code analysis
  • Easy integration with Gradle and Maven build systems
  • Highly customizable with the ability to write custom rules

Cons of detekt

  • Limited to Kotlin language analysis only
  • Smaller community and fewer out-of-the-box rules compared to SonarQube
  • Less comprehensive reporting and visualization features

Code Comparison

detekt configuration example:

detekt {
    config = files("$projectDir/config/detekt.yml")
    buildUponDefaultConfig = true
    allRules = false
}

SonarQube configuration example:

sonar.projectKey=my:project
sonar.sources=src
sonar.java.binaries=build/classes
sonar.kotlin.detekt.reportPaths=build/reports/detekt/detekt.xml

Summary

detekt is a lightweight, Kotlin-specific static code analysis tool that integrates easily with build systems. It offers high customizability but has a narrower focus compared to SonarQube. SonarQube, on the other hand, provides a more comprehensive analysis across multiple languages and offers advanced reporting features, but may be considered heavier and more complex to set up for smaller projects.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

SonarQube Build Status Quality Gate Status

Continuous Inspection

SonarQube provides the capability to not only show the health of an application but also to highlight issues newly introduced. With a Quality Gate in place, you can achieve Clean Code and therefore improve code quality systematically.

Links

Have Questions or Feedback?

For support questions ("How do I?", "I got this error, why?", ...), please first read the documentation and then head to the SonarSource Community. The answer to your question has likely already been answered! 🤓

Be aware that this forum is a community, so the standard pleasantries ("Hi", "Thanks", ...) are expected. And if you don't get an answer to your thread, you should sit on your hands for at least three days before bumping it. Operators are not standing by. 😄

Contributing

If you would like to see a new feature or report a bug, please create a new thread in our forum.

Please be aware that we are not actively looking for feature contributions. The truth is that it's extremely difficult for someone outside SonarSource to comply with our roadmap and expectations. Therefore, we typically only accept minor cosmetic changes and typo fixes.

With that in mind, if you would like to submit a code contribution, please create a pull request for this repository. Please explain your motives to contribute this change: what problem you are trying to fix, what improvement you are trying to make.

Make sure that you follow our code style and all tests are passing (Travis build is executed for each pull request).

Willing to contribute to SonarSource products? We are looking for smart, passionate, and skilled people to help us build world-class code-quality solutions. Have a look at our current job offers here!

Building

To build sources locally follow these instructions.

Build and Run Unit Tests

Execute from the project base directory:

./gradlew build

The zip distribution file is generated in sonar-application/build/distributions/. Unzip it and start the server by executing:

# on Linux
bin/linux-x86-64/sonar.sh start
# or on MacOS
bin/macosx-universal-64/sonar.sh start
# or on Windows
bin\windows-x86-64\StartSonar.bat

Open in IDE

If the project has never been built, then build it as usual (see previous section) or use the quicker command:

./gradlew ide

Then open the root file build.gradle as a project in IntelliJ or Eclipse.

Gradle Hints

./gradlew commandDescription
dependencieslist dependencies
licenseFormat --rerun-tasksfix source headers by applying HEADER.txt
wrapper --gradle-version 5.2.1upgrade wrapper

License

Copyright 2008-2024 SonarSource.

Licensed under the GNU Lesser General Public License, Version 3.0