Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: configure SonarCloud to exclude test files and generated code (#19314)

zchpeter030d7bff75b0
diff --git a/.sonarcloud.properties b/.sonarcloud.properties
new file mode 100644
index 0000000000..c8d5655572
--- /dev/null
+++ b/.sonarcloud.properties
@@ -0,0 +1,32 @@
+# Path to sources
+sonar.sources=.
+
+# Exclude generated code, build artifacts, and dependencies from analysis
+sonar.exclusions=\
+ backend/generated-go,\
+ proto/gen,\
+ bytebase-build,\
+ frontend/node_modules
+
+# Path to tests — identify test files so they are analyzed as tests, not source
+sonar.test.inclusions=\
+ backend/**/*_test.go,\
+ backend/**/testdata/**,\
+ backend/**/test-data/**,\
+ frontend/src/**/*.test.ts,\
+ frontend/src/**/*.test.tsx,\
+ frontend/src/**/*.spec.ts,\
+ frontend/src/**/*.spec.tsx
+
+# Source encoding
+sonar.sourceEncoding=UTF-8
+
+# Exclusions for copy-paste detection
+sonar.cpd.exclusions=\
+ backend/**/*_test.go,\
+ backend/**/testdata/**,\
+ backend/**/test-data/**,\
+ backend/generated-go,\
+ frontend/src/**/*.test.ts,\
+ frontend/src/**/*.test.tsx,\
+ proto/gen
diff --git a/CLAUDE.md b/CLAUDE.md
index b3e8df3f94..4f0b7d0f90 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -155,6 +155,7 @@ psql -U bbdev bbdev
- Configuration breaking changes (removed flags, changed behavior)
- **Description** — Clearly describe what the PR changes and why
- **Testing** — Include information about how the changes were tested
+- **SonarCloud** — When creating or updating a PR, update `.sonarcloud.properties` to reflect the latest file structure. Use `sonar.exclusions` for generated code, build artifacts, and dependencies (directory paths only). Use `sonar.test.inclusions` for test file patterns (wildcards like `**/*_test.go`). Use `sonar.cpd.exclusions` to skip copy-paste detection on test files
## Common Go Lint Rules