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

Fix shellcheck warnings in hack/build.sh script #1859

Closed
dsimansk opened this issue Aug 30, 2023 · 1 comment · Fixed by #1860
Closed

Fix shellcheck warnings in hack/build.sh script #1859

dsimansk opened this issue Aug 30, 2023 · 1 comment · Fixed by #1860
Assignees
Labels
good first issue Denotes an issue ready for a new contributor. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.
Milestone

Comments

@dsimansk
Copy link
Contributor

dsimansk commented Aug 30, 2023

There are a few warnings in our ./hack/build.sh script that would be nice to fix. It might pop-up in case of changing the script in the future.

There are several more with INFO severity level. Those can be ignored for now.

➜  client git:(main) shellcheck -S warning hack/build.sh

In hack/build.sh line 40:
  pushd $(basedir) >/dev/null 2>&1
        ^--------^ SC2046 (warning): Quote this to prevent word splitting.


In hack/build.sh line 43:
  if $(has_flag --help -h); then
     ^-------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).


In hack/build.sh line 48:
  if $(has_flag --watch -w); then
     ^--------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).


In hack/build.sh line 52:
    if $(has_flag --test -t); then
       ^-------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).


In hack/build.sh line 61:
  if $(has_flag --fast -f); then
     ^-------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).


In hack/build.sh line 64:
    if $(has_flag --test -t); then
       ^-------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).


In hack/build.sh line 71:
  if $(has_flag --test -t); then
     ^-------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).


In hack/build.sh line 77:
  if $(has_flag --codegen -c); then
     ^----------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).


In hack/build.sh line 83:
  if $(has_flag --all -x); then
     ^------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).


In hack/build.sh line 118:
  find $(echo "$source_dirs") -name "*.go" -print0 | xargs -0 gofmt -s -w
       ^--------------------^ SC2046 (warning): Quote this to prevent word splitting.


In hack/build.sh line 123:
  go_run "golang.org/x/tools/cmd/goimports@${GOIMPORTS_VERSION}" -w $(echo "$source_dirs")
                                                                    ^--------------------^ SC2046 (warning): Quote this to prevent word splitting.


In hack/build.sh line 124:
  find $(echo "$source_dirs") -name "*.go" -print0 | xargs -0 gofmt -s -w
       ^--------------------^ SC2046 (warning): Quote this to prevent word splitting.


In hack/build.sh line 139:
  if $(file kn | grep -q -i "Windows"); then
     ^-- SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).


In hack/build.sh line 199:
  $(basedir)/hack/update-deps.sh
  ^--------^ SC2046 (warning): Quote this to prevent word splitting.


In hack/build.sh line 211:
    local fswatch_opts='-e "^\..*$" -o pkg cmd'
                       ^----------------------^ SC2089 (warning): Quotes/backslashes will be treated literally. Use an array.


In hack/build.sh line 212:
    if $(has_flag --test -t); then
       ^-------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).


In hack/build.sh line 215:
    if $(has_flag --verbose); then
       ^-------------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).


In hack/build.sh line 231:
    fswatch $fswatch_opts | xargs -n1 -I{} sh -c "$command && echo 👌 OK"
            ^-----------^ SC2090 (warning): Quotes/backslashes in this variable will not be respected.


In hack/build.sh line 261:
    filters="$@"
            ^--^ SC2124 (warning): Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.


In hack/build.sh line 321:
display_help() {
^-- SC2120 (warning): display_help references arguments, but none are ever passed.


In hack/build.sh line 326:
Usage: $(basename $BASH_SOURCE) [... options ...]
                  ^----------^ SC2128 (warning): Expanding an array without an index only gives the first element.


In hack/build.sh line 356:
if $(has_flag --debug); then
   ^-----------------^ SC2091 (warning): Remove surrounding $() to avoid executing output (or use eval if intentional).


In hack/build.sh line 362:
source $(basedir)/vendor/knative.dev/hack/library.sh
       ^--------^ SC2046 (warning): Quote this to prevent word splitting.


In hack/build.sh line 366:
  source "${file}"
         ^-------^ SC1090 (warning): ShellCheck can't follow non-constant source. Use a directive to specify location.


In hack/build.sh line 368:
source $(basedir)/hack/build-flags.sh
       ^--------^ SC2046 (warning): Quote this to prevent word splitting.

For more information:
  https://www.shellcheck.net/wiki/SC1090 -- ShellCheck can't follow non-const...
  https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word splitt...
  https://www.shellcheck.net/wiki/SC2089 -- Quotes/backslashes will be treate...

/kind cleanup
/kind good-first-issue

@knative-prow knative-prow bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. good first issue Denotes an issue ready for a new contributor. labels Aug 30, 2023
@dsimansk dsimansk added this to the Knative 1.12 milestone Aug 30, 2023
@xiangpingjiang
Copy link
Contributor

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants