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

[Feature request][Bash] Add rules to provide tips on adding local, or readonly status to variables #2987

Open
2 tasks done
LLyaudet opened this issue May 20, 2024 · 0 comments

Comments

@LLyaudet
Copy link

LLyaudet commented May 20, 2024

Hello :),

I may have used readonly or local keywords in some of my shell scripts in the past.
But at some point, I forgot about this keywords.

For new checks and feature suggestions

See #1944
for the issue that recalled me of it.
I checked that no current rule (activated with --enable=all for example) yields suggestions to add such keywords in your code.
I have a very simple rule to propose:
If there is only one match of the regexp like "^\s*@my_variable_name@=.*$" adapted to the variable in the current file, propose to add readonly keyword. Another feature would be to define a project variant of this to check all lines of bash scripts in . for example instead of just the current file. Regarding local vs global variable in functions, it could make sense that each variable in a function is defined with local or declare or typeset or that a warning is issued by some rule (the case of exterior variables could be dealed with # shellcheck disable=SC1111(@my_variable_name@) at beginning of function with function scope.

Best regards,
Laurent Lyaudet

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

No branches or pull requests

1 participant