question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gdformat creates a line longer than 100 symbols and gdlint complains about it

See original GitHub issue

In my project I run both gdlint and gdformat and I found something what seems like a bug.

I have a file with the following content:

static func on_quest_finished(_state: GameState, _quest_type: String, _iker_id: int, _etadata: Dictionary):
	pass

The line with function declaration is 107 characters long, so gdlint complains about it, but gdformat is perfectly fine with this code:

$ gdlint tmp/test.gd
tmp/test.gd:1: Error: Max allowed line length (100) exceeded (max-line-length)
Failure: 1 problem found
$ gdformat tmp/test.gd  --diff
1 file would be left unchanged

If I manually change the code so it fits in 100 symbols:

static func on_quest_finished(
	_state: GameState, _quest_type: String, _iker_id: int, _etadata: Dictionary
):
	pass

gdlint is happy, but gdformat wants to revert it to oneline (and violate the 100 length rule):

$ gdlint tmp/test.gd
Success: no problems found
$ gdformat tmp/test.gd  --diff
would reformat tmp/test.gd
--- tmp/test.gd
+++ tmp/test.gd
@@ -1,4 +1,2 @@
-static func on_quest_finished(
-	_state: GameState, _quest_type: String, _iker_id: int, _etadata: Dictionary
-):
+static func on_quest_finished(_state: GameState, _quest_type: String, _iker_id: int, _etadata: Dictionary):
 	pass
1 file would be reformatted, 0 files would be left unchanged.

If I make the line in the original file 1 symbol longer (note _metadata vs _etadata):

static func on_quest_finished(_state: GameState, _quest_type: String, _iker_id: int, _metadata: Dictionary):
	pass

both gdlint and gdformat start to complain about it (as expeected):

$ gdlint tmp/test.gd
tmp/test.gd:1: Error: Max allowed line length (100) exceeded (max-line-length)
Failure: 1 problem found
$ gdformat tmp/test.gd  --diff
would reformat tmp/test.gd
--- tmp/test.gd
+++ tmp/test.gd
@@ -1,2 +1,4 @@
-static func on_quest_finished(_state: GameState, _quest_type: String, _iker_id: int, _metadata: Dictionary):
+static func on_quest_finished(
+	_state: GameState, _quest_type: String, _iker_id: int, _metadata: Dictionary
+):
 	pass
1 file would be reformatted, 0 files would be left unchanged.

The workaround is to silence gdlint with # gdlint:ignore = max-line-length, so it’s not super-critical, but still it’s a bug.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Sconycommented, Dec 4, 2022

@ngburke the thing is - patterns are not fully implemented i.e. formatter always formats them into one line. This yields lines invalid from gdlint PoV.

0reactions
ngburkecommented, Dec 4, 2022

The formatter and linter also don’t play nice with line continuations. Contrived example:

match x:
  "one", "two", "three", "four", "five", .... (and so on)

If I fix the linter long line complaint using this:

match x:
  "one", "two", "three", "four", "five", \
  ... etc. \

Then the linter is happy, but the formatter wants to put the lines back into one. Thanks for all your efforts on these tools, they are generally very helpful!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · Scony/godot-gdscript-toolkit
gdformat creates a line longer than 100 symbols and gdlint complains about it bug Something isn't working formatter. #168 opened on Jul 21...
Read more >
In python, how to tweak Black formatter, if possible?
This is due to the default line length for black being longer than you'd like – 88 characters per line. To decrease the...
Read more >
Format your Code with GDFormat
Godot 3.2 is lacking a code formatter for GDScript. Formatting your code by hand is a time-consuming process, time you could instead use...
Read more >
The Black code style - Black 22.12.0 documentation
Black defaults to 88 characters per line, which happens to be 10% over 80. This number was found to produce significantly shorter files...
Read more >
Wrap line if length exceeds
I have the following config: Unfortuntely, it wraps and creates an new line when the find function is called. Do you have an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found