{"results":{"result":{"added-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-url":"https://github.com/gama-platform/gama/pull/275","old-code-health":7.484064336747742,"modified-files":{"code-health":7.496938835316318,"old-code-health":7.484064336747742,"files":[{"file":"gama.core/src/gama/core/runtime/GAMA.java","loc":392,"old-loc":389,"code-health":7.6694205073174455,"old-code-health":7.6694205073174455},{"file":"gama.core/src/gama/core/runtime/concurrent/BufferingController.java","loc":239,"old-loc":230,"code-health":9.6882083290695,"old-code-health":9.6882083290695},{"file":"gama.core/src/gama/gaml/statements/SaveStatement.java","loc":376,"old-loc":375,"code-health":5.924262706509263,"old-code-health":5.939913220519425}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"275","analysis-time":"2024-08-01T08:41:50Z","negative-impact-count":1,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":2,"commits":["4097eec4053a2d150f1dc1e26350ebd69dd614c3","a26d3f790d1f8ed05099134f8d509aa9b4376838"],"is-negative-review":true,"negative-findings":{"number-of-types":1,"number-of-files-touched":1,"findings":[{"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","refactoring-examples":[{"architectural-component-id":null,"author-name":"AlexisDrogoul","training-data":{"loc-added":"22","loc-deleted":"13","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"9.536386775820924"},"author-email":"579256+AlexisDrogoul@users.noreply.github.com","commit-full-message":"- Extract chart configuration and styling properties into ChartProperties with FontSpec, AxisRange, and AxisVisibility components\n- Introduce IChartEngine and ChartOutputFactory to decouple chart creation from JFreeChart\n- Update IChart in gama.api with default getNativeChart() and getJFChart() methods\n- Update SnapshotMaker to render snapshots directly via IChart.getImage(...)\n- Simplify concrete JFreeChart output subclasses (Scatter, Histogram, Pie, Radar, Heatmap, BoxAndWhiskerCategory)\n- Resolve CodeScene quality gate rules by extracting plot and legend configuration helper methods","commit-date":"2026-09-16T17:38:02Z","current-rev":"6adb4401a","filename":"gama/gama.core/src/gama/core/outputs/layers/charts/ChartJFreeChartOutput.java","previous-rev":"c501d1e11","commit-title":"refactor: simplify chart classes and introduce pluggable chart engine","language":"Java","id":"58fc13daaafe8c0c448a1ddfb3923e51fe1fbd3f","model-score":0.53,"author-id":null,"project-id":51964,"delta-file-score":0.29573047,"diff":"diff --git a/gama.core/src/gama/core/outputs/layers/charts/ChartJFreeChartOutput.java b/gama.core/src/gama/core/outputs/layers/charts/ChartJFreeChartOutput.java\nindex cb4dc5bfc..724823bc5 100644\n--- a/gama.core/src/gama/core/outputs/layers/charts/ChartJFreeChartOutput.java\n+++ b/gama.core/src/gama/core/outputs/layers/charts/ChartJFreeChartOutput.java\n@@ -146,14 +146,4 @@ public class ChartJFreeChartOutput extends ChartOutput implements ChartProgressL\n \n-\t@Override\n-\tpublic void initChart(final IScope scope, final String chartname) {\n-\t\tsuper.initChart(scope, chartname);\n-\t\tif (chart == null) return;\n-\n-\t\tinitRenderer(scope);\n-\t\tfinal Plot plot = chart.getPlot();\n-\t\tchart.addProgressListener(this);\n-\t\tchart.setBorderVisible(false);\n-\t\tplot.setOutlineVisible(false);\n+\tprivate void configureChartTitle() {\n \t\tchart.setTitle(this.getName());\n-\n \t\tif (chart.getTitle() != null) {\n@@ -165,3 +155,6 @@ public class ChartJFreeChartOutput extends ChartOutput implements ChartProgressL\n \t\t}\n+\t}\n \n+\tprivate void configureChartBackgrounds() {\n+\t\tPlot plot = chart.getPlot();\n \t\tif (properties.getBackgroundColor() == null) {\n@@ -178,15 +171,16 @@ public class ChartJFreeChartOutput extends ChartOutput implements ChartProgressL\n \t\t}\n+\t}\n \n-\t\tif (chart.getLegend() != null) {\n-\t\t\tLegendTitle legend = chart.getLegend();\n-\t\t\tlegend.setItemFont(properties.getLegendFont());\n-\t\t\tlegend.setFrame(BlockBorder.NONE);\n-\t\t\tlegend.setPosition(RectangleEdge.BOTTOM);\n+\tprivate void configureChartLegend(final IScope scope) {\n+\t\tif (chart.getLegend() == null) return;\n+\t\tLegendTitle legend = chart.getLegend();\n+\t\tlegend.setItemFont(properties.getLegendFont());\n+\t\tlegend.setFrame(BlockBorder.NONE);\n+\t\tlegend.setPosition(RectangleEdge.BOTTOM);\n \n-\t\t\tconfigureLegendPosition(legend, plot, scope);\n-\t\t\tconfigureLegendOrientation(legend);\n+\t\tconfigureLegendPosition(legend, chart.getPlot(), scope);\n+\t\tconfigureLegendOrientation(legend);\n \n-\t\t\tif (properties.getTextColor() != null) {\n-\t\t\t\tlegend.setItemPaint(IColor.toAWTColor(properties.getTextColor()));\n-\t\t\t}\n+\t\tif (properties.getTextColor() != null) {\n+\t\t\tlegend.setItemPaint(IColor.toAWTColor(properties.getTextColor()));\n \t\t}\n@@ -194,2 +188,17 @@ public class ChartJFreeChartOutput extends ChartOutput implements ChartProgressL\n \n+\t@Override\n+\tpublic void initChart(final IScope scope, final String chartname) {\n+\t\tsuper.initChart(scope, chartname);\n+\t\tif (chart == null) return;\n+\n+\t\tinitRenderer(scope);\n+\t\tchart.addProgressListener(this);\n+\t\tchart.setBorderVisible(false);\n+\t\tchart.getPlot().setOutlineVisible(false);\n+\n+\t\tconfigureChartTitle();\n+\t\tconfigureChartBackgrounds();\n+\t\tconfigureChartLegend(scope);\n+\t}\n+\n \tprotected void configureLegendPosition(final LegendTitle legend, final Plot plot, final IScope scope) {\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"AlexisDrogoul","training-data":{"loc-added":"23","loc-deleted":"27","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.44","delta-n-functions":"0","current-file-score":"9.536386775820924"},"author-email":"579256+AlexisDrogoul@users.noreply.github.com","commit-full-message":"","commit-date":"2026-09-02T06:25:12Z","current-rev":"0a5f1fd1d","filename":"gama/gama.core/src/gama/core/outputs/layers/charts/ChartJFreeChartOutput.java","previous-rev":"96cb6e0b7","commit-title":"Fix chart legend personalization and datalist color/legend handling (#1186, #1187)","language":"Java","id":"82632572e418f9c978f94eaefc61ed41784c64dc","model-score":0.39,"author-id":null,"project-id":51964,"delta-file-score":0.42258495,"diff":"diff --git a/gama.core/src/gama/core/outputs/layers/charts/ChartJFreeChartOutput.java b/gama.core/src/gama/core/outputs/layers/charts/ChartJFreeChartOutput.java\nindex 5c8ce3bde..80e0a65e1 100644\n--- a/gama.core/src/gama/core/outputs/layers/charts/ChartJFreeChartOutput.java\n+++ b/gama.core/src/gama/core/outputs/layers/charts/ChartJFreeChartOutput.java\n@@ -238,3 +238,3 @@ public class ChartJFreeChartOutput extends ChartOutput implements ChartProgressL\n \t\tif (chart.getLegend() != null) {\n-\t\t\tLegendTitle legend = chart.getLegend(); // Get the existing legend\n+\t\t\tLegendTitle legend = chart.getLegend();\n \t\t\tlegend.setItemFont(getLegendFont());\n@@ -242,46 +242,42 @@ public class ChartJFreeChartOutput extends ChartOutput implements ChartProgressL\n \t\t\tlegend.setPosition(RectangleEdge.BOTTOM);\n-\t\t\t// legend.setPadding(5, 5, 5, 5);\n-\t\t\t// Set legend position\n-\t\t\tswitch (series_label_position) {\n-\t\t\t\tcase IKeyword.LEFT:\n-\t\t\t\t\tlegend.setPosition(RectangleEdge.LEFT);\n-\t\t\t\t\tbreak;\n-\t\t\t\tcase IKeyword.RIGHT:\n-\t\t\t\t\tlegend.setPosition(RectangleEdge.RIGHT);\n-\t\t\t\t\tbreak;\n-\t\t\t\tcase IKeyword.TOP:\n-\t\t\t\t\tlegend.setPosition(RectangleEdge.TOP);\n-\t\t\t\t\tbreak;\n-\t\t\t\tcase \"none\":\n-\t\t\t\t\tlegend.setVisible(false);\n-\t\t\t\t\tbreak;\n-\t\t\t\tcase \"onchart\":\n-\t\t\t\t\tif (plot instanceof XYPlot p) {\n-\t\t\t\t\t\t// Place the legend inside the chart area at the corner specified by the anchor\n-\t\t\t\t\t\tdouble x = series_label_anchor.getX() / 2 + 0.25; // Normalize to [0.25, 0.75]\n-\t\t\t\t\t\tdouble y = series_label_anchor.getY() / 2 + 0.25;\n-\t\t\t\t\t\tXYTitleAnnotation ta = new XYTitleAnnotation(x, y, legend, RectangleAnchor.CENTER);\n-\t\t\t\t\t\tta.setMaxWidth(0.5); // Legend will take up to 50% of the chart width by default\n-\t\t\t\t\t\tta.setMaxHeight(0.5);\n-\t\t\t\t\t\tlegend.setHorizontalAlignment(HorizontalAlignment.CENTER);\n-\t\t\t\t\t\tlegend.setVerticalAlignment(VerticalAlignment.CENTER);\n-\t\t\t\t\t\t// Legend with 50% transparency by default\n-\t\t\t\t\t\tlegend.setBackgroundPaint(IColor.toAWTColor(Colors.rgb(scope, backgroundColor, 0.5)));\n-\t\t\t\t\t\tp.addAnnotation(ta);\n-\t\t\t\t\t\t// Remove the default legend\n-\t\t\t\t\t\tchart.removeLegend();\n-\t\t\t\t\t}\n-\t\t\t}\n \n-\t\t\tif (\"vertical\".equalsIgnoreCase(legend_orientation)) {\n-\t\t\t\tlegend.getItemContainer().setArrangement(new org.jfree.chart.block.ColumnArrangement());\n-\t\t\t} else if (\"horizontal\".equalsIgnoreCase(legend_orientation)) {\n-\t\t\t\tlegend.getItemContainer().setArrangement(new org.jfree.chart.block.FlowArrangement());\n-\t\t\t}\n+\t\t\tconfigureLegendPosition(legend, plot, scope);\n+\t\t\tconfigureLegendOrientation(legend);\n \n-\t\t\t// Set legend text color\n \t\t\tif (textColor != null) { legend.setItemPaint(IColor.toAWTColor(textColor)); }\n+\t\t}\n+\n+\t}\n \n+\tprivate void configureLegendPosition(final LegendTitle legend, final Plot plot, final IScope scope) {\n+\t\tswitch (series_label_position) {\n+\t\t\tcase IKeyword.LEFT -> legend.setPosition(RectangleEdge.LEFT);\n+\t\t\tcase IKeyword.RIGHT -> legend.setPosition(RectangleEdge.RIGHT);\n+\t\t\tcase IKeyword.TOP -> legend.setPosition(RectangleEdge.TOP);\n+\t\t\tcase \"none\" -> legend.setVisible(false);\n+\t\t\tcase \"onchart\" -> {\n+\t\t\t\tif (plot instanceof XYPlot p) {\n+\t\t\t\t\tdouble x = series_label_anchor.getX() / 2 + 0.25;\n+\t\t\t\t\tdouble y = series_label_anchor.getY() / 2 + 0.25;\n+\t\t\t\t\tXYTitleAnnotation ta = new XYTitleAnnotation(x, y, legend, RectangleAnchor.CENTER);\n+\t\t\t\t\tta.setMaxWidth(0.5);\n+\t\t\t\t\tta.setMaxHeight(0.5);\n+\t\t\t\t\tlegend.setHorizontalAlignment(HorizontalAlignment.CENTER);\n+\t\t\t\t\tlegend.setVerticalAlignment(VerticalAlignment.CENTER);\n+\t\t\t\t\tlegend.setBackgroundPaint(IColor.toAWTColor(Colors.rgb(scope, backgroundColor, 0.5)));\n+\t\t\t\t\tp.addAnnotation(ta);\n+\t\t\t\t\tchart.removeLegend();\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\tdefault -> {\n+\t\t\t}\n \t\t}\n+\t}\n \n+\tprivate void configureLegendOrientation(final LegendTitle legend) {\n+\t\tif (\"vertical\".equalsIgnoreCase(legend_orientation)) {\n+\t\t\tlegend.getItemContainer().setArrangement(new org.jfree.chart.block.ColumnArrangement());\n+\t\t} else if (\"horizontal\".equalsIgnoreCase(legend_orientation)) {\n+\t\t\tlegend.getItemContainer().setArrangement(new org.jfree.chart.block.FlowArrangement());\n+\t\t}\n \t}\n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":true,"line":417,"what-changed":"privateExecuteIn increases in cyclomatic complexity from 27 to 28, 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"}]},"positive-impact-count":1,"repo":"gama","code-health":7.496938835316318,"version":"3.0","authors":["Baptiste Lesquoy"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":1,"number-of-files-touched":1,"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, 31 % 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 31.03% to 30.51%, threshold = 30.0%"}]},"notices":{"number-of-types":1,"number-of-files-touched":1,"findings":[{"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).","name":"Overall Code Complexity","file":"gama.core/src/gama/gaml/statements/SaveStatement.java","refactoring-examples":null,"change-level":"notice","is-hotspot?":true,"what-changed":"The mean cyclomatic complexity increases from 11.88 to 12.00, threshold = 4","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","change-type":"degraded"}]},"external-review-provider":"GitHub"},"analysistime":"2024-08-01T08:41:49.000Z","project-name":"gama","repository":"https://github.com/gama-platform/gama.git"}}