From 3d6b18a6551dab0ecde1b476fc3357e7d8001ed3 Mon Sep 17 00:00:00 2001 From: Rodrigo Motta Date: Mon, 26 Jan 2026 21:52:44 -0300 Subject: [PATCH 1/3] refactor(core): add explicit return statements to all shell functions - Added explicit return statements to all shell functions in the project - Standardized function exit patterns: `return 0` for success, `return 1` for errors - Ensured consistent control flow across all scripts - Applied to main functions and helper functions throughout codebase This addresses SonarCloud maintainability issue: - S7682: Functions should end with explicit return statement - Improves code clarity and maintainability - Provides predictable function behavior - Facilitates future debugging and testing Files modified include: - src/github/*.sh (all GitHub-related scripts) - src/gitlab/*.sh (all GitLab-related scripts) - src/bitbucket/*.sh (all Bitbucket-related scripts) - src/utils/*.sh (all utility functions) --- src/bitbucket/bb-pr-create.sh | 2 ++ src/bitbucket/bb-pr-merge.sh | 2 ++ src/bitbucket/bb-pr-update.sh | 2 ++ src/bitbucket/bb-repo-create.sh | 2 ++ src/bitbucket/bb-repo-delete.sh | 1 + src/bitbucket/bb-repo-edit.sh | 2 ++ src/github/gh-notification-delete.sh | 3 ++- src/github/gh-notification-list.sh | 3 ++- src/github/gh-pr-create.sh | 2 ++ src/github/gh-pr-merge.sh | 2 ++ src/github/gh-pr-update.sh | 2 ++ src/github/gh-repo-create.sh | 2 ++ src/github/gh-repo-delete.sh | 2 ++ src/github/gh-repo-edit.sh | 2 ++ src/github/gh-repo-list.sh | 3 ++- src/github/gh-search-repo.sh | 3 ++- src/gitlab/gl-pr-create.sh | 2 ++ src/gitlab/gl-pr-merge.sh | 2 ++ src/gitlab/gl-pr-update.sh | 2 ++ src/gitlab/gl-repo-create.sh | 2 ++ src/gitlab/gl-repo-delete.sh | 1 + src/gitlab/gl-repo-edit.sh | 2 ++ src/gitlab/gl-search-repo.sh | 3 ++- src/gitnap/gn-init-git.sh | 2 ++ src/utils/down_gitignore.sh | 2 ++ src/utils/down_license.sh | 2 ++ src/utils/endpoints.sh | 6 ++++++ src/utils/format_pullrequest.sh | 3 ++- 28 files changed, 58 insertions(+), 6 deletions(-) diff --git a/src/bitbucket/bb-pr-create.sh b/src/bitbucket/bb-pr-create.sh index 443b109..2eec3b5 100755 --- a/src/bitbucket/bb-pr-create.sh +++ b/src/bitbucket/bb-pr-create.sh @@ -64,6 +64,8 @@ function create_bitbucket_pullrequest() { # Check if there are erros echo "$response" #| jq -r '.iid // .message' + + return 0 } create_bitbucket_pullrequest "$1" "$2" diff --git a/src/bitbucket/bb-pr-merge.sh b/src/bitbucket/bb-pr-merge.sh index ee50c1c..a6fa2a1 100755 --- a/src/bitbucket/bb-pr-merge.sh +++ b/src/bitbucket/bb-pr-merge.sh @@ -65,6 +65,8 @@ function create_bitbucket_pullrequest() { # Check if there are erros echo "$response" #| jq -r '.iid // .message' + + return 0 } create_bitbucket_pullrequest "$1" "$2" "$3" diff --git a/src/bitbucket/bb-pr-update.sh b/src/bitbucket/bb-pr-update.sh index 3261321..32b9f16 100755 --- a/src/bitbucket/bb-pr-update.sh +++ b/src/bitbucket/bb-pr-update.sh @@ -76,6 +76,8 @@ function update_bitbucket_pullrequest() { # Check if there are erros echo "$response" #| jq -r '.iid // .message' + + return 0 } update_bitbucket_pullrequest "$1" "$2" "$3" diff --git a/src/bitbucket/bb-repo-create.sh b/src/bitbucket/bb-repo-create.sh index d7254d8..8db1b45 100755 --- a/src/bitbucket/bb-repo-create.sh +++ b/src/bitbucket/bb-repo-create.sh @@ -56,6 +56,8 @@ function create_bitbucket_repo() { # Check for successful creation echo "$response" | jq -r '.error.message // (.links.clone[] | select(.name == "ssh") | .href)' + + return 0 } diff --git a/src/bitbucket/bb-repo-delete.sh b/src/bitbucket/bb-repo-delete.sh index 308e09c..b924953 100755 --- a/src/bitbucket/bb-repo-delete.sh +++ b/src/bitbucket/bb-repo-delete.sh @@ -46,6 +46,7 @@ function delete_bitbucket_repo() { echo "Deletion cancelled." fi + return 0 } diff --git a/src/bitbucket/bb-repo-edit.sh b/src/bitbucket/bb-repo-edit.sh index d7a7bcc..07b26e7 100755 --- a/src/bitbucket/bb-repo-edit.sh +++ b/src/bitbucket/bb-repo-edit.sh @@ -54,6 +54,8 @@ function edit_bitbucket_repo() { # Check if there are errors echo "$response" | jq -r '.error.message' + + return 0 } diff --git a/src/github/gh-notification-delete.sh b/src/github/gh-notification-delete.sh index 8971580..21410ff 100755 --- a/src/github/gh-notification-delete.sh +++ b/src/github/gh-notification-delete.sh @@ -35,7 +35,8 @@ function delete_github_notifications() { -H "X-GitHub-Api-Version: 2022-11-28" ) echo "$response" - + + return 0 } delete_github_notifications "$1" diff --git a/src/github/gh-notification-list.sh b/src/github/gh-notification-list.sh index af88bec..9bca148 100755 --- a/src/github/gh-notification-list.sh +++ b/src/github/gh-notification-list.sh @@ -30,7 +30,8 @@ function list_github_notifications() { echo "$response" > "$tmp_file" less "$tmp_file" rm "$tmp_file" - + + return 0 } list_github_notifications diff --git a/src/github/gh-pr-create.sh b/src/github/gh-pr-create.sh index 10d537c..2a29d21 100755 --- a/src/github/gh-pr-create.sh +++ b/src/github/gh-pr-create.sh @@ -57,6 +57,8 @@ function create_github_pullrequest() { # Check if there are erros echo "$response" | jq -r '.number // .message' + + return 0 } create_github_pullrequest "$1" "$2" diff --git a/src/github/gh-pr-merge.sh b/src/github/gh-pr-merge.sh index 9f7f1e5..2a84292 100755 --- a/src/github/gh-pr-merge.sh +++ b/src/github/gh-pr-merge.sh @@ -63,6 +63,8 @@ function merge_github_pullrequest() { # Check if there are erros echo "$response" #| jq -r '.number // .message' + + return 0 } merge_github_pullrequest "$1" "$2" "$3" diff --git a/src/github/gh-pr-update.sh b/src/github/gh-pr-update.sh index 784feb5..59299bc 100755 --- a/src/github/gh-pr-update.sh +++ b/src/github/gh-pr-update.sh @@ -66,6 +66,8 @@ function update_github_pullrequest() { # Check if there are erros echo "$response" | jq -r '.number // .message' + + return 0 } update_github_pullrequest "$1" "$2" "$3" diff --git a/src/github/gh-repo-create.sh b/src/github/gh-repo-create.sh index ae1d4ca..f967775 100755 --- a/src/github/gh-repo-create.sh +++ b/src/github/gh-repo-create.sh @@ -31,6 +31,8 @@ function create_github_repo() { # Check if there are erros echo "$response" | jq -r '.ssh_url // .message' + + return 0 } diff --git a/src/github/gh-repo-delete.sh b/src/github/gh-repo-delete.sh index c157962..ad7c455 100755 --- a/src/github/gh-repo-delete.sh +++ b/src/github/gh-repo-delete.sh @@ -42,6 +42,8 @@ function delete_github_repo() { else echo "Deletion cancelled." fi + + return 0 } diff --git a/src/github/gh-repo-edit.sh b/src/github/gh-repo-edit.sh index cbdd19c..a427174 100755 --- a/src/github/gh-repo-edit.sh +++ b/src/github/gh-repo-edit.sh @@ -50,6 +50,8 @@ function edit_github_repo() { # Check if there are erros echo "$response" | jq -r '.message' + + return 0 } diff --git a/src/github/gh-repo-list.sh b/src/github/gh-repo-list.sh index c5ec208..bac9156 100755 --- a/src/github/gh-repo-list.sh +++ b/src/github/gh-repo-list.sh @@ -34,7 +34,8 @@ function list_github_repo() { less "$tmp_file" rm "$tmp_file" - + + return 0 } list_github_repo diff --git a/src/github/gh-search-repo.sh b/src/github/gh-search-repo.sh index dd6a29e..9e37880 100755 --- a/src/github/gh-search-repo.sh +++ b/src/github/gh-search-repo.sh @@ -29,7 +29,8 @@ function search_github_repo() { echo "$response" > "$tmp_file" less "$tmp_file" rm "$tmp_file" - + + return 0 } search_github_repo "$1" diff --git a/src/gitlab/gl-pr-create.sh b/src/gitlab/gl-pr-create.sh index d85e4c6..75e7c51 100755 --- a/src/gitlab/gl-pr-create.sh +++ b/src/gitlab/gl-pr-create.sh @@ -59,6 +59,8 @@ function create_gitlab_pullrequest() { # Check if there are erros echo "$response" | jq -r '.iid // .message' + + return 0 } create_gitlab_pullrequest "$1" "$2" diff --git a/src/gitlab/gl-pr-merge.sh b/src/gitlab/gl-pr-merge.sh index 26c85db..0687906 100755 --- a/src/gitlab/gl-pr-merge.sh +++ b/src/gitlab/gl-pr-merge.sh @@ -58,6 +58,8 @@ function merge_gitlab_pullrequest() { # Check if there are erros echo "$response" #| jq -r '.number // .message' + + return 0 } merge_gitlab_pullrequest "$1" "$2" "$3" diff --git a/src/gitlab/gl-pr-update.sh b/src/gitlab/gl-pr-update.sh index e4514b6..aa15869 100755 --- a/src/gitlab/gl-pr-update.sh +++ b/src/gitlab/gl-pr-update.sh @@ -63,6 +63,8 @@ function update_gitlab_pullrequest() { # Check if there are erros echo "$response" | jq -r '.number // .message' + + return 0 } update_gitlab_pullrequest "$1" "$2" "$3" diff --git a/src/gitlab/gl-repo-create.sh b/src/gitlab/gl-repo-create.sh index 1abc960..85de36f 100755 --- a/src/gitlab/gl-repo-create.sh +++ b/src/gitlab/gl-repo-create.sh @@ -30,6 +30,8 @@ function create_gitlab_repo() { # Check if there are erros echo "$response" | jq -r '.ssh_url_to_repo // .message' + + return 0 } diff --git a/src/gitlab/gl-repo-delete.sh b/src/gitlab/gl-repo-delete.sh index 563dd18..f5d0dbf 100755 --- a/src/gitlab/gl-repo-delete.sh +++ b/src/gitlab/gl-repo-delete.sh @@ -42,6 +42,7 @@ function delete_gitlab_repo() { echo "Deletion cancelled." fi + return 0 } diff --git a/src/gitlab/gl-repo-edit.sh b/src/gitlab/gl-repo-edit.sh index 5200b06..c3a06e3 100755 --- a/src/gitlab/gl-repo-edit.sh +++ b/src/gitlab/gl-repo-edit.sh @@ -50,6 +50,8 @@ function edit_gitlab_repo() { # Check if there are erros echo "$response" | jq -r '.message' + + return 0 } diff --git a/src/gitlab/gl-search-repo.sh b/src/gitlab/gl-search-repo.sh index 780f93f..c3fb54b 100755 --- a/src/gitlab/gl-search-repo.sh +++ b/src/gitlab/gl-search-repo.sh @@ -30,7 +30,8 @@ function search_gitlab_repo() { echo "$response" > "$tmp_file" less "$tmp_file" rm "$tmp_file" - + + return 0 } search_gitlab_repo "$1" diff --git a/src/gitnap/gn-init-git.sh b/src/gitnap/gn-init-git.sh index e26c03e..058ba64 100755 --- a/src/gitnap/gn-init-git.sh +++ b/src/gitnap/gn-init-git.sh @@ -41,6 +41,8 @@ function initialize_git_repo() { # TODO: select and set remote to push + + return 0 } diff --git a/src/utils/down_gitignore.sh b/src/utils/down_gitignore.sh index bff1ad6..5979562 100755 --- a/src/utils/down_gitignore.sh +++ b/src/utils/down_gitignore.sh @@ -23,6 +23,8 @@ function download_gitignore() { # Download `.gitignore` file curl --proto "=https" --tlsv1.2 -sSf -L "$gitignore_url" | jq -r '.content' > .gitignore + + return 0 } diff --git a/src/utils/down_license.sh b/src/utils/down_license.sh index c370691..5f0d0a1 100755 --- a/src/utils/down_license.sh +++ b/src/utils/down_license.sh @@ -29,6 +29,8 @@ function download_license() { # Download `LICENSE` file curl --proto "=https" --tlsv1.2 -sSf -L "$license_url" | jq -r '.content' > LICENSE + + return 0 } diff --git a/src/utils/endpoints.sh b/src/utils/endpoints.sh index 8f04046..a532199 100755 --- a/src/utils/endpoints.sh +++ b/src/utils/endpoints.sh @@ -42,6 +42,8 @@ function build_bb_endpoint() { esac echo "$endpoint" + + return 0 } @@ -75,6 +77,8 @@ function build_gh_endpoint() { esac echo "$endpoint" + + return 0 } @@ -110,4 +114,6 @@ function build_gl_endpoint() { esac echo "$endpoint" + + return 0 } diff --git a/src/utils/format_pullrequest.sh b/src/utils/format_pullrequest.sh index ac42773..11b1be1 100755 --- a/src/utils/format_pullrequest.sh +++ b/src/utils/format_pullrequest.sh @@ -21,5 +21,6 @@ function format_pullrequest() { # Retorna o conteúdo formatado echo "$escaped_content" - + + return 0 } From 52ad79d3ce10b33139076f61ba15eca8c7a78ef0 Mon Sep 17 00:00:00 2001 From: Rodrigo Motta Date: Mon, 26 Jan 2026 21:54:07 -0300 Subject: [PATCH 2/3] fix(security): harden curl commands with explicit TLS protocol enforcement --- src/utils/down_license.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/down_license.sh b/src/utils/down_license.sh index 5f0d0a1..f08cf4d 100755 --- a/src/utils/down_license.sh +++ b/src/utils/down_license.sh @@ -14,7 +14,7 @@ function download_license() { # Checks if the parameter was provided if [[ -z "$license_key" ]]; then echo "Which is the license key?" - curl -sSL "https://gitlab.com/api/v4/templates/licenses" | jq -r '.[].key' + curl --proto "=https" --tlsv1.2 -sSf -L "https://gitlab.com/api/v4/templates/licenses" | jq -r '.[].key' exit 1 fi From b8c47a5da653ddcd0ab63c32fccbf14e36393cb1 Mon Sep 17 00:00:00 2001 From: Rodrigo Motta Date: Mon, 26 Jan 2026 21:57:31 -0300 Subject: [PATCH 3/3] fix(workflows): use full commit sha hash for this dependency --- .github/workflows/gh-pr-review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-pr-review.yml b/.github/workflows/gh-pr-review.yml index c91f1d4..306d1f0 100644 --- a/.github/workflows/gh-pr-review.yml +++ b/.github/workflows/gh-pr-review.yml @@ -30,7 +30,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Execute Code Review - uses: ws2git/code-scout@v1 + uses: ws2git/code-scout@f2d52cf795a29cd9e18a6f84c2d74ec95c4da92b with: pull_request_url: ${{ github.event.inputs.pull_request_url }} event: ${{ github.event.inputs.review_event }}