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

Test the shell code issue. #66

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

Conversation

sandyyeah100
Copy link
Collaborator

@sandyyeah100 sandyyeah100 commented Sep 10, 2024

Test the shellcheck analyzer integration.

Copy link

Codety
Issues found in this pull request based on Codety's default factory settings:

Shell

File Issue
code-issue-examples/shell/bad-shell.sh 🟡 [styling] [2089] Quotes/backslashes will be treated literally. Use an array. view
🟡 [styling] [2090] Quotes/backslashes in this variable will not be respected. view
🟡 [styling] [2088] Tilde does not expand in quotes. Use $HOME. view
🟡 [styling] [2061] Quote the parameter to -name so the shell won't interpret it. view
🟡 [styling] [2035] Use ./glob or -- glob so names with dashes won't become options. view
🔴 [styling] [2148] Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive. view
🟡 [styling] [2086] Double quote to prevent globbing and word splitting. view
code-issue-examples/shell/bad-shell-2.sh 🟡 [styling] [2184] Quote arguments to unset so they're not glob expanded. view
🟡 [styling] [2064] Use single quotes, otherwise this expands now rather than when signalled. view

echo $1 # Unquoted variables
find . -name *.ogg # Unquoted find/grep patterns
rm "~/my file.txt" # Quoted tilde expansion
v='--verbose="true"'; cmd $v # Literal quotes in variables

Choose a reason for hiding this comment

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

Codety
CodetyBot:

  • 🟡 [styling] [2089] Quotes/backslashes will be treated literally. Use an array.
  • 🟡 [styling] [2090] Quotes/backslashes in this variable will not be respected.

v='--verbose="true"'; cmd $v # Literal quotes in variables
echo $1 # Unquoted variables
find . -name *.ogg # Unquoted find/grep patterns
rm "~/my file.txt" # Quoted tilde expansion

Choose a reason for hiding this comment

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

Codety
CodetyBot:

  • 🟡 [styling] [2088] Tilde does not expand in quotes. Use $HOME.

rm "~/my file.txt" # Quoted tilde expansion
v='--verbose="true"'; cmd $v # Literal quotes in variables
echo $1 # Unquoted variables
find . -name *.ogg # Unquoted find/grep patterns

Choose a reason for hiding this comment

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

Codety
CodetyBot:

  • 🟡 [styling] [2061] Quote the parameter to -name so the shell won't interpret it.
  • 🟡 [styling] [2035] Use ./glob or -- glob so names with dashes won't become options.

find . -name *.ogg # Unquoted find/grep patterns
rm "~/my file.txt" # Quoted tilde expansion
v='--verbose="true"'; cmd $v # Literal quotes in variables
echo $1 # Unquoted variables

Choose a reason for hiding this comment

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

Codety
CodetyBot:

  • 🔴 [styling] [2148] Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
  • 🟡 [styling] [2086] Double quote to prevent globbing and word splitting.

echo 'Path is $PATH' # Variables in single quotes
trap "echo Took ${SECONDS}s" 0 # Prematurely expanded trap

Choose a reason for hiding this comment

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

Codety
CodetyBot:

  • 🟡 [styling] [2064] Use single quotes, otherwise this expands now rather than when signalled.

echo 'Path is $PATH' # Variables in single quotes
trap "echo Took ${SECONDS}s" 0 # Prematurely expanded trap
unset var[i] # Array index treated as glob

Choose a reason for hiding this comment

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

Codety
CodetyBot:

  • 🟡 [styling] [2184] Quote arguments to unset so they're not glob expanded.

random1223 added a commit to random1223/shellcheck that referenced this pull request Sep 10, 2024
Add Codety Scanner into the static analysis solution list. 
Here are the examples of the result:
* Codety's pull request code review example: codetyio/codety-scanner#66 (comment)
* Codety's GitHub code scan result example : https://github.com/codetyio/codety-scanner/runs/29907371258

Codety Scanner is open source: https://github.com/codetyio/codety-scanner
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.

1 participant