{"id":555,"date":"2020-09-11T08:00:42","date_gmt":"2020-09-11T08:00:42","guid":{"rendered":"https:\/\/metrics.blogg.gu.se\/?p=555"},"modified":"2020-08-23T11:43:46","modified_gmt":"2020-08-23T11:43:46","slug":"recommending-refactoring-via-commit-message-analysis","status":"publish","type":"post","link":"https:\/\/metrics.blogg.gu.se\/?p=555","title":{"rendered":"Recommending refactoring via commit message analysis"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"413\" src=\"https:\/\/metrics.blogg.gu.se\/files\/2020\/08\/electrical-planning-3536767_1920-1024x413.jpg\" alt=\"\" class=\"wp-image-556\" srcset=\"https:\/\/metrics.blogg.gu.se\/files\/2020\/08\/electrical-planning-3536767_1920-1024x413.jpg 1024w, https:\/\/metrics.blogg.gu.se\/files\/2020\/08\/electrical-planning-3536767_1920-300x121.jpg 300w, https:\/\/metrics.blogg.gu.se\/files\/2020\/08\/electrical-planning-3536767_1920-768x310.jpg 768w, https:\/\/metrics.blogg.gu.se\/files\/2020\/08\/electrical-planning-3536767_1920-1200x484.jpg 1200w, https:\/\/metrics.blogg.gu.se\/files\/2020\/08\/electrical-planning-3536767_1920-1320x532.jpg 1320w, https:\/\/metrics.blogg.gu.se\/files\/2020\/08\/electrical-planning-3536767_1920.jpg 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p>Image by <a href=\"https:\/\/pixabay.com\/users\/annca-1564471\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3536767\">annca<\/a> from <a href=\"https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3536767\">Pixabay<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/doi.org\/10.1016\/j.infsof.2020.106332\">https:\/\/doi.org\/10.1016\/j.infsof.2020.106332<\/a><\/p>\n\n\n\n<p class=\"has-drop-cap\">In the process of reviewing code, we can identify refactoring pretty easy. We read the code, try to understand it and provide comments. In the understanding phase we also get ideas about possible alternative &#8211; why is this done this way? \n<\/p>\n\n\n\n<p>Now, when writing the comments, we rarely have the time to refactor the code. In CI, this process of reviewing comes when we commit the code to the main branch and therefore we expect this to be delivered and used soon. So, it\u2019s too late to refactor, we need to do it in the next iteration. \n<\/p>\n\n\n\n<p>But the next iteration is the same, we need to deliver new functions, not \u201cgolden plate\u201d the existing code, deliver it to the main branch, etc. When is the time for refactoring then? How do we document the possibilities and use them when we have a bit of time?\n<\/p>\n\n\n\n<p>In this work, the authors look at the commit messages and identify refactoring possibilities for that, complementing the static and dynamic analysis of code. The method presented in the paper is based on the analysis of code from open source projects, the refactoring applied to the code and the analysis of the QMOOD quality attributes that were related to these commits. \n<\/p>\n\n\n\n<p>The following quote from the paper explains a bit how the gist of the extraction of the refactored code works: \n<\/p>\n\n\n\n<p>Identifying refactoring rationale has two parts. The first part is the detection of the files that are refactored by developers in a commit. The second part is the identification of changes in the QMOOD quality attributes then comparing these changes with the information in the commit message.\n<\/p>\n\n\n\n<p>For the first part, we used the GitHub API to identify the changed files in each commit. In the second part, we compared the QMOOD quality attribute values before and after the commit to capture the actual quality changes for each file. Once the changed files and quality attributes were identified, we checked if the developers&nbsp;<em>intended<\/em>&nbsp;to actually improve these files and quality attributes. In fact, we preprocessed the commit messages and we used the names of code elements in the changed files and the changed quality metrics as keywords to match with words in the commit message. Once the refactoring rationale is automatically detected using this procedure, we continue with the next step to find better refactoring recommendations that can fully meet the developer\u2019s intentions and expectations. In case that no quality changes were identified at all then a warning will be generated to developers that the manually applied refactorings are not addressing the quality issues described in his commit message. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Image by annca from Pixabay https:\/\/doi.org\/10.1016\/j.infsof.2020.106332 In the process of reviewing code, we can identify refactoring pretty easy. We read the code, try to understand it and provide comments. In the understanding phase we also get ideas about possible alternative &#8211; why is this done this way? Now, when writing the comments, we rarely have &hellip; <a href=\"https:\/\/metrics.blogg.gu.se\/?p=555\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Recommending refactoring via commit message analysis&#8221;<\/span><\/a><\/p>\n","protected":false},"author":68,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,7,4,9],"tags":[],"_links":{"self":[{"href":"https:\/\/metrics.blogg.gu.se\/index.php?rest_route=\/wp\/v2\/posts\/555"}],"collection":[{"href":"https:\/\/metrics.blogg.gu.se\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/metrics.blogg.gu.se\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/metrics.blogg.gu.se\/index.php?rest_route=\/wp\/v2\/users\/68"}],"replies":[{"embeddable":true,"href":"https:\/\/metrics.blogg.gu.se\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=555"}],"version-history":[{"count":1,"href":"https:\/\/metrics.blogg.gu.se\/index.php?rest_route=\/wp\/v2\/posts\/555\/revisions"}],"predecessor-version":[{"id":557,"href":"https:\/\/metrics.blogg.gu.se\/index.php?rest_route=\/wp\/v2\/posts\/555\/revisions\/557"}],"wp:attachment":[{"href":"https:\/\/metrics.blogg.gu.se\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/metrics.blogg.gu.se\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/metrics.blogg.gu.se\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}