-
Notifications
You must be signed in to change notification settings - Fork 21
Resolve Shellcheck v0.11 warnings #132
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
base: main
Are you sure you want to change the base?
Conversation
shellcheck v0.11 now gives the following warnings,
In kdump-logger.sh line 163:
ddebug()
^-- SC2329 (info): This function is never invoked. Check usage (or ignored if invoked indirectly).
In kdump-logger.sh line 171:
dinfo()
^-- SC2329 (info): This function is never invoked. Check usage (or ignored if invoked indirectly).
...
This happens because since shellcheck commit
4f81dbe ("Add warning about uninvoked functions,
reduce repeated triggering of SC2317 (fixes #2966)"), shellcheck
have a separate SC2329 for unreachable functions.
[1] koalaman/shellcheck@4f81dbe
Signed-off-by: Coiby Xu <coxu@redhat.com>
Summary of ChangesHello @coiby, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on maintaining code quality by updating Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request updates shellcheck disable comments to use the SC2329 warning code, which is correct for the latest version of shellcheck. The changes are appropriate. For kdump-logger.sh, I've provided a suggestion to refactor the code to avoid disabling the shellcheck warning, which is a better long-term solution. The change in kdumpctl is fine as it addresses a known false positive.
| # @retval 1 if something has gone wrong | ||
| # @retval 0 on success. | ||
| # shellcheck disable=SC2317 # skip for empty functions like dwarn | ||
| # shellcheck disable=SC2329 # skip for empty functions like dwarn |
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.
Instead of disabling the SC2329 warning, it's better to fix the underlying issue. The empty function definitions for loggers like ddebug, dinfo, dwarn, etc., inside dlog_init trigger this warning because they are called with arguments that they don't use.
You can silence this warning by modifying these empty functions to explicitly consume and ignore any arguments passed to them. This is considered better practice than disabling a static analysis check.
For example, you can change:
ddebug()
{
:
}to:
ddebug()
{
: "$@"
}This change should be applied to all the empty logger function definitions in dlog_init (ddebug, dinfo, dwarn, dwarning, derror). This will make the code cleaner and the shellcheck disable comment will no longer be needed.
shellcheck v0.11 emits the following warnings,
In kdumpctl line 551:
_record_block_drivers()
^-- SC2329 (info): This function is never invoked. Check usage (or ignored if invoked indirectly).
In dracut/99kdumpbase/module-setup.sh line 902:
kdump_check_setup_iscsi() {
^-- SC2329 (info): This function is never invoked. Check usage (or ignored if invoked indirectly).
These warnings are false positives caused by a regression of shellcheck
koalaman/shellcheck#3273
Before shellcheck fixes it, let's suppress this warning for now.
Signed-off-by: Coiby Xu <coxu@redhat.com>
Suppress the following shellcheck warnings,
In spec/kdumpctl_general_spec.sh line 8:
grubby() {
^-- SC2329 (info): This function is never invoked. Check usage (or ignored if invoked indirectly).
...
In spec/kdumpctl_general_spec.sh line 77:
...
In spec/kdumpctl_manage_crashkernel_spec.sh line 12:
...
In spec/kdumpctl_reset_crashkernel_spec.sh line 12:
...
In spec/kdumpctl_reset_crashkernel_spec.sh line 17:
...
In spec/kdumpctl_setup_crypttab_spec.sh line 22:
get_all_kdump_crypt_dev() {
^-- SC2329 (info): This function is never invoked. Check usage (or ignored if invoked indirectly).
...
In spec/kdumpctl_setup_crypttab_spec.sh line 82:
The stderr should include "Device UUID=$(get_all_kdump_crypt_dev) doesn't exist"
^---------------------^ SC2218 (error): This function is only defined later. Move the definition up
Signed-off-by: Coiby Xu <coxu@redhat.com>
51eed30 to
96e67b0
Compare
This PR resolves warnings emitted by current shellcheck (v0.11).