GDSuite Docs

Linting

Spot code that works but is probably a mistake, or hard to read.

A linter reads your scripts and points at code that is probably not what you meant, or will be hard to work with later. The code may run fine today: the linter catches what a careful reviewer would mention.

The linter warns
func heal(amount: int) -> void:
	health = health


func is_dead() -> bool:
	if health <= 0:
		return true
	else:
		return false
After the fix
func heal(amount: int) -> void:
	health = health + amount


func is_dead() -> bool:
	return health <= 0
player.gd:2:2: warning[self-assignment]: `health` is assigned to itself.
player.gd:8:2: warning[no-else-return]: Unnecessary "else" after "return"

What it looks for

35 rules, in a few families. Most come from gdlint, the linter of gdtoolkit, and follow Godot's style guide:

FamilyExample of what it catches
NamesA function called TakeDamage instead of take_damage, a constant called maxHealth
OrderSignals declared below functions, class_name after extends
Likely mistakesx = x, x == x, the same scene loaded twice in one script
Simpler codeAn else after a return, a pass that isn't needed
SizeA line over 100 characters, a script over 1000 lines, a function with more than 10 parameters

The Lint rules page lists every rule, whether it is on by default, and its options.

Errors that stop a script from running are not the linter's job: they are what type checking finds.

Lint your project

gdsuite lint                    # the whole project
gdsuite lint -- player/         # only this folder
gdsuite lint -- --fix           # repair what is safe to repair, list the rest

Each problem is one line: file, line, column, the rule's name in brackets, and what is wrong:

player/player.gd:11:1: warning[class-definitions-order]: Definition out of order in global scope: `signals` must come before `others`
test/test_player.gd:12:24: warning[duplicated-load]: duplicated loading of "res://player/player.gd"
2 lint problems in 3 files

When you disagree with a rule

Rules are advice. Turn one off for the whole project in gdsuite.toml:

[lint]
disable = ["max-public-methods"]

[lint.rules.max-line-length]
max = 130

Or silence it on one line, when the code is right as it is:

var Scene = preload("res://enemy.tscn")  # gdtidy: ignore=class-load-variable-name

Comments written for gdlint (# gdlint: ignore=...) work too.

In a check

Lint is the second step of gdsuite check, after formatting.

In the Godot editor

Not yet: a Problems list in the editor, where a click opens the script at the line, is planned for the GDSuite editor addon.

Go further