{"results":{"result":{"added-files":{"code-health":9.387218218812514,"old-code-health":0.0,"files":[{"file":"tests/interpret/test_uncertainty_utils.py","loc":237,"code-health":9.387218218812514}]},"external-review-url":"https://github.com/pykale/pykale/pull/502","old-code-health":6.590126285918684,"modified-files":{"code-health":7.489594850267923,"old-code-health":6.590126285918684,"files":[{"file":"kale/interpret/uncertainty_quantiles.py","loc":1022,"old-loc":1120,"code-health":6.166865646598316,"old-code-health":3.8874418290802275},{"file":"examples/landmark_uncertainty/main.py","loc":221,"old-loc":198,"code-health":8.309192717406994,"old-code-health":8.416665600415342},{"file":"tests/pipeline/test_uncertainty_qbin_pipeline.py","loc":514,"old-loc":476,"code-health":8.735011076962444,"old-code-health":7.85296571050319},{"file":"kale/interpret/box_plot.py","loc":1867,"old-loc":1674,"code-health":7.106711345609554,"old-code-health":6.30344731029596},{"file":"kale/embed/uncertainty_fitting.py","loc":109,"old-loc":109,"code-health":9.190255756212718,"old-code-health":9.190255756212718},{"file":"kale/evaluate/similarity_metrics.py","loc":110,"old-loc":110,"code-health":9.159127824487724,"old-code-health":9.159127824487724},{"file":"kale/interpret/uncertainty_utils.py","loc":613,"old-loc":458,"code-health":8.56295825361204,"old-code-health":9.387218218812514},{"file":"tests/interpret/test_uncertainty_quantiles.py","loc":87,"old-loc":225,"code-health":10.0,"old-code-health":9.6882083290695}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"502","analysis-time":"2025-12-28T15:31:44Z","negative-impact-count":6,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":0,"commits":["1fd9b0e122717e6e422a8d016b0455b636e0e5a5","9f425931fb66eb424e5c88fe25fcf65436b714fa","84cd34a4ab93db6a8862c717b39184d2ae4736bb","a55e467ff7392d3e825b4cccf5b71d0485300616","b8ef5c4abf994c824305e3b5689377e3b0590794","d1aeb83ab13d2538070b12e9aa0f8bca78c4e154","031f4e6f8650ee535e4d2788eb0554e412f5f69c","cf7244c3490f068fd381afcf6b6d0b5e7608fb57","cd267c6b4937e134115d1846721bf6d52e96fcd1","e8f5a2af52bc21c4630752b132ec67d547641e4c","898f7ae022a593d68d09aef32b31aef907e74223"],"is-negative-review":true,"negative-findings":{"number-of-types":5,"number-of-files-touched":4,"findings":[{"method":"QuantileBinningAnalyzer._plot_metrics","why-it-occurs":"A complex conditional is an expression inside a branch such as an <code>if</code>-statmeent which consists of multiple, logical operations. Example: <code>if (x.started() && y.running())</code>.Complex conditionals make the code even harder to read, and contribute to the Complex Method code smell. Encapsulate them.","name":"Complex Conditional","file":"kale/interpret/uncertainty_quantiles.py","refactoring-examples":[{"diff":"diff --git a/complex_conditional.js b/complex_conditional.js\nindex c43da09584..94259ce874 100644\n--- a/complex_conditional.js\n+++ b/complex_conditional.js\n@@ -1,16 +1,34 @@\n function messageReceived(message, timeReceived) {\n-   // Ignore all messages which aren't from known customers:\n-   if (!message.sender &&\n-       customers.getId(message.name) == null) {\n+   // Refactoring #1: encapsulate the business rule in a\n+   // function. A clear name replaces the need for the comment:\n+   if (!knownCustomer(message)) {\n      log('spam received -- ignoring');\n      return;\n    }\n \n-  // Provide an auto-reply when outside business hours:\n-  if ((timeReceived.getHours() > 17) ||\n-      (timeReceived.getHours() < 8)) {\n+  // Refactoring #2: encapsulate the business rule.\n+  // Again, note how a clear function name replaces the\n+  // need for a code comment:\n+  if (outsideBusinessHours(timeReceived)) {\n     return autoReplyTo(message);\n   }\n \n   pingAgentFor(message);\n+}\n+\n+function outsideBusinessHours(timeReceived) {\n+  // Refactoring #3: replace magic numbers with\n+  // symbols that communicate with the code reader:\n+  const closingHour = 17;\n+  const openingHour = 8;\n+\n+  const hours = timeReceived.getHours();\n+\n+  // Refactoring #4: simple conditional rules can\n+  // be further clarified by introducing a variable:\n+  const afterClosing = hours > closingHour;\n+  const beforeOpening = hours < openingHour;\n+\n+  // Yeah -- look how clear the business rule is now!\n+  return afterClosing || beforeOpening;\n }\n\\ No newline at end of file\n","language":"python","improvement-type":"Complex Conditional"}],"change-level":"warning","is-hotspot?":false,"line":944,"what-changed":"QuantileBinningAnalyzer._plot_metrics has 1 complex conditionals with 2 branches, threshold = 2","how-to-fix":"Apply the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring so that the complex conditional is encapsulated in a separate function with a good name that captures the business rule. Optionally, for simple expressions, introduce a new variable which holds the result of the complex conditional.","change-type":"introduced"},{"why-it-occurs":"This code health issue is measured as the average number of function arguments across the whole file. A function with many arguments can be simplified either by a) splitting the function if it has too many responsibilities, or b) by introducing an abstraction (class, record, struct, etc.) which encapsulates the arguments. ","name":"Missing Arguments Abstractions","file":"kale/interpret/uncertainty_quantiles.py","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"what-changed":"The average number of function arguments in this module is 5.82 across 11 functions. The average arguments threshold is 4.00","how-to-fix":"Start by investigating the responsibilities of the function. Make sure it doesn't do too many things, in which case it should be split into smaller and more cohesive functions. Consider the refactoring [INTRODUCE PARAMETER OBJECT](https://refactoring.com/catalog/introduceParameterObject.html) to encapsulate arguments that refer to the same logical concept.","change-type":"introduced"},{"method":"main","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":"examples/landmark_uncertainty/main.py","refactoring-examples":[{"architectural-component-id":null,"author-name":"xianyuanliu","training-data":{"loc-added":"4","loc-deleted":"13","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"8.816158827775617"},"author-email":"19544506+xianyuanliu@users.noreply.github.com","commit-full-message":"","commit-date":"2025-10-13T16:10:03Z","current-rev":"05dc1b5b","filename":"pykale/kale/embed/video/res3d.py","previous-rev":"e2b09c3d","commit-title":"remove unuse functions","language":"Python","id":"cd249f71e263eb51fddd3e95a5bff314a4ebcbfe","model-score":0.54,"author-id":null,"project-id":66070,"delta-file-score":0.27077925,"diff":"diff --git a/kale/embed/video/res3d.py b/kale/embed/video/res3d.py\nindex 7b7ac168..81256c4b 100644\n--- a/kale/embed/video/res3d.py\n+++ b/kale/embed/video/res3d.py\n@@ -112,4 +112,2 @@ class BasicBlock(nn.Module):\n             out = self.SELayerC(out)\n-        if \"SELayerCT\" in dir(self):\n-            out = self.SELayerCT(out)\n         if \"SELayerMC\" in dir(self):\n@@ -118,15 +116,8 @@ class BasicBlock(nn.Module):\n             out = self.SELayerMAC(out)\n-\n         if \"SELayerT\" in dir(self):  # check temporal-wise\n             out = self.SELayerT(out)\n-\n-        if \"SELayerCTc\" in dir(self):  # check channel-temporal-wise\n-            out = self.SELayerCTc(out)\n-        if \"SELayerCTt\" in dir(self):\n-            out = self.SELayerCTt(out)\n-\n-        if \"SELayerTCt\" in dir(self):  # check temporal-channel-wise\n-            out = self.SELayerTCt(out)\n-        if \"SELayerTCc\" in dir(self):\n-            out = self.SELayerTCc(out)\n+        if \"SELayerCT\" in dir(self):\n+            out = self.SELayerCT(out)\n+        if \"SELayerTC\" in dir(self):\n+            out = self.SELayerTC(out)\n \n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"xianyuanliu","training-data":{"loc-added":"4","loc-deleted":"40","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.62","delta-n-functions":"0","current-file-score":"9.6882083290695"},"author-email":"19544506+xianyuanliu@users.noreply.github.com","commit-full-message":"","commit-date":"2025-10-13T16:21:27Z","current-rev":"bf57597c","filename":"pykale/kale/embed/video/se_i3d.py","previous-rev":"05dc1b5b","commit-title":"simplify SELayer usage","language":"Python","id":"e19f247d4295b07be33df8cc3049b1c82d2dc7e8","model-score":0.29,"author-id":null,"project-id":66070,"delta-file-score":0.7666241,"diff":"diff --git a/kale/embed/video/se_i3d.py b/kale/embed/video/se_i3d.py\nindex e447cb50..e6a747e5 100644\n--- a/kale/embed/video/se_i3d.py\n+++ b/kale/embed/video/se_i3d.py\n@@ -60,24 +60,5 @@ class SEInceptionI3DRGB(nn.Module):\n             model.Mixed_4f.add_module(attention, se_layer(temporal_length // 4))\n-            # model.Mixed_5b.add_module(attention, SELayerT(temporal_length//8))\n-            # model.Mixed_5c.add_module(attention, SELayerT(temporal_length//8))\n \n-        # Add channel-temporal-wise SELayer\n-        elif attention == \"SELayerCT\":\n-            se_layer = get_selayer(attention)\n-            channel_schedule = [\n-                (\"Mixed_3b\", 256, temporal_length // 2),\n-                (\"Mixed_3c\", 480, temporal_length // 2),\n-                (\"Mixed_4b\", 512, temporal_length // 4),\n-                (\"Mixed_4c\", 512, temporal_length // 4),\n-                (\"Mixed_4d\", 512, temporal_length // 4),\n-                (\"Mixed_4e\", 528, temporal_length // 4),\n-                (\"Mixed_4f\", 832, temporal_length // 4),\n-                (\"Mixed_5b\", 832, max(1, temporal_length // 8)),\n-                (\"Mixed_5c\", 1024, max(1, temporal_length // 8)),\n-            ]\n-            for module_name, channels, temporal in channel_schedule:\n-                getattr(model, module_name).add_module(attention, se_layer(channels, temporal))\n-\n-        # Add temporal-channel-wise SELayer\n-        elif attention == \"SELayerTC\":\n+        # Add channel-temporal & temporal-channel SELayer\n+        elif attention in [\"SELayerCT\", \"SELayerTC\"]:\n             se_layer = get_selayer(attention)\n@@ -138,21 +119,4 @@ class SEInceptionI3DFlow(nn.Module):\n \n-        # Add channel-temporal-wise SELayer\n-        elif attention == \"SELayerCT\":\n-            se_layer = get_selayer(attention)\n-            channel_schedule = [\n-                (\"Mixed_3b\", 256, temporal_length // 4),\n-                (\"Mixed_3c\", 480, temporal_length // 4),\n-                (\"Mixed_4b\", 512, temporal_length // 8),\n-                (\"Mixed_4c\", 512, temporal_length // 8),\n-                (\"Mixed_4d\", 512, temporal_length // 8),\n-                (\"Mixed_4e\", 528, temporal_length // 8),\n-                (\"Mixed_4f\", 832, temporal_length // 8),\n-                (\"Mixed_5b\", 832, max(1, temporal_length // 16)),\n-                (\"Mixed_5c\", 1024, max(1, temporal_length // 16)),\n-            ]\n-            for module_name, channels, temporal in channel_schedule:\n-                getattr(model, module_name).add_module(attention, se_layer(channels, temporal))\n-\n-        # Add temporal-channel-wise SELayer\n-        elif attention == \"SELayerTC\":\n+        # Add channel-temporal & temporal-channel SELayer\n+        elif attention in [\"SELayerCT\", \"SELayerTC\"]:\n             se_layer = get_selayer(attention)\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"xianyuanliu","training-data":{"loc-added":"4","loc-deleted":"36","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.8","delta-n-functions":"0","current-file-score":"8.283981080161325"},"author-email":"19544506+xianyuanliu@users.noreply.github.com","commit-full-message":"","commit-date":"2025-10-13T16:21:27Z","current-rev":"bf57597c","filename":"pykale/kale/embed/video/se_res3d.py","previous-rev":"05dc1b5b","commit-title":"simplify SELayer usage","language":"Python","id":"5ecccb3808efe3e7d72c139ed2030cfbbbf2f6a1","model-score":0.14,"author-id":null,"project-id":66070,"delta-file-score":0.68473357,"diff":"diff --git a/kale/embed/video/se_res3d.py b/kale/embed/video/se_res3d.py\nindex c682f8eb..65a318c1 100644\n--- a/kale/embed/video/se_res3d.py\n+++ b/kale/embed/video/se_res3d.py\n@@ -66,20 +66,4 @@ def _se_video_resnet_rgb(arch, attention, pretrained=False, progress=True, **kwa\n \n-    # Add channel-temporal-wise SELayer\n-    elif attention == \"SELayerCT\":\n-        se_layer = get_selayer(attention)\n-        layer_schedule = [\n-            (\"layer1\", \"0\", 64, temporal_length),\n-            (\"layer1\", \"1\", 64, temporal_length),\n-            (\"layer2\", \"0\", 128, temporal_length // 2),\n-            (\"layer2\", \"1\", 128, temporal_length // 2),\n-            (\"layer3\", \"0\", 256, temporal_length // 4),\n-            (\"layer3\", \"1\", 256, temporal_length // 4),\n-            (\"layer4\", \"0\", 512, max(1, temporal_length // 8)),\n-            (\"layer4\", \"1\", 512, max(1, temporal_length // 8)),\n-        ]\n-        for layer_name, block_idx, channels, temporal in layer_schedule:\n-            getattr(model, layer_name)._modules[block_idx].add_module(attention, se_layer(channels, temporal))\n-\n-    # Add temporal-channel-wise SELayer\n-    elif attention == \"SELayerTC\":\n+    # Add channel-temporal & temporal-channel SELayer\n+    elif attention in [\"SELayerCT\", \"SELayerTC\"]:\n         se_layer = get_selayer(attention)\n@@ -132,4 +116,4 @@ def _se_video_resnet_flow(arch, attention, pretrained=False, progress=True, **kw\n \n-    # Add channel-temporal-wise SELayer\n-    elif attention == \"SELayerCT\":\n+    # Add channel-temporal & temporal-channel SELayer\n+    elif attention in [\"SELayerCT\", \"SELayerTC\"]:\n         se_layer = get_selayer(attention)\n@@ -148,18 +132,2 @@ def _se_video_resnet_flow(arch, attention, pretrained=False, progress=True, **kw\n \n-    # Add temporal-channel-wise SELayer\n-    elif attention == \"SELayerTC\":\n-        se_layer = get_selayer(attention)\n-        layer_schedule = [\n-            (\"layer1\", \"0\", 64, temporal_length),\n-            (\"layer1\", \"1\", 64, temporal_length),\n-            (\"layer2\", \"0\", 128, temporal_length // 2),\n-            (\"layer2\", \"1\", 128, temporal_length // 2),\n-            (\"layer3\", \"0\", 256, temporal_length // 4),\n-            (\"layer3\", \"1\", 256, temporal_length // 4),\n-            (\"layer4\", \"0\", 512, max(1, temporal_length // 8)),\n-            (\"layer4\", \"1\", 512, max(1, temporal_length // 8)),\n-        ]\n-        for layer_name, block_idx, channels, temporal in layer_schedule:\n-            getattr(model, layer_name)._modules[block_idx].add_module(attention, se_layer(channels, temporal))\n-\n     else:\n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":44,"what-changed":"main already has high cyclomatic complexity, and now it increases in Lines of Code from 166 to 189","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":"quantile_binning_and_est_errors","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":"kale/interpret/uncertainty_utils.py","refactoring-examples":[{"architectural-component-id":null,"author-name":"xianyuanliu","training-data":{"loc-added":"4","loc-deleted":"13","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"8.816158827775617"},"author-email":"19544506+xianyuanliu@users.noreply.github.com","commit-full-message":"","commit-date":"2025-10-13T16:10:03Z","current-rev":"05dc1b5b","filename":"pykale/kale/embed/video/res3d.py","previous-rev":"e2b09c3d","commit-title":"remove unuse functions","language":"Python","id":"cd249f71e263eb51fddd3e95a5bff314a4ebcbfe","model-score":0.54,"author-id":null,"project-id":66070,"delta-file-score":0.27077925,"diff":"diff --git a/kale/embed/video/res3d.py b/kale/embed/video/res3d.py\nindex 7b7ac168..81256c4b 100644\n--- a/kale/embed/video/res3d.py\n+++ b/kale/embed/video/res3d.py\n@@ -112,4 +112,2 @@ class BasicBlock(nn.Module):\n             out = self.SELayerC(out)\n-        if \"SELayerCT\" in dir(self):\n-            out = self.SELayerCT(out)\n         if \"SELayerMC\" in dir(self):\n@@ -118,15 +116,8 @@ class BasicBlock(nn.Module):\n             out = self.SELayerMAC(out)\n-\n         if \"SELayerT\" in dir(self):  # check temporal-wise\n             out = self.SELayerT(out)\n-\n-        if \"SELayerCTc\" in dir(self):  # check channel-temporal-wise\n-            out = self.SELayerCTc(out)\n-        if \"SELayerCTt\" in dir(self):\n-            out = self.SELayerCTt(out)\n-\n-        if \"SELayerTCt\" in dir(self):  # check temporal-channel-wise\n-            out = self.SELayerTCt(out)\n-        if \"SELayerTCc\" in dir(self):\n-            out = self.SELayerTCc(out)\n+        if \"SELayerCT\" in dir(self):\n+            out = self.SELayerCT(out)\n+        if \"SELayerTC\" in dir(self):\n+            out = self.SELayerTC(out)\n \n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"xianyuanliu","training-data":{"loc-added":"4","loc-deleted":"40","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.62","delta-n-functions":"0","current-file-score":"9.6882083290695"},"author-email":"19544506+xianyuanliu@users.noreply.github.com","commit-full-message":"","commit-date":"2025-10-13T16:21:27Z","current-rev":"bf57597c","filename":"pykale/kale/embed/video/se_i3d.py","previous-rev":"05dc1b5b","commit-title":"simplify SELayer usage","language":"Python","id":"e19f247d4295b07be33df8cc3049b1c82d2dc7e8","model-score":0.29,"author-id":null,"project-id":66070,"delta-file-score":0.7666241,"diff":"diff --git a/kale/embed/video/se_i3d.py b/kale/embed/video/se_i3d.py\nindex e447cb50..e6a747e5 100644\n--- a/kale/embed/video/se_i3d.py\n+++ b/kale/embed/video/se_i3d.py\n@@ -60,24 +60,5 @@ class SEInceptionI3DRGB(nn.Module):\n             model.Mixed_4f.add_module(attention, se_layer(temporal_length // 4))\n-            # model.Mixed_5b.add_module(attention, SELayerT(temporal_length//8))\n-            # model.Mixed_5c.add_module(attention, SELayerT(temporal_length//8))\n \n-        # Add channel-temporal-wise SELayer\n-        elif attention == \"SELayerCT\":\n-            se_layer = get_selayer(attention)\n-            channel_schedule = [\n-                (\"Mixed_3b\", 256, temporal_length // 2),\n-                (\"Mixed_3c\", 480, temporal_length // 2),\n-                (\"Mixed_4b\", 512, temporal_length // 4),\n-                (\"Mixed_4c\", 512, temporal_length // 4),\n-                (\"Mixed_4d\", 512, temporal_length // 4),\n-                (\"Mixed_4e\", 528, temporal_length // 4),\n-                (\"Mixed_4f\", 832, temporal_length // 4),\n-                (\"Mixed_5b\", 832, max(1, temporal_length // 8)),\n-                (\"Mixed_5c\", 1024, max(1, temporal_length // 8)),\n-            ]\n-            for module_name, channels, temporal in channel_schedule:\n-                getattr(model, module_name).add_module(attention, se_layer(channels, temporal))\n-\n-        # Add temporal-channel-wise SELayer\n-        elif attention == \"SELayerTC\":\n+        # Add channel-temporal & temporal-channel SELayer\n+        elif attention in [\"SELayerCT\", \"SELayerTC\"]:\n             se_layer = get_selayer(attention)\n@@ -138,21 +119,4 @@ class SEInceptionI3DFlow(nn.Module):\n \n-        # Add channel-temporal-wise SELayer\n-        elif attention == \"SELayerCT\":\n-            se_layer = get_selayer(attention)\n-            channel_schedule = [\n-                (\"Mixed_3b\", 256, temporal_length // 4),\n-                (\"Mixed_3c\", 480, temporal_length // 4),\n-                (\"Mixed_4b\", 512, temporal_length // 8),\n-                (\"Mixed_4c\", 512, temporal_length // 8),\n-                (\"Mixed_4d\", 512, temporal_length // 8),\n-                (\"Mixed_4e\", 528, temporal_length // 8),\n-                (\"Mixed_4f\", 832, temporal_length // 8),\n-                (\"Mixed_5b\", 832, max(1, temporal_length // 16)),\n-                (\"Mixed_5c\", 1024, max(1, temporal_length // 16)),\n-            ]\n-            for module_name, channels, temporal in channel_schedule:\n-                getattr(model, module_name).add_module(attention, se_layer(channels, temporal))\n-\n-        # Add temporal-channel-wise SELayer\n-        elif attention == \"SELayerTC\":\n+        # Add channel-temporal & temporal-channel SELayer\n+        elif attention in [\"SELayerCT\", \"SELayerTC\"]:\n             se_layer = get_selayer(attention)\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"xianyuanliu","training-data":{"loc-added":"4","loc-deleted":"36","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.8","delta-n-functions":"0","current-file-score":"8.283981080161325"},"author-email":"19544506+xianyuanliu@users.noreply.github.com","commit-full-message":"","commit-date":"2025-10-13T16:21:27Z","current-rev":"bf57597c","filename":"pykale/kale/embed/video/se_res3d.py","previous-rev":"05dc1b5b","commit-title":"simplify SELayer usage","language":"Python","id":"5ecccb3808efe3e7d72c139ed2030cfbbbf2f6a1","model-score":0.14,"author-id":null,"project-id":66070,"delta-file-score":0.68473357,"diff":"diff --git a/kale/embed/video/se_res3d.py b/kale/embed/video/se_res3d.py\nindex c682f8eb..65a318c1 100644\n--- a/kale/embed/video/se_res3d.py\n+++ b/kale/embed/video/se_res3d.py\n@@ -66,20 +66,4 @@ def _se_video_resnet_rgb(arch, attention, pretrained=False, progress=True, **kwa\n \n-    # Add channel-temporal-wise SELayer\n-    elif attention == \"SELayerCT\":\n-        se_layer = get_selayer(attention)\n-        layer_schedule = [\n-            (\"layer1\", \"0\", 64, temporal_length),\n-            (\"layer1\", \"1\", 64, temporal_length),\n-            (\"layer2\", \"0\", 128, temporal_length // 2),\n-            (\"layer2\", \"1\", 128, temporal_length // 2),\n-            (\"layer3\", \"0\", 256, temporal_length // 4),\n-            (\"layer3\", \"1\", 256, temporal_length // 4),\n-            (\"layer4\", \"0\", 512, max(1, temporal_length // 8)),\n-            (\"layer4\", \"1\", 512, max(1, temporal_length // 8)),\n-        ]\n-        for layer_name, block_idx, channels, temporal in layer_schedule:\n-            getattr(model, layer_name)._modules[block_idx].add_module(attention, se_layer(channels, temporal))\n-\n-    # Add temporal-channel-wise SELayer\n-    elif attention == \"SELayerTC\":\n+    # Add channel-temporal & temporal-channel SELayer\n+    elif attention in [\"SELayerCT\", \"SELayerTC\"]:\n         se_layer = get_selayer(attention)\n@@ -132,4 +116,4 @@ def _se_video_resnet_flow(arch, attention, pretrained=False, progress=True, **kw\n \n-    # Add channel-temporal-wise SELayer\n-    elif attention == \"SELayerCT\":\n+    # Add channel-temporal & temporal-channel SELayer\n+    elif attention in [\"SELayerCT\", \"SELayerTC\"]:\n         se_layer = get_selayer(attention)\n@@ -148,18 +132,2 @@ def _se_video_resnet_flow(arch, attention, pretrained=False, progress=True, **kw\n \n-    # Add temporal-channel-wise SELayer\n-    elif attention == \"SELayerTC\":\n-        se_layer = get_selayer(attention)\n-        layer_schedule = [\n-            (\"layer1\", \"0\", 64, temporal_length),\n-            (\"layer1\", \"1\", 64, temporal_length),\n-            (\"layer2\", \"0\", 128, temporal_length // 2),\n-            (\"layer2\", \"1\", 128, temporal_length // 2),\n-            (\"layer3\", \"0\", 256, temporal_length // 4),\n-            (\"layer3\", \"1\", 256, temporal_length // 4),\n-            (\"layer4\", \"0\", 512, max(1, temporal_length // 8)),\n-            (\"layer4\", \"1\", 512, max(1, temporal_length // 8)),\n-        ]\n-        for layer_name, block_idx, channels, temporal in layer_schedule:\n-            getattr(model, layer_name)._modules[block_idx].add_module(attention, se_layer(channels, temporal))\n-\n     else:\n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":274,"what-changed":"quantile_binning_and_est_errors has a cyclomatic complexity of 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":"introduced"},{"method":"plot_cumulative","why-it-occurs":"Overly long functions make the code harder to read. The recommended maximum function length for the Python language is 70 lines of code. Severity: Brain Method - Complex Method - Long Method.","name":"Large Method","file":"kale/interpret/uncertainty_utils.py","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":340,"what-changed":"plot_cumulative has 103 lines, threshold = 70","how-to-fix":"We recommend to be careful here -- just splitting long functions don't necessarily make the code easier to read. Instead, look for natural chunks inside the functions that expresses a specific task or concern. Often, such concerns are indicated by a Code Comment followed by an if-statement. Use the [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring to encapsulate that concern.","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":"tests/interpret/test_uncertainty_utils.py","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":102,"what-changed":"The module contains 4 functions with similar structure: TestCorrelationInputValidation.test_empty_arrays,TestCorrelationInputValidation.test_mismatched_array_lengths,TestPlotFunctions.test_plot_cumulative_basic,TestPlotFunctions.test_plot_cumulative_with_save","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"}]},"positive-impact-count":18,"repo":"pykale","code-health":7.583682034022121,"version":"3.0","authors":["Ji Zhongwei"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":9,"number-of-files-touched":4,"findings":[{"name":"Lines of Code in a Single File","file":"kale/interpret/uncertainty_quantiles.py","change-type":"fixed","change-level":"improvement","is-hotspot?":false,"why-it-occurs":"This module has 598 lines of code (comments stripped away). This puts the module at risk of evolving into a Brain Class. Brain Classes are problematic since changes become more complex over time, harder to test, and challenging to refactor. Act now to prevent future maintenance issues.","how-to-fix":"Look for opportunities to modularize the design. This is done by identifying groups of functions that represent different responsibilities and/or operate on different data. Once you have identified the different responsibilities, then use refactorings like [EXTRACT CLASS](https://refactoring.com/catalog/extractClass.html).","what-changed":"The lines of code in this module is no longer above the threshold"},{"name":"Overall Function Size","file":"kale/interpret/uncertainty_quantiles.py","change-type":"fixed","change-level":"improvement","is-hotspot?":false,"what-changed":"The median function size in this module is no longer above the threshold"},{"method":"generate_fig_individual_bin_comparison","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":"kale/interpret/uncertainty_quantiles.py","change-level":"improvement","is-hotspot?":false,"line":385,"what-changed":"generate_fig_individual_bin_comparison is no longer above the threshold for cyclomatic complexity","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":"fixed"},{"method":"generate_fig_comparing_bins","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":"kale/interpret/uncertainty_quantiles.py","change-level":"improvement","is-hotspot?":false,"line":910,"what-changed":"generate_fig_comparing_bins is no longer above the threshold for cyclomatic complexity","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":"fixed"},{"method":"quantile_binning_and_est_errors","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":"kale/interpret/uncertainty_quantiles.py","change-level":"improvement","is-hotspot?":false,"line":47,"what-changed":"quantile_binning_and_est_errors is no longer above the threshold for cyclomatic complexity","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":"fixed"},{"method":"plot_cumulative","why-it-occurs":"Overly long functions make the code harder to read. The recommended maximum function length for the Python language is 70 lines of code. Severity: Brain Method - Complex Method - Long Method.","name":"Large Method","file":"kale/interpret/uncertainty_quantiles.py","change-level":"improvement","is-hotspot?":false,"line":274,"what-changed":"plot_cumulative is no longer above the threshold for lines of code","how-to-fix":"We recommend to be careful here -- just splitting long functions don't necessarily make the code easier to read. Instead, look for natural chunks inside the functions that expresses a specific task or concern. Often, such concerns are indicated by a Code Comment followed by an if-statement. Use the [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring to encapsulate that concern.","change-type":"fixed"},{"method":"generate_fig_individual_bin_comparison","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":"kale/interpret/uncertainty_quantiles.py","change-level":"improvement","is-hotspot?":false,"line":385,"what-changed":"generate_fig_individual_bin_comparison is no longer above the threshold for logical blocks with deeply nested code","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":"fixed"},{"method":"generate_fig_comparing_bins","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":"kale/interpret/uncertainty_quantiles.py","change-level":"improvement","is-hotspot?":false,"line":910,"what-changed":"generate_fig_comparing_bins is no longer above the threshold for logical blocks with deeply nested code","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":"fixed"},{"name":"Overall Code Complexity","file":"kale/interpret/uncertainty_quantiles.py","change-type":"improved","change-level":"improvement","is-hotspot?":false,"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).","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","what-changed":"The mean cyclomatic complexity decreases from 13.57 to 5.45, threshold = 4"},{"method":"generate_fig_individual_bin_comparison","why-it-occurs":"Deep nested logic means that you have control structures like if-statements or loops inside other control structures. Deep nested logic increases the cognitive load on the programmer reading the code. The human working memory has a maximum capacity of 3-4 items; beyond that threshold, we struggle with keeping things in our head. Consequently, deep nested logic has a strong correlation to defects and accounts for roughly 20% of all programming mistakes.\n\nCodeScene measures the maximum nesting depth inside each function. The deeper the nesting, the lower the code health. The threshold for the Python language is  levels of nesting.","name":"Deep, Nested Complexity","file":"kale/interpret/uncertainty_quantiles.py","change-level":"improvement","is-hotspot?":false,"line":385,"what-changed":"generate_fig_individual_bin_comparison is no longer above the threshold for nested complexity depth","how-to-fix":"Occassionally, it's possible to get rid of the nested logic by [Replacing Conditionals with Guard Clauses](https://refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html).\n\nAnother viable strategy is to identify smaller building blocks inside the nested chunks of logic and extract those responsibilities into smaller, cohesive, and well-named functions. The [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring explains the steps.","change-type":"fixed"},{"method":"generate_fig_comparing_bins","why-it-occurs":"Deep nested logic means that you have control structures like if-statements or loops inside other control structures. Deep nested logic increases the cognitive load on the programmer reading the code. The human working memory has a maximum capacity of 3-4 items; beyond that threshold, we struggle with keeping things in our head. Consequently, deep nested logic has a strong correlation to defects and accounts for roughly 20% of all programming mistakes.\n\nCodeScene measures the maximum nesting depth inside each function. The deeper the nesting, the lower the code health. The threshold for the Python language is  levels of nesting.","name":"Deep, Nested Complexity","file":"kale/interpret/uncertainty_quantiles.py","change-level":"improvement","is-hotspot?":false,"line":910,"what-changed":"generate_fig_comparing_bins is no longer above the threshold for nested complexity depth","how-to-fix":"Occassionally, it's possible to get rid of the nested logic by [Replacing Conditionals with Guard Clauses](https://refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html).\n\nAnother viable strategy is to identify smaller building blocks inside the nested chunks of logic and extract those responsibilities into smaller, cohesive, and well-named functions. The [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring explains the steps.","change-type":"fixed"},{"method":"quantile_binning_and_est_errors","why-it-occurs":"Functions with many arguments indicate either a) low cohesion where the function has too many responsibilities, or b) a missing abstraction that encapsulates those arguments.\n\nThe threshold for the Python language is 4 function arguments.","name":"Excess Number of Function Arguments","file":"kale/interpret/uncertainty_quantiles.py","change-level":"improvement","is-hotspot?":false,"line":47,"what-changed":"quantile_binning_and_est_errors is no longer above the threshold for number of arguments","how-to-fix":"Start by investigating the responsibilities of the function. Make sure it doesn't do too many things, in which case it should be split into smaller and more cohesive functions. Consider the refactoring [INTRODUCE PARAMETER OBJECT](https://refactoring.com/catalog/introduceParameterObject.html) to encapsulate arguments that refer to the same logical concept.","change-type":"fixed"},{"method":"plot_cumulative","why-it-occurs":"Functions with many arguments indicate either a) low cohesion where the function has too many responsibilities, or b) a missing abstraction that encapsulates those arguments.\n\nThe threshold for the Python language is 4 function arguments.","name":"Excess Number of Function Arguments","file":"kale/interpret/uncertainty_quantiles.py","change-level":"improvement","is-hotspot?":false,"line":274,"what-changed":"plot_cumulative is no longer above the threshold for number of arguments","how-to-fix":"Start by investigating the responsibilities of the function. Make sure it doesn't do too many things, in which case it should be split into smaller and more cohesive functions. Consider the refactoring [INTRODUCE PARAMETER OBJECT](https://refactoring.com/catalog/introduceParameterObject.html) to encapsulate arguments that refer to the same logical concept.","change-type":"fixed"},{"method":"test_qbin_pipeline","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":"tests/pipeline/test_uncertainty_qbin_pipeline.py","change-level":"improvement","is-hotspot?":false,"line":170,"what-changed":"test_qbin_pipeline is no longer above the threshold for cyclomatic complexity","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":"fixed"},{"method":"test_qbin_pipeline","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":"tests/pipeline/test_uncertainty_qbin_pipeline.py","change-level":"improvement","is-hotspot?":false,"line":170,"what-changed":"test_qbin_pipeline is no longer above the threshold for logical blocks with deeply nested code","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":"fixed"},{"name":"Low Cohesion","file":"kale/interpret/box_plot.py","change-type":"fixed","change-level":"improvement","is-hotspot?":false,"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.","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).","what-changed":"The number of different responsibilities in this module is no longer above the threshold"},{"method":"TestPlotFunctions.test_plot_cumulative_basic","why-it-occurs":"Functions with many arguments indicate either a) low cohesion where the function has too many responsibilities, or b) a missing abstraction that encapsulates those arguments.\n\nThe threshold for the Python language is 4 function arguments.","name":"Excess Number of Function Arguments","file":"tests/interpret/test_uncertainty_quantiles.py","change-level":"improvement","is-hotspot?":false,"line":169,"what-changed":"TestPlotFunctions.test_plot_cumulative_basic is no longer above the threshold for number of arguments","how-to-fix":"Start by investigating the responsibilities of the function. Make sure it doesn't do too many things, in which case it should be split into smaller and more cohesive functions. Consider the refactoring [INTRODUCE PARAMETER OBJECT](https://refactoring.com/catalog/introduceParameterObject.html) to encapsulate arguments that refer to the same logical concept.","change-type":"fixed"},{"method":"TestPlotFunctions.test_plot_cumulative_with_save","why-it-occurs":"Functions with many arguments indicate either a) low cohesion where the function has too many responsibilities, or b) a missing abstraction that encapsulates those arguments.\n\nThe threshold for the Python language is 4 function arguments.","name":"Excess Number of Function Arguments","file":"tests/interpret/test_uncertainty_quantiles.py","change-level":"improvement","is-hotspot?":false,"line":206,"what-changed":"TestPlotFunctions.test_plot_cumulative_with_save is no longer above the threshold for number of arguments","how-to-fix":"Start by investigating the responsibilities of the function. Make sure it doesn't do too many things, in which case it should be split into smaller and more cohesive functions. Consider the refactoring [INTRODUCE PARAMETER OBJECT](https://refactoring.com/catalog/introduceParameterObject.html) to encapsulate arguments that refer to the same logical concept.","change-type":"fixed"}]},"notices":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"external-review-provider":"GitHub"},"analysistime":"2025-12-28T15:31:43.000Z","project-name":"pykale","repository":"https://github.com/pykale/pykale.git"}}