{"results":{"result":{"added-files":{"code-health":9.166676008232097,"old-code-health":0.0,"files":[{"file":"gama.core/src/gama/gaml/statements/save/SaveOptions.java","loc":29,"code-health":9.6882083290695},{"file":"gama.core/src/gama/core/runtime/concurrent/BufferingController.java","loc":216,"code-health":9.096655465156704}]},"external-review-url":"https://github.com/gama-platform/gama/pull/183","old-code-health":8.27473529757963,"modified-files":{"code-health":8.34426778738593,"old-code-health":8.27473529757963,"files":[{"file":"gama.core/src/gama/core/runtime/GAMA.java","loc":386,"old-loc":361,"code-health":7.6694205073174455,"old-code-health":7.6694205073174455},{"file":"gama.core/src/gama/core/kernel/simulation/SimulationAgent.java","loc":593,"old-loc":589,"code-health":7.7403397140855175,"old-code-health":7.7403397140855175},{"file":"gama.core/src/gama/gaml/statements/save/CSVSaver.java","loc":104,"old-loc":128,"code-health":7.9087644186687704,"old-code-health":7.9087644186687704},{"file":"gama.core/src/gama/gaml/statements/save/TextSaver.java","loc":40,"old-loc":60,"code-health":10.0,"old-code-health":9.6882083290695},{"file":"gama.core/src/gama/core/common/interfaces/IKeyword.java","loc":419,"old-loc":418,"code-health":10.0,"old-code-health":10.0},{"file":"gama.core/src/gama/gaml/statements/SaveStatement.java","loc":375,"old-loc":351,"code-health":5.939913220519425,"old-code-health":5.6498981617114525},{"file":"gama.headless/src/gama/headless/runtime/GamaHeadlessWebSocketServer.java","loc":143,"old-loc":143,"code-health":8.156697608179734,"old-code-health":8.156697608179734},{"file":"gama.core/src/gama/core/common/interfaces/ISaveDelegate.java","loc":21,"old-loc":21,"code-health":10.0,"old-code-health":10.0},{"file":"gama.core/src/gama/gaml/statements/save/ASCSaver.java","loc":111,"old-loc":118,"code-health":10.0,"old-code-health":9.6882083290695},{"file":"gama.core/src/gama/gaml/statements/save/AbstractShapeSaver.java","loc":265,"old-loc":265,"code-health":6.702976241074402,"old-code-health":6.3146784700660135},{"file":"gama.core/src/gama/gaml/statements/save/GeoTiffSaver.java","loc":91,"old-loc":89,"code-health":10.0,"old-code-health":9.6882083290695},{"file":"gama.core/src/gama/gaml/statements/save/GraphSaver.java","loc":34,"old-loc":34,"code-health":10.0,"old-code-health":9.6882083290695},{"file":"gama.core/src/gama/gaml/statements/save/JsonSaver.java","loc":30,"old-loc":29,"code-health":10.0,"old-code-health":9.6882083290695},{"file":"gama.core/src/gama/gaml/statements/save/KmlSaver.java","loc":24,"old-loc":24,"code-health":10.0,"old-code-health":9.6882083290695},{"file":"gama.extension.image/src/gama/extension/image/ImageSaver.java","loc":120,"old-loc":118,"code-health":9.485374140625545,"old-code-health":9.21744523236767},{"file":"gama.core/src/gama/gaml/statements/save/ShapeSaver.java","loc":95,"old-loc":95,"code-health":8.413528317237752,"old-code-health":8.413528317237752},{"file":"gama.core/src/gama/gaml/operators/Files.java","loc":459,"old-loc":437,"code-health":7.215320576432742,"old-code-health":7.215320576432742},{"file":"gama.core/src/gama/core/common/preferences/GamaPreferences.java","loc":628,"old-loc":622,"code-health":8.95517096544394,"old-code-health":8.95517096544394},{"file":"gama.core/src/gama/core/metamodel/agent/AbstractAgent.java","loc":313,"old-loc":311,"code-health":10.0,"old-code-health":10.0},{"file":"gama.core/src/gama/gaml/statements/WriteStatement.java","loc":136,"old-loc":92,"code-health":10.0,"old-code-health":10.0}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"183","analysis-time":"2024-06-10T10:23:32Z","negative-impact-count":4,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":4,"commits":["d1fd02d0f0de9beec0ef8d0a8e1fe712028e37ea","c145e147af0608a4f47af0f323eb198257b59d4a","115f6c9d0938ee60826512431e625fa5bc1d8942","ae19b0be10401143a15485ab035bb68f39b9ecda","624db55d72090365230d8dbc7eb1cdc1eb358710","c82dc680b5d05c3b5bcc0fac6745349b3c8f5d23","232cd7fbf5990d0066aa8f2b0318c1349d3634b0","5c6dc4a393711a882348efa5a1022c63b01cfbfb","f98a9f71a6f19ee58f8bbffbd640e1e359c404a5","d8393968bca8855821ada88357d00193bfccb56a","1ce9c80e91eb31a3c2b2e6872948e29b7c750213","30d258f0e8e7920ff980ab0cb970182260d71614","bbd95640f1d0688a29676bfbe277787ad6e7d921","dfcff5aca10e9f8ef1a308d7f6b3e5fa147fd51a"],"is-negative-review":false,"negative-findings":{"number-of-types":4,"number-of-files-touched":3,"findings":[{"method":"save","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.extension.image/src/gama/extension/image/ImageSaver.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":62,"what-changed":"save increases in cyclomatic complexity from 12 to 13, threshold = 9","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"degraded"},{"method":"SaveOptions","why-it-occurs":"Counts the maximum number of arguments to each class' constructor. Too many arguments give a lower code health score. The rationale is that many constructor arguments indicate either a unit with low cohesion or an injection of dependencies on the wrong abstraction level.","name":"Constructor Over-Injection","file":"gama.core/src/gama/gaml/statements/save/SaveOptions.java","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":18,"what-changed":"SaveOptions has 6 arguments, threshold = 5","how-to-fix":"There are multiple ways of addressing constructor over-injection. Sometimes you can introduce [FACADE](https://en.wikipedia.org/wiki/Facade_pattern) services that encapsulate lower-level dependencies.\n\nIn many cases, Constructor Over-Injection is a symptom of a deeper problem. Make sure to investigate the root cause, and get some inspiration and examples from [Mark Seemann's article](https://blog.ploeh.dk/2018/08/27/on-constructor-over-injection/) on the issue.","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":"gama.core/src/gama/core/runtime/concurrent/BufferingController.java","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":108,"what-changed":"The module contains 2 functions with similar structure: askWriteConsole,askWriteFile","how-to-fix":"A certain degree of duplicated code might be acceptable. The problems start when it is the same behavior that is duplicated across the functions in the module, ie. a violation of the Don't Repeat Yourself (DRY) principle. DRY violations lead to code that is changed together in predictable patterns, which is both expensive and risky. DRY violations can be identified using CodeScene's X-Ray analysis to detect clusters of change coupled functions with high code similarity. [Read More](https://codescene.com/blog/software-revolution-part3/)\n\nOnce you have identified the similarities across functions, look to extract and encapsulate the concept that varies into its own function(s). These shared abstractions can then be re-used, which minimizes the amount of duplication and simplifies change.","change-type":"introduced"},{"method":"appendWriteConsoleRequestToMap","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.core/src/gama/core/runtime/concurrent/BufferingController.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":201,"what-changed":"appendWriteConsoleRequestToMap 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"}]},"positive-impact-count":20,"repo":"gama","code-health":8.38776735865262,"version":"3.0","authors":["Baptiste Lesquoy"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":7,"number-of-files-touched":12,"findings":[{"name":"Primitive Obsession","file":"gama.core/src/gama/core/runtime/GAMA.java","change-type":"improved","change-level":"improvement","is-hotspot?":true,"why-it-occurs":"Code that uses a high degree of built-in, primitives such as integers, strings, floats, lacks a domain language that encapsulates the validation and semantics of function arguments. Primitive Obsession has several consequences: 1) In a statically typed language, the compiler will detect less erroneous assignments. 2) Security impact since the possible value range of a variable/argument isn't retricted.\n\nIn this module, 32 % of all functions have primitive types as arguments.","how-to-fix":"Primitive Obsession indicates a missing domain language. Introduce data types that encapsulate the details and constraints of your domain. For example, instead of `int userId`, consider `User clicked`.","what-changed":"The ratio of primitive types in function arguments decreases from 40.00% to 31.58%, threshold = 30.0%"},{"method":"save","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.core/src/gama/gaml/statements/save/CSVSaver.java","change-level":"improvement","is-hotspot?":false,"line":78,"what-changed":"save decreases in cyclomatic complexity from 24 to 20, 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":"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 Java language is 4 function arguments.","name":"Excess Number of Function Arguments","file":"gama.core/src/gama/gaml/statements/save/CSVSaver.java","change-level":"improvement","is-hotspot?":false,"line":156,"what-changed":"save decreases from 7 to 5 arguments, threshold = 4","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":"improved"},{"method":"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 Java language is 4 function arguments.","name":"Excess Number of Function Arguments","file":"gama.core/src/gama/gaml/statements/save/TextSaver.java","change-level":"improvement","is-hotspot?":false,"line":92,"what-changed":"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"},{"method":"privateExecuteIn","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.core/src/gama/gaml/statements/SaveStatement.java","change-level":"improvement","is-hotspot?":false,"line":416,"what-changed":"privateExecuteIn decreases in cyclomatic complexity from 30 to 27, 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":"SaveStatement.SaveValidator.validate","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.core/src/gama/gaml/statements/SaveStatement.java","change-level":"improvement","is-hotspot?":false,"line":223,"what-changed":"SaveStatement.SaveValidator.validate decreases from 5 to 4 logical blocks with deeply nested code, threshold is one single block 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"},{"method":"privateExecuteIn","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.core/src/gama/gaml/statements/SaveStatement.java","change-level":"improvement","is-hotspot?":false,"line":416,"what-changed":"privateExecuteIn decreases from 4 to 3 logical blocks with deeply nested code, threshold is one single block 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"},{"name":"Overall Code Complexity","file":"gama.core/src/gama/gaml/statements/SaveStatement.java","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.43 to 11.88, threshold = 4"},{"method":"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 Java language is 4 function arguments.","name":"Excess Number of Function Arguments","file":"gama.core/src/gama/gaml/statements/save/ASCSaver.java","change-level":"improvement","is-hotspot?":false,"line":56,"what-changed":"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"},{"method":"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 Java language is 4 function arguments.","name":"Excess Number of Function Arguments","file":"gama.core/src/gama/gaml/statements/save/AbstractShapeSaver.java","change-level":"improvement","is-hotspot?":false,"line":119,"what-changed":"save decreases from 7 to 5 arguments, threshold = 4","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":"improved"},{"method":"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 Java language is 4 function arguments.","name":"Excess Number of Function Arguments","file":"gama.core/src/gama/gaml/statements/save/AbstractShapeSaver.java","change-level":"improvement","is-hotspot?":false,"line":143,"what-changed":"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"},{"name":"Missing Arguments Abstractions","file":"gama.core/src/gama/gaml/statements/save/AbstractShapeSaver.java","change-type":"fixed","change-level":"improvement","is-hotspot?":false,"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. ","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.","what-changed":"The average number of function arguments is no longer above the threshold"},{"name":"Primitive Obsession","file":"gama.core/src/gama/gaml/statements/save/AbstractShapeSaver.java","change-type":"fixed","change-level":"improvement","is-hotspot?":false,"why-it-occurs":"Code that uses a high degree of built-in, primitives such as integers, strings, floats, lacks a domain language that encapsulates the validation and semantics of function arguments. Primitive Obsession has several consequences: 1) In a statically typed language, the compiler will detect less erroneous assignments. 2) Security impact since the possible value range of a variable/argument isn't retricted.\n\nIn this module, 29 % of all functions have primitive types as arguments.","how-to-fix":"Primitive Obsession indicates a missing domain language. Introduce data types that encapsulate the details and constraints of your domain. For example, instead of `int userId`, consider `User clicked`.","what-changed":"The ratio of primivite types in function arguments is no longer above the threshold"},{"method":"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 Java language is 4 function arguments.","name":"Excess Number of Function Arguments","file":"gama.core/src/gama/gaml/statements/save/GeoTiffSaver.java","change-level":"improvement","is-hotspot?":false,"line":63,"what-changed":"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"},{"method":"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 Java language is 4 function arguments.","name":"Excess Number of Function Arguments","file":"gama.core/src/gama/gaml/statements/save/GraphSaver.java","change-level":"improvement","is-hotspot?":false,"line":46,"what-changed":"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"},{"method":"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 Java language is 4 function arguments.","name":"Excess Number of Function Arguments","file":"gama.core/src/gama/gaml/statements/save/JsonSaver.java","change-level":"improvement","is-hotspot?":false,"line":33,"what-changed":"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"},{"method":"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 Java language is 4 function arguments.","name":"Excess Number of Function Arguments","file":"gama.core/src/gama/gaml/statements/save/KmlSaver.java","change-level":"improvement","is-hotspot?":false,"line":37,"what-changed":"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"},{"method":"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 Java language is 4 function arguments.","name":"Excess Number of Function Arguments","file":"gama.extension.image/src/gama/extension/image/ImageSaver.java","change-level":"improvement","is-hotspot?":false,"line":61,"what-changed":"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"},{"name":"Primitive Obsession","file":"gama.core/src/gama/gaml/operators/Files.java","change-type":"improved","change-level":"improvement","is-hotspot?":false,"why-it-occurs":"Code that uses a high degree of built-in, primitives such as integers, strings, floats, lacks a domain language that encapsulates the validation and semantics of function arguments. Primitive Obsession has several consequences: 1) In a statically typed language, the compiler will detect less erroneous assignments. 2) Security impact since the possible value range of a variable/argument isn't retricted.\n\nIn this module, 48 % of all functions have primitive types as arguments.","how-to-fix":"Primitive Obsession indicates a missing domain language. Introduce data types that encapsulate the details and constraints of your domain. For example, instead of `int userId`, consider `User clicked`.","what-changed":"The ratio of primitive types in function arguments decreases from 50.00% to 48.15%, threshold = 30.0%"},{"name":"String Heavy Function Arguments","file":"gama.core/src/gama/gaml/operators/Files.java","change-type":"improved","change-level":"improvement","is-hotspot?":false,"why-it-occurs":"String is a generic type that fail to capture the constraints of the domain object it represents. In this module, 43 % of all function arguments are string types.","how-to-fix":"Heavy string usage indicates a missing domain language. Introduce data types that encapsulate the semantics. For example, a user_name is better represented as a constrained User type rather than a pure string, which could be anything.","what-changed":"The ratio of strings in function arguments decreases from 44.23% to 42.59%, threshold = 39.0%"}]},"notices":{"number-of-types":1,"number-of-files-touched":1,"findings":[{"method":"SaveStatement.SaveValidator.validate","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.core/src/gama/gaml/statements/SaveStatement.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":"notice","is-hotspot?":false,"line":223,"what-changed":"SaveStatement.SaveValidator.validate increases in cyclomatic complexity from 50 to 51, threshold = 9","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"degraded"}]},"external-review-provider":"GitHub"},"analysistime":"2024-06-10T10:23:32.000Z","project-name":"gama","repository":"https://github.com/gama-platform/gama.git"}}