{"id":628,"date":"2015-07-14T14:42:11","date_gmt":"2015-07-14T09:12:11","guid":{"rendered":"http:\/\/techtwaddle.net\/?p=628"},"modified":"2015-07-14T14:42:11","modified_gmt":"2015-07-14T09:12:11","slug":"using-sonarqube-intellij-plugin-for-code-analysis","status":"publish","type":"post","link":"https:\/\/techtwaddle.co.in\/blog\/2015\/07\/14\/using-sonarqube-intellij-plugin-for-code-analysis\/","title":{"rendered":"Using SonarQube IntelliJ plugin for Code Analysis"},"content":{"rendered":"<p>SonarQube provides a <a href=\"http:\/\/docs.sonarqube.org\/display\/SONAR\/SonarQube+in+IntelliJ\">plugin for IntelliJ<\/a> (and <a href=\"http:\/\/docs.sonarqube.org\/display\/SONAR\/Installing+SonarQube+in+Eclipse\">Eclipse<\/a> as well) which is a great tool to perform dev-box code analysis before committing or checking-in your changes. It gives the developers a chance to check and make sure they aren\u2019t introducing any new defects or technical debt in the code they have added or modified. Here\u2019s how to set up the plugin and get going.<\/p>\n<p><strong>Install SonarQube IntelliJ Plugin<\/strong><\/p>\n<ul>\n<li>Launch IntelliJ and go to File -&gt; Settings -&gt; Plugins<\/li>\n<li>Search for &#8216;sonarqube&#8217; and install the plugin<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.techtwaddle.co.in\/blog\/wp-content\/uploads\/2015\/07\/clip_image001.png\"><img decoding=\"async\" loading=\"lazy\" title=\"clip_image001\" style=\"border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px\" border=\"0\" alt=\"clip_image001\" src=\"https:\/\/www.techtwaddle.co.in\/blog\/wp-content\/uploads\/2015\/07\/clip_image001_thumb.png\" width=\"679\" height=\"384\" \/><\/a><\/p>\n<p><strong>Setting up SonarQube plugin<\/strong><\/p>\n<ul>\n<li>In IntelliJ go to File -&gt; Settings -&gt; Other Settings -&gt; SonarQube<\/li>\n<li>Add details about the sonar server here. The plugin will use this to download the quality profile\/analyzers etc.<\/li>\n<li>This plugin executes the analysis in preview mode where no data is pushed to the server.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.techtwaddle.co.in\/blog\/wp-content\/uploads\/2015\/07\/image31.png\"><img decoding=\"async\" loading=\"lazy\" title=\"image\" style=\"border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/www.techtwaddle.co.in\/blog\/wp-content\/uploads\/2015\/07\/image_thumb31.png\" width=\"663\" height=\"404\" \/><\/a><\/p>\n<p><strong>Associate your IntelliJ project with Sonar project<\/strong><\/p>\n<ul>\n<li>Right click on the project in IntelliJ and select &quot;Associate with SonarQube\u2026&quot;<\/li>\n<li>Search for the sonar project and select it<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.techtwaddle.co.in\/blog\/wp-content\/uploads\/2015\/07\/image32.png\"><img decoding=\"async\" loading=\"lazy\" title=\"image\" style=\"border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/www.techtwaddle.co.in\/blog\/wp-content\/uploads\/2015\/07\/image_thumb32.png\" width=\"645\" height=\"242\" \/><\/a><\/p>\n<p><strong>Running the analysis<\/strong><\/p>\n<ul>\n<li>Make your code changes<\/li>\n<li>Right click on the project and select Analyze -&gt; Run Inspection by Name\u2026<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.techtwaddle.co.in\/blog\/wp-content\/uploads\/2015\/07\/clip_image0018.png\"><img decoding=\"async\" loading=\"lazy\" title=\"clip_image001[8]\" style=\"border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px\" border=\"0\" alt=\"clip_image001[8]\" src=\"https:\/\/www.techtwaddle.co.in\/blog\/wp-content\/uploads\/2015\/07\/clip_image0018_thumb.png\" width=\"678\" height=\"410\" \/><\/a><\/p>\n<ul>\n<li>In the search box type &quot;Sonarqube&quot; and select &quot;SonarQube Issue&quot; from the result list<\/li>\n<li>In the &quot;Inspection Scope&quot; dialog, select Custom Scope and set its value to Changed Files. This will ensure that the analysis is run on the files modified by you.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.techtwaddle.co.in\/blog\/wp-content\/uploads\/2015\/07\/clip_image002.png\"><img decoding=\"async\" loading=\"lazy\" title=\"clip_image002\" style=\"border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px\" border=\"0\" alt=\"clip_image002\" src=\"https:\/\/www.techtwaddle.co.in\/blog\/wp-content\/uploads\/2015\/07\/clip_image002_thumb.png\" width=\"370\" height=\"106\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.techtwaddle.co.in\/blog\/wp-content\/uploads\/2015\/07\/clip_image003.png\"><img decoding=\"async\" loading=\"lazy\" title=\"clip_image003\" style=\"border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px\" border=\"0\" alt=\"clip_image003\" src=\"https:\/\/www.techtwaddle.co.in\/blog\/wp-content\/uploads\/2015\/07\/clip_image003_thumb.png\" width=\"440\" height=\"366\" \/><\/a><\/p>\n<ul>\n<li>The plugin will run the preview analysis and display the results in the inspection tab. The inspection shows issues in two files which were modified before the analysis.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.techtwaddle.co.in\/blog\/wp-content\/uploads\/2015\/07\/clip_image004.png\"><img decoding=\"async\" loading=\"lazy\" title=\"clip_image004\" style=\"border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px\" border=\"0\" alt=\"clip_image004\" src=\"https:\/\/www.techtwaddle.co.in\/blog\/wp-content\/uploads\/2015\/07\/clip_image004_thumb.png\" width=\"690\" height=\"282\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SonarQube provides a plugin for IntelliJ (and Eclipse as well) which is a great tool to perform dev-box code analysis before committing or checking-in your changes. It gives the developers a chance to check and make sure they aren\u2019t introducing any new defects or technical debt in the code they have added or modified. Here\u2019s &hellip; <a href=\"https:\/\/techtwaddle.co.in\/blog\/2015\/07\/14\/using-sonarqube-intellij-plugin-for-code-analysis\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Using SonarQube IntelliJ plugin for Code Analysis<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[10,6,24,25],"tags":[26],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1ktFF-a8","_links":{"self":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts\/628"}],"collection":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/comments?post=628"}],"version-history":[{"count":1,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts\/628\/revisions"}],"predecessor-version":[{"id":629,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts\/628\/revisions\/629"}],"wp:attachment":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/media?parent=628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/categories?post=628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/tags?post=628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}