SK-2520: extract hard coded strings to constants and update linting r…#164
Conversation
|
✅ Gitleaks Findings: No secrets detected. Safe to proceed! |
|
Semgrep Findings: Issues with Error level severity are found (Error is Highest severity in Semgrep), Please resolve the issues before merging. |
|
GoSec Findings: No issues found, Good to merge. |
There was a problem hiding this comment.
Pull request overview
This PR extracts hardcoded string literals into constants as part of a linting audit to improve code maintainability and readability across the GO SDK v2. The changes introduce new linting rules to enforce the use of constants over hardcoded values and update existing code to reference well-defined constants.
Changes:
- Added new constants for file extensions, entity types, HTTP headers, JSON keys, JWT claims, and other commonly used string literals
- Refactored existing code to use constants instead of hardcoded string values
- Updated linting configuration to enable
goconstandadd-constantrules to enforce constant usage
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| v2/internal/constants/constants.go | Added 170+ new constant definitions for file extensions, entity types, HTTP headers, JSON keys, and other string literals |
| v2/utils/messages/error_logs.go | Added three new error message constants for JSON marshalling and file operations |
| v2/utils/error/message.go | Added constant for unmarshal error message and adjusted import alias |
| v2/utils/error/skyflow_exception.go | Replaced hardcoded strings with constants for HTTP status, content types, error keys, and headers |
| v2/internal/vault/controller/vault_controller.go | Replaced hardcoded strings with constants for environment variables and response keys |
| v2/internal/vault/controller/detect_controller.go | Replaced hardcoded strings with constants for file types, extensions, entity types, and file processing |
| v2/internal/vault/controller/connection_controller.go | Replaced hardcoded strings with constants for headers, request types, and content types |
| v2/internal/validation/validations.go | Replaced hardcoded strings with constants for request types, entity types, protocols, and validation context |
| v2/internal/helpers/helpers.go | Replaced hardcoded strings with constants for JWT claims, credential keys, JSON keys, and SDK metadata |
| v2/.golangci.yml | Added goconst linter and add-constant rule to enforce constant usage patterns |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Why:
Following the Node SDK linting audit and refactor, this ticket focuses on applying the same linting standards and best practices across GO SDK v2.
The goal is to ensure consistent use of constants over hardcoded values across GO SDK v2, improving maintainability and readability.
Goal:
Update linting rules to discourage hardcoded literals where constants should be used.
Refactor existing code to replace hardcoded values with well-defined constants.