{"id":2367,"date":"2022-03-24T07:10:17","date_gmt":"2022-03-24T07:10:17","guid":{"rendered":"https:\/\/blog.embold.io\/?p=2367"},"modified":"2022-03-24T09:51:04","modified_gmt":"2022-03-24T09:51:04","slug":"change-in-analysis-components-to-files","status":"publish","type":"post","link":"https:\/\/blog.embold.io\/ru\/change-in-analysis-components-to-files\/","title":{"rendered":"Change in Analysis: Components to Files"},"content":{"rendered":"\n<h2><strong><span style=\"text-decoration: underline\">Background<\/span><\/strong><\/h2>\n\n\n\n<p>Before we address the change from\ncomponents to files, it is important we understand what components are and why\ndid we choose to analyze components in the 1<sup>st<\/sup> version of Embold.<\/p>\n\n\n\n<p>In object-oriented programming,\nClass is the most important building block. It is the blueprint for creating data structures and implementations of\nmember functions or methods. The design of code is\ndependent on how classes interact with each other.<\/p>\n\n\n\n<p>In the first version of Embold, we\ncalled classes, interfaces and structures as components which basically is just\na container. In this article, class and component will be used interchangeably.<\/p>\n\n\n\n<p>Though component-based analysis worked well with object-oriented languages, it started showing some flaws when we introduced support for C and for scripting languages like JavaScript and Python. In these scripting languages developers started using files more than classes whereas, in languages like C, classes were mostly used only as placeholder eg. Structures. <\/p>\n\n\n\n<p>To handle these cases, we introduced a virtual component that acted as a container to which all File-level variables or methods are attached. But as we added support for more languages, it became more and more apparent that we needed to change the way we represented the analysis. <\/p>\n\n\n\n<h2><strong><span style=\"text-decoration: underline\">Analysis of files instead of components<\/span><\/strong><\/h2>\n\n\n\n<p>In the new version of Embold, we perform the analysis on files rather than components. &nbsp;There are also some changes in how the analysis is represented on the UI.<\/p>\n\n\n\n<h3><strong>Embold Rating<\/strong><\/h3>\n\n\n\n<p>Earlier all Ratings (Overall,\nDesign, Metrics, Code Issues, Duplication) were calculated at a component level.\nDespite the fact that issues and duplication are physical attributes, they had\nbeen tagged to components through a complex calculation. <\/p>\n\n\n\n<p>In the new version of Embold, components have only Design and Metrics ratings whereas files have all 5 ratings. Design or Metric rating for a file is calculated on a pro-rata basis (based on LOC) if that file contains a part of component(s). <\/p>\n\n\n\n<h3><strong>Code Issues and Duplication<\/strong><\/h3>\n\n\n\n<p>With this change in analysis, we tag issues and duplication to file instead of component. Rating for a file is based on a number of duplications &amp; number of code issues present in that file.<\/p>\n\n\n\n<p>So, you will see a difference in duplication percentage if you compare analyses done on old and new versions of Embold. e.g. <\/p>\n\n\n\n<p><strong>LOC of file = 200&nbsp;&nbsp;<\/strong>&nbsp;&nbsp; <\/p>\n\n\n\n<p><strong>LOC of component in that file = 100<\/strong><\/p>\n\n\n\n<p><strong>Number of duplicated lines in that component = 10 <\/strong><\/p>\n\n\n\n<p><strong>Duplication with component-based analysis=10%<\/strong><\/p>\n\n\n\n<p><strong>Duplication in file-based analysis = 5% <\/strong><\/p>\n\n\n\n<h3><strong>Antipatterns<\/strong><\/h3>\n\n\n\n<p>In the new version of Embold, the occurrences of antipatterns where class-level dependencies occur and if the class is accessing File-level variables\/functions has reduced considerably. Take the example of feature envy. <\/p>\n\n\n\n<p>Feature Envy depends on how many member variables of a component are accessed directly from a particular function. File-level global level variables should be accessed directly and are not termed as accessing class-level member variables directly. However, as it was treated as a Component and its members were Global Functions\/Variables, such variables were used to calculate Feature Envy Antipattern. With the new approach, such variables won&#8217;t be treated as member variables and so the number of Feature Envy antipatterns reported will reduce.<\/p>\n\n\n\n<h3><strong>Metrics and Files<\/strong><\/h3>\n\n\n\n<p>Before this change, the UI had a components page and that was the entry point. But it was hard to see data at the File level. Clicking on any component, you would be redirected to the code view page, where it would show the files containing that component. The metrics and Anti Patterns on the top row were related to the Component. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"849\" height=\"408\" src=\"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/kk.png\" alt=\"Components to files\" class=\"wp-image-2368\" srcset=\"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/kk.png 849w, https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/kk-768x369.png 768w, https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/kk-585x281.png 585w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/figure>\n\n\n\n<p>Now with this change, we will see Files listed instead of components and clicking on any file, you will be redirected to the code view of that file.&nbsp; The metrics and anti-patterns will be at the file level. But if you go to the component inside the file, you will still be able to see component level metrics. That data is not lost.<\/p>\n\n\n\n<p>Metrics are now calculated at component level as well as at file level. &nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1430\" height=\"723\" src=\"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/components-to-files.png\" alt=\"Components to files\" class=\"wp-image-2369\" srcset=\"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/components-to-files.png 1430w, https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/components-to-files-768x388.png 768w, https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/components-to-files-1170x592.png 1170w, https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/components-to-files-585x296.png 585w\" sizes=\"(max-width: 1430px) 100vw, 1430px\" \/><\/figure>\n\n\n\n<p>We have introduced 3 new metrics\nfor Files <\/p>\n\n\n\n<ul><li>Number of Implemented Methods<\/li><li>&nbsp;Number of Implemented Classes<\/li><li>Number of Global Variables&nbsp; <\/li><\/ul>\n\n\n\n<h3><strong>Old scans (snapshots)<\/strong><\/h3>\n\n\n\n<p>&nbsp;All the analysis data for older snapshots was tagged to components and now they are tagged to files. Hence, we will not show data for older scans on the files page and heatmap page. We urge you to scan the repository again to see the analysis.<\/p>\n\n\n\n<p>&nbsp;You will see the page below for older snapshots. Please rescan the code to see the heatmap.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1199\" height=\"539\" src=\"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/old-snaps.png\" alt=\"Components to files\" class=\"wp-image-2370\" srcset=\"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/old-snaps.png 1199w, https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/old-snaps-768x345.png 768w, https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/old-snaps-1170x526.png 1170w, https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/old-snaps-585x263.png 585w\" sizes=\"(max-width: 1199px) 100vw, 1199px\" \/><\/figure>\n\n\n\n<h2><span style=\"text-decoration: underline\">What Next?<\/span><\/h2>\n\n\n\n<p>We are still making improvements in File-level representation and analysis data. We are in the process of adding more file-level Anti Patterns and metrics. We will also be adding a new metrics page where you will be able to configure metric thresholds. So stay tuned! <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Background Before we address the change from components to files, it is important we understand what components are and why did we choose to analyze components in the 1st version&hellip;<\/p>\n","protected":false},"author":24,"featured_media":2371,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6,1],"tags":[179,300],"better_featured_image":{"id":2371,"alt_text":"Components to file","caption":"","description":"","media_type":"image","media_details":{"width":3000,"height":2000,"file":"2022\/03\/MicrosoftTeams-image.png","sizes":{"thumbnail":{"file":"MicrosoftTeams-image-150x150.png","width":150,"height":150,"mime-type":"image\/png","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/MicrosoftTeams-image-150x150.png"},"medium_large":{"file":"MicrosoftTeams-image-768x512.png","width":768,"height":512,"mime-type":"image\/png","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/MicrosoftTeams-image-768x512.png"},"penci-full-thumb":{"file":"MicrosoftTeams-image-1170x780.png","width":1170,"height":780,"mime-type":"image\/png","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/MicrosoftTeams-image-1170x780.png"},"penci-slider-thumb":{"file":"MicrosoftTeams-image-1170x663.png","width":1170,"height":663,"mime-type":"image\/png","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/MicrosoftTeams-image-1170x663.png"},"penci-magazine-slider":{"file":"MicrosoftTeams-image-780x516.png","width":780,"height":516,"mime-type":"image\/png","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/MicrosoftTeams-image-780x516.png"},"penci-slider-full-thumb":{"file":"MicrosoftTeams-image-1920x800.png","width":1920,"height":800,"mime-type":"image\/png","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/MicrosoftTeams-image-1920x800.png"},"penci-single-full":{"file":"MicrosoftTeams-image-1920x1280.png","width":1920,"height":1280,"mime-type":"image\/png","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/MicrosoftTeams-image-1920x1280.png"},"penci-thumb":{"file":"MicrosoftTeams-image-585x390.png","width":585,"height":390,"mime-type":"image\/png","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/MicrosoftTeams-image-585x390.png"},"penci-masonry-thumb":{"file":"MicrosoftTeams-image-585x390.png","width":585,"height":390,"mime-type":"image\/png","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/MicrosoftTeams-image-585x390.png"},"penci-thumb-square":{"file":"MicrosoftTeams-image-585x585.png","width":585,"height":585,"mime-type":"image\/png","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/MicrosoftTeams-image-585x585.png"},"penci-thumb-vertical":{"file":"MicrosoftTeams-image-480x650.png","width":480,"height":650,"mime-type":"image\/png","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/MicrosoftTeams-image-480x650.png"},"penci-thumb-small":{"file":"MicrosoftTeams-image-263x175.png","width":263,"height":175,"mime-type":"image\/png","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/MicrosoftTeams-image-263x175.png"},"jr_insta_square":{"file":"MicrosoftTeams-image-640x640.png","width":640,"height":640,"mime-type":"image\/png","source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/MicrosoftTeams-image-640x640.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"post":2367,"source_url":"https:\/\/blog.embold.io\/wp-content\/uploads\/sites\/2\/2022\/03\/MicrosoftTeams-image.png"},"translation":{"provider":"WPGlobus","version":"2.10.8","language":"ru","enabled_languages":["en","es","de","fr","ru"],"languages":{"en":{"title":true,"content":true,"excerpt":false},"es":{"title":false,"content":false,"excerpt":false},"de":{"title":false,"content":false,"excerpt":false},"fr":{"title":false,"content":false,"excerpt":false},"ru":{"title":false,"content":false,"excerpt":false}}},"_links":{"self":[{"href":"https:\/\/blog.embold.io\/ru\/wp-json\/wp\/v2\/posts\/2367"}],"collection":[{"href":"https:\/\/blog.embold.io\/ru\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.embold.io\/ru\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.embold.io\/ru\/wp-json\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.embold.io\/ru\/wp-json\/wp\/v2\/comments?post=2367"}],"version-history":[{"count":3,"href":"https:\/\/blog.embold.io\/ru\/wp-json\/wp\/v2\/posts\/2367\/revisions"}],"predecessor-version":[{"id":2374,"href":"https:\/\/blog.embold.io\/ru\/wp-json\/wp\/v2\/posts\/2367\/revisions\/2374"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.embold.io\/ru\/wp-json\/wp\/v2\/media\/2371"}],"wp:attachment":[{"href":"https:\/\/blog.embold.io\/ru\/wp-json\/wp\/v2\/media?parent=2367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embold.io\/ru\/wp-json\/wp\/v2\/categories?post=2367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embold.io\/ru\/wp-json\/wp\/v2\/tags?post=2367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}