We’ll learn how to integrate SonarLint with Eclipse and IntelliJ in this post. This will allow you to assess the quality of your test automation before committing it to your code repository. Eclipse and IntelliJ are the most popular IDEs for Selenium Test Automation. Another easy way to integrate with SonarQube is using Jenkins jobs. Read more on how to set up Jenkins and SonarQube for test automation.
What is SonarLint?
SonarLint is an IDE extension that helps you detect and fix quality issues as you write code. Like a spell checker, SonarLint squiggles flaws so that they can be fixed before committing code.
Skip to: How to install SonarLint for IntelliJ
How to install SonarLint for Eclipse?
Sonarlint for Eclipse is simple to install and configure. There are a few options for installing this; pick the one that works best for you.
- Install SonarLint via Eclipse Marketplace
- Install as New Software to Eclipse
- Install by Drag Drop from Eclipse Marketplace
Install SonarLint via Eclipse Marketplace
- Open Eclipse Marketplace : Help > Eclipse Marketplace
- Click the search tab to search for “SonarLint”
- Click on the Install button against the search result for SonarLint Plugin
- Installation should get started post accepting the license agreement
- Finish by restarting Eclipse. The Eclipse SonarLint marker will then be enabled on issues in the codebase based on the common pre-set rules with SonarLint standalone.
Install SonarLint as New Software to Eclipse
- Go to Menu Option: Help > Install New Software
- Enter “‘http://eclipse.sonarlint.org/” in the “Work with” field at Available Software window
- Select SonarLint install options and click Next, click finish in the next window
Install SonarLint by Drag-Drop from Eclipse Marketplace
- Go to SonarLint Eclipse plugin Page – https://www.sonarlint.org/eclipse
- Click on “Install in Eclipse for Free” on the top right, a pop-up with available IDEs will appear
- Click on Eclipse, which will take you to the eclipse market place page
- drag install button there to Eclipse workspace
- check the plugin option and click finish
- You may want to navigate to this page directly – https://marketplace.eclipse.org/content/sonarlint
Bind Eclipse with SonarQube
SonarLint uses the analyzers, quality profiles, and parameters configured on the SonarQube server when the Eclipse project is linked to the SonarQube server project. follow the below steps to bind Sonarlint with SonarQube Server.
- Go to File > New > Other
- Under SonarLint, Select New Server
- Click next and fill the wizard with the Sonar sever details (URL and credentials or token) and test connection.
- Click on Add to select the Project and Done.
How to Install SonarLint for IntelliJ
- Go to Settings > Plugin
- Search for SonarLint in the search box
- Click on Install button
- Restart IntelliJ and you are done
Right Click on the file to analyze. Then Go to SonarLint > Analyze with SonarLint