Merged
Conversation
Signed-off-by: BoxBoxJason <contact@boxboxjason.dev>
Signed-off-by: BoxBoxJason <contact@boxboxjason.dev>
There was a problem hiding this comment.
Pull request overview
This PR adds exported constants for commonly-used SonarQube API enum/string values across the Go SDK to reduce user hardcoding, and then updates validations + unit/e2e tests to use those constants consistently.
Changes:
- Introduces many new exported constants (rule severities/impacts/types/statuses, selection filters, project qualifiers/visibility, CE task statuses/types/fields, hotspot statuses/resolutions, etc.).
- Replaces hardcoded string literals in “allowed values” validation sets with the new constants.
- Refactors unit tests and integration tests to use the new constants.
Reviewed changes
Copilot reviewed 49 out of 49 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sonar/users_service_test.go | Uses selection filter constants in tests. |
| sonar/users_service.go | Adds homepage/notice-type constants and uses them in allowed sets. |
| sonar/user_tokens_service.go | Adds token type constants and uses them in allowed set. |
| sonar/user_groups_service_test.go | Uses selection filter constants in tests. |
| sonar/user_groups_service.go | Adds group field constants; uses selection filter constants in allowed set. |
| sonar/system_service.go | Adds log level/name constants; uses them in allowed sets. |
| sonar/rules_service_test.go | Updates tests to use rule/impact/type/status/software-quality constants. |
| sonar/rules_service.go | Adds rule enum constants; updates validations and docs to use correct allowed sets. |
| sonar/qualityprofiles_service_test.go | Uses new severity/impact constants in tests. |
| sonar/qualityprofiles_service.go | Updates severity/impact validation to use renamed allowed sets. |
| sonar/projects_service_test.go | Uses new project qualifier/visibility constants in tests. |
| sonar/projects_service.go | Adds project qualifier/visibility constants; uses them in allowed sets. |
| sonar/project_badges_service.go | Adds badge metric constants; uses them in allowed set. |
| sonar/permissions_service_test.go | Uses project qualifier constants in tests. |
| sonar/permissions_service.go | Adds permission constants; uses them in allowed sets. |
| sonar/new_code_periods_service_test.go | Uses new-code-period type constants in tests. |
| sonar/new_code_periods_service.go | Adds new-code-period type constants; uses them in allowed set. |
| sonar/navigation_service_test.go | Uses project qualifier constants in tests. |
| sonar/measures_service_test.go | Uses measure strategy constant in tests. |
| sonar/measures_service.go | Adds measure strategy/sort-filter constants; uses them in allowed sets. |
| sonar/issues_service_test.go | Uses rule severity/type/impact severity + issue transition constants in tests. |
| sonar/issues_service.go | Adds issue transition/status/resolution/scope constants; updates validations to renamed allowed sets. |
| sonar/hotspots_service_test.go | Uses hotspot status/resolution + OWASP/SANS constants in tests. |
| sonar/hotspots_service.go | Adds hotspot status/resolution constants; uses them in allowed sets. |
| sonar/favorites_service_test.go | Uses project qualifier constants in tests. |
| sonar/components_service_test.go | Uses project qualifier + strategy constants in tests. |
| sonar/common.go | Centralizes many shared constants; renames allowed severity/impact sets and rewires allowed maps to constants. |
| sonar/clean_code_policy_v2_service_test.go | Updates tests to use new constants (but has a few inconsistent constant selections). |
| sonar/clean_code_policy_v2_service.go | Switches validation to renamed impact/rule severity allowed sets. |
| sonar/ce_service_test.go | Uses CE task status/type/field constants in tests. |
| sonar/ce_service.go | Adds CE task status/type/field constants; uses them in allowed sets. |
| sonar/analysis_v2_service_test.go | Uses rule severity + software quality/impact constants in v2 analysis tests. |
| sonar/alm_integrations_service_test.go | Uses new-code-period type constants in tests. |
| sonar/alm_integrations_service.go | Uses new-code-period type constants in allowed set. |
| internal/cli/flags_test.go | Imports sonar package to assert parsed severities against constants. |
| integration_testing/v2_clean_code_policy_test.go | Uses new constants in v2 clean-code-policy e2e tests. |
| integration_testing/user_groups_test.go | Uses selection filter constants in e2e tests. |
| integration_testing/rules_test.go | Uses rule severity/type/status constants in e2e tests. |
| integration_testing/qualityprofiles_test.go | Uses selection filter constants in e2e tests. |
| integration_testing/qualitygates_test.go | Uses selection filter constants in e2e tests. |
| integration_testing/projects_test.go | Uses project visibility/qualifier constants in e2e tests. |
| integration_testing/permissions_test.go | Uses project visibility/qualifier constants in e2e tests. |
| integration_testing/new_code_periods_test.go | Uses new-code-period type constants in e2e tests. |
| integration_testing/measures_test.go | Uses measure strategy/sort-filter constants in e2e tests. |
| integration_testing/issues_test.go | Uses impact severity, issue status/category, transition, rule severity/type constants in e2e tests. |
| integration_testing/hotspots_test.go | Uses hotspot status/resolution constants in e2e tests. |
| integration_testing/components_test.go | Uses qualifier + strategy constants in e2e tests. |
| integration_testing/ce_test.go | Uses task status/type constants in e2e tests. |
| integration_testing/alm_integrations_test.go | Uses new-code-period type constants in e2e tests. |
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: BoxBoxJason <contact+github@boxboxjason.dev>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: BoxBoxJason <contact+github@boxboxjason.dev>
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.
Description of your changes
This PR introduces constants to help the users use preconfigured "valid" values and reduce hardcoding in their codebase.
It also uses them directly in the unit tests & e2e tests to ensure they are working as intended.
Closes #173
I have:
How has this code been tested
I have:
make lintpasses to verify that the code style is correct.make testpasses to verify that the code is working as intended.make e2epasses to verify that end-to-end tests pass against a real SonarQube instance.