Skip to content

feat: create usage constants#194

Merged
BoxBoxJason merged 4 commits intomainfrom
feat/usage-constants
Mar 18, 2026
Merged

feat: create usage constants#194
BoxBoxJason merged 4 commits intomainfrom
feat/usage-constants

Conversation

@BoxBoxJason
Copy link
Copy Markdown
Owner

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:

  • Followed the git conventional commit message format.
  • Made sure all changes are covered by proper tests, reaching a coverage of at least 80% when applicable.

How has this code been tested

I have:

  • Made sure make lint passes to verify that the code style is correct.
  • Made sure make test passes to verify that the code is working as intended.
  • Made sure make e2e passes to verify that end-to-end tests pass against a real SonarQube instance.

Signed-off-by: BoxBoxJason <contact@boxboxjason.dev>
Signed-off-by: BoxBoxJason <contact@boxboxjason.dev>
@BoxBoxJason BoxBoxJason added this to the User Production Readiness milestone Mar 15, 2026
@BoxBoxJason BoxBoxJason self-assigned this Mar 15, 2026
@BoxBoxJason BoxBoxJason added enhancement New feature or request unit-test Unit test related work e2e end to end tests related work sdk SonarQube golang SDK related work labels Mar 15, 2026
@BoxBoxJason BoxBoxJason requested a review from Copilot March 15, 2026 23:49
@BoxBoxJason BoxBoxJason changed the title Feat/usage constants feat: create usage constants Mar 15, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

BoxBoxJason and others added 2 commits March 19, 2026 00:36
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>
@BoxBoxJason BoxBoxJason merged commit ce637aa into main Mar 18, 2026
4 checks passed
@BoxBoxJason BoxBoxJason deleted the feat/usage-constants branch March 18, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e end to end tests related work enhancement New feature or request sdk SonarQube golang SDK related work unit-test Unit test related work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create Constants for common values

2 participants