-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a GitHub "Action" to enforce code style #15
Conversation
logger.gd
Outdated
print( | ||
( | ||
"[ERROR] [logger] Could not create the '%s' directory; exited with error %d." | ||
% [base_dir, err] | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not an improvement IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. This happens because the line length is capped at 100. I could change the command to:
gdformat --line-length=500 logger.gd
This should solve this kind of formatting!
logger.gd
Outdated
|
||
func validate_path(path): | ||
"""Validate the path given as argument, making it possible to write to | ||
the designated file or folder. Returns whether the path is valid.""" | ||
if !(path.is_abs_path() or path.is_rel_path()): | ||
if ! (path.is_abs_path() or path.is_rel_path()): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a weird style change. Maybe replace !
with not
and then it makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is still the case and an issue was created: Scony/godot-gdscript-toolkit#106
How do we want to approach this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say work it around with not
instead of !
, which is also more pythonic.
logger.gd
Outdated
"path": get_path(), | ||
"queue_mode": get_queue_mode() | ||
} | ||
return {"path": get_path(), "queue_mode": get_queue_mode()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it keep them split if you add a trailing comma?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it does!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say it would be good to do then, it's more readable IMO.
logger.gd
Outdated
"module": "{MOD}", | ||
"message": "{MSG}" | ||
} | ||
const FORMAT_IDS = {"level": "{LVL}", "module": "{MOD}", "message": "{MSG}"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to add a trailing comma to keep them on separate lines.
@@ -261,17 +284,17 @@ var invalid_memory_cache = false | |||
var logfiles = {} | |||
var modules = {} | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well... Autoformatters are dumb :)
I guess we can live with it.
Right now the linter will always fail due to its configuration:
To make the linter somewhat useful I propose to disable: Is this something I should do? |
logger.gd
Outdated
@@ -631,8 +641,7 @@ func load_config(configfile = default_configfile_path): | |||
# Load modules config and initialize them | |||
modules = {} | |||
for module_cfg in config.get_value(PLUGIN_NAME, "modules"): | |||
var module = Module.new(module_cfg["name"], module_cfg["output_level"], \ | |||
module_cfg["output_strategies"], get_logfile(module_cfg["logfile_path"])) | |||
var module = Module.new(module_cfg["name"], module_cfg["output_level"], module_cfg["output_strategies"], get_logfile(module_cfg["logfile_path"])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it keep things multiline if written this way?
var module = Module.new(module_cfg["name"], module_cfg["output_level"], module_cfg["output_strategies"], get_logfile(module_cfg["logfile_path"])) | |
var module = Module.new( | |
module_cfg["name"], | |
module_cfg["output_level"], | |
module_cfg["output_strategies"], | |
get_logfile(module_cfg["logfile_path"]) | |
) |
or similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this will be formatted to one line.
Sorry for the delay. Yeah disabling what you need for the linter to pass seems good. We can always assess the options that we had to disable in a second step once we have a working formatter and linter merged. As for the max line length, you can experiment with e.g. 120 or 140 (we use 120 for Python formatting in Godot code for example) to avoid splitting everything needlessly, but still split the occasional very long lines. But if the output is not good, I'm also fine with setting 500 to be virtually unlimited. |
ac1b993
to
6e808f4
Compare
a0d13e6
to
3ce5dea
Compare
I set it to 150. It looks like that value works (for now). |
I think this is as good as it gets, but if you want to have some things improved let me know. |
Thanks! |
As proposed in #12. Let's discuss the results.