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

Abierto
#370 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust
Área
tooling

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
483
Forks
40
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de GDQuest/GDScript-formatter

Todos los issues de GDQuest/GDScript-formatter

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.