Skip to content
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

Apply ShellCheck to a few files in the tools/ directory #402

Merged
merged 6 commits into from
Feb 22, 2023
Merged

Apply ShellCheck to a few files in the tools/ directory #402

merged 6 commits into from
Feb 22, 2023

Conversation

neuroevolutus
Copy link
Contributor

This is a PR addressing ShellCheck suggestions for a few files in the tools/ directory of this project. As there is some existing interest in improving code with ShellCheck (#365, #83), I thought it would be helpful to begin applying some of these suggestions. @akinomyoga, if you are able to review my work to check for improvements/mistakes, I would be extremely grateful!

Copy link
Contributor

@akinomyoga akinomyoga left a comment

Choose a reason for hiding this comment

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

Thank you for your contributions! I actually wanted to process all at once, but incremental changes are also welcome! I was thinking of merging as many PRs as possible before applying the style changes because the global style changes would introduce unnecessary conflicts in the PRs, but I believe tools/ directory is safe to introduce the style changes. Thanks!

I think about a half of the suggested changes are good ones, but there are still some noises. I left comments. Could you check them?

tools/git-prompt.sh Outdated Show resolved Hide resolved
tools/install.sh Outdated Show resolved Hide resolved
tools/install.sh Outdated Show resolved Hide resolved
tools/install.sh Outdated Show resolved Hide resolved
tools/install.sh Outdated Show resolved Hide resolved
@neuroevolutus neuroevolutus marked this pull request as draft February 20, 2023 05:33
@neuroevolutus
Copy link
Contributor Author

In the function _omb_install_main, I've altered the code to have a single local declaration for all of the function's variables so I could avoid having far more occurrences of the # shellcheck disable=SC2155 ignore line.

@neuroevolutus neuroevolutus marked this pull request as ready for review February 20, 2023 07:53
@akinomyoga
Copy link
Contributor

In the function _omb_install_main, I've altered the code to have a single local declaration for all of the function's variables so I could avoid having far more occurrences of the # shellcheck disable=SC2155 ignore line.

Thanks, but I actually prefer the previous version. The variable scope should be kept small, and I wouldn't like to change the code in a worse direction just to suppress the warnings. Two separate lines of disable=SC2155 would be just fine. It is understandable to declare RED, ..., and NORMAL before the if statement rather than declaring them in each branch, so the declaration in the previous version 4212951c is 👍.

@neuroevolutus neuroevolutus marked this pull request as draft February 22, 2023 01:17
@neuroevolutus neuroevolutus marked this pull request as ready for review February 22, 2023 03:41
Hint addressed: SC2162

Hint disabled: SC1090
Hints disabled: SC1090, SC2317
Hints addressed: SC2059, SC2155

Hints disabled: SC1003, SC2016, SC2317, SC1090, SC2155
akinomyoga
akinomyoga previously approved these changes Feb 22, 2023
Copy link
Contributor

@akinomyoga akinomyoga left a comment

Choose a reason for hiding this comment

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

Thank you for your patience and all the updates! I think I'll later merge this.

@akinomyoga
Copy link
Contributor

I added a newline bc4018b.

@akinomyoga
Copy link
Contributor

akinomyoga commented Feb 22, 2023

Ah, I actually think we should move the declaration of local ncolors outside the if statement (3ef2484) because otherwise, the later code unintendedly references the global variable ncolors when the if condition is not satisfied.

@akinomyoga akinomyoga merged commit 8b8a3b3 into ohmybash:master Feb 22, 2023
@akinomyoga
Copy link
Contributor

Thanks. I've merged it.

@neuroevolutus neuroevolutus deleted the apply-shellcheck-hints branch February 23, 2023 01:15
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.

2 participants