Skip to content

Commit 72d1396

Browse files
committed
fix: Combine ghp_ and gho_ token validation to resolve SonarCloud duplicate code warning
- Merge identical return True statements for ghp_ and gho_ tokens - Both token types use same length validation (>= 40) - Resolves SonarCloud code duplication warning
1 parent 2c796a0 commit 72d1396

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

githubauthlib/github_auth.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ def _validate_token(token: str) -> bool:
6161
# GitHub organization tokens start with 'gho_' and are 40 characters long
6262
# GitHub fine-grained tokens start with 'github_pat_' and are longer
6363
# Allow for some flexibility in token length for testing
64-
if token.startswith("ghp_") and len(token) >= 40:
65-
return True
66-
elif token.startswith("gho_") and len(token) >= 40:
64+
if (token.startswith("ghp_") or token.startswith("gho_")) and len(token) >= 40:
6765
return True
6866
elif token.startswith("github_pat_") and len(token) > 40:
6967
return True

0 commit comments

Comments
 (0)