{"results":{"result":{"added-files":{"code-health":9.842730062691356,"old-code-health":0.0,"files":[{"file":"gama.core/src/gama/core/runtime/concurrent/WriteController.java","loc":114,"code-health":9.842730062691357}]},"external-review-url":"https://github.com/gama-platform/gama/pull/183","old-code-health":7.839486151205395,"modified-files":{"code-health":7.832954207635122,"old-code-health":7.839486151205395,"files":[{"file":"gama.core/src/gama/core/runtime/GAMA.java","loc":373,"old-loc":361,"code-health":7.6694205073174455,"old-code-health":7.6694205073174455},{"file":"gama.core/src/gama/core/kernel/simulation/SimulationAgent.java","loc":590,"old-loc":589,"code-health":7.7403397140855175,"old-code-health":7.7403397140855175},{"file":"gama.core/src/gama/gaml/statements/save/CSVSaver.java","loc":106,"old-loc":128,"code-health":7.9087644186687704,"old-code-health":7.9087644186687704},{"file":"gama.core/src/gama/gaml/statements/save/TextSaver.java","loc":58,"old-loc":60,"code-health":9.6882083290695,"old-code-health":9.6882083290695}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"183","analysis-time":"2024-05-23T11:30:04Z","negative-impact-count":1,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":1,"commits":["d1fd02d0f0de9beec0ef8d0a8e1fe712028e37ea","c145e147af0608a4f47af0f323eb198257b59d4a"],"is-negative-review":false,"negative-findings":{"number-of-types":1,"number-of-files-touched":1,"findings":[{"method":"flushOwner","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/core/runtime/concurrent/WriteController.java","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":116,"what-changed":"flushOwner has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is one single, nested 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":"introduced"}]},"positive-impact-count":1,"repo":"gama","code-health":8.017575035577435,"version":"3.0","authors":["Baptiste Lesquoy"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":1,"number-of-files-touched":1,"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.core/src/gama/gaml/statements/save/CSVSaver.java","change-level":"improvement","is-hotspot?":false,"line":99,"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"}]},"notices":{"number-of-types":1,"number-of-files-touched":1,"findings":[{"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, 42 % of all functions have primitive types as arguments.","name":"Primitive Obsession","file":"gama.core/src/gama/core/runtime/GAMA.java","refactoring-examples":[{"diff":"diff --git a/PrimitiveObsession.java b/PrimitiveObsession.java\nindex 8178547c76..11d4bb9daf 100644\n--- a/PrimitiveObsession.java\n+++ b/PrimitiveObsession.java\n@@ -1,9 +1,5 @@\n public class PrimitiveObsessionExample {\n-\tpublic JsonNode search(String query, Integer pages, Integer pageSize) {\n-\t\treturn httpClient.get(String.format(\"%s?q=%s&pages=%d&pageSize=%d\",\n-\t\t\t\t\tbaseUrl,\n-\t\t\t\t\tquery,\n-\t\t\t\t\tpages == null ? 10 : pages,\n-\t\t\t\t\tpageSize == null ? 10 : pages));\n+\tpublic JsonNode search(SearchRequest request) {\n+\t\treturn httpClient.get(request.getUrl());\n \t}\n }\n","language":"java","improvement-type":"Primitive Obsession"}],"change-level":"notice","is-hotspot?":true,"what-changed":"The ratio of primitive types in function arguments increases from 40.00% to 42.31%, threshold = 30.0%","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`.","change-type":"degraded"}]},"external-review-provider":"GitHub"},"analysistime":"2024-05-23T11:30:04.000Z","project-name":"gama","repository":"https://github.com/gama-platform/gama.git"}}