Feature: Standardize Function - #20
Merged
Merged
Conversation
- 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)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Control Flow with Explicit Return Statements
This pull request implements a comprehensive code quality improvement by adding explicit return statements to all shell functions throughout the project. This enhancement addresses SonarCloud maintainability warnings and establishes consistent control flow patterns across the entire codebase.
Changes Implemented:
Function Standardization: Updated every shell function to include explicit
returnstatementsPattern Consistency: Applied uniform return patterns:
return 0for successful function completionreturn 1(or appropriate exit code) for error conditionsScope: Modified all functions across all modules:
src/github/src/gitlab/src/bitbucket/src/utils/Technical Details:
Before (Implicit Return)
After (Explicit Return)
Patterns Applied:
return 0(success) or appropriate error codeBenefits:
1. Improved Code Clarity
2. Enhanced Maintainability
3. Better Error Handling
4. SonarCloud Compliance
Motivation:
While shell scripts often rely on implicit returns (the exit status of the last command), explicit return statements provide several key advantages:
This refactoring follows shell scripting best practices as documented in: