{"id":30680,"date":"2022-07-22T20:33:13","date_gmt":"2022-07-22T20:33:13","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=30680"},"modified":"2022-12-23T05:52:18","modified_gmt":"2022-12-23T05:52:18","slug":"how-to-analyze-powershell-code-using-sonarqube","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-analyze-powershell-code-using-sonarqube\/","title":{"rendered":"How to Analyze Powershell code using Sonarqube?"},"content":{"rendered":"\n<p>SonarQube do not support Powershell language at present to analyze a Powershell code. There is no SonarQube PowerShell Plugin available as of now.<\/p>\n\n\n\n<p><strong>Please refer<\/strong> &#8211; https:\/\/www.sonarqube.org\/features\/multi-languages\/<\/p>\n\n\n\n<p><strong>Alternative method is PSScriptSAnalyzer.<\/strong><\/p>\n\n\n\n<p><strong>What is PSScriptSAnalyzer?<\/strong><br>PSScriptAnalyzer is a static code checker for PowerShell modules and scripts. PSScriptAnalyzer checks the quality of PowerShell code by running a set of rules.<\/p>\n\n\n\n<p><strong>Please refer this<\/strong> &#8211; <a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/utility-modules\/psscriptanalyzer\/overview?view=ps-modules\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.microsoft.com\/en-us\/powershell\/utility-modules\/psscriptanalyzer\/overview?view=ps-modules<\/a><\/p>\n\n\n\n<p><strong>Can we integrate PSScriptSAnalyzer in SonarQube?<\/strong><\/p>\n\n\n\n<p>Yes. SonarQube plugins is a best way to integrate externals tools and functionality.<br>Refer &#8211; https:\/\/www.sonarplugins.com\/ But i could not find any officual plugins for this. Later, based on more searches, i found 2 plugins which has been developed by community for the same integration.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Plugin #1- https:\/\/github.com\/gretard\/sonar-ps-plugin<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>Plugin #2- https:\/\/github.com\/jairbubbles\/sonar-powershell<\/li><\/ul>\n\n\n\n<p><strong>Plugin #1 <\/strong>seems to be latest and updated code which we must try and see the integration.Plugin #1 is using PSScriptSAnalyzer only as a scan engine. Plugin #2 is writtern in 2016 and i feel that this has been obselete and need to be re-written.<\/p>\n\n\n\n<p><strong>Intro of sonar-ps-plugin<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Reporting of issues found by PSScriptAnalyzer<\/li><li>Cyclomatic and cognitive complexity metrics (since version 0.3.0)<\/li><li>Reporting number of lines of code and comment lines metrics (since version 0.3.2)<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>SonarQube do not support Powershell language at present to analyze a Powershell code. There is no SonarQube PowerShell Plugin available as of now. Please refer &#8211; https:\/\/www.sonarqube.org\/features\/multi-languages\/ Alternative method is PSScriptSAnalyzer. What is PSScriptSAnalyzer?PSScriptAnalyzer is a static code checker for PowerShell modules and scripts. PSScriptAnalyzer checks the quality of PowerShell code by running a set&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-30680","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=30680"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30680\/revisions"}],"predecessor-version":[{"id":30681,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30680\/revisions\/30681"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=30680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=30680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=30680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}