{"results":{"result":{"added-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-url":"https://github.com/SasView/sasview/pull/3166","old-code-health":9.542673300036391,"modified-files":{"code-health":9.54773037377563,"old-code-health":9.542673300036391,"files":[{"file":"src/sas/system/user.py","loc":84,"old-loc":11,"code-health":9.6882083290695,"old-code-health":10.0},{"file":"src/sas/system/log.py","loc":51,"old-loc":46,"code-health":10.0,"old-code-health":10.0},{"file":"src/sas/sascalc/fit/models.py","loc":225,"old-loc":230,"code-health":9.842730062691357,"old-code-health":9.842730062691357},{"file":"src/sas/system/lib.py","loc":40,"old-loc":40,"code-health":10.0,"old-code-health":10.0},{"file":"src/sas/qtgui/Utilities/CategoryInstaller.py","loc":112,"old-loc":111,"code-health":9.404979908960527,"old-code-health":9.404979908960527},{"file":"src/sas/system/config/config_meta.py","loc":162,"old-loc":162,"code-health":9.27267860277969,"old-code-health":9.27267860277969},{"file":"src/sas/sascalc/doc_regen/makedocumentation.py","loc":190,"old-loc":191,"code-health":8.733920274890703,"old-code-health":8.733920274890703},{"file":"src/sas/sascalc/doc_regen/regenmodel.py","loc":313,"old-loc":313,"code-health":9.6882083290695,"old-code-health":9.6882083290695},{"file":"docs/sphinx-docs/build_sphinx.py","loc":199,"old-loc":200,"code-health":10.0,"old-code-health":10.0},{"file":"src/sas/cli.py","loc":133,"old-loc":131,"code-health":9.26101975637713,"old-code-health":9.26101975637713}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"3166","analysis-time":"2025-04-04T21:02:32Z","negative-impact-count":1,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":1,"commits":["55c786116760cc4c9ec1edc5c9344d78f51cca92","a4aa1735ee325186d26fd06ef0d38035bc8bbada","0834a370bb12f20bb0a1d1e3b702b5d08cec39ab","cace1df23d6b0aac23809573c86c59d2794f87a0","98e029390749afbf9e23c603e5730a6b082af019","d671f9253938b1667a5ed577ff4b3a2c08b62b1f","946e37aeaf145c5372a11017917bb73bcf8b7562","79dc1d195c30306d64d73db29ded49be540d3204","2dc503f955757e6805a669bb953bbbf7b1affa1f","68310df4789369fb3e370f8b44c8575118e1a9d0","c6c3c2e92746e77ad84ea2275b5c59fd6028fe3c","c6cce1a1f9ef78af4fceed12801ce8ecf8c02749","572594c5aef5209fa086f11688541d92a437868e","9ea68f0aa3dd1d03aaf4723a4d46fc664f4615ac","333f3742b5fae23475b2eddb87b8678178ff08f4","bf2f67c5bbf521e9b971b718daf073e5c53d9adc","578a83f84ddd5ca67a64289c9865a02d3b3e2384","ccfb7a8609bc75e7bd39055a53c8125491cca271","95f99634410da1ad3602d5b16bd410ec82586025","1aabb7d961e9b9e6f868caae3fa3e644e57b9661","727a8e068acddc808a035d4b3a94f6b3170576c6","3f91b9ceb84d59b22812c35182e865db39744a9d","38ba41e0bfa1e3dc9715d8cca4ad939113256b6f"],"is-negative-review":true,"negative-findings":{"number-of-types":1,"number-of-files-touched":1,"findings":[{"method":"copy_old_files_to_new_location","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the Python language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"src/sas/system/user.py","refactoring-examples":[{"architectural-component-id":null,"author-name":"krzywon","training-data":{"loc-added":"18","loc-deleted":"21","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"krzywon@yahoo.com","commit-full-message":"","commit-date":"2025-04-07T15:46:05Z","current-rev":"82b3f8919","filename":"sasview/src/sas/system/user.py","previous-rev":"38ba41e0b","commit-title":"Code clean up to improve CodeScene check","language":"Python","id":"f870de94519dc4c085730e9a88f17e294ca2c6d9","model-score":0.47,"author-id":null,"project-id":64300,"delta-file-score":0.31179166,"diff":"diff --git a/src/sas/system/user.py b/src/sas/system/user.py\nindex 41aed44e6..4634828fe 100644\n--- a/src/sas/system/user.py\n+++ b/src/sas/system/user.py\n@@ -100,23 +100,20 @@ def copy_old_files_to_new_location():\n \n-    # Copy the old log to the new location\n-    old_log = user_dir / 'sasview.log'\n-    new_log = Path(get_log_dir()) / 'sasview.log'\n-    if old_log.exists() and not new_log.exists():\n-        shutil.copy2(old_log, new_log)\n-\n-    # Copy plugin models to new location\n-    old_plugins = old_sasview_usr_dir / 'plugin_models'\n-    new_plugins = Path(get_plugin_dir())\n-    if old_plugins.exists():\n-        files = [f for f in os.listdir(old_plugins) if os.path.isfile(os.path.join(old_plugins, f))]\n-        for file in files:\n-            if not Path(new_plugins, file).exists():\n-                shutil.copy2(Path(old_plugins, file), Path(new_plugins, file))\n-\n-    # Copy config file over\n-    new_config_dir = Path(get_config_dir())\n+    # Values used multiple times that need to be defined\n     config_name = f'config-{sasview_version.split(\".\")[0]}'\n-    old_config = old_sasview_usr_dir / config_name\n-    new_config = new_config_dir / config_name\n-    if not new_config.exists() and old_config.exists():\n-        shutil.copy2(old_config, new_config)\n+    old_plugins = old_sasview_usr_dir / 'plugin_models'\n+    plugin_files = [f for f in os.listdir(old_plugins) if os.path.isfile(os.path.join(old_plugins, f))]\n+\n+    # Create a dictionary mapping old file locations to their respective new locations and populate it with\n+    #  the log and config file locations.\n+    location_map = {\n+        user_dir / 'sasview.log': Path(get_log_dir()) / 'sasview.log',  # Log file\n+        old_sasview_usr_dir / config_name: Path(get_config_dir()) / config_name  # Configuration file\n+    }\n+    # Add any existing plugin files\n+    location_map.update({old_plugins / f_name: Path(get_plugin_dir()) / f_name for f_name in plugin_files})\n+\n+    # Iterate through dictionary, check if new files exist, and move files that haven't already been created\n+    for old_path, new_path in location_map.items():\n+        if old_path.exists() and not new_path.exists():\n+            shutil.copy2(old_path, new_path)\n+\n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":93,"what-changed":"copy_old_files_to_new_location has a cyclomatic complexity of 9, threshold = 9","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"introduced"}]},"positive-impact-count":0,"repo":"sasview","code-health":9.54773037377563,"version":"3.0","authors":["krzywon"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"notices":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"external-review-provider":"GitHub"},"analysistime":"2025-04-04T21:02:32.000Z","project-name":"sasview","repository":"https://github.com/SasView/sasview.git"}}