Format comparisons, functions, and redirections to be consistent#1201
Format comparisons, functions, and redirections to be consistent#1201spacewander merged 3 commits intotj:mainfrom
Conversation
spacewander
left a comment
There was a problem hiding this comment.
Could we put this check in the CI?
ferdnyc
left a comment
There was a problem hiding this comment.
This seems like a helpful bit of cleanup, @hyperupcall -- I agree with @spacewander, it would be good to have those checks in the CI as well.
|
|
||
| # add another workspace to global git config | ||
| function addworkspace { | ||
| addworkspace() { |
There was a problem hiding this comment.
There's still some inconsistency allowed here because when your script adds parentheses, it adds them without a space after the function name...
|
|
||
| # guarded execution of a git command in one specific repository | ||
| function guardedExecution () { | ||
| guardedExecution () { |
There was a problem hiding this comment.
But if they're already present, it will leave the format however it was previously...
| FORCE=0 | ||
|
|
||
| function _usage() { | ||
| _usage() { |
There was a problem hiding this comment.
Which means the results have all of:
# Definitions without a space, because they
# were changed from
function fname { ... }
# to
fname() { }
# Definitions without a space, because they were
# changed from
function fname() { ... }
# to
fname() { ... }
# Definitions with a space, because they were
# changed from
function fname () { ... }
# to
fname () { ... }(And that's just in the ones the script modified.) Would it be better to decide on a particular style and apply it consistently?
There was a problem hiding this comment.
The checkstyle.py script doesn't add rules that are supported by other tools. For example, shfmt supports automatically fixing that whitespace inconsistency.
I would rather add a proper tool like shfmt instead of tweaking the regular expressions to support different forms of whitespace.
|
Script added to CI!. |
|
@hyperupcall |
It can be difficult reading through scripts here with every file seemingly having a different convention (for argument parsing, help menu, function delarations, etc.). This cleans up some of that with a little checkstyle.py script I made for asdf-vm a while back (it has autofix). It catches some things that ShellCheck doesn't, or autofixes things that ShellCheck doesn't.
One thing I would like to do, is add a
chekstyle.pyhere, so we can easily enforce those style issues (and possibly other automatically fixable things) for new PRs. Is there interest in that?