{"results":{"result":{"added-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-url":"https://github.com/pytroll/satpy/pull/3292","old-code-health":9.188833948884973,"modified-files":{"code-health":9.139557905188646,"old-code-health":9.188833948884973,"files":[{"file":"satpy/dataset/dataid.py","loc":607,"old-loc":606,"code-health":8.283981080161325,"old-code-health":8.283981080161325},{"file":"satpy/readers/core/seviri.py","loc":891,"old-loc":887,"code-health":8.545379580978913,"old-code-health":8.545379580978913},{"file":"satpy/readers/seviri_l1b_hrit.py","loc":661,"old-loc":654,"code-health":9.6882083290695,"old-code-health":9.6882083290695},{"file":"satpy/tests/reader_tests/test_goes_imager_nc_noaa.py","loc":438,"old-loc":429,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/readers/fci_l1c_nc.py","loc":560,"old-loc":546,"code-health":9.6882083290695,"old-code-health":9.6882083290695},{"file":"satpy/tests/reader_tests/test_fci_l1c_nc.py","loc":1122,"old-loc":1097,"code-health":8.95517096544394,"old-code-health":8.95517096544394},{"file":"satpy/tests/reader_tests/test_seviri_l1b_hrit.py","loc":545,"old-loc":541,"code-health":8.816158827775617,"old-code-health":8.816158827775617},{"file":"satpy/tests/reader_tests/test_seviri_l1b_calibration.py","loc":358,"old-loc":334,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/tests/reader_tests/test_seviri_l1b_native.py","loc":1228,"old-loc":1224,"code-health":7.545948593178235,"old-code-health":7.545948593178235},{"file":"satpy/readers/virr_l1b.py","loc":124,"old-loc":115,"code-health":9.536386775820924,"old-code-health":9.458490982776196},{"file":"satpy/tests/reader_tests/test_virr_l1b.py","loc":144,"old-loc":144,"code-health":8.679575849015766,"old-code-health":8.679575849015766},{"file":"satpy/readers/scmi.py","loc":234,"old-loc":226,"code-health":9.6882083290695,"old-code-health":9.6882083290695},{"file":"satpy/tests/reader_tests/test_scmi.py","loc":237,"old-loc":231,"code-health":9.387218218812514,"old-code-health":9.387218218812514},{"file":"satpy/readers/abi_l1b.py","loc":126,"old-loc":120,"code-health":9.842730062691357,"old-code-health":9.842730062691357},{"file":"satpy/tests/reader_tests/test_abi_l1b.py","loc":389,"old-loc":388,"code-health":9.6882083290695,"old-code-health":9.6882083290695},{"file":"satpy/readers/abi_l2_nc.py","loc":105,"old-loc":105,"code-health":9.096655465156704,"old-code-health":9.096655465156704},{"file":"satpy/tests/reader_tests/test_abi_l2_nc.py","loc":332,"old-loc":332,"code-health":9.096655465156704,"old-code-health":9.096655465156704},{"file":"satpy/readers/agri_l1.py","loc":47,"old-loc":42,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/tests/reader_tests/test_agri_l1.py","loc":349,"old-loc":336,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/readers/hrit_jma.py","loc":336,"old-loc":331,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/tests/reader_tests/test_ahi_hrit.py","loc":435,"old-loc":416,"code-health":9.6882083290695,"old-code-health":9.6882083290695},{"file":"satpy/readers/ahi_hsd.py","loc":684,"old-loc":672,"code-health":9.23194447551745,"old-code-health":9.23194447551745},{"file":"satpy/tests/reader_tests/test_ahi_hsd.py","loc":653,"old-loc":648,"code-health":9.603465296750686,"old-code-health":9.603465296750686},{"file":"satpy/readers/ami_l1b.py","loc":223,"old-loc":210,"code-health":9.21744523236767,"old-code-health":9.21744523236767},{"file":"satpy/tests/reader_tests/test_ami_l1b.py","loc":334,"old-loc":324,"code-health":9.096655465156704,"old-code-health":9.096655465156704},{"file":"satpy/readers/hrpt.py","loc":215,"old-loc":210,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/tests/reader_tests/test_avhrr_l0_hrpt.py","loc":136,"old-loc":132,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/tests/reader_tests/test_viirs_l1b.py","loc":350,"old-loc":347,"code-health":8.684993063221759,"old-code-health":8.684993063221759},{"file":"satpy/readers/aapp_l1b.py","loc":544,"old-loc":533,"code-health":8.986083904487282,"old-code-health":9.011465636836428},{"file":"satpy/tests/reader_tests/test_aapp_l1b.py","loc":510,"old-loc":504,"code-health":8.511403984377601,"old-code-health":8.511403984377601},{"file":"satpy/readers/eps_l1b.py","loc":332,"old-loc":318,"code-health":9.10236688957248,"old-code-health":9.10236688957248},{"file":"satpy/tests/reader_tests/test_eps_l1b.py","loc":244,"old-loc":239,"code-health":9.387218218812514,"old-code-health":9.387218218812514},{"file":"satpy/readers/avhrr_l1b_gaclac.py","loc":262,"old-loc":254,"code-health":8.564024942980211,"old-code-health":8.612182000040617},{"file":"satpy/tests/reader_tests/test_avhrr_l1b_gaclac.py","loc":399,"old-loc":393,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/readers/viirs_compact.py","loc":373,"old-loc":366,"code-health":8.434468632705734,"old-code-health":8.458097196498738},{"file":"satpy/readers/epic_l1b_h5.py","loc":75,"old-loc":68,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/tests/reader_tests/test_epic_l1b_h5.py","loc":100,"old-loc":94,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/readers/sgli_l1b.py","loc":187,"old-loc":181,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/readers/slstr_l1b.py","loc":320,"old-loc":315,"code-health":9.842730062691357,"old-code-health":9.842730062691357},{"file":"satpy/tests/reader_tests/test_slstr_l1b.py","loc":274,"old-loc":259,"code-health":9.387218218812514,"old-code-health":10.0},{"file":"satpy/readers/mersi_l1b.py","loc":208,"old-loc":201,"code-health":8.816158827775617,"old-code-health":9.096655465156704},{"file":"satpy/tests/reader_tests/test_mersi_l1b.py","loc":610,"old-loc":595,"code-health":8.086892622648167,"old-code-health":9.160278598379644},{"file":"satpy/readers/seviri_l1b_nc.py","loc":333,"old-loc":326,"code-health":9.6882083290695,"old-code-health":9.6882083290695},{"file":"satpy/tests/reader_tests/test_seviri_l1b_nc.py","loc":329,"old-loc":325,"code-health":9.255778637508053,"old-code-health":9.255778637508053},{"file":"satpy/readers/viirs_l1b.py","loc":220,"old-loc":216,"code-health":8.108915197076929,"old-code-health":8.988900121251596},{"file":"satpy/readers/gms/gms5_vissr_l1b.py","loc":655,"old-loc":648,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/tests/reader_tests/gms/test_gms5_vissr_l1b.py","loc":562,"old-loc":557,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/readers/goes_imager_hrit.py","loc":410,"old-loc":403,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/tests/reader_tests/test_goes_imager_hrit.py","loc":159,"old-loc":151,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/readers/goes_imager_nc.py","loc":1174,"old-loc":1158,"code-health":7.6694205073174455,"old-code-health":7.6694205073174455},{"file":"satpy/tests/reader_tests/test_goes_imager_nc_eum.py","loc":124,"old-loc":118,"code-health":9.387218218812514,"old-code-health":10.0},{"file":"satpy/readers/insat3d_img_l1b_h5.py","loc":171,"old-loc":164,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/tests/reader_tests/test_insat3d_img_l1b_h5.py","loc":244,"old-loc":239,"code-health":9.6882083290695,"old-code-health":9.6882083290695},{"file":"satpy/readers/modis_l1b.py","loc":236,"old-loc":229,"code-health":9.6882083290695,"old-code-health":9.6882083290695},{"file":"satpy/tests/reader_tests/modis_tests/test_modis_l1b.py","loc":175,"old-loc":168,"code-health":8.816158827775617,"old-code-health":8.816158827775617},{"file":"satpy/readers/msi_ec_l1c_h5.py","loc":57,"old-loc":50,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/tests/reader_tests/test_msi_ec_l1c.py","loc":105,"old-loc":98,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/readers/core/fy4.py","loc":190,"old-loc":183,"code-health":9.6882083290695,"old-code-health":10.0},{"file":"satpy/tests/reader_tests/test_fy4_base.py","loc":32,"old-loc":32,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/tests/reader_tests/test_ghi_l1.py","loc":333,"old-loc":302,"code-health":9.387218218812514,"old-code-health":9.387218218812514},{"file":"satpy/readers/msu_gsa_l1b.py","loc":76,"old-loc":69,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/tests/reader_tests/test_msu_gsa_l1b.py","loc":147,"old-loc":142,"code-health":10.0,"old-code-health":10.0},{"file":"satpy/readers/olci_nc.py","loc":327,"old-loc":321,"code-health":9.128118197753722,"old-code-health":9.128118197753722}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"3292","analysis-time":"2026-05-08T13:53:49Z","negative-impact-count":11,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":2,"commits":["29b1cd2bd1fe483a96ebd4f871c98659232faf90","e0af123e81a6d13f87554a6e996cd3ec10d5c04b","8505da375146715afc15c7c8c17a7841db16870c","83668d0cdbfd9a3b3052da0926d2fcaa534dc40e","e43a62ca7d28253ad3c13bea8ed0075533aed482","d19d606de70e52eec3a4ad4dbe94427b2ef0abc6","d44b8ea6f8896553f4b75dbeef2eac74efa13a6c","1200fd476ca66de505b180ac1432ed7cbdf26362","489b941068a8b11eb56e1990b3c2e6ff0b227208","3d537b7f571a84328b387c1b518015529689034d","985a18d27954441f81420f4ea08c8605d0a6f9a2","92c8124e28c565366dc5c2403deb58f244ec495e","624aec851d8d96d354c61d5112a269542c0b645a","82a47d421f120e445771010b0e8667455ede0c1b","346dd2eb409c6b7d579f24a13073a68ebd2b146f","e2fab1cda3c3d9468ace95453a2a94969736aa43","f3dd90c54c89ad1b108218a930956591a6f5551a","683de53e8a079dde6506add67b1eb9c2196136ce","5ac9a26f4f9ab0020be3a4d18f5710501a02a326","de1c5d77add181f8d658ae1e06a5d416092ad99c","d04e7cd36a8a019202b282e069b5b4afd13dff47","b5aa4fc6d12ad3733d31aa45e7d19b751d0d4f98","e8f392fee2539fdef69412a0f33aa8261b7fcc34","c0ec08733efb83dcd3e4a9bcf35bd7e661250c75","52d310beaac4ed3a6631705259fd1e5cfd4031d1","e5b0954943b305a360478464f654671c75b12719","ed11b0a54989e9c492c77c0782158c73ef3076c5","f09547aabebaf229e22ea604776466495a3080b4","8813bf97586e04d40c37acb37f151c2e720418d1","38b95c43e7557f4e8096670fab636cf3db7233b9","fa2af4e36e7b8b03ff3ddcaa236d58e2627efd93","566ed1a426f5e64b03793b1b67b55a35bd171829","eec7aa543bcf90a8ea1b827b23b8f0c56b530192","202a4077de5be148c3c4449f580319ccbea25163","14ddf8ad2f7b9eeb9442b430861556605bace498","16ff0c50e428edbd6473eb1d2c3ffb201279975f","62bf54b00c7ac824aa27fcf29bc468ef782c095d","d4fe0ccadae82f6547bdb6b3e9efcfb023d6db3b","1dfb4051045262822407d3830f962d9ae9f8218c","fd87e0be5693aca02c57f7e0d088ffc26101c9d7","1cd171f88d2be2f97169bcfa829d4ccf5a5c6b1f","9bc6e64bb33fe19b7f75f6861a4185373fff8d27","15cd4c534027e4ffe2247816e971149c72d5612e","1e313eb14e95b320d7ec8de46482eaec929da24b","1f5adf1b02d78f046b34d04a972c212eee323798","46222bf1d817b23b8477aa4285edf4f1ff1d7b68","fadf3d8208003b1d11587bf4b38481b50e1be898","48920cbfad1b3883fb3a115a37ea2141311266a4"],"is-negative-review":true,"negative-findings":{"number-of-types":5,"number-of-files-touched":9,"findings":[{"method":"_vis_calibrate","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":"satpy/readers/aapp_l1b.py","refactoring-examples":[{"diff":"diff --git a/complex_method.js b/complex_method.js\nindex 10cce78e6d..0c1a8cabaf 100644\n--- a/complex_method.js\n+++ b/complex_method.js\n@@ -1,15 +1,20 @@\n function postItem(item) {\n   if (!item.id) {\n-    if (item.x != null && item.y != null) {\n-      post(item);\n-    } else {\n-      throw Error(\"Item must have x and y\");\n-    }\n+    // extract a separate function for creating new item\n+    postNew(item);\n   } else {\n-    if (item.x < 10 && item.y > 25) {\n-      put(item);\n-    } else {\n-      throw Error(\"Item must have an x and y value between 10 and 25\");\n-    }\n+    // and one for updating existing items\n+    updateItem(item);\n   }\n }\n+\n+function postNew(item) {\n+  validateNew(item);\n+  post(item);\n+}\n+\n+function updateItem(item) {\n+  validateUpdate(item);\n+  put(item);\n+}\n+\n","language":"python","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":543,"what-changed":"_vis_calibrate increases in cyclomatic complexity from 11 to 12, 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":"degraded"},{"method":"GACLACFile.get_dataset","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":"satpy/readers/avhrr_l1b_gaclac.py","refactoring-examples":[{"diff":"diff --git a/complex_method.js b/complex_method.js\nindex 10cce78e6d..0c1a8cabaf 100644\n--- a/complex_method.js\n+++ b/complex_method.js\n@@ -1,15 +1,20 @@\n function postItem(item) {\n   if (!item.id) {\n-    if (item.x != null && item.y != null) {\n-      post(item);\n-    } else {\n-      throw Error(\"Item must have x and y\");\n-    }\n+    // extract a separate function for creating new item\n+    postNew(item);\n   } else {\n-    if (item.x < 10 && item.y > 25) {\n-      put(item);\n-    } else {\n-      throw Error(\"Item must have an x and y value between 10 and 25\");\n-    }\n+    // and one for updating existing items\n+    updateItem(item);\n   }\n }\n+\n+function postNew(item) {\n+  validateNew(item);\n+  post(item);\n+}\n+\n+function updateItem(item) {\n+  validateUpdate(item);\n+  put(item);\n+}\n+\n","language":"python","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":150,"what-changed":"GACLACFile.get_dataset increases in cyclomatic complexity from 13 to 15, 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":"degraded"},{"method":"VIIRSCompactFileHandler.read_dataset","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":"satpy/readers/viirs_compact.py","refactoring-examples":[{"diff":"diff --git a/complex_method.js b/complex_method.js\nindex 10cce78e6d..0c1a8cabaf 100644\n--- a/complex_method.js\n+++ b/complex_method.js\n@@ -1,15 +1,20 @@\n function postItem(item) {\n   if (!item.id) {\n-    if (item.x != null && item.y != null) {\n-      post(item);\n-    } else {\n-      throw Error(\"Item must have x and y\");\n-    }\n+    // extract a separate function for creating new item\n+    postNew(item);\n   } else {\n-    if (item.x < 10 && item.y > 25) {\n-      put(item);\n-    } else {\n-      throw Error(\"Item must have an x and y value between 10 and 25\");\n-    }\n+    // and one for updating existing items\n+    updateItem(item);\n   }\n }\n+\n+function postNew(item) {\n+  validateNew(item);\n+  post(item);\n+}\n+\n+function updateItem(item) {\n+  validateUpdate(item);\n+  put(item);\n+}\n+\n","language":"python","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":223,"what-changed":"VIIRSCompactFileHandler.read_dataset increases in cyclomatic complexity from 11 to 12, 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":"degraded"},{"why-it-occurs":"Duplicated code often leads to code that's harder to change since the same logical change has to be done in multiple functions. More duplication gives lower code health.","name":"Code Duplication","file":"satpy/tests/reader_tests/test_slstr_l1b.py","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":274,"what-changed":"The module contains 2 functions with similar structure: test_radiance_factor_calibration,test_reflectance_calibration","how-to-fix":"A certain degree of duplicated code might be acceptable. The problems start when it is the same behavior that is duplicated across the functions in the module, ie. a violation of the Don't Repeat Yourself (DRY) principle. DRY violations lead to code that is changed together in predictable patterns, which is both expensive and risky. DRY violations can be identified using CodeScene's X-Ray analysis to detect clusters of change coupled functions with high code similarity. [Read More](https://codescene.com/blog/software-revolution-part3/)\n\nOnce you have identified the similarities across functions, look to extract and encapsulate the concept that varies into its own function(s). These shared abstractions can then be re-used, which minimizes the amount of duplication and simplifies change.","change-type":"introduced"},{"method":"MERSIL1B.get_dataset","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":"satpy/readers/mersi_l1b.py","refactoring-examples":[{"diff":"diff --git a/complex_method.js b/complex_method.js\nindex 10cce78e6d..0c1a8cabaf 100644\n--- a/complex_method.js\n+++ b/complex_method.js\n@@ -1,15 +1,20 @@\n function postItem(item) {\n   if (!item.id) {\n-    if (item.x != null && item.y != null) {\n-      post(item);\n-    } else {\n-      throw Error(\"Item must have x and y\");\n-    }\n+    // extract a separate function for creating new item\n+    postNew(item);\n   } else {\n-    if (item.x < 10 && item.y > 25) {\n-      put(item);\n-    } else {\n-      throw Error(\"Item must have an x and y value between 10 and 25\");\n-    }\n+    // and one for updating existing items\n+    updateItem(item);\n   }\n }\n+\n+function postNew(item) {\n+  validateNew(item);\n+  post(item);\n+}\n+\n+function updateItem(item) {\n+  validateUpdate(item);\n+  put(item);\n+}\n+\n","language":"python","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":131,"what-changed":"MERSIL1B.get_dataset has a cyclomatic complexity of 10, 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"},{"why-it-occurs":"Cohesion is a measure of how well the elements in a file belong together. CodeScene measures cohesion using the LCOM4 metric (Lack of Cohesion Measure). With LCOM4, the functions inside a module are related if a) they access the same data members, or b) they call each other. High Cohesion is desirable as it means that all functions are related and likely to represent the same responsibility. Low Cohesion is problematic since it means that the module contains multiple behaviors. Low Cohesion leads to code that's harder to understand, requires more tests, and very often become a coordination magnet for developers.","name":"Low Cohesion","file":"satpy/tests/reader_tests/test_mersi_l1b.py","refactoring-examples":[{"diff":"diff --git a/low_cohesion_example.js b/low_cohesion_example.js\nindex 1ae56cf85b..209fc02c73 100644\n--- a/low_cohesion_example.js\n+++ b/low_cohesion_example.js\n@@ -2,8 +2,10 @@\n \n var userLayer = connectUsers(myConnectionProperties);\n \n-var chessEngine = startEngine(gameProperties);\n+// [Refactoring: moved the data related to chess to a new chessGame.js module]\n \n+// The module contains login related functionality that forms one behaviour: all\n+// code is related since it either a) uses the same data, or b) calls the same functions.\n export function login(newUser) {\n   val authenticated = userLayer.authenticate(newUser);\n   traceLoginFor(authenticated);\n@@ -19,11 +21,6 @@ function traceLogin(user) {\n    // ...some code...\n }\n \n-// playChess seems like a very unrelated responsibility.\n-// Should it really be within the same module?\n-\n-export function playChess(loggedInUser) {\n-   var board = chessEngine.newBoard();\n-\n-   return newGameOn(board, loggedInUser);\n-}\n+// [Refactoring: moved playChess to a new chessGame.js module\n+// As a result of this refactoring, the module maintains a\n+// single behavior where all code and data is related: high cohesion.]\n","language":"python","improvement-type":"Low Cohesion"}],"change-level":"warning","is-hotspot?":false,"what-changed":"This module has at least 5 different responsibilities amongst its 27 functions, threshold = 4","how-to-fix":"Look to modularize the code by splitting the file into more cohesive units; functions that belong together should still be located together. A common refactoring is [EXTRACT CLASS](https://refactoring.com/catalog/extractClass.html).","change-type":"introduced"},{"method":"VIIRSL1BFileHandler._get_dataset_valid_range","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":"satpy/readers/viirs_l1b.py","refactoring-examples":[{"diff":"diff --git a/complex_method.js b/complex_method.js\nindex 10cce78e6d..0c1a8cabaf 100644\n--- a/complex_method.js\n+++ b/complex_method.js\n@@ -1,15 +1,20 @@\n function postItem(item) {\n   if (!item.id) {\n-    if (item.x != null && item.y != null) {\n-      post(item);\n-    } else {\n-      throw Error(\"Item must have x and y\");\n-    }\n+    // extract a separate function for creating new item\n+    postNew(item);\n   } else {\n-    if (item.x < 10 && item.y > 25) {\n-      put(item);\n-    } else {\n-      throw Error(\"Item must have an x and y value between 10 and 25\");\n-    }\n+    // and one for updating existing items\n+    updateItem(item);\n   }\n }\n+\n+function postNew(item) {\n+  validateNew(item);\n+  post(item);\n+}\n+\n+function updateItem(item) {\n+  validateUpdate(item);\n+  put(item);\n+}\n+\n","language":"python","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":135,"what-changed":"VIIRSL1BFileHandler._get_dataset_valid_range 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"},{"method":"VIIRSL1BFileHandler._get_dataset_valid_range","why-it-occurs":"A Bumpy Road is a function that contains multiple chunks of nested conditional logic inside the same function. The deeper the nesting and the more bumps, the lower the code health.\n\nA bumpy code road represents a lack of encapsulation which becomes an obstacle to comprehension. In imperative languages there’s also an increased risk for feature entanglement, which leads to complex state management. CodeScene considers the following rules for the code health impact: 1) The deeper the nested conditional logic of each bump, the higher the tax on our working memory. 2) The more bumps inside a function, the more expensive it is to refactor as each bump represents a missing abstraction. 3) The larger each bump – that is, the more lines of code it spans – the harder it is to build up a mental model of the function. The nesting depth for what is considered a bump is  levels of conditionals.","name":"Bumpy Road Ahead","file":"satpy/readers/viirs_l1b.py","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":135,"what-changed":"VIIRSL1BFileHandler._get_dataset_valid_range has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is 2 blocks per function","how-to-fix":"Bumpy Road implementations indicate a lack of encapsulation. Check out the detailed description of the [Bumpy Road code health issue](https://codescene.com/blog/bumpy-road-code-complexity-in-context/).\n\nA Bumpy Road often suggests that the function/method does too many things. The first refactoring step is to identify the different possible responsibilities of the function. Consider extracting those responsibilities into smaller, cohesive, and well-named functions. The [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring is the primary response.","change-type":"introduced"},{"why-it-occurs":"Overall Code Complexity is measured by the mean cyclomatic complexity across all functions in the file. The lower the number, the better.\n\nCyclomatic complexity is a function level metric that measures the number of logical branches (if-else, loops, etc.). Cyclomatic complexity is a rough complexity measure, but useful as a way of estimating the minimum number of unit tests you would need. As such, prefer functions with low cyclomatic complexity (2-3 branches).","name":"Overall Code Complexity","file":"satpy/readers/viirs_l1b.py","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"what-changed":"This module has a mean cyclomatic complexity of 4.06 across 16 functions. The mean complexity threshold is 4","how-to-fix":"You address the overall cyclomatic complexity by a) modularizing the code, and b) abstract away the complexity. Let's look at some examples:\n\nModularizing the Code: Do an X-Ray and inspect the local hotspots. Are there any complex conditional expressions? If yes, then do a [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring. Extract the conditional logic into a separate function and put a good name on that function. This clarifies the intent and makes the original function easier to read. Repeat until all complex conditional expressions have been simplified.\n\n","change-type":"introduced"},{"why-it-occurs":"Duplicated code often leads to code that's harder to change since the same logical change has to be done in multiple functions. More duplication gives lower code health.","name":"Code Duplication","file":"satpy/tests/reader_tests/test_goes_imager_nc_eum.py","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":34,"what-changed":"The module contains 2 functions with similar structure: GOESNCEUMFileHandlerRadianceTest.setUp,GOESNCEUMFileHandlerVISTest.setUp","how-to-fix":"A certain degree of duplicated code might be acceptable. The problems start when it is the same behavior that is duplicated across the functions in the module, ie. a violation of the Don't Repeat Yourself (DRY) principle. DRY violations lead to code that is changed together in predictable patterns, which is both expensive and risky. DRY violations can be identified using CodeScene's X-Ray analysis to detect clusters of change coupled functions with high code similarity. [Read More](https://codescene.com/blog/software-revolution-part3/)\n\nOnce you have identified the similarities across functions, look to extract and encapsulate the concept that varies into its own function(s). These shared abstractions can then be re-used, which minimizes the amount of duplication and simplifies change.","change-type":"introduced"},{"method":"FY4Base.calibrate","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":"satpy/readers/core/fy4.py","refactoring-examples":[{"diff":"diff --git a/complex_method.js b/complex_method.js\nindex 10cce78e6d..0c1a8cabaf 100644\n--- a/complex_method.js\n+++ b/complex_method.js\n@@ -1,15 +1,20 @@\n function postItem(item) {\n   if (!item.id) {\n-    if (item.x != null && item.y != null) {\n-      post(item);\n-    } else {\n-      throw Error(\"Item must have x and y\");\n-    }\n+    // extract a separate function for creating new item\n+    postNew(item);\n   } else {\n-    if (item.x < 10 && item.y > 25) {\n-      put(item);\n-    } else {\n-      throw Error(\"Item must have an x and y value between 10 and 25\");\n-    }\n+    // and one for updating existing items\n+    updateItem(item);\n   }\n }\n+\n+function postNew(item) {\n+  validateNew(item);\n+  post(item);\n+}\n+\n+function updateItem(item) {\n+  validateUpdate(item);\n+  put(item);\n+}\n+\n","language":"python","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":133,"what-changed":"FY4Base.calibrate 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":2,"repo":"satpy","code-health":9.139557905188646,"version":"3.0","authors":["Martin Raspaud","Panu Lahtinen"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":2,"number-of-files-touched":2,"findings":[{"method":"VIRR_L1B.get_dataset","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":"satpy/readers/virr_l1b.py","change-level":"improvement","is-hotspot?":false,"line":82,"what-changed":"VIRR_L1B.get_dataset decreases in cyclomatic complexity from 14 to 10, 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":"improved"},{"method":"TestVIIRSL1BReaderDay.test_load_every_m_band_refl","why-it-occurs":"Duplicated code often leads to code that's harder to change since the same logical change has to be done in multiple functions. More duplication gives lower code health.","name":"Code Duplication","file":"satpy/tests/reader_tests/test_viirs_l1b.py","change-level":"improvement","is-hotspot?":false,"what-changed":"reduced similar code in: TestVIIRSL1BReaderDay.test_load_every_m_band_refl","how-to-fix":"A certain degree of duplicated code might be acceptable. The problems start when it is the same behavior that is duplicated across the functions in the module, ie. a violation of the Don't Repeat Yourself (DRY) principle. DRY violations lead to code that is changed together in predictable patterns, which is both expensive and risky. DRY violations can be identified using CodeScene's X-Ray analysis to detect clusters of change coupled functions with high code similarity. [Read More](https://codescene.com/blog/software-revolution-part3/)\n\nOnce you have identified the similarities across functions, look to extract and encapsulate the concept that varies into its own function(s). These shared abstractions can then be re-used, which minimizes the amount of duplication and simplifies change.","change-type":"improved"}]},"notices":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"external-review-provider":"GitHub"},"analysistime":"2026-05-08T13:53:48.000Z","project-name":"satpy","repository":"https://github.com/pytroll/satpy.git"}}