{"results":{"result":{"added-files":{"code-health":9.358650006604803,"old-code-health":0.0,"files":[{"file":"gama.export/src/gama/export/ExportActivator.java","loc":20,"code-health":10.0},{"file":"gama.export/src/gama/export/GamaZipBuilder.java","loc":206,"code-health":8.569894424318617},{"file":"gama.export/src/gama/export/ZipHelper.java","loc":97,"code-health":10.0},{"file":"gama.export/src/gama/export/dependency/BundleDependencyAnalyzer.java","loc":145,"code-health":8.545379580978913},{"file":"gama.export/src/gama/export/ExportHelper.java","loc":29,"code-health":10.0},{"file":"gama.export/src/gama/export/ui/ExportModelDialog.java","loc":146,"code-health":10.0},{"file":"gama.ui.editor/src/gaml/compiler/ui/editor/toolbar/ExportExperimentSelectionListener.java","loc":71,"code-health":10.0},{"file":"gama.ui.application/src/gama/ui/application/workbench/PickExperimentDialog.java","loc":70,"code-health":10.0},{"file":"gama.ui.application/src/gama/ui/application/workbench/StartupModelHelper.java","loc":133,"code-health":9.387218218812514},{"file":"gama.ui.experiment/src/gama/ui/experiment/commands/SelectExperiment.java","loc":20,"code-health":10.0},{"file":"gama.ui.navigator/src/gama/ui/navigator/commands/ExportProjectAsSimulation.java","loc":118,"code-health":9.240656298427343}]},"external-review-url":"https://github.com/gama-platform/gama/pull/1121","old-code-health":7.902613392001834,"modified-files":{"code-health":7.840581807236393,"old-code-health":7.902613392001834,"files":[{"file":"gama.ui.application/src/gama/ui/application/workbench/ApplicationWorkbenchAdvisor.java","loc":124,"old-loc":127,"code-health":8.95517096544394,"old-code-health":8.882578852711319},{"file":"gama.workspace/src/gama/workspace/manager/WorkspaceManager.java","loc":325,"old-loc":324,"code-health":7.1088648194613215,"old-code-health":7.1088648194613215},{"file":"gama.ui.application/src/gama/ui/application/workbench/PerspectiveHelper.java","loc":303,"old-loc":299,"code-health":8.785903643346572,"old-code-health":8.810649153753822},{"file":"gama.api/src/gama/api/utils/prefs/GamaPreferences.java","loc":626,"old-loc":627,"code-health":9.096655465156704,"old-code-health":9.096655465156704},{"file":"gaml.compiler/src/gaml/compiler/prototypes/FacetArtefact.java","loc":162,"old-loc":160,"code-health":8.335526084425592,"old-code-health":8.335526084425592},{"file":"gama.dev/src/gama/dev/FLAGS.java","loc":19,"old-loc":18,"code-health":10.0,"old-code-health":10.0},{"file":"gama.ui.editor/src/gaml/compiler/ui/editor/GamlEditor.java","loc":854,"old-loc":847,"code-health":6.706999151260716,"old-code-health":6.706999151260716},{"file":"gama.ui.application/src/gama/ui/application/Application.java","loc":128,"old-loc":124,"code-health":9.536386775820924,"old-code-health":9.536386775820924},{"file":"gama.api/src/gama/api/GAMA.java","loc":427,"old-loc":419,"code-health":7.325861446783724,"old-code-health":7.9087644186687704},{"file":"gama.core/src/gama/core/experiment/ExperimentSpecies.java","loc":669,"old-loc":661,"code-health":7.580659696942534,"old-code-health":7.580659696942534},{"file":"gama.ui.experiment/src/gama/ui/experiment/perspective/SimulationPerspective.java","loc":37,"old-loc":35,"code-health":10.0,"old-code-health":10.0},{"file":"gama.workspace/src/gama/workspace/metadata/FileMetaDataProvider.java","loc":470,"old-loc":469,"code-health":6.771753017248467,"old-code-health":6.771753017248467},{"file":"gama.api/src/gama/api/kernel/simulation/DefaultExperimentController.java","loc":239,"old-loc":238,"code-health":8.009360876139223,"old-code-health":8.009360876139223},{"file":"gama.api/src/gama/api/ui/IGui.java","loc":146,"old-loc":146,"code-health":9.387218218812514,"old-code-health":9.387218218812514},{"file":"gama.ui.shared/src/gama/ui/shared/utils/LaunchingOverlay.java","loc":274,"old-loc":269,"code-health":7.484843848750904,"old-code-health":7.788037646779413},{"file":"gama.ui.shared/src/gama/ui/shared/utils/SwtGui.java","loc":526,"old-loc":526,"code-health":8.418757860080511,"old-code-health":8.418757860080511}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"1121","analysis-time":"2026-07-24T08:43:17Z","negative-impact-count":16,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":3,"commits":["d4ae6364f1e5a435bf802b22104a680a035cd789","93910bdbf16ecce8900e0c705ae8ef294977dfd9","7ad4a4aed80bfe11cbef104e4bb8fe8ff4f1d988","c874ec6f1051f289a359dfc60b33801bd2db8a20","bbd13120d2180e90240ed17159bd3f86f4b863bb","683cdf662c4331a44d3a6d4df5b69f1e48329918","7913b625d0c386285e95adca596b5ec6968a38a9","c9c39941cf2e58bc740db5847a55f5fe344dc0d2","3c003e8f80b43fb12a7e38bed4bc03b84052aeaa","acdc51518e13c8774217285e8dbbd2df168fc87c","488533b4fc7e8de2b9a54e15d289936cbec79463","c8ec3cb16fd63171980120cc3601ba664e96c478","a71fe7a94b3c5be68d4be0dd3c553479b17aee4e","a9b657ea2e0fc24caf9d6ac85365aaffe5e89d03","f07d69caae9c7d09cee297f211dc94a6bf7cbf9d","401b02370e448295c1c17cc94f0e2cd05b6d18f3","fb233a3a622258d45728ff2e5e432792dff73419","a1bb9262e38f1130c383ce758df8e8f8b3a5f81a","395b68c9115aafbd4ec338b9cf794da6a1f6932c"],"is-negative-review":true,"negative-findings":{"number-of-types":5,"number-of-files-touched":7,"findings":[{"method":"openPerspective","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":"gama.ui.application/src/gama/ui/application/workbench/PerspectiveHelper.java","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":"java","improvement-type":"Complex Conditional"}],"change-level":"warning","is-hotspot?":false,"line":360,"what-changed":"openPerspective increases from 1 complex conditionals with 2 branches to 1 complex conditionals with 3 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":"degraded"},{"method":"zip","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the Java language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"gama.export/src/gama/export/GamaZipBuilder.java","refactoring-examples":[{"diff":"diff --git a/ComplexMethod.java b/ComplexMethod.java\nindex 842ae72ed1..540a630f78 100644\n--- a/ComplexMethod.java\n+++ b/ComplexMethod.java\n@@ -1,19 +1,19 @@\n public class ComplexMethod {\n \tpublic void postItem(Item a) throws ValidationException {\n \t\tif (a.isNew()) {\n-\t\t\t// Validate new object\n-\t\t\tif (a.getX() != null && a.getY() != null && a.getZ() != null) {\n-\t\t\t\tpost(a);\n-\t\t\t} else {\n-\t\t\t\tthrow new ValidationException(\"incomplete new object\");\n-\t\t\t}\n+\t\t\tpostNew(a);\n \t\t} else {\n-\t\t\t// Validate update\n-\t\t\tif (a.getX() < 10 && a.getY() > 25 && a.getZ() > 0) {\n-\t\t\t\tpost(a);\n-\t\t\t} else {\n-\t\t\t\tthrow new ValidationException(\"invalid update\");\n-\t\t\t}\n+\t\t\tpostUpdate(a);\n \t\t}\n \t}\n+\n+\tprivate void postNew(Item a) throws ValidationException {\n+\t\ta.ensureComplete();\n+\t\tpost(a);\n+\t}\n+\n+\tprivate void postUpdate(Item a) throws ValidationException {\n+\t\ta.ensureValidUpdate();\n+\t\tpost(a);\n+\t}\n }\n","language":"java","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":161,"what-changed":"zip has a cyclomatic complexity of 18, 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":"filter","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the Java language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"gama.export/src/gama/export/GamaZipBuilder.java","refactoring-examples":[{"diff":"diff --git a/ComplexMethod.java b/ComplexMethod.java\nindex 842ae72ed1..540a630f78 100644\n--- a/ComplexMethod.java\n+++ b/ComplexMethod.java\n@@ -1,19 +1,19 @@\n public class ComplexMethod {\n \tpublic void postItem(Item a) throws ValidationException {\n \t\tif (a.isNew()) {\n-\t\t\t// Validate new object\n-\t\t\tif (a.getX() != null && a.getY() != null && a.getZ() != null) {\n-\t\t\t\tpost(a);\n-\t\t\t} else {\n-\t\t\t\tthrow new ValidationException(\"incomplete new object\");\n-\t\t\t}\n+\t\t\tpostNew(a);\n \t\t} else {\n-\t\t\t// Validate update\n-\t\t\tif (a.getX() < 10 && a.getY() > 25 && a.getZ() > 0) {\n-\t\t\t\tpost(a);\n-\t\t\t} else {\n-\t\t\t\tthrow new ValidationException(\"invalid update\");\n-\t\t\t}\n+\t\t\tpostUpdate(a);\n \t\t}\n \t}\n+\n+\tprivate void postNew(Item a) throws ValidationException {\n+\t\ta.ensureComplete();\n+\t\tpost(a);\n+\t}\n+\n+\tprivate void postUpdate(Item a) throws ValidationException {\n+\t\ta.ensureValidUpdate();\n+\t\tpost(a);\n+\t}\n }\n","language":"java","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":135,"what-changed":"filter 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":"filter","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":"gama.export/src/gama/export/GamaZipBuilder.java","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":"java","improvement-type":"Complex Conditional"}],"change-level":"warning","is-hotspot?":false,"line":141,"what-changed":"filter has 1 complex conditionals with 6 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"},{"method":"getMinimalGamaPluginSet","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the Java language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"gama.export/src/gama/export/dependency/BundleDependencyAnalyzer.java","refactoring-examples":[{"diff":"diff --git a/ComplexMethod.java b/ComplexMethod.java\nindex 842ae72ed1..540a630f78 100644\n--- a/ComplexMethod.java\n+++ b/ComplexMethod.java\n@@ -1,19 +1,19 @@\n public class ComplexMethod {\n \tpublic void postItem(Item a) throws ValidationException {\n \t\tif (a.isNew()) {\n-\t\t\t// Validate new object\n-\t\t\tif (a.getX() != null && a.getY() != null && a.getZ() != null) {\n-\t\t\t\tpost(a);\n-\t\t\t} else {\n-\t\t\t\tthrow new ValidationException(\"incomplete new object\");\n-\t\t\t}\n+\t\t\tpostNew(a);\n \t\t} else {\n-\t\t\t// Validate update\n-\t\t\tif (a.getX() < 10 && a.getY() > 25 && a.getZ() > 0) {\n-\t\t\t\tpost(a);\n-\t\t\t} else {\n-\t\t\t\tthrow new ValidationException(\"invalid update\");\n-\t\t\t}\n+\t\t\tpostUpdate(a);\n \t\t}\n \t}\n+\n+\tprivate void postNew(Item a) throws ValidationException {\n+\t\ta.ensureComplete();\n+\t\tpost(a);\n+\t}\n+\n+\tprivate void postUpdate(Item a) throws ValidationException {\n+\t\ta.ensureValidUpdate();\n+\t\tpost(a);\n+\t}\n }\n","language":"java","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":207,"what-changed":"getMinimalGamaPluginSet 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":"getMinimalGamaPluginSet","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":"gama.export/src/gama/export/dependency/BundleDependencyAnalyzer.java","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":"java","improvement-type":"Complex Conditional"}],"change-level":"warning","is-hotspot?":false,"line":236,"what-changed":"getMinimalGamaPluginSet has 1 complex conditionals with 3 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"},{"method":"getMinimalGamaPluginSet","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":"gama.export/src/gama/export/dependency/BundleDependencyAnalyzer.java","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":207,"what-changed":"getMinimalGamaPluginSet 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"},{"method":"getMinimalGamaPluginSet","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 Java language is 4 levels of nesting.","name":"Deep, Nested Complexity","file":"gama.export/src/gama/export/dependency/BundleDependencyAnalyzer.java","refactoring-examples":[{"architectural-component-id":null,"author-name":"Baptiste Lesquoy","training-data":{"loc-added":"43","loc-deleted":"44","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"2.0","delta-n-functions":"0","current-file-score":"8.679575849015766"},"author-email":"lesquoy.baptiste@gmail.com","commit-full-message":"","commit-date":"2026-07-07T05:19:26Z","current-rev":"8f16712fe","filename":"gama/gama.core/src/gama/core/util/file/GamaCSVFile.java","previous-rev":"0ef823b50","commit-title":"[Files] refactor csv reading + fixes the exception in #1127","language":"Java","id":"bdd415e8b84060b15aa056022e28f27252c1bc5e","model-score":0.09,"author-id":null,"project-id":51964,"delta-file-score":1.0546844,"diff":"diff --git a/gama.core/src/gama/core/util/file/GamaCSVFile.java b/gama.core/src/gama/core/util/file/GamaCSVFile.java\nindex 140a28f86..97cf7de16 100644\n--- a/gama.core/src/gama/core/util/file/GamaCSVFile.java\n+++ b/gama.core/src/gama/core/util/file/GamaCSVFile.java\n@@ -416,58 +416,41 @@ public class GamaCSVFile extends GamaFile<IMatrix<Object>, Object> implements IF\n \t\t\tscope.getGui().getStatus().beginTask(task, IStatusMessage.DOWNLOAD_ICON);\n-\t\t\tif (t == IType.INT) {\n-\t\t\t\tmatrix = GamaMatrixFactory.createIntMatrix((int) userSize.getX(), (int) userSize.getY());\n-\t\t\t\tfinal int[] m = ((GamaIntMatrix) matrix).getMatrix();\n-\t\t\t\tint i = 0;\n-\t\t\t\twhile (reader.readRecord()) {\n-\t\t\t\t\tpercentage = reader.getCurrentRecord() / userSize.getY();\n-\t\t\t\t\tscope.getGui().getStatus().setTaskCompletion(task, percentage);\n-\t\t\t\t\tint nbC = 0;\n-\t\t\t\t\tfor (final String s : reader.getValues()) {\n-\t\t\t\t\t\tm[i++] = Cast.asInt(scope, s);\n-\t\t\t\t\t\tnbC++;\n-\t\t\t\t\t}\n-\t\t\t\t\twhile (nbC < matrix.getCols(null)) {\n-\t\t\t\t\t\tm[i++] = 0;\n-\t\t\t\t\t\tnbC++;\n-\t\t\t\t\t}\n-\t\t\t\t}\n-\t\t\t} else if (t == IType.FLOAT) {\n-\t\t\t\tmatrix = GamaMatrixFactory.createFloatMatrix((int) userSize.getX(), (int) userSize.getY());\n-\t\t\t\tfinal double[] m = ((GamaFloatMatrix) matrix).getMatrix();\n-\t\t\t\tint i = 0;\n-\t\t\t\twhile (reader.readRecord()) {\n-\t\t\t\t\tpercentage = reader.getCurrentRecord() / userSize.getY();\n-\t\t\t\t\tscope.getGui().getStatus().setTaskCompletion(task, percentage);\n-\t\t\t\t\tint nbC = 0;\n-\t\t\t\t\tfor (final String s : reader.getValues()) {\n-\t\t\t\t\t\tm[i++] = Cast.asFloat(scope, s);\n-\t\t\t\t\t\tnbC++;\n-\t\t\t\t\t}\n-\t\t\t\t\twhile (nbC < matrix.getCols(null)) {\n-\t\t\t\t\t\tm[i++] = 0.0;\n-\t\t\t\t\t\tnbC++;\n+\t\t\tObject defaultVal;\n+\t\t\t\n+\t\t\tswitch (t){\n+\t\t\t\tcase IType.FLOAT:\n+\t\t\t\t\tdefaultVal = 0.0;\n+\t\t\t\t\tmatrix = GamaMatrixFactory.createFloatMatrix((int) userSize.getX(), (int) userSize.getY());\n+\t\t\t\t\tbreak;\n+\t\t\t\tcase IType.INT:\n+\t\t\t\t\tdefaultVal = 0;\n+\t\t\t\t\tmatrix = GamaMatrixFactory.createIntMatrix((int) userSize.getX(), (int) userSize.getY());\n+\t\t\t\t\tbreak;\n+\t\t\t\tdefault:\n+\t\t\t\t\tdefaultVal = null;\n+\t\t\t\t\tmatrix = GamaMatrixFactory.create((int) userSize.getX(), (int) userSize.getY(), Types.STRING);\n+\t\t\t\t\n+\t\t\t}\n+\t\t\t\n+\t\t\tfinal int cols = matrix.getCols(null);\n+\t\t\tfinal int nbElmt = cols * matrix.getRows(null);\n+\t\t\t\n+\t\t\tint i = 0;\n+\t\t\treadingLoop:\n+\t\t\twhile (reader.readRecord()) {\n+\t\t\t\tpercentage = reader.getCurrentRecord() / userSize.getY();\n+\t\t\t\tscope.getGui().getStatus().setTaskCompletion(task, percentage);\n+\t\t\t\tint nbC = 0;\n+\t\t\t\tfor (final String s : reader.getValues()) {\n+\t\t\t\t\tif (i == nbElmt) {\n+\t\t\t\t\t\treportUnprocessedData(scope);\n+\t\t\t\t\t\tbreak readingLoop;\n \t\t\t\t\t}\n+\t\t\t\t\tmatrix.set(scope, i/cols, i%cols, s);\n+\t\t\t\t\ti++;\n+\t\t\t\t\tnbC++;\n \t\t\t\t}\n-\t\t\t} else {\n-\t\t\t\tmatrix = GamaMatrixFactory.create((int) userSize.getX(), (int) userSize.getY(), Types.STRING);\n-\t\t\t\tfinal Object[] m = ((GamaObjectMatrix) matrix).getMatrix();\n-\t\t\t\tint i = 0;\n-\t\t\t\twhile (reader.readRecord()) {\n-\t\t\t\t\tpercentage = reader.getCurrentRecord() / userSize.getY();\n-\t\t\t\t\tscope.getGui().getStatus().setTaskCompletion(task, percentage);\n-\t\t\t\t\tint nbC = 0;\n-\n-\t\t\t\t\tfor (final String s : reader.getValues()) {\n-\t\t\t\t\t\tif (i == m.length) {\n-\t\t\t\t\t\t\tGAMA.reportError(scope, GamaRuntimeException.warning(\"The file \" + getFile(scope).getName()\n-\t\t\t\t\t\t\t\t\t+ \" seems to contain data that have not been processed\", scope), false);\n-\t\t\t\t\t\t\tbreak;\n-\t\t\t\t\t\t}\n-\t\t\t\t\t\tnbC++;\n-\t\t\t\t\t\tm[i++] = s;\n-\t\t\t\t\t}\n-\t\t\t\t\twhile (nbC < matrix.getCols(null)) {\n-\t\t\t\t\t\tm[i++] = null;\n-\t\t\t\t\t\tnbC++;\n-\t\t\t\t\t}\n+\t\t\t\twhile (nbC < cols && i < nbElmt) {\n+\t\t\t\t\tmatrix.set(scope, i/cols, i%cols, defaultVal);\n+\t\t\t\t\ti++;\n+\t\t\t\t\tnbC++;\n \t\t\t\t}\n@@ -481,2 +464,18 @@ public class GamaCSVFile extends GamaFile<IMatrix<Object>, Object> implements IF\n \n+\t/**\n+\t * Reports, as a non-blocking warning, that the file contains more data than the matrix computed from its (possibly\n+\t * cached or under-estimated) metadata can hold. See issue #1127: this happens typically when the file has been\n+\t * modified outside of GAMA (so that the cached dimensions are stale) or when it lacks a trailing newline. The\n+\t * warning is reported only once, when the matrix is full, and the remaining records are ignored instead of throwing\n+\t * an ArrayIndexOutOfBoundsException.\n+\t *\n+\t * @param scope\n+\t *            the scope\n+\t */\n+\tprivate void reportUnprocessedData(final IScope scope) {\n+\t\tGAMA.reportError(scope, GamaRuntimeException.warning(\n+\t\t\t\t\"The file \" + getFile(scope).getName() + \" seems to contain data that have not been processed\", scope),\n+\t\t\t\tfalse);\n+\t}\n+\n \t/**\n","improvement-type":"Deep, Nested Complexity"}],"change-level":"warning","is-hotspot?":false,"line":207,"what-changed":"getMinimalGamaPluginSet has a nested complexity depth of 4, threshold = 4","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":"introduced"},{"method":"pickExperiment","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the Java language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"gama.ui.application/src/gama/ui/application/workbench/StartupModelHelper.java","refactoring-examples":[{"diff":"diff --git a/ComplexMethod.java b/ComplexMethod.java\nindex 842ae72ed1..540a630f78 100644\n--- a/ComplexMethod.java\n+++ b/ComplexMethod.java\n@@ -1,19 +1,19 @@\n public class ComplexMethod {\n \tpublic void postItem(Item a) throws ValidationException {\n \t\tif (a.isNew()) {\n-\t\t\t// Validate new object\n-\t\t\tif (a.getX() != null && a.getY() != null && a.getZ() != null) {\n-\t\t\t\tpost(a);\n-\t\t\t} else {\n-\t\t\t\tthrow new ValidationException(\"incomplete new object\");\n-\t\t\t}\n+\t\t\tpostNew(a);\n \t\t} else {\n-\t\t\t// Validate update\n-\t\t\tif (a.getX() < 10 && a.getY() > 25 && a.getZ() > 0) {\n-\t\t\t\tpost(a);\n-\t\t\t} else {\n-\t\t\t\tthrow new ValidationException(\"invalid update\");\n-\t\t\t}\n+\t\t\tpostUpdate(a);\n \t\t}\n \t}\n+\n+\tprivate void postNew(Item a) throws ValidationException {\n+\t\ta.ensureComplete();\n+\t\tpost(a);\n+\t}\n+\n+\tprivate void postUpdate(Item a) throws ValidationException {\n+\t\ta.ensureValidUpdate();\n+\t\tpost(a);\n+\t}\n }\n","language":"java","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":53,"what-changed":"pickExperiment 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":"pickExperiment","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":"gama.ui.application/src/gama/ui/application/workbench/StartupModelHelper.java","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":53,"what-changed":"pickExperiment 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"},{"method":"getModel","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":"gama.ui.application/src/gama/ui/application/workbench/StartupModelHelper.java","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":144,"what-changed":"getModel 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"},{"method":"runGuiExperiment","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":"gama.api/src/gama/api/GAMA.java","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":389,"what-changed":"runGuiExperiment 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"},{"method":"runGuiExperiment","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 Java language is 4 levels of nesting.","name":"Deep, Nested Complexity","file":"gama.api/src/gama/api/GAMA.java","refactoring-examples":[{"architectural-component-id":null,"author-name":"Baptiste Lesquoy","training-data":{"loc-added":"43","loc-deleted":"44","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"2.0","delta-n-functions":"0","current-file-score":"8.679575849015766"},"author-email":"lesquoy.baptiste@gmail.com","commit-full-message":"","commit-date":"2026-07-07T05:19:26Z","current-rev":"8f16712fe","filename":"gama/gama.core/src/gama/core/util/file/GamaCSVFile.java","previous-rev":"0ef823b50","commit-title":"[Files] refactor csv reading + fixes the exception in #1127","language":"Java","id":"bdd415e8b84060b15aa056022e28f27252c1bc5e","model-score":0.09,"author-id":null,"project-id":51964,"delta-file-score":1.0546844,"diff":"diff --git a/gama.core/src/gama/core/util/file/GamaCSVFile.java b/gama.core/src/gama/core/util/file/GamaCSVFile.java\nindex 140a28f86..97cf7de16 100644\n--- a/gama.core/src/gama/core/util/file/GamaCSVFile.java\n+++ b/gama.core/src/gama/core/util/file/GamaCSVFile.java\n@@ -416,58 +416,41 @@ public class GamaCSVFile extends GamaFile<IMatrix<Object>, Object> implements IF\n \t\t\tscope.getGui().getStatus().beginTask(task, IStatusMessage.DOWNLOAD_ICON);\n-\t\t\tif (t == IType.INT) {\n-\t\t\t\tmatrix = GamaMatrixFactory.createIntMatrix((int) userSize.getX(), (int) userSize.getY());\n-\t\t\t\tfinal int[] m = ((GamaIntMatrix) matrix).getMatrix();\n-\t\t\t\tint i = 0;\n-\t\t\t\twhile (reader.readRecord()) {\n-\t\t\t\t\tpercentage = reader.getCurrentRecord() / userSize.getY();\n-\t\t\t\t\tscope.getGui().getStatus().setTaskCompletion(task, percentage);\n-\t\t\t\t\tint nbC = 0;\n-\t\t\t\t\tfor (final String s : reader.getValues()) {\n-\t\t\t\t\t\tm[i++] = Cast.asInt(scope, s);\n-\t\t\t\t\t\tnbC++;\n-\t\t\t\t\t}\n-\t\t\t\t\twhile (nbC < matrix.getCols(null)) {\n-\t\t\t\t\t\tm[i++] = 0;\n-\t\t\t\t\t\tnbC++;\n-\t\t\t\t\t}\n-\t\t\t\t}\n-\t\t\t} else if (t == IType.FLOAT) {\n-\t\t\t\tmatrix = GamaMatrixFactory.createFloatMatrix((int) userSize.getX(), (int) userSize.getY());\n-\t\t\t\tfinal double[] m = ((GamaFloatMatrix) matrix).getMatrix();\n-\t\t\t\tint i = 0;\n-\t\t\t\twhile (reader.readRecord()) {\n-\t\t\t\t\tpercentage = reader.getCurrentRecord() / userSize.getY();\n-\t\t\t\t\tscope.getGui().getStatus().setTaskCompletion(task, percentage);\n-\t\t\t\t\tint nbC = 0;\n-\t\t\t\t\tfor (final String s : reader.getValues()) {\n-\t\t\t\t\t\tm[i++] = Cast.asFloat(scope, s);\n-\t\t\t\t\t\tnbC++;\n-\t\t\t\t\t}\n-\t\t\t\t\twhile (nbC < matrix.getCols(null)) {\n-\t\t\t\t\t\tm[i++] = 0.0;\n-\t\t\t\t\t\tnbC++;\n+\t\t\tObject defaultVal;\n+\t\t\t\n+\t\t\tswitch (t){\n+\t\t\t\tcase IType.FLOAT:\n+\t\t\t\t\tdefaultVal = 0.0;\n+\t\t\t\t\tmatrix = GamaMatrixFactory.createFloatMatrix((int) userSize.getX(), (int) userSize.getY());\n+\t\t\t\t\tbreak;\n+\t\t\t\tcase IType.INT:\n+\t\t\t\t\tdefaultVal = 0;\n+\t\t\t\t\tmatrix = GamaMatrixFactory.createIntMatrix((int) userSize.getX(), (int) userSize.getY());\n+\t\t\t\t\tbreak;\n+\t\t\t\tdefault:\n+\t\t\t\t\tdefaultVal = null;\n+\t\t\t\t\tmatrix = GamaMatrixFactory.create((int) userSize.getX(), (int) userSize.getY(), Types.STRING);\n+\t\t\t\t\n+\t\t\t}\n+\t\t\t\n+\t\t\tfinal int cols = matrix.getCols(null);\n+\t\t\tfinal int nbElmt = cols * matrix.getRows(null);\n+\t\t\t\n+\t\t\tint i = 0;\n+\t\t\treadingLoop:\n+\t\t\twhile (reader.readRecord()) {\n+\t\t\t\tpercentage = reader.getCurrentRecord() / userSize.getY();\n+\t\t\t\tscope.getGui().getStatus().setTaskCompletion(task, percentage);\n+\t\t\t\tint nbC = 0;\n+\t\t\t\tfor (final String s : reader.getValues()) {\n+\t\t\t\t\tif (i == nbElmt) {\n+\t\t\t\t\t\treportUnprocessedData(scope);\n+\t\t\t\t\t\tbreak readingLoop;\n \t\t\t\t\t}\n+\t\t\t\t\tmatrix.set(scope, i/cols, i%cols, s);\n+\t\t\t\t\ti++;\n+\t\t\t\t\tnbC++;\n \t\t\t\t}\n-\t\t\t} else {\n-\t\t\t\tmatrix = GamaMatrixFactory.create((int) userSize.getX(), (int) userSize.getY(), Types.STRING);\n-\t\t\t\tfinal Object[] m = ((GamaObjectMatrix) matrix).getMatrix();\n-\t\t\t\tint i = 0;\n-\t\t\t\twhile (reader.readRecord()) {\n-\t\t\t\t\tpercentage = reader.getCurrentRecord() / userSize.getY();\n-\t\t\t\t\tscope.getGui().getStatus().setTaskCompletion(task, percentage);\n-\t\t\t\t\tint nbC = 0;\n-\n-\t\t\t\t\tfor (final String s : reader.getValues()) {\n-\t\t\t\t\t\tif (i == m.length) {\n-\t\t\t\t\t\t\tGAMA.reportError(scope, GamaRuntimeException.warning(\"The file \" + getFile(scope).getName()\n-\t\t\t\t\t\t\t\t\t+ \" seems to contain data that have not been processed\", scope), false);\n-\t\t\t\t\t\t\tbreak;\n-\t\t\t\t\t\t}\n-\t\t\t\t\t\tnbC++;\n-\t\t\t\t\t\tm[i++] = s;\n-\t\t\t\t\t}\n-\t\t\t\t\twhile (nbC < matrix.getCols(null)) {\n-\t\t\t\t\t\tm[i++] = null;\n-\t\t\t\t\t\tnbC++;\n-\t\t\t\t\t}\n+\t\t\t\twhile (nbC < cols && i < nbElmt) {\n+\t\t\t\t\tmatrix.set(scope, i/cols, i%cols, defaultVal);\n+\t\t\t\t\ti++;\n+\t\t\t\t\tnbC++;\n \t\t\t\t}\n@@ -481,2 +464,18 @@ public class GamaCSVFile extends GamaFile<IMatrix<Object>, Object> implements IF\n \n+\t/**\n+\t * Reports, as a non-blocking warning, that the file contains more data than the matrix computed from its (possibly\n+\t * cached or under-estimated) metadata can hold. See issue #1127: this happens typically when the file has been\n+\t * modified outside of GAMA (so that the cached dimensions are stale) or when it lacks a trailing newline. The\n+\t * warning is reported only once, when the matrix is full, and the remaining records are ignored instead of throwing\n+\t * an ArrayIndexOutOfBoundsException.\n+\t *\n+\t * @param scope\n+\t *            the scope\n+\t */\n+\tprivate void reportUnprocessedData(final IScope scope) {\n+\t\tGAMA.reportError(scope, GamaRuntimeException.warning(\n+\t\t\t\t\"The file \" + getFile(scope).getName() + \" seems to contain data that have not been processed\", scope),\n+\t\t\t\tfalse);\n+\t}\n+\n \t/**\n","improvement-type":"Deep, Nested Complexity"}],"change-level":"warning","is-hotspot?":false,"line":389,"what-changed":"runGuiExperiment has a nested complexity depth of 4, threshold = 4","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":"introduced"},{"method":"buildAndOpen","why-it-occurs":"Overly long functions make the code harder to read. The recommended maximum function length for the Java language is 70 lines of code. Severity: Brain Method - Complex Method - Long Method.","name":"Large Method","file":"gama.ui.shared/src/gama/ui/shared/utils/LaunchingOverlay.java","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":282,"what-changed":"buildAndOpen has 72 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"},{"method":"getProjectFromEvent","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":"gama.ui.navigator/src/gama/ui/navigator/commands/ExportProjectAsSimulation.java","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":56,"what-changed":"getProjectFromEvent 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"},{"method":"getProjectFromEvent","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 Java language is 4 levels of nesting.","name":"Deep, Nested Complexity","file":"gama.ui.navigator/src/gama/ui/navigator/commands/ExportProjectAsSimulation.java","refactoring-examples":[{"architectural-component-id":null,"author-name":"Baptiste Lesquoy","training-data":{"loc-added":"43","loc-deleted":"44","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"2.0","delta-n-functions":"0","current-file-score":"8.679575849015766"},"author-email":"lesquoy.baptiste@gmail.com","commit-full-message":"","commit-date":"2026-07-07T05:19:26Z","current-rev":"8f16712fe","filename":"gama/gama.core/src/gama/core/util/file/GamaCSVFile.java","previous-rev":"0ef823b50","commit-title":"[Files] refactor csv reading + fixes the exception in #1127","language":"Java","id":"bdd415e8b84060b15aa056022e28f27252c1bc5e","model-score":0.09,"author-id":null,"project-id":51964,"delta-file-score":1.0546844,"diff":"diff --git a/gama.core/src/gama/core/util/file/GamaCSVFile.java b/gama.core/src/gama/core/util/file/GamaCSVFile.java\nindex 140a28f86..97cf7de16 100644\n--- a/gama.core/src/gama/core/util/file/GamaCSVFile.java\n+++ b/gama.core/src/gama/core/util/file/GamaCSVFile.java\n@@ -416,58 +416,41 @@ public class GamaCSVFile extends GamaFile<IMatrix<Object>, Object> implements IF\n \t\t\tscope.getGui().getStatus().beginTask(task, IStatusMessage.DOWNLOAD_ICON);\n-\t\t\tif (t == IType.INT) {\n-\t\t\t\tmatrix = GamaMatrixFactory.createIntMatrix((int) userSize.getX(), (int) userSize.getY());\n-\t\t\t\tfinal int[] m = ((GamaIntMatrix) matrix).getMatrix();\n-\t\t\t\tint i = 0;\n-\t\t\t\twhile (reader.readRecord()) {\n-\t\t\t\t\tpercentage = reader.getCurrentRecord() / userSize.getY();\n-\t\t\t\t\tscope.getGui().getStatus().setTaskCompletion(task, percentage);\n-\t\t\t\t\tint nbC = 0;\n-\t\t\t\t\tfor (final String s : reader.getValues()) {\n-\t\t\t\t\t\tm[i++] = Cast.asInt(scope, s);\n-\t\t\t\t\t\tnbC++;\n-\t\t\t\t\t}\n-\t\t\t\t\twhile (nbC < matrix.getCols(null)) {\n-\t\t\t\t\t\tm[i++] = 0;\n-\t\t\t\t\t\tnbC++;\n-\t\t\t\t\t}\n-\t\t\t\t}\n-\t\t\t} else if (t == IType.FLOAT) {\n-\t\t\t\tmatrix = GamaMatrixFactory.createFloatMatrix((int) userSize.getX(), (int) userSize.getY());\n-\t\t\t\tfinal double[] m = ((GamaFloatMatrix) matrix).getMatrix();\n-\t\t\t\tint i = 0;\n-\t\t\t\twhile (reader.readRecord()) {\n-\t\t\t\t\tpercentage = reader.getCurrentRecord() / userSize.getY();\n-\t\t\t\t\tscope.getGui().getStatus().setTaskCompletion(task, percentage);\n-\t\t\t\t\tint nbC = 0;\n-\t\t\t\t\tfor (final String s : reader.getValues()) {\n-\t\t\t\t\t\tm[i++] = Cast.asFloat(scope, s);\n-\t\t\t\t\t\tnbC++;\n-\t\t\t\t\t}\n-\t\t\t\t\twhile (nbC < matrix.getCols(null)) {\n-\t\t\t\t\t\tm[i++] = 0.0;\n-\t\t\t\t\t\tnbC++;\n+\t\t\tObject defaultVal;\n+\t\t\t\n+\t\t\tswitch (t){\n+\t\t\t\tcase IType.FLOAT:\n+\t\t\t\t\tdefaultVal = 0.0;\n+\t\t\t\t\tmatrix = GamaMatrixFactory.createFloatMatrix((int) userSize.getX(), (int) userSize.getY());\n+\t\t\t\t\tbreak;\n+\t\t\t\tcase IType.INT:\n+\t\t\t\t\tdefaultVal = 0;\n+\t\t\t\t\tmatrix = GamaMatrixFactory.createIntMatrix((int) userSize.getX(), (int) userSize.getY());\n+\t\t\t\t\tbreak;\n+\t\t\t\tdefault:\n+\t\t\t\t\tdefaultVal = null;\n+\t\t\t\t\tmatrix = GamaMatrixFactory.create((int) userSize.getX(), (int) userSize.getY(), Types.STRING);\n+\t\t\t\t\n+\t\t\t}\n+\t\t\t\n+\t\t\tfinal int cols = matrix.getCols(null);\n+\t\t\tfinal int nbElmt = cols * matrix.getRows(null);\n+\t\t\t\n+\t\t\tint i = 0;\n+\t\t\treadingLoop:\n+\t\t\twhile (reader.readRecord()) {\n+\t\t\t\tpercentage = reader.getCurrentRecord() / userSize.getY();\n+\t\t\t\tscope.getGui().getStatus().setTaskCompletion(task, percentage);\n+\t\t\t\tint nbC = 0;\n+\t\t\t\tfor (final String s : reader.getValues()) {\n+\t\t\t\t\tif (i == nbElmt) {\n+\t\t\t\t\t\treportUnprocessedData(scope);\n+\t\t\t\t\t\tbreak readingLoop;\n \t\t\t\t\t}\n+\t\t\t\t\tmatrix.set(scope, i/cols, i%cols, s);\n+\t\t\t\t\ti++;\n+\t\t\t\t\tnbC++;\n \t\t\t\t}\n-\t\t\t} else {\n-\t\t\t\tmatrix = GamaMatrixFactory.create((int) userSize.getX(), (int) userSize.getY(), Types.STRING);\n-\t\t\t\tfinal Object[] m = ((GamaObjectMatrix) matrix).getMatrix();\n-\t\t\t\tint i = 0;\n-\t\t\t\twhile (reader.readRecord()) {\n-\t\t\t\t\tpercentage = reader.getCurrentRecord() / userSize.getY();\n-\t\t\t\t\tscope.getGui().getStatus().setTaskCompletion(task, percentage);\n-\t\t\t\t\tint nbC = 0;\n-\n-\t\t\t\t\tfor (final String s : reader.getValues()) {\n-\t\t\t\t\t\tif (i == m.length) {\n-\t\t\t\t\t\t\tGAMA.reportError(scope, GamaRuntimeException.warning(\"The file \" + getFile(scope).getName()\n-\t\t\t\t\t\t\t\t\t+ \" seems to contain data that have not been processed\", scope), false);\n-\t\t\t\t\t\t\tbreak;\n-\t\t\t\t\t\t}\n-\t\t\t\t\t\tnbC++;\n-\t\t\t\t\t\tm[i++] = s;\n-\t\t\t\t\t}\n-\t\t\t\t\twhile (nbC < matrix.getCols(null)) {\n-\t\t\t\t\t\tm[i++] = null;\n-\t\t\t\t\t\tnbC++;\n-\t\t\t\t\t}\n+\t\t\t\twhile (nbC < cols && i < nbElmt) {\n+\t\t\t\t\tmatrix.set(scope, i/cols, i%cols, defaultVal);\n+\t\t\t\t\ti++;\n+\t\t\t\t\tnbC++;\n \t\t\t\t}\n@@ -481,2 +464,18 @@ public class GamaCSVFile extends GamaFile<IMatrix<Object>, Object> implements IF\n \n+\t/**\n+\t * Reports, as a non-blocking warning, that the file contains more data than the matrix computed from its (possibly\n+\t * cached or under-estimated) metadata can hold. See issue #1127: this happens typically when the file has been\n+\t * modified outside of GAMA (so that the cached dimensions are stale) or when it lacks a trailing newline. The\n+\t * warning is reported only once, when the matrix is full, and the remaining records are ignored instead of throwing\n+\t * an ArrayIndexOutOfBoundsException.\n+\t *\n+\t * @param scope\n+\t *            the scope\n+\t */\n+\tprivate void reportUnprocessedData(final IScope scope) {\n+\t\tGAMA.reportError(scope, GamaRuntimeException.warning(\n+\t\t\t\t\"The file \" + getFile(scope).getName() + \" seems to contain data that have not been processed\", scope),\n+\t\t\t\tfalse);\n+\t}\n+\n \t/**\n","improvement-type":"Deep, Nested Complexity"}],"change-level":"warning","is-hotspot?":false,"line":56,"what-changed":"getProjectFromEvent has a nested complexity depth of 4, threshold = 4","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":"introduced"}]},"positive-impact-count":2,"repo":"gama","code-health":8.091453040058083,"version":"3.0","authors":["rubenanko"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":2,"number-of-files-touched":1,"findings":[{"method":"postStartup","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the Java language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"gama.ui.application/src/gama/ui/application/workbench/ApplicationWorkbenchAdvisor.java","change-level":"improvement","is-hotspot?":false,"line":93,"what-changed":"postStartup decreases in cyclomatic complexity from 14 to 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":"improved"},{"method":"postStartup","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":"gama.ui.application/src/gama/ui/application/workbench/ApplicationWorkbenchAdvisor.java","change-level":"improvement","is-hotspot?":false,"line":93,"what-changed":"postStartup decreases from 4 to 3 logical blocks with deeply nested code, 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":"improved"}]},"notices":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"external-review-provider":"GitHub"},"analysistime":"2026-07-24T08:43:17.000Z","project-name":"gama","repository":"https://github.com/gama-platform/gama.git"}}