{"id":29340,"date":"2022-03-31T10:08:09","date_gmt":"2022-03-31T10:08:09","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=29340"},"modified":"2022-12-23T06:19:59","modified_gmt":"2022-12-23T06:19:59","slug":"what-is-sonarlint-and-how-it-works-an-overview-and-its-use-cases","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/what-is-sonarlint-and-how-it-works-an-overview-and-its-use-cases\/","title":{"rendered":"What is Sonarlint and How it works? An Overview and Its Use Cases"},"content":{"rendered":"<h3>History &amp; Origin of Sonarlint<\/h3>\n<p class=\"components__Paragraph-sc-1qoaqm8-8 Informations__ParagraphTitle-sc-12n5oc2-0 dnPAao fiBytT\">More than your average linting tool<\/p>\n<p class=\"components__Paragraph-sc-1qoaqm8-8 dnPAao\">Your current linting tools may come with overhead \u2013 specialized tools for languages or longer setup and config time. With SonarLint, you can settle on a single solution to address your Code Quality and Code Security issues. We have you covered with hundreds of unique, language-specific rules to catch Bugs, Code Smells, and Security Vulnerabilities right in the IDE, as you code.<\/p>\n<h3>What is\u00a0 Sonarlint<\/h3>\n<p>SonarLint\u00a0<b>enables you to code better with on-the-fly analysis and support for hundreds of deep static analysis rules to detect common mistakes, tricky bugs, and security issues<\/b>.<\/p>\n<div class=\"css-jhgw9t e1o72rle2\" data-testid=\"column-block-row-item\">\n<div class=\"css-1ufog59 e1o72rle1\">\n<h3 class=\"css-eefkmt e1o72rle0\" data-testid=\"column-block-row-item-headline\">eal-time feedback as you code<\/h3>\n<div class=\"css-13l41i2 e1o72rle3\" data-testid=\"column-block-row-item-text\">\n<p>Your IDE is the best place to catch coding issues. SonarLint enables you to code better with on-the-fly analysis and support for hundreds of deep static analysis rules to detect common mistakes, tricky bugs, and security issues.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"css-jhgw9t e1o72rle2\" data-testid=\"column-block-row-item\">\n<div class=\"css-1ufog59 e1o72rle1\">\n<h3 class=\"css-eefkmt e1o72rle0\" data-testid=\"column-block-row-item-headline\">easy to use, no configuration required<\/h3>\n<div class=\"css-13l41i2 e1o72rle3\" data-testid=\"column-block-row-item-text\">\n<p>Get maximum coverage for your programming language with no installation overhead or lengthy setup. Just install the plugin and continue to code while SonarLint assists you in the background. It&#8217;s the only in-IDE solution you&#8217;ll ever need.<\/p>\n<\/div>\n<h3>How Sonarlint works aka Sonarlint architecture?<\/h3>\n<p>SonarLint in IntelliJ.\u00a0<b>The SonarLint IntelliJ plug-in allows you to see an easy report about code issues right inside IntelliJ<\/b>. It runs an immediate analysis as you change code, and by &#8216;binding&#8217; your plug-in with the OpenLMIS SonarQube server, it uses the same set of rules and checks.<\/p>\n<h1 id=\"SonarQubeandSonarLintUserGuide-WaystoUseSonar\">Ways to Use Sonar<\/h1>\n<p>There are three main use cases for Sonar that we are encouraging during the OpenLMIS v3 development:<\/p>\n<p>1)\u00a0<strong>SonarLint plug-in in IntelliJ<\/strong>. We encourage all developers to use it. We want to clean up code as we touch it (fix as we go).<br \/>\n2)\u00a0<strong>During Reviews<\/strong>: Open Sonar to look at errors and issues in the code during a review. Also look at test coverage to consider whether the new code has enough tests. Bring up issues in the Fisheye review process.<br \/>\n3)\u00a0<strong>Periodically Triage<\/strong>: The teams map pull up Sonar periodically to look at our most common issues and to look at broader trends in test coverage. We can use this to guide our discussions about what to prioritize as we work towards improved test coverage and quality.<\/p>\n<h1 id=\"SonarQubeandSonarLintUserGuide-FalsePositives\">False Positives<\/h1>\n<p>Sometimes SonarQube and SonarLint will show errors or issues that are not really a problem. A good time to discuss this is the code review process. If peers agree that something isn&#8217;t really a bug, we can leave it coded that way.<\/p>\n<p>Although Sonar metrics are aligned with OpenLMIS coding standards, you may disagree with the filters and metrics that Sonar is using. If so, it&#8217;s worth bringing that up for team discussion. There may be rules we want to adjust or change. It is possible for us to adjust the rulesets and change our coding standards, but only after significant consideration. There is also good reason to stick with the industry-standard rules and best practices.<\/p>\n<\/div>\n<h3>Feature and Advantage of using Sonarlint<\/h3>\n<h1 class=\"components__Header1-sc-1qoaqm8-3 features__PageTitle-sc-13ejmnc-1 cPOpTr bTyLeg\">Get the power to write better code<\/h1>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-29342 size-full\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/03\/screenshot-feature-1.png\" alt=\"\" width=\"490\" height=\"281\" \/><\/p>\n<div class=\"Slalom__Root-sc-13j1j8p-0 fXwyNN\">\n<section class=\"Slalom__Picket-sc-13j1j8p-4 dFAIsP\">\n<article class=\"Slalom__Feature-sc-13j1j8p-1 enqaeq\">\n<h2 class=\"components__Header3-sc-1qoaqm8-6-h2 Slalom__FeatureHeader-sc-13j1j8p-2 kBdQtz UMQQu\">Bug detection<\/h2>\n<p class=\"components__Paragraph-sc-1qoaqm8-8 Slalom__FeatureDescription-sc-13j1j8p-3 dnPAao bbgMhy\">Benefit from\u00a0<span class=\"Slalom__ExternalLinkText-sc-13j1j8p-6 fsSPid\">thousands of rules<\/span>\u00a0; which detect common mistakes, tricky bugs and known vulnerabilities.<\/p>\n<h2 class=\"components__Header3-sc-1qoaqm8-6-h2 Slalom__FeatureHeader-sc-13j1j8p-2 kBdQtz UMQQu\">Instant feedback<\/h2>\n<p class=\"components__Paragraph-sc-1qoaqm8-8 Slalom__FeatureDescription-sc-13j1j8p-3 dnPAao bbgMhy\">On-the-fly! Issues are detected and reported as you code, just like a spell-checker.<\/p>\n<h2 class=\"components__Header3-sc-1qoaqm8-6-h2 Slalom__FeatureHeader-sc-13j1j8p-2 kBdQtz UMQQu\">Know what to do<\/h2>\n<p class=\"components__Paragraph-sc-1qoaqm8-8 Slalom__FeatureDescription-sc-13j1j8p-3 dnPAao bbgMhy\">SonarLint precisely pinpoints where the problem is, and gives you recommendations on how to fix it.<\/p>\n<\/article>\n<div>\n<div class=\"Slalom__Picture-sc-13j1j8p-5 eficWC gatsby-image-wrapper\">\n<div aria-hidden=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-29343 size-full\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/03\/screenshot-feature-2.png\" alt=\"\" width=\"490\" height=\"274\" \/><\/div>\n<p><img decoding=\"async\" src=\"https:\/\/www.sonarlint.org\/static\/53504bf7fe8e4d83743a38b78bd6bc5a\/d99e3\/screenshot-feature-1.png\" alt=\"\" \/><\/div>\n<\/div>\n<\/section>\n<section class=\"Slalom__Picket-sc-13j1j8p-4 dFAIsP\">\n<div>\n<div class=\"Slalom__Picture-sc-13j1j8p-5 eficWC gatsby-image-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.sonarlint.org\/static\/bd27a496423de687c6b3235bd8deaa22\/d99e3\/screenshot-feature-2.png\" alt=\"\" \/><\/div>\n<\/div>\n<article class=\"Slalom__Feature-sc-13j1j8p-1 enqaeq\">\n<h2 class=\"components__Header3-sc-1qoaqm8-6-h2 Slalom__FeatureHeader-sc-13j1j8p-2 kBdQtz UMQQu\">Learn from your mistakes<\/h2>\n<p class=\"components__Paragraph-sc-1qoaqm8-8 Slalom__FeatureDescription-sc-13j1j8p-3 dnPAao bbgMhy\">Rich documentation lets you understand issues in detail and discover coding best practices.<\/p>\n<h2 class=\"components__Header3-sc-1qoaqm8-6-h2 Slalom__FeatureHeader-sc-13j1j8p-2 kBdQtz UMQQu\">Uncover old issues<\/h2>\n<p class=\"components__Paragraph-sc-1qoaqm8-8 Slalom__FeatureDescription-sc-13j1j8p-3 dnPAao bbgMhy\">See which issues were already existing, and become a hero for fixing them.<\/p>\n<h3>Best Alternative of Sonarlint<\/h3>\n<div class=\"co8aDb\" role=\"heading\"><b>Top Alternatives to SonarLint<\/b><\/div>\n<div class=\"RqBzHd\">\n<ul class=\"i8Z77e\">\n<li class=\"TrT0Xe\">ReSharper. It is a popular developer productivity extension for Microsoft Visual Studio.<\/li>\n<li class=\"TrT0Xe\">SonarQube. SonarQube provides an overview of the overall health of your source code and.<\/li>\n<li class=\"TrT0Xe\">FindBugs. It detects possible bugs in Java programs.<\/li>\n<li class=\"TrT0Xe\">PMD.<\/li>\n<li class=\"TrT0Xe\">JSLint.<\/li>\n<li class=\"TrT0Xe\">ESLint.<\/li>\n<li class=\"TrT0Xe\">Pylint.<\/li>\n<li class=\"TrT0Xe\">Checkstyle.<\/li>\n<\/ul>\n<h3>Best Resources, Tutorials and Guide for\u00a0 Sonarlint<\/h3>\n<ol>\n<li>devopsschool.com<\/li>\n<li>sonarlint.org<\/li>\n<li>sonarsource.com<\/li>\n<\/ol>\n<h3>Free Video Tutorials of\u00a0 Sonarlint<\/h3>\n<figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_13945\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/bKi6d5MrD-U?enablejsapi=1&autoplay=0&cc_load_policy=0&cc_lang_pref=&iv_load_policy=1&loop=0&rel=1&fs=1&playsinline=0&autohide=2&theme=dark&color=red&controls=1&disablekb=0&\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure>\n<figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_72279\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/5A5LGjN3PE0?enablejsapi=1&autoplay=0&cc_load_policy=0&cc_lang_pref=&iv_load_policy=1&loop=0&rel=1&fs=1&playsinline=0&autohide=2&theme=dark&color=red&controls=1&disablekb=0&\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure>\n<h3>Interview Questions and Answer for Sonarlint<\/h3>\n<ol>\n<li><strong>Difference between SonarQube and SonarLint?<\/strong><\/li>\n<\/ol>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-27224\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/SonarQube-SonarLint.png\" alt=\"\" width=\"966\" height=\"254\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/SonarQube-SonarLint.png 966w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/SonarQube-SonarLint-300x79.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/SonarQube-SonarLint-768x202.png 768w\" sizes=\"auto, (max-width: 966px) 100vw, 966px\" \/><\/figure>\n<p>SonarLint lives only in the IDE (IntelliJ, Eclipse and Visual Studio). Its purpose is to give instantaneous feedback as you type your code. For this, it concentrates on what code you are adding or updating.<\/p>\n<p>SonarQube is a central server that processes full analyses (triggered by the various SonarQube Scanners). Its purpose is to give a 360\u00b0 vision of the quality of your code base. For this, it analyzes all the source lines of your project on a regular basis.<\/p>\n<p>Both SonarLint and SonarQube rely on the same static source code analyzers \u2013 most of them being written using SonarSource technology.<\/p>\n<p>2.\u00a0<strong>How to suppress warning for a specific method with Intellij SonarLint plugin?<\/strong><\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-27225\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/ojjCY-1024x423.png\" alt=\"\" width=\"1024\" height=\"423\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/ojjCY-1024x423.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/ojjCY-300x124.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/ojjCY-768x318.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/ojjCY.png 1417w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<p>The \/\/NOSONAR tag is useful to deactivate all rules at a given line but is not suitable to deactivate all rules (or only a given rule) for all the lines of a method or a class. This is why support for @SuppressWarnings(\u201call\u201d) has been added to SonarQube.<\/p>\n<p>SINCE 2.8 of Java Plugin, you can also use @SuppressWarnings annotation with a list of rule keys:<\/p>\n<p>@SuppressWarnings(\u201csquid:S2078\u201d) or<\/p>\n<p>@SuppressWarnings({\u201csquid:S2078\u201d, \u201csquid:S2076\u201d}).<\/p>\n<p>3.\u00a0<strong>How to turn off SonarLint automatic triggering on IntelliJ IDEA?<\/strong><\/p>\n<figure class=\"wp-block-image\"><img \/><\/figure>\n<p>For intellij:<\/p>\n<p>Go to File -&gt; Settings New window will open In new window Expand tools -&gt; locate SonarLint and click on it. Under settings tab of SonarLint -&gt; uncheck the box \u2018Automatically trigger Analysis\u2019.<\/p>\n<p>Built-in string formatting vs string concatenation as logging parameter?<\/p>\n<p>using SonarLint that shows me an issue in the following line.<\/p>\n<p>LOGGER.debug(\u201cComparing objects: \u201d + object1 + \u201d and \u201d + object2);<\/p>\n<p>Side-note: The method that contains this line might get called quite often.<\/p>\n<p>The description for this issue is<\/p>\n<p>\u201cPreconditions\u201d and logging arguments should not require evaluation (squid:S2629)<\/p>\n<p>Passing message arguments that require further evaluation into a Guava com.google.common.base.Preconditions check can result in a performance penalty. That\u2019s because whether or not they\u2019re needed, each argument must be resolved before the method is actually called.<\/p>\n<p>Similarly, passing concatenated strings into a logging method can also incur a needless performance hit because the concatenation will be performed every time the method is called, whether or not the log level is low enough to show the message.<\/p>\n<p>Instead, you should structure your code to pass static or pre-computed values into Preconditions conditions check and logging calls.<\/p>\n<p>Specifically, the built-in string formatting should be used instead of string concatenation, and if the message is the result of a method call, then Preconditions should be skipped altoghether, and the relevant exception should be conditionally thrown instead.<\/p>\n<p><strong>Noncompliant Code Example<\/strong><\/p>\n<pre class=\"wp-block-code\"><code>logger.log(Level.DEBUG, \"Something went wrong: \" + message);  \/\/ Noncompliant; string concatenation performed even when log level too high to show DEBUG messages\r\nLOG.error(\"Unable to open file \" + csvPath, e);  \/\/ Noncompliant\r\nPreconditions.checkState(a &gt; 0, \"Arg must be positive, but got \" + a); \/\/ Noncompliant. String concatenation performed even when a &gt; 0\r\nPreconditions.checkState(condition, formatMessage());  \/\/Noncompliant. formatMessage() invoked regardless of condition\r\nPreconditions.checkState(condition, \"message: %s\", formatMessage()); \/\/ Noncompliant\r\n<\/code><\/pre>\n<p><strong>Compliant Solution<\/strong><\/p>\n<pre class=\"wp-block-code\"><code>logger.log(Level.SEVERE, \"Something went wrong: %s\", message);  \/\/ String formatting only applied if needed\r\nlogger.log(Level.SEVERE, () -&gt; \"Something went wrong: \" + message); \/\/since Java 8, we can use Supplier , which will be evaluated lazily\r\nLOG.error(\"Unable to open file {}\", csvPath, e);\r\nif (LOG.isDebugEnabled() {   LOG.debug(\"Unable to open file \" + csvPath, e);  \/\/ this is compliant, because it will not evaluate if log level is above debug. }\r\nPreconditions.checkState(arg &gt; 0, \"Arg must be positive, but got %d\", a);  \/\/ String formatting only applied if needed\r\nif (!condition) {   throw new IllegalStateException(formatMessage()); \/\/ formatMessage() only invoked conditionally }\r\nif (!condition) {   throw new IllegalStateException(\"message: \" + formatMessage()); }\r\n<\/code><\/pre>\n<p>4.\u00a0<strong>Cognitive Complexity and its effect on the code?<\/strong><\/p>\n<p>W.r.t to one of the java projects, we recently started using SonarLint. Output of the code analysis shows too many critical code smell alerts.<\/p>\n<p>Critical code smell: Refactor this method to reduce its Cognitive Complexity.<\/p>\n<p>5.\u00a0<strong>Is Cognitive Complexity an industry standard?<\/strong><\/p>\n<p>Impacts of Cognitive Complexity on code apart from readability and maintainability.<\/p>\n<p>Does Cognitive Complexity apply only to methods or any other parts of code?<\/p>\n<p>Any specific criteria on which Cognitive Complexity depends on?<\/p>\n<p>Best practices to improve Cognitive Complexity of a code.<\/p>\n<p>6.\u00a0<strong>How to use SonarLint in Eclipse?<\/strong><\/p>\n<p>If you want to analyze a complete project with the Sonar Lint plugin, you can trick the plugin by searching all Java files with a text editor and replacing \u201cpackage\u201d with \u201d package\u201d. This will cause SVN or git changes. Open the \u201cSonar Lint Report\u201d view and run the analysis on the \u201cCurrent project\u201d. Afterwards, revert all your SVN changes. Do not run the analysis again as the Sonar Lint Plugin only analyzes changed files.<\/p>\n<p>7.\u00a0<strong>How do you customize SonarLint rules in IntelliJ IDEA?<\/strong><\/p>\n<p>SonarLint 1.0 for Eclipse and IntelliJ do not allow to edit the quality profile (or set of rules) to be used for the analysis. Moreover, SonarLint 1.x works completely independently of a SonarQube server (having a SonarQube server is not a requirement), and therefore does not have the ability to reuse a quality profile defined there.<\/p>\n<p>SonarLint 2.0 will have an optional mode that connects to a SonarQube server, and will offer this feature \u2013 but this isn\u2019t available yet.<\/p>\n<p>8.\u00a0<strong>Sonarlint command line version dropped?<\/strong><\/p>\n<p>It would appear that Sonarsource has discontinued development on the command line instance of the sonarlint tool. The link to the page on the sonarlint website now returns a 404 and there is no mention of the product on the sonarlint website.<\/p>\n<p>9.\u00a0<strong>Disable sonarlint automatic analysis in Eclipse by default?<\/strong><\/p>\n<p>Window-&gt;Preferences-&gt;SonarLint-&gt;File Exclusions Then New GLOB Pattern: \u201c**\/*\u201d<\/p>\n<p>10.\u00a0<strong>Unable to Finish connecting to SonarQube server?<\/strong><\/p>\n<p>SonarLint in Eclipse are storing credentials in Eclipse secure storage that itself is protected by a master password. So you must reset it or delete it to add a new SonarQube server connection. You can try this step :<\/p>\n<p>In your Eclipse Go to Window &gt; Preferences, filter and find Secure Storage.<\/p>\n<p>In the Tab Contents find and highlight org.sonarlint.eclipse.core, click Delete &gt; Apply &gt; OK. After deletion process is finished, Eclipse will ask if you want to restart the IDE. It is strongly recommended that you restart the IDE and try again to adding SonarQube server in Eclipse.<\/p>\n<p>11.\u00a0<strong>Method has 8 parameters, which is greater than 7 authorized?<\/strong><\/p>\n<p>here are two things to consider here.<\/p>\n<p>You can adjust this rule in Sonar and increase the number of authorized parameters. Say put it 10 instead of default (?) 7.<\/p>\n<p>UPD: the advice below is based on the old question version. It might be not applicable to the new question context any more.<\/p>\n<p>But generally you should reconsider your method interface. Having many arguments means that something can be wrong in your architecture and the Single responsibility principle might be broken.<\/p>\n<p>Say in your particular example, I would expect, that you can have an aggregate class Order:<\/p>\n<pre class=\"wp-block-code\"><code>public class Order {\r\n   private CountryCode countryCode;\r\n   private String orderId;\r\n   private User user;\r\n   private String orderId;\r\n   private String item;\r\n   private List&lt;Person&gt; persons;\r\n   private ShippingAddress address;\r\n   private PaymentMethod payment;\r\n   private Product product;\r\n   \/\/ ...\r\n}\r\n<\/code><\/pre>\n<p>Which is much logical to manage instead of dealing with many parameters. Then your issues will be solved automatically:<\/p>\n<p>@GetMapping<\/p>\n<p>public void updateSomething(Order order) { \u2026 }<\/p>\n<p>12.\u00a0<strong>What is the correct way to make a custom .NET Exception serializable?<\/strong><\/p>\n<pre class=\"wp-block-code\"><code>namespace SerializableExceptions\r\n{\r\n    using System;\r\n    using System.Runtime.Serialization;\r\n\r\n    [Serializable]\r\n    \/\/ Important: This attribute is NOT inherited from Exception, and MUST be specified \r\n    \/\/ otherwise serialization will fail with a SerializationException stating that\r\n    \/\/ \"Type X in Assembly Y is not marked as serializable.\"\r\n    public class SerializableExceptionWithoutCustomProperties : Exception\r\n    {\r\n        public SerializableExceptionWithoutCustomProperties()\r\n        {\r\n        }\r\n\r\n        public SerializableExceptionWithoutCustomProperties(string message) \r\n            : base(message)\r\n        {\r\n        }\r\n\r\n        public SerializableExceptionWithoutCustomProperties(string message, Exception innerException) \r\n            : base(message, innerException)\r\n        {\r\n}\r\n\r\n        \/\/ Without this constructor, deserialization will fail\r\n        protected SerializableExceptionWithoutCustomProperties(SerializationInfo info, StreamingContext context) \r\n            : base(info, context)\r\n        {\r\n        }\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>13.\u00a0<strong>Is there a way to integrate sonarlint plugin in pom.xml?<\/strong><\/p>\n<p>SonarLint is a local plugin that can be embedded in your IDE. In the plugin setting you can put the \u201cAutomatically trigger analysis\u201d in order to have feedback while writing.<\/p>\n<p>In order to perform continuous integration you should use SonarQube, it is possible to integrate it with Jenkins or Codemagic and also with Maven. It is possible to add SonarQube to your pull requests as well.<\/p>\n<p>Unable to trigger SonarLint Analysis on whole Project?<\/p>\n<p>Open the SonarLint Tool Window, go to the Project files tab, and click in the \u201cplay\u201d button. There is also an action to which you can assign a shortcut.<\/p>\n<p><strong>14. SonarLint Use the primitive boolean expression here?<\/strong><\/p>\n<p>As other already mentioned, Sonar wants you to make sure that you don\u2019t have any null pointer exception, or at least that\u2019s what i have seen too when i do a check before trying to validate against the variable:<\/p>\n<p>if i have the next, Sonar complains<\/p>\n<pre class=\"wp-block-code\"><code>if (properties.getEnabled()) {\r\n       \/\/ Your code\r\n}\r\nBut if i add a quick validation against nulls, Sonar stops complaining about it\r\n\r\nif (properties.getEnabled() != null &amp;&amp; properties.getEnabled()) {\r\n       \/\/ Your code\r\n}\r\nNow, as you mentioned you can use the Boolean class to use the next\r\nBoolean.TRUE.equals(properties.getEnabled());\r\nAs\r\nif (Boolean.TRUE.equals(properties.getEnabled())){\r\n       \/\/ Your code\r\n}\r\n\r\nHow to configure the rule set of SonarLint in Visual Studio Code?\r\nClick on Edit in settings.json\r\n\r\nAdd to \"sonarlint.rules\": the rule you wand to disable as follow:\r\n\r\n    \"javascript:S1488\": {\r\n        \"level\": \"off\"\r\n    }\r\n\r\n<\/code><\/pre>\n<p>15.\u00a0<strong>How to install an older Eclipse plugin of SonarLint?<\/strong><\/p>\n<p>Instead of using Eclipse Marketplace, use menu in Help \u2192 Install New Software. Add sonarlint URL:<\/p>\n<p>You will see all available version of sonarlint. If you already have it installed with unexpected version, you need to uninstall it first in Help \u2192 Installation Details.<\/p>\n<p>Update your \u201cSonarTS \u2013 Code Analyzer for TypeScript\u201d (just push the button) Thats all. Don\u2019t forget restart your server<\/p>\n<p>16.\u00a0<strong>How to exclude JS files from on-the-fly analysis in SonarLint for IntelliJ IDEA?<\/strong><\/p>\n<p>Settings<\/p>\n<p>Other settings<\/p>\n<p>Sonarlint General Settings<\/p>\n<p>File exclusions<\/p>\n<p>Press \u2018+\u2019<\/p>\n<p>**\/*.js<\/p>\n<p>17.\u00a0<strong>How to install sonarlint plugin in Platform: Eclipse Mars.1 (4.5.1)?<\/strong><\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-27219\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/vK1tI-1024x531.png\" alt=\"\" width=\"1024\" height=\"531\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/vK1tI-1024x531.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/vK1tI-300x155.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/vK1tI-768x398.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/vK1tI.png 1299w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<p>18.\u00a0<strong>How to get SonarLint for Eclipse logs?<\/strong><\/p>\n<ul>\n<li>Open Eclipse Console view<\/li>\n<li>Open the SonarLint Console image<\/li>\n<li>Enable Verbose output and Analysis logs image<\/li>\n<li>Reproduce the issue (e.g. reopen the offending file)<\/li>\n<\/ul>\n<p><strong>Sometimes errors are not in the SonarLint console, but could be directly in Eclipse error logs.<\/strong><\/p>\n<ul>\n<li>Open Eclipse Error Log view<\/li>\n<li>Look for an error event related to SonarLint<\/li>\n<li>Open event details to get the stacktrace<\/li>\n<\/ul>\n<p>19.\u00a0<strong>How SonarLint for Eclipse decides if a file is a test?<\/strong><\/p>\n<p>There is a regular expression you can configure in SonarLint settings to specify which files should be considered as tests.image<\/p>\n<p>Recent Eclipse versions added the concept of test sources 55 (only for Java projects). When available, SonarLint will also rely on it (see the green icon for test folders).<\/p>\n<p>image<\/p>\n<p>In the end, if you want to know how a file was effectively classified by SonarLint, look at the SonarLint Console with Verbose output, and search for something like:<\/p>\n<p>Starting analysis with configuration:<\/p>\n<pre class=\"wp-block-code\"><code>[\r\n  baseDir: [...]\r\n  workDir: [...]\r\n  extraProperties: {sonar.java.target=1.8, [...]}\r\n  inputFiles: [\r\n    file:\/home\/julien\/Prog\/Projects\/sonarlint-core\/core\/src\/test\/java\/org\/sonar\/api\/utils\/log\/SonarLintLoggerTest.java (UTF-8) [test]\r\n  ]\r\n]\r\nand notice the [test] qualifier after the filename, to indicate SonarLint classified the file as test.\r\n<\/code><\/pre>\n<p>20.\u00a0<strong>How to get SonarLint for IntelliJ logs?<\/strong><\/p>\n<p>Open the SonarLint tool window (View &gt; Tool Windows &gt; Sonarlint)<\/p>\n<p>Enable Verbose output and Analysis logs SonarLintIntelliJ-Logs<\/p>\n<p>SonarLintIntelliJ-Logs<\/p>\n<p>1092\u00d7283 31.9 KB<\/p>\n<p>Reproduce the issue (e.g. reopen the offending file)<\/p>\n<\/div>\n<\/article>\n<\/section>\n<\/div>\n<p>&nbsp;<\/p>\n<div class=\"css-1ufog59 e1o72rle1\">\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<h3><\/h3>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>History &amp; Origin of Sonarlint More than your average linting tool Your current linting tools may come with overhead \u2013 specialized tools for languages or longer setup and config time. With SonarLint, you can settle on a single solution to address your Code Quality and Code Security issues. We have you covered with hundreds of&#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-29340","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/29340","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=29340"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/29340\/revisions"}],"predecessor-version":[{"id":32430,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/29340\/revisions\/32430"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=29340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=29340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=29340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}