-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add config linting script that checks for bool casing #6203
Conversation
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.
great idea, couple of tweaks though
@@ -0,0 +1,9 @@ | |||
#!/bin/bash |
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.
it might be simpler just to grep for the incorrect formats, rather than try to correct them?
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 considered this at first, but I wanted to be able to add this to scripts-dev/lint.sh
which could get run in a pre-commit hook for instance.
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'm not quite sure that follows... lint.sh
doesn't correct for incorrect imports or pep8 failures, it just complains if they are wrong.
There might be value in having a script to correct the problems, but given how often it's likely to be a problem versus the added complexity of this script, I don't think it's worthwhile?
scripts-dev/config-lint.sh
Outdated
# Exits with 0 if there are no problems, or another code otherwise. | ||
|
||
# Fix non-lowercase true/false values | ||
sed -i -E "s/(#.*): +True(.*)/\1: true\2/g; s/(#.*): +False(.*)/\1: false\2/g;" synapse/config/*.py |
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.
- why do we require a #
- some of the groups are redundant:
sed -i -E "s/(#.*): +True(.*)/\1: true\2/g; s/(#.*): +False(.*)/\1: false\2/g;" synapse/config/*.py | |
sed -i -E "s/(#.*): +True/\1: true/g; s/(#.*): +False/\1: false/g;" synapse/config/*.py |
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.
The code can contain false positives without the hash, such as docstrings:
synapse/synapse/config/logger.py
Line 199 in b617864
use_worker_options (bool): True to use the 'worker_log_config' option |
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.
ahhh. we should probably run it on the sample config rather than attempt to match only the config bits within synapse/config
.
Co-Authored-By: Richard van der Hoff <[email protected]>
…g/synapse into anoa/lowercase_config_defaults
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 think it's worth noting that your script has missed
synapse/docs/sample_config.yaml
Line 414 in 0155478
enabled: False |
Yep, had to fix this case manually. I've also switched it so that the script just fixes the sample config instead of your code. I also changed the |
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.
lgtm then
* commit '409c62b27': Add config linting script that checks for bool casing (#6203)
Add a linting script that enforces all boolean values in the default config be lowercase.
This has annoyed me for a while so I decided to fix it.
Pipelines repo PR: matrix-org/pipelines#12Not necessary anymore.