-
Notifications
You must be signed in to change notification settings - Fork 6
chore: fix SonarCloud S7682 violations and trigger CodeRabbit audit #63
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -41,19 +41,22 @@ find_project_root() { | |||||||||||||||||||||||||||
| # Get current branch | ||||||||||||||||||||||||||||
| get_branch() { | ||||||||||||||||||||||||||||
| git branch --show-current 2>/dev/null || echo "not-a-git-repo" | ||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Check if on protected branch | ||||||||||||||||||||||||||||
| is_protected_branch() { | ||||||||||||||||||||||||||||
| local branch | ||||||||||||||||||||||||||||
| branch=$(get_branch) | ||||||||||||||||||||||||||||
| [[ "$branch" == "main" || "$branch" == "master" ]] | ||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
Comment on lines
47
to
53
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: The For example:
🐛 Proposed fix - remove the return 0 from this predicate function is_protected_branch() {
local branch
branch=$(get_branch)
[[ "$branch" == "main" || "$branch" == "master" ]]
- return 0
}Alternatively, if SonarCloud requires explicit returns, use the comparison's exit status: is_protected_branch() {
local branch
branch=$(get_branch)
- [[ "$branch" == "main" || "$branch" == "master" ]]
- return 0
+ if [[ "$branch" == "main" || "$branch" == "master" ]]; then
+ return 0
+ else
+ return 1
+ fi
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Get recent commits | ||||||||||||||||||||||||||||
| get_recent_commits() { | ||||||||||||||||||||||||||||
| local count="${1:-10}" | ||||||||||||||||||||||||||||
| git log --oneline -"$count" 2>/dev/null || echo "No commits" | ||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Get uncommitted changes count | ||||||||||||||||||||||||||||
|
|
@@ -62,6 +65,7 @@ get_uncommitted_changes() { | |||||||||||||||||||||||||||
| staged=$(git diff --cached --name-only 2>/dev/null | wc -l | tr -d '[:space:]') | ||||||||||||||||||||||||||||
| unstaged=$(git diff --name-only 2>/dev/null | wc -l | tr -d '[:space:]') | ||||||||||||||||||||||||||||
| echo "staged:${staged:-0},unstaged:${unstaged:-0}" | ||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Get TODO.md status | ||||||||||||||||||||||||||||
|
|
@@ -95,6 +99,7 @@ get_ralph_status() { | |||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||
| echo "active:false" | ||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Get open PRs | ||||||||||||||||||||||||||||
|
|
@@ -110,6 +115,7 @@ get_pr_status() { | |||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||
| echo "gh-not-installed" | ||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Check workflow adherence | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
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.
There are two issues with these logging functions:
log_errorfunction should print to standard error (>&2) to follow standard practice for error messages. This allows callers to separate normal output from error output.Here's a suggested fix for both issues: