{"id":13284,"date":"2016-03-17T11:47:28","date_gmt":"2016-03-17T11:47:28","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/?p=13284"},"modified":"2020-03-05T06:24:31","modified_gmt":"2020-03-05T14:24:31","slug":"sonarqube-sdk-to-build-plugins-for-roslyn-analyzers-released","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/sonarqube-sdk-to-build-plugins-for-roslyn-analyzers-released\/","title":{"rendered":"SonarQube: SDK to build plugins for Roslyn Analyzers released"},"content":{"rendered":"<p>Last month we <a href=\"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2016\/02\/18\/sonarqube-scanner-for-msbuild-v2-0-released-support-for-third-party-roslyn-analyzers\/\" target=\"_blank\" rel=\"noopener noreferrer\">announced<\/a> the pre-release version of the <em>SDK for SonarQube Roslyn Analyzer Plugins<\/em>, the purpose of which is to create a <em>SonarQube<\/em> plugin for a Roslyn analyzer. We are pleased to announce that <a href=\"https:\/\/github.com\/SonarSource-VisualStudio\/sonarqube-roslyn-sdk\" target=\"_blank\" rel=\"noopener noreferrer\">version 1 of the SDK<\/a> is now available.<\/p>\n<p>We have made a few small but significant changes for the release version:<\/p>\n<h2>Removed the need for the JDK when generating a plugin<\/h2>\n<p>Previously, the SDK compiled Java code on the fly which meant the Java Development Kit had to be installed on the machine. Now, the plugin is created by injecting files into a pre-built <em>jar<\/em> file so the JDK is no longer required, making the SDK easier to install and use.<\/p>\n<h2>Added support for NuGet packages that require license acceptance<\/h2>\n<p>NuGet packages can specify that the user accept the license terms for the package. The SDK checks whether the analyzer package or any of its dependencies require license acceptance and presents a list of any that do, together with links to the licenses:<\/p>\n<p><figure id=\"attachment_13294\" aria-labelledby=\"figcaption_attachment_13294\" class=\"wp-caption alignnone\" ><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/SDK.LicenseRequired.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"wp-image-13294 size-mediumlarge\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/03\/SDK.LicenseRequired-500x181.png\" alt=\"Package requires license acceptance\" width=\"500\" height=\"181\" \/><\/a><figcaption id=\"figcaption_attachment_13294\" class=\"wp-caption-text\">Package requires license acceptance<\/figcaption><\/figure><\/p>\n<p>Once you have checked the license terms and chosen to accept them you can run the plugin generator again, this time specifying the <em>\/acceptLicenses<\/em> option. The plugin jar will be created, and you will be shown a list of the licenses that have been accepted:<\/p>\n<p><figure id=\"attachment_13323\" aria-labelledby=\"figcaption_attachment_13323\" class=\"wp-caption alignnone\" ><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/SDK.LicensesAccepted.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"wp-image-13323 size-mediumlarge\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/03\/SDK.LicensesAccepted-500x181.png\" alt=\"Licenses accepted - plugin created\" width=\"500\" height=\"181\" \/><\/a><figcaption id=\"figcaption_attachment_13323\" class=\"wp-caption-text\">Licenses accepted &#8211; plugin created<\/figcaption><\/figure><\/p>\n<h2>Added basic support for remediation data<\/h2>\n<p>SonarQube uses the SQALE method to quantify and manage technical debt. One aspect of this is the ability to provide an estimate of the remediation cost for individual rules. By default the generated plugin will only contain rule definitions; it won\u2019t contain any information about the remediation costs. However, it is possible to specify the SQALE information for individual rules in an XML file, and the plugin generator will automatically generate a template XML file for the analyzer being packaged:<\/p>\n<p><figure id=\"attachment_13314\" aria-labelledby=\"figcaption_attachment_13314\" class=\"wp-caption alignnone\" ><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/SDK.SqaleSkeleton.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"wp-image-13314 size-mediumlarge\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/03\/SDK.SqaleSkeleton-500x181.png\" alt=\"SQALE template generated\" width=\"500\" height=\"181\" \/><\/a><figcaption id=\"figcaption_attachment_13314\" class=\"wp-caption-text\">SQALE template generated<\/figcaption><\/figure><\/p>\n<p>The template file provides placeholders for every rule, and specifies a constant remediation cost for each rule. If you want to provide richer SQALE remediation information, you can copy and manually edit the template file. Once you have updated the file, you can feed it back to the generator using the \/sqale:[filename] option. When you look at the resulting rule definitions in SonarQube, you\u2019ll see the remediation values, and these will be used to calculate the technical debt:<\/p>\n<p><figure id=\"attachment_13313\" aria-labelledby=\"figcaption_attachment_13313\" class=\"wp-caption alignnone\" ><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/SDK.SqaleInSQ.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"wp-image-13313 size-mediumlarge\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/03\/SDK.SqaleInSQ-500x171.png\" alt=\"Remediation information available in SonarQube\" width=\"500\" height=\"171\" \/><\/a><figcaption id=\"figcaption_attachment_13313\" class=\"wp-caption-text\">Remediation information available to SonarQube<\/figcaption><\/figure><\/p>\n<p>The <em>SonarQube<\/em> <a href=\"http:\/\/docs.sonarqube.org\/display\/SONAR\/Technical+Debt\" target=\"_blank\" rel=\"noopener noreferrer\">documentation<\/a> contains more information on the SQALE method and how it is used in <em>SonarQube<\/em>.<\/p>\n<p>&nbsp;<\/p>\n<h2>Next steps<\/h2>\n<p>If you are a <em>SonarQube<\/em> administrator and there is a Roslyn analyzer package you want to use, check with the package author to see if they have already create a <em>SonarQube<\/em> plugin for it (they might have already provided the SQALE information for their rules). Otherwise, you will be able to use the SDK to create a plugin yourself.<\/p>\n<p>We\u2019ve tested the SDK against the most-frequently downloaded NuGet analyzer packages and were able to create <em>SonarQube<\/em> plugins for them. There a couple of <a href=\"https:\/\/jira.sonarsource.com\/browse\/SFSRAP-42?jql=project%20%3D%20SFSRAP%20AND%20resolution%20%3D%20Unresolved%20ORDER%20BY%20created%20DESC\" target=\"_blank\" rel=\"noopener noreferrer\">known issues<\/a>, only one of which is blocking (<a href=\"https:\/\/jira.sonarsource.com\/browse\/SFSRAP-32\" target=\"_blank\" rel=\"noopener noreferrer\">SFSRAP-32<\/a>: we don\u2019t currently generate plugins for NuGet packages that just aggregate other packages).<\/p>\n<p>If you discover any issues or have any other feedback, please let us know.<\/p>\n<h2>In other news&#8230;<\/h2>\n<p>In addition to the SDK, we have been working on adding support for a new <em>Connected Mode<\/em> in <em>SonarLint for Visual Studio<\/em> to improve the developer experience when\u00a0using <em>SonarQube<\/em> to manage technical debt. Read <a href=\"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2016\/03\/17\/bind-a-visual-studio-solution-to-a-sonarqube-project-provisions-and-configures-roslyn-analyzers\/\" target=\"_blank\" rel=\"noopener noreferrer\">Jean-Marc&#8217;s post<\/a> about the newly-released <em>SonarLint for Visual Studio 2.0<\/em> for the details.<\/p>\n<p><em>For support, look on\u00a0StackOverflow for questions\u00a0tagged with <\/em><a href=\"http:\/\/stackoverflow.com\/questions\/tagged\/sonarqube-msbuild-runner\" target=\"_blank\" rel=\"noopener noreferrer\"><em>sonarqube-msbuild-runner<\/em><\/a><\/p>\n<p><em>For bugs, go to the\u00a0<\/em><a href=\"https:\/\/groups.google.com\/forum\/#!forum\/sonarqube\" target=\"_blank\" rel=\"noopener noreferrer\"><em>SonarQube Google Group<\/em><\/a><em>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last month we announced the pre-release version of the SDK for SonarQube Roslyn Analyzer Plugins, the purpose of which is to create a SonarQube plugin for a Roslyn analyzer. We are pleased to announce that version 1 of the SDK is now available. We have made a few small but significant changes for the release [&hellip;]<\/p>\n","protected":false},"author":181,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229,1,249],"tags":[],"class_list":["post-13284","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-community","category-devops","category-open-source"],"acf":[],"blog_post_summary":"<p>Last month we announced the pre-release version of the SDK for SonarQube Roslyn Analyzer Plugins, the purpose of which is to create a SonarQube plugin for a Roslyn analyzer. We are pleased to announce that version 1 of the SDK is now available. We have made a few small but significant changes for the release [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/13284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/181"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=13284"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/13284\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=13284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=13284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=13284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}