extends SceneTree const SKIP_DIRS := [".git", ".godot", "addons"] func _initialize() -> void: var errors: Array[String] = [] _scan_dir("res://", errors) if errors.is_empty(): print("Lint passed: no GDScript syntax errors found") quit(0) else: for e in errors: printerr(e) printerr("Lint failed: %d file(s) with syntax errors" % errors.size()) quit(1) func _scan_dir(path: String, errors: Array[String]) -> void: var dir := DirAccess.open(path) if dir == null: return dir.list_dir_begin() var entry := dir.get_next() while entry != "": if entry == "." or entry == "..": entry = dir.get_next() continue var full_path := path.path_join(entry) if dir.current_is_dir(): if not SKIP_DIRS.has(entry): _scan_dir(full_path, errors) elif entry.ends_with(".gd"): var script := GDScript.new() script.source_code = FileAccess.get_file_as_string(full_path) if script.reload() != OK: errors.append("%s: syntax error" % full_path) entry = dir.get_next()