Skip to content

Conversation

@kim-tsao
Copy link
Member

@kim-tsao kim-tsao commented Dec 5, 2025

Description

Now that Sonarcloud is enabled, we should set the analysis scope and exclude test files from source scanning in order to reduce the noise.

Which issue(s) does this PR fix or relate to

PR acceptance criteria

  • Tests
  • Documentation

How to test changes / Special notes to the reviewer

@rhdh-qodo-merge
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🔒 No security concerns identified
⚡ Recommended focus areas for review

Possible Misconfiguration

Using both sonar.sources = . and sonar.tests = . points tests and sources to the same root, relying solely on inclusions/exclusions to separate them. This can lead to double counting or misclassification, especially if patterns miss some files. Consider scoping sonar.sources to non-test dirs and sonar.tests to explicit test dirs.

sonar.sources = .
sonar.tests= .

# Include test subdirectories in test scope
sonar.test.inclusions = tests/**/*, integration_tests/**/*, **/*_test.go

# Exclude test subdirectories from source scope
sonar.exclusions = tests/**/*, integration_tests/**/*, **/*_test.go
Glob Patterns

The glob **/*_test.go appears in both test inclusions and source exclusions. Ensure this matches your language mix; for non-Go projects it’s unnecessary, and for multi-language repos you might also need patterns for other test conventions (e.g., **/*.spec.ts, **/*Test.java). Validate that the patterns are correct and exhaustive.

sonar.test.inclusions = tests/**/*, integration_tests/**/*, **/*_test.go

# Exclude test subdirectories from source scope
sonar.exclusions = tests/**/*, integration_tests/**/*, **/*_test.go
📄 References
  1. redhat-developer/rhdh-operator/best_practices.md [116-165]
  2. redhat-developer/rhdh-operator/best_practices.md [110-115]
  3. redhat-developer/rhdh-operator/README.md [78-84]
  4. redhat-developer/rhdh-operator/README.md [74-77]
  5. redhat-developer/rhdh-operator/examples/rhdh-cr.yaml [5-30]
  6. redhat-developer/rhdh-operator/docs/orchestrator.md [164-243]
  7. redhat-developer/rhdh-operator/docs/orchestrator-cicd.md [221-232]
  8. redhat-developer/rhdh-operator/config/profile/rhdh/default-config/deployment.yaml [74-82]

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 5, 2025

@rhdh-qodo-merge rhdh-qodo-merge bot added the enhancement New feature or request label Dec 5, 2025
@rhdh-qodo-merge
Copy link

PR Type

Enhancement


Description

  • Add SonarCloud configuration file to define analysis scope

  • Exclude test files from source scanning to reduce noise

  • Include test directories in dedicated test scope


File Walkthrough

Relevant files
Configuration changes
.sonarcloud.properties
Configure SonarCloud analysis scope and exclusions             

.sonarcloud.properties

  • Created new SonarCloud configuration file with analysis scope settings
  • Configured source and test scopes to include all directories
  • Defined test file inclusions for tests/, integration_tests/, and
    *_test.go patterns
  • Excluded test files from source scope to prevent duplication and
    reduce analysis noise
+9/-0     

@rhdh-qodo-merge
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Remove redundant test file exclusion

Remove the redundant sonar.exclusions property. Files specified in
sonar.test.inclusions are automatically excluded from source analysis, so this
explicit exclusion is unnecessary.

.sonarcloud.properties [5-9]

 # Include test subdirectories in test scope
 sonar.test.inclusions = tests/**/*, integration_tests/**/*, **/*_test.go
 
-# Exclude test subdirectories from source scope
-sonar.exclusions = tests/**/*, integration_tests/**/*, **/*_test.go
-
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that sonar.exclusions is redundant because files matched by sonar.test.inclusions are automatically excluded from source analysis, thus simplifying the configuration and improving maintainability.

Low
Organization
best practice
Clarify analysis scope intent

Clarify intent in comments to explain that tests are analyzed but not counted as
sources due to explicit inclusions/exclusions, preventing confusion.

.sonarcloud.properties [1-3]

-# add test files to analysis scope 
+# Analyze entire repo but treat tests as tests only (see inclusions/exclusions below)
 sonar.sources = .
-sonar.tests= .
+sonar.tests = .
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why:
Relevant best practice - Keep documentation synchronized with implementation changes, specifying scope and behavior to avoid user confusion when behavior evolves.

Low
  • More

Copy link
Member

@rm3l rm3l left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Dec 8, 2025
@openshift-ci
Copy link

openshift-ci bot commented Dec 8, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rm3l

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Dec 8, 2025
@rm3l rm3l merged commit 674488e into redhat-developer:main Dec 8, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants