_init() does not wrap like other functions + unwanted formatting case for a function call chain

Offen
#370 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
55/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
rust
Bereich
tooling

Rechercherichtung

Reproduce both cases with gdscript-formatter 0.27.0 using the default max_line_length of 100, then inspect the formatter paths for function signatures and chained calls. Add regression coverage for both examples; done means formatting preserves already-valid input or produces output that stays within the configured limit.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

With 0.27.0 and the default settings (max_line_length: 100, tabs), the formatter produces lines longer than 100 columns, which gdscript-formatter lint then refuses. In both cases below, the input already passes lint and the formatted output doesn't, so a project that runs --check and lint together can't satisfy both.

1. A wrapped function signature is re-joined into one line of 101–109 columns

This looks like #300 again. That issue's own example still reproduces on 0.27.0 (it stays on one 108-column line).

Input (passes lint):

const SHADER := "res://a.gdshader"
const FADE_S := 1.0


func _init(
	node_name: String = "SkidMarks",
	shader_path: String = SHADER,
	fade_s: float = FADE_S,
) -> void:
	name = node_name

gdscript-formatter --stdout output:

func _init(node_name: String = "SkidMarks", shader_path: String = SHADER, fade_s: float = FADE_S) -> void:
	name = node_name
max-line-length:warning: Line is too long. Found 106 characters, maximum allowed is 100

Lengthening the last parameter shows that the signature stays on one line up to 109 columns and only wraps from 110.

2. A long argument to a chained call is pulled up onto a backslash-continued line

Input (passes lint, longest line 89 columns with tabs at 4):

func test_it() -> void:
	assert_that(x).override_failure_message(
		"this is a long failure message that goes on and on to push it beyond the limit %s" % x
	).is_true()

Output:

func test_it() -> void:
	assert_that(x) \
			.override_failure_message("this is a long failure message that goes on and on to push it beyond the limit %s"
	% x) \
			.is_true()
max-line-length:warning: Line is too long. Found 121 characters, maximum allowed is 100

This may be related to #360. Here, though, the input already fits, and the output both exceeds the limit and splits the % operand onto a line with less indentation.

Expected: in both cases, output that stays within max_line_length, or at least keeps an input that already fits.

macOS arm64, gdscript-formatter 0.27.0 release binary.

Vorherrschende Sprache
Rust
Sterne
483
Forks
40
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus GDQuest/GDScript-formatter

Alle Issues in GDQuest/GDScript-formatter

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.