From 4023e50d37a52aae6038f86809f07834466ba0ab Mon Sep 17 00:00:00 2001 From: Roman <2776447+rganz@users.noreply.github.com> Date: Mon, 14 Sep 2026 10:19:14 +0200 Subject: [PATCH] Analyse static functions, and stop merging them into the function above _analyze_functions opened a new function only on begins_with("func "), which a static declaration does not match. Two things followed from that single test. The static function was never analysed, so no length, parameter, nesting, complexity or return type check ever saw it. Its body was appended to the function above, because the parser was still inside that one, inflating that function's reported length and complexity. Normalising a leading "static " before the test keeps the substr(5) assumption in _parse_function_signature valid and fixes both. Measured on a probe project against this tree. A two line function followed by an eight line static function was reported at 12 lines and is now not reported at all; the static function was reported not at all and is now reported at its own 9 lines. Same root as the open report about annotations in front of a declaration: the parser decides what a declaration is from the text of one line. ignore-handler and strict-handler have the same blind spot for their own ranges, which this commit deliberately leaves alone. --- .../gdscript-linter/analyzer/checkers/function-checker.gd | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/gdscript-linter/analyzer/checkers/function-checker.gd b/addons/gdscript-linter/analyzer/checkers/function-checker.gd index ab7cbcf..989c0f3 100644 --- a/addons/gdscript-linter/analyzer/checkers/function-checker.gd +++ b/addons/gdscript-linter/analyzer/checkers/function-checker.gd @@ -23,6 +23,13 @@ func analyze_functions(lines: Array, file_result, add_issue_callback: Callable, var line: String = lines[i] var trimmed := line.strip_edges() + # A static function is a function. Matching only "func " meant a static + # declaration never opened a new function, so its body was appended to the + # function above it and the static one was never analysed. Normalising here + # keeps the substr(5) assumption in _parse_function_signature valid. + if trimmed.begins_with("static func "): + trimmed = trimmed.substr(7) + if trimmed.begins_with("func "): # Finalize previous function if in_function and current_func: