DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • My Experiences with Maven in IntelliJ IDEA and NetBeans IDE
  • Using Python Libraries in Java
  • DGS GraphQL and Spring Boot
  • How to Build a New API Quickly Using Spring Boot and Maven

Trending

  • After 9 Years, Microsoft Fulfills This Windows Feature Request
  • Unlocking the Potential of Apache Iceberg: A Comprehensive Analysis
  • Mastering Deployment Strategies: Navigating the Path to Seamless Software Releases
  • How To Build AI-Powered Prompt Templates Using the Salesforce Prompt Builder
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. How to Run a Code Analysis From Maven or an IDE

How to Run a Code Analysis From Maven or an IDE

Not particularly keen on using just SonarQube to run your code analysis? No problem, here we have some alternatives that you might prefer.

By 
Matias Fornara user avatar
Matias Fornara
·
Jan. 23, 18 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
18.5K Views

Join the DZone community and get the full member experience.

Join For Free

In part two of this blog series on code analysis, I showed you how to do a proof of concept quickly using a SonarQube Docker image, and run the analysis from SonarQube Scanner. In this third and final post, we will see two SonarQube alternatives: Maven and an IDE.

Running the Analysis With Maven

To begin with this process, the first thing you must do is add the SonarQube plugin to your Maven project as follows:

Screen Shot 2018-01-20 at 11.06.59 AM-min

(This is for Maven 2, for Maven 3 check here).

At this point you have everything necessary to perform your code analysis from Maven, so it will perform the analysis in the SonarQube server that you have already installed in a Docker container (explained here).

Then, all that remains is to go to the directory of your project and execute the Maven goal with the following command:

mvn sonar:sonar -Dsonar.host.url=http://docker-ip:port


The name of the project in SonarQube and the version is taken from the Maven project (at the beginning of the pom file). See the documentation about the parameters here.

As a result, you will see something like this:

Screen Shot 2018-01-20 at 11.09.33 AM-min

In this way, you’ll obtain your SonarQube-generated report:

sonarqube report

Running the Analysis in an IDE

This other method will allow you to execute the analysis directly from the IDE of your preference. Here we will show you the use of the SonarLint plugin for IntelliJ, but its equivalent for other development environments such as Eclipse or Visual Studio.

Sonarlint in Intellij

The first thing is to download the SonarLint plugin from the IntelliJ plugin manager. Once installed, proceed with the configuration.

2. Configuration (1)

Select “Enable binding to remote SonarQube server” and then select “Configure servers.”

sonarling2-min

Then add a server, entering the IP and the port of the server:

sonarlint3-768x354-min

Select authentication through username and password, entering the corresponding credentials. After advancing in the wizard, choose some of the existing projects in the SonarQube server to link it.

At this time you can proceed to analyze the project you want:

ejecutar-sonarlint-768x483

Obtaining a result as shown below:

resultado-sonarlint-768x200-1-min

After executing the analysis, you can go to your code and SonarLint will mark the errors or possible corrections to be made as if it were a syntax error marked by the IDE itself.

What a surprise it is to see all the failures that SonarQube reports, no!? You can learn a lot by incorporating this tool early in a project. What do you think?

Integrated development environment Apache Maven

Published at DZone with permission of Matias Fornara, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • My Experiences with Maven in IntelliJ IDEA and NetBeans IDE
  • Using Python Libraries in Java
  • DGS GraphQL and Spring Boot
  • How to Build a New API Quickly Using Spring Boot and Maven

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!