{"results":{"result":{"added-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-url":"https://github.com/gama-platform/gama/pull/230","old-code-health":2.650108169071508,"modified-files":{"code-health":2.872921787094837,"old-code-health":2.650108169071508,"files":[{"file":"gama.annotations/src/gama/annotations/precompiler/IConstantCategory.java","loc":13,"old-loc":12,"code-health":10.0,"old-code-health":10.0},{"file":"gama.documentation/src/gama/documentation/MainGenerateWiki.java","loc":37,"old-loc":41,"code-health":10.0,"old-code-health":10.0},{"file":"gama.documentation/src/gama/documentation/util/UnifyDoc.java","loc":120,"old-loc":96,"code-health":8.997354731618337,"old-code-health":9.022772285419025},{"file":"gama.processor/src/gama/processor/doc/DocProcessor.java","loc":1294,"old-loc":1269,"code-health":2.029578770102505,"old-code-health":1.8610458978275581}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"230","analysis-time":"2024-06-27T02:49:48Z","negative-impact-count":2,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":1,"commits":["bb4e4b194831dce8a2c8e55d212b5051cdc66578","0e8dd5abc279fe749ea8a7703d887f4b46d5e210","24afcdb876abea67ef4e1579f28132d2b5e7ef1e","f3210c6c7bc888ba3a0366373a70af7a0635ce13","0a326346c1021cc88c4ee13d72ee9cef8749d85c","a8ef63b0a7c56d952cc9073870808e3231efd701"],"is-negative-review":true,"negative-findings":{"number-of-types":2,"number-of-files-touched":2,"findings":[{"method":"mergeFiles","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.documentation/src/gama/documentation/util/UnifyDoc.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":99,"what-changed":"mergeFiles increases in cyclomatic complexity from 14 to 15, threshold = 9","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"degraded"},{"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.processor/src/gama/processor/doc/DocProcessor.java","refactoring-examples":null,"change-level":"warning","is-hotspot?":true,"line":753,"what-changed":"The module contains 5 functions with similar structure: addCategories,addConcepts,processDocXMLStatementsInsideKind,processDocXMLStatementsInsideSymbol and 1 more functions","how-to-fix":"A certain degree of duplicated code might be acceptable. The problems start when it is the same behavior that is duplicated across the functions in the module, ie. a violation of the Don't Repeat Yourself (DRY) principle. DRY violations lead to code that is changed together in predictable patterns, which is both expensive and risky. DRY violations can be identified using CodeScene's X-Ray analysis to detect clusters of change coupled functions with high code similarity. [Read More](https://codescene.com/blog/software-revolution-part3/)\n\nOnce you have identified the similarities across functions, look to extract and encapsulate the concept that varies into its own function(s). These shared abstractions can then be re-used, which minimizes the amount of duplication and simplifies change.","change-type":"introduced"}]},"positive-impact-count":9,"repo":"gama","code-health":2.872921787094837,"version":"3.0","authors":["benoitgaudou","Baptiste Lesquoy"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":4,"number-of-files-touched":1,"findings":[{"name":"Overall Code Complexity","file":"gama.processor/src/gama/processor/doc/DocProcessor.java","change-type":"improved","change-level":"improvement","is-hotspot?":true,"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 9.22 to 7.77, threshold = 4"},{"method":"getDocElt","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.processor/src/gama/processor/doc/DocProcessor.java","change-level":"improvement","is-hotspot?":true,"line":1340,"what-changed":"getDocElt decreases from 9 to 8 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":"processDocXMLOperators","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.processor/src/gama/processor/doc/DocProcessor.java","change-level":"improvement","is-hotspot?":true,"line":593,"what-changed":"processDocXMLOperators decreases from 5 to 2 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":"processDocXMLConstants","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.processor/src/gama/processor/doc/DocProcessor.java","change-level":"improvement","is-hotspot?":true,"line":272,"what-changed":"processDocXMLConstants is no longer above the threshold for logical blocks with deeply nested code","how-to-fix":"Bumpy Road implementations indicate a lack of encapsulation. Check out the detailed description of the [Bumpy Road code health issue](https://codescene.com/blog/bumpy-road-code-complexity-in-context/).\n\nA Bumpy Road often suggests that the function/method does too many things. The first refactoring step is to identify the different possible responsibilities of the function. Consider extracting those responsibilities into smaller, cohesive, and well-named functions. The [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring is the primary response.","change-type":"fixed"},{"method":"getDocElt","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.processor/src/gama/processor/doc/DocProcessor.java","change-level":"improvement","is-hotspot?":true,"line":1340,"what-changed":"getDocElt decreases in cyclomatic complexity from 42 to 38, 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":"processDocXMLOperators","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.processor/src/gama/processor/doc/DocProcessor.java","change-level":"improvement","is-hotspot?":true,"line":593,"what-changed":"processDocXMLOperators decreases in cyclomatic complexity from 24 to 12, threshold = 9","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"improved"},{"method":"processDocXMLConstants","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.processor/src/gama/processor/doc/DocProcessor.java","change-level":"improvement","is-hotspot?":true,"line":272,"what-changed":"processDocXMLConstants is no longer above the threshold for cyclomatic complexity","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"fixed"},{"method":"processDocXMLOperators","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  levels of nesting.","name":"Deep, Nested Complexity","file":"gama.processor/src/gama/processor/doc/DocProcessor.java","change-level":"improvement","is-hotspot?":true,"line":617,"what-changed":"processDocXMLOperators is no longer above the threshold for nested complexity depth","how-to-fix":"Occassionally, it's possible to get rid of the nested logic by [Replacing Conditionals with Guard Clauses](https://refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html).\n\nAnother viable strategy is to identify smaller building blocks inside the nested chunks of logic and extract those responsibilities into smaller, cohesive, and well-named functions. The [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring explains the steps.","change-type":"fixed"},{"method":"processDocXMLConstants","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  levels of nesting.","name":"Deep, Nested Complexity","file":"gama.processor/src/gama/processor/doc/DocProcessor.java","change-level":"improvement","is-hotspot?":true,"line":272,"what-changed":"processDocXMLConstants is no longer above the threshold for nested complexity depth","how-to-fix":"Occassionally, it's possible to get rid of the nested logic by [Replacing Conditionals with Guard Clauses](https://refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html).\n\nAnother viable strategy is to identify smaller building blocks inside the nested chunks of logic and extract those responsibilities into smaller, cohesive, and well-named functions. The [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring explains the steps.","change-type":"fixed"}]},"notices":{"number-of-types":1,"number-of-files-touched":1,"findings":[{"why-it-occurs":"This module has 1228 lines of code (comments stripped away). This puts the module at risk of evolving into a Brain Class. Brain Classes are problematic since changes become more complex over time, harder to test, and challenging to refactor. Act now to prevent future maintenance issues.","name":"Lines of Code in a Single File","file":"gama.processor/src/gama/processor/doc/DocProcessor.java","refactoring-examples":null,"change-level":"notice","is-hotspot?":true,"what-changed":"The lines of code increases from 1204 to 1228, improve code health by reducing it to 1000","how-to-fix":"Look for opportunities to modularize the design. This is done by identifying groups of functions that represent different responsibilities and/or operate on different data. Once you have identified the different responsibilities, then use refactorings like [EXTRACT CLASS](https://refactoring.com/catalog/extractClass.html).","change-type":"degraded"}]},"external-review-provider":"GitHub"},"analysistime":"2024-06-27T02:49:48.000Z","project-name":"gama","repository":"https://github.com/gama-platform/gama.git"}}