Skip to content

Format comparisons, functions, and redirections to be consistent #1201

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hyperupcall
Copy link
Collaborator

@hyperupcall hyperupcall commented Mar 24, 2025

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.py here, so we can easily enforce those style issues (and possibly other automatically fixable things) for new PRs. Is there interest in that?

Copy link
Collaborator

@spacewander spacewander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we put this check in the CI?

Copy link

@ferdnyc ferdnyc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

function addworkspace {
addworkspace() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still some inconsistency allowed here because when your script adds parentheses, it adds them without a space after the function name...

function guardedExecution () {
guardedExecution () {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if they're already present, it will leave the format however it was previously...

function _usage() {
_usage() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants