{"id":402509,"date":"2024-06-29T16:33:11","date_gmt":"2024-06-29T16:33:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=402509"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=402509","title":{"rendered":"<span>Best warnings of static analyzer<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>Everyone who runs the static analyzer on a project for the first time is slightly shocked by hundreds, thousands or even tens of thousands of warnings. It may be frustrating. Is my code so terrible? Or is the analyzer lying? In any case, filtering by the severity changes the situation, not completely though. That&#8217;s why we thought about how we could improve the first experience with the analyzer. Let me show you the new feature step by step&#8230;<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/886\/8a8\/0a1\/8868a80a18a1dda03794ede55aaae840.png\" width=\"580\" height=\"327\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/886\/8a8\/0a1\/8868a80a18a1dda03794ede55aaae840.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>Intelligence Diagnostic Filter<\/h2>\n<p>What does a person, who runs code through a static analyzer for the first time, encounter? When run on large projects, a static analyzer produces a huge number of warnings for various code fragments.<\/p>\n<p>Yes, it may be an enormous number of warnings. Of course, there will be <em>false positives<\/em> among them. Alas, static analysis cannot exist without false positives. Therefore, it was necessary to create a new approach that would simplify the process when one is just starting out with the analyzer.<\/p>\n<p>That&#8217;s how we got the idea to develop a special mechanism that would analyze a list of warnings and find the most interesting ones among them. We named it the <strong>Intelligence Diagnostic Filter<\/strong> or <strong>IDF<\/strong> for short.<\/p>\n<p>I will not go into the details of its implementation in this article. The <a href=\"https:\/\/habr.com\/users\/IchNikola\/\">developer<\/a> who created the mechanism will explain it better. So, don&#8217;t forget to <a href=\"https:\/\/habr.com\/company\/pvs-studio\/blog\/\">subscribe to our Habr account<\/a> so as not to miss his article \ud83d\ude42<\/p>\n<h2>Let&#8217;s look at the top ten warnings<\/h2>\n<p>Well, you have <a href=\"https:\/\/pvs-studio.com\/best_warnings\">installed the analyzer<\/a> \u2013 what&#8217;s next? Of course, you need to <em>run it on a large project<\/em>. Otherwise, the picture will be incomplete. There is a simple <a href=\"https:\/\/pvs-studio.com\/blog\/posts\/0158\/\">pattern<\/a> here \u2013 the <em>more code lines<\/em> you have, the more difficult it is to maintain the code quality. Accordingly, the more difficult it is to maintain the code quality, the <em>more bugs<\/em> this code contains.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c26\/3c0\/c3b\/c263c0c3b1aaf9081f9165f95f0f34d0.png\" alt=\"This is what the first run of the analyzer may look like...\" title=\"This is what the first run of the analyzer may look like...\" width=\"1051\" height=\"344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c26\/3c0\/c3b\/c263c0c3b1aaf9081f9165f95f0f34d0.png\"\/><figcaption>This is what the first run of the analyzer may look like&#8230;<\/figcaption><\/figure>\n<p>We have to admit, it&#8217;s not so exciting to appreciate the capabilities of the analyzer by looking through these warnings all at once. So open the additional toolbar and click on <em>Best Warnings<\/em> button:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f57\/9d0\/921\/f579d0921b538be8b777303b95124d28.png\" alt=\"Example of the button in the PVS-Studio plugin for Visual Studio\" title=\"Example of the button in the PVS-Studio plugin for Visual Studio\" width=\"1051\" height=\"344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f57\/9d0\/921\/f579d0921b538be8b777303b95124d28.png\"\/><figcaption>Example of the button in the PVS-Studio plugin for Visual Studio<\/figcaption><\/figure>\n<p>After a short processing pause, you get a list of the most significant code problems according to the <strong>IDF<\/strong>. This mechanism was also developed to demonstrate various features of the analyzer. Therefore, we limited the number of similar warnings in the output. This helps look at various types of code problems at once. This will also simplify further study of the remaining warnings.<\/p>\n<p><strong><em>Note.<\/em><\/strong><em> Remember to mark the most interesting warnings with a star! It will be easier to find them later \ud83d\ude42<\/em><\/p>\n<h2>What&#8217;s next?<\/h2>\n<p>Of course, do not ignore other warnings. The <em>Analyzer Best Warnings<\/em> mode was made to help you see how <strong>PVS-Studio<\/strong> benefits your project. This mode also demonstrates the abilities of static analysis. Therefore, after studying the <strong>most significant code problems<\/strong> according to the <strong>IDF<\/strong> mechanism, let&#8217;s go back to other warnings.<\/p>\n<p>To do this, just click on the <em>Best Warnings<\/em> button one more time:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/751\/21c\/007\/75121c00753804b2801ef4238eec112c.png\" alt=\"Example of a button in the PVS-Studio plugin for Visual Studio\" title=\"Example of a button in the PVS-Studio plugin for Visual Studio\" width=\"1051\" height=\"344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/751\/21c\/007\/75121c00753804b2801ef4238eec112c.png\"\/><figcaption>Example of a button in the PVS-Studio plugin for Visual Studio<\/figcaption><\/figure>\n<p>Now it&#8217;s time to study all the remaining warnings. In fact, this is an optional step \u2013 you don&#8217;t have to view ALL the remaining warnings, you can view only <em>High<\/em> level ones, for example:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/86b\/7fc\/e63\/86b7fce632580b3592c32bbedb309a57.png\" alt=\"How to filter warnings in the PVS-Studio plugin for Visual Studio\" title=\"How to filter warnings in the PVS-Studio plugin for Visual Studio\" width=\"1052\" height=\"345\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/86b\/7fc\/e63\/86b7fce632580b3592c32bbedb309a57.png\"\/><figcaption>How to filter warnings in the PVS-Studio plugin for Visual Studio<\/figcaption><\/figure>\n<p>New warnings can get lost among the remaining ones. Also, the remaining warnings can distract you from the further use of the analyzer. In this case. So, I advise you to use the <a href=\"https:\/\/pvs-studio.com\/docs\/manual\/0032\/\">mechanism of warning suppression<\/a>.<\/p>\n<p>Click on the <em>Suppress All Messages<\/em> button:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6bb\/02d\/5ae\/6bb02d5ae4bf2d186cf6de4ce41f14c4.png\" alt=\"How to suppress warnings in the Visual Studio plugin\" title=\"How to suppress warnings in the Visual Studio plugin\" width=\"1051\" height=\"344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6bb\/02d\/5ae\/6bb02d5ae4bf2d186cf6de4ce41f14c4.png\"\/><figcaption>How to suppress warnings in the Visual Studio plugin<\/figcaption><\/figure>\n<p>Now you will see the warnings <em>strictly for the new code<\/em>. This is a super useful mechanism, so don&#8217;t be afraid to use it. You can always bring these warnings back to the log from the suppression file.<\/p>\n<p><strong><em>Note.<\/em><\/strong><em> Warnings do not disappear without a trace! If you edit the code next to a suppressed warning, it will show up again.<\/em><\/p>\n<h2>IDF development<\/h2>\n<p>Of course, we will further develop this intelligent filtering mechanism. <em>Analyzer Best Warnings<\/em> is the first feature that is based on <strong>IDF<\/strong>, but it&#8217;s not the last one \ud83d\ude42<\/p>\n<p>We have various thoughts and ideas on how else we can use it. For example, we may add the ability to sort the entire report. This feature would be convenient, since later you can hide the least reliable warnings according to the <strong>IDF<\/strong>. Or we may add the ability to adjust the user-specific settings for projects&#8230;<\/p>\n<p>In a word, there are a huge number of ideas! However, the real driving force of changes and improvements is <em>not developers, but users<\/em>. This is one of our most important principles \u2013 we <em>take into account the wishes of our audience<\/em>.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/best_warnings\">Try the new feature<\/a> and send us your thoughts and ideas! That way, we will not only find out what you think about the new mechanism, but also find the right vector of its development.<\/p>\n<h2>Additional links<\/h2>\n<ul>\n<li>\n<p><a href=\"https:\/\/pvs-studio.com\/blog\/posts\/0743\/\">How to introduce a static code analyzer in a legacy project and not to discourage the team<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/pvs-studio.com\/blog\/posts\/0753\/\">Static analysis: from getting started to integration<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/586258\/\"> https:\/\/habr.com\/ru\/articles\/586258\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>Everyone who runs the static analyzer on a project for the first time is slightly shocked by hundreds, thousands or even tens of thousands of warnings. It may be frustrating. Is my code so terrible? Or is the analyzer lying? In any case, filtering by the severity changes the situation, not completely though. That&#8217;s why we thought about how we could improve the first experience with the analyzer. Let me show you the new feature step by step&#8230;<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>Intelligence Diagnostic Filter<\/h2>\n<p>What does a person, who runs code through a static analyzer for the first time, encounter? When run on large projects, a static analyzer produces a huge number of warnings for various code fragments.<\/p>\n<p>Yes, it may be an enormous number of warnings. Of course, there will be <em>false positives<\/em> among them. Alas, static analysis cannot exist without false positives. Therefore, it was necessary to create a new approach that would simplify the process when one is just starting out with the analyzer.<\/p>\n<p>That&#8217;s how we got the idea to develop a special mechanism that would analyze a list of warnings and find the most interesting ones among them. We named it the <strong>Intelligence Diagnostic Filter<\/strong> or <strong>IDF<\/strong> for short.<\/p>\n<p>I will not go into the details of its implementation in this article. The <a href=\"https:\/\/habr.com\/users\/IchNikola\/\">developer<\/a> who created the mechanism will explain it better. So, don&#8217;t forget to <a href=\"https:\/\/habr.com\/company\/pvs-studio\/blog\/\">subscribe to our Habr account<\/a> so as not to miss his article \ud83d\ude42<\/p>\n<h2>Let&#8217;s look at the top ten warnings<\/h2>\n<p>Well, you have <a href=\"https:\/\/pvs-studio.com\/best_warnings\">installed the analyzer<\/a> \u2013 what&#8217;s next? Of course, you need to <em>run it on a large project<\/em>. Otherwise, the picture will be incomplete. There is a simple <a href=\"https:\/\/pvs-studio.com\/blog\/posts\/0158\/\">pattern<\/a> here \u2013 the <em>more code lines<\/em> you have, the more difficult it is to maintain the code quality. Accordingly, the more difficult it is to maintain the code quality, the <em>more bugs<\/em> this code contains.<\/p>\n<figure class=\"full-width\"><figcaption>This is what the first run of the analyzer may look like&#8230;<\/figcaption><\/figure>\n<p>We have to admit, it&#8217;s not so exciting to appreciate the capabilities of the analyzer by looking through these warnings all at once. So open the additional toolbar and click on <em>Best Warnings<\/em> button:<\/p>\n<figure class=\"full-width\"><figcaption>Example of the button in the PVS-Studio plugin for Visual Studio<\/figcaption><\/figure>\n<p>After a short processing pause, you get a list of the most significant code problems according to the <strong>IDF<\/strong>. This mechanism was also developed to demonstrate various features of the analyzer. Therefore, we limited the number of similar warnings in the output. This helps look at various types of code problems at once. This will also simplify further study of the remaining warnings.<\/p>\n<p><strong><em>Note.<\/em><\/strong><em> Remember to mark the most interesting warnings with a star! It will be easier to find them later \ud83d\ude42<\/em><\/p>\n<h2>What&#8217;s next?<\/h2>\n<p>Of course, do not ignore other warnings. The <em>Analyzer Best Warnings<\/em> mode was made to help you see how <strong>PVS-Studio<\/strong> benefits your project. This mode also demonstrates the abilities of static analysis. Therefore, after studying the <strong>most significant code problems<\/strong> according to the <strong>IDF<\/strong> mechanism, let&#8217;s go back to other warnings.<\/p>\n<p>To do this, just click on the <em>Best Warnings<\/em> button one more time:<\/p>\n<figure class=\"full-width\"><figcaption>Example of a button in the PVS-Studio plugin for Visual Studio<\/figcaption><\/figure>\n<p>Now it&#8217;s time to study all the remaining warnings. In fact, this is an optional step \u2013 you don&#8217;t have to view ALL the remaining warnings, you can view only <em>High<\/em> level ones, for example:<\/p>\n<figure class=\"full-width\"><figcaption>How to filter warnings in the PVS-Studio plugin for Visual Studio<\/figcaption><\/figure>\n<p>New warnings can get lost among the remaining ones. Also, the remaining warnings can distract you from the further use of the analyzer. In this case. So, I advise you to use the <a href=\"https:\/\/pvs-studio.com\/docs\/manual\/0032\/\">mechanism of warning suppression<\/a>.<\/p>\n<p>Click on the <em>Suppress All Messages<\/em> button:<\/p>\n<figure class=\"full-width\"><figcaption>How to suppress warnings in the Visual Studio plugin<\/figcaption><\/figure>\n<p>Now you will see the warnings <em>strictly for the new code<\/em>. This is a super useful mechanism, so don&#8217;t be afraid to use it. You can always bring these warnings back to the log from the suppression file.<\/p>\n<p><strong><em>Note.<\/em><\/strong><em> Warnings do not disappear without a trace! If you edit the code next to a suppressed warning, it will show up again.<\/em><\/p>\n<h2>IDF development<\/h2>\n<p>Of course, we will further develop this intelligent filtering mechanism. <em>Analyzer Best Warnings<\/em> is the first feature that is based on <strong>IDF<\/strong>, but it&#8217;s not the last one \ud83d\ude42<\/p>\n<p>We have various thoughts and ideas on how else we can use it. For example, we may add the ability to sort the entire report. This feature would be convenient, since later you can hide the least reliable warnings according to the <strong>IDF<\/strong>. Or we may add the ability to adjust the user-specific settings for projects&#8230;<\/p>\n<p>In a word, there are a huge number of ideas! However, the real driving force of changes and improvements is <em>not developers, but users<\/em>. This is one of our most important principles \u2013 we <em>take into account the wishes of our audience<\/em>.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/best_warnings\">Try the new feature<\/a> and send us your thoughts and ideas! That way, we will not only find out what you think about the new mechanism, but also find the right vector of its development.<\/p>\n<h2>Additional links<\/h2>\n<ul>\n<li>\n<p><a href=\"https:\/\/pvs-studio.com\/blog\/posts\/0743\/\">How to introduce a static code analyzer in a legacy project and not to discourage the team<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/pvs-studio.com\/blog\/posts\/0753\/\">Static analysis: from getting started to integration<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/586258\/\"> https:\/\/habr.com\/ru\/articles\/586258\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-402509","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/402509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=402509"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/402509\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=402509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=402509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=402509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}