gdformat creates a line longer than 100 symbols and gdlint complains about it
See original GitHub issueIn 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:
- Created a year ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.The formatter and linter also don’t play nice with line continuations. Contrived example:
If I fix the linter long line complaint using this:
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!