About this project

gdstyle is a linter and formatter for GDScript, the scripting language used by the Godot 4.x game engine. It is written in Rust and distributed as a single static binary, so running it does not require Python, a Rust toolchain, or a Godot installation. What it does The tool checks GDScript files for style violations, naming inconsistencies, and common code-quality problems, and can reformat files to follow the official Godot style guide. Many conventions are drawn from GDQuest's GDScript style guide. It ships 56 rules grouped into five categories: - Syntax (1 rule): reports lexer errors such as unterminated strings or invalid numbers. - Naming (11 rules): enforces PascalCase for classes and enums, snake_case for functions, variables, signals, and file names, SCREAMING_SNAKE_CASE for constants and enum members, past-tense signal names, and PascalCase node paths. - Formatting (20 rules): covers line length, trailing whitespace and newlines, tabs vs spaces, boolean operators, quote style, comment spacing, parentheses, number literals, statement-per-line, blank lines, trailing commas, operator/colon/comma/brace spacing, call parentheses, float zeros, large-number underscores, and enum layout. - Ordering (1 rule): enforces the canonical Godot class-member order, from annotations and class_name through signals, enums, constants, variables, virtual methods, methods, and inner classes. - Quality (23 rules): limits on function, file, parameter, nesting, return, branch, local-variable, class-variable, public-method, and inner-class counts, plus checks for unnecessary pass, self-comparison, self-assignment, duplicate dictionary keys, duplicated load calls, unreachable code, await in loops, allocation in loops, node lookups in _process, and more. Most rules are enabled by default at warning severity. A few advisory rules (type hints, empty functions, debug prints) are off by default and must be enabled explicitly. Formatter and auto-fix The fmt subcommand reformats files in place and is idempotent. It normalizes indentation, whitespace, blank lines, boolean operators, quotes, comment spacing, punctuation spacing, numeric literals, and trailing newlines, expands single-line enums, reorders class members, and wraps long lines at commas inside delimiters, at and/or in conditions, and at word boundaries in comments. Lines without a breakable pattern are left alone. The check subcommand supports --fix for safe fixes and --unsafe-fix for renames and reordering. Unsafe renames are propagated across other .gd files and into .tscn/.tres scene wiring; anything that cannot be rewritten safely is reported as a warning. Fixes are written to disk without backup or confirmation, so the README advises committing or stashing first. Configuration and suppression Configuration lives in gdstyle.toml or .gdstyle.toml, discovered by walking up the directory tree, or passed with --config. Settings include line length, tab usage, various size limits, exclude/include patterns, and per-rule severity overrides (off, warn, error). Unknown rule names in the config are reported on stderr. Diagnostics can be silenced per line or per file with # gdstyle:ignore and # gdstyle:ignore-file comments, optionally narrowed to specific rule IDs. Ignoring the member-order rule also pins a member so the formatter will not move it. Integration Output can be text or JSON, and exit codes distinguish clean runs, lint errors or exceeded warning caps, and configuration errors. The README documents GitHub Actions usage, pre-commit hooks (gdstyle and gdstyle-fmt), and a minimal raw git hook. An optional Godot editor plugin provides a bottom panel with clickable diagnostics, single-click fixes, and lint/format on save, using GDExtension when available and falling back to the CLI binary. The crate is also usable as a Rust library.