From df8ae6ff928549dd37ffe6d3529b1641c53da09b Mon Sep 17 00:00:00 2001 From: Konrad Ferdinand Heimel Date: Mon, 3 Aug 2026 17:02:37 +0200 Subject: [PATCH 1/2] :green_heart: fix(sonar): exclude generated + cluster/namespaced mirror from duplication gate The SonarCloud quality gate failed on the sole condition new_duplicated_lines_density (~22.9% vs <=3%). ~77% of the flagged duplication is Upjet-generated zz_*.go and ~23% is the intentional cluster/ <-> namespaced/ mirror of hand-written controllers and API types. Add .sonarcloud.properties (the file Automatic Analysis actually reads; sonar-project.properties is ignored): - sonar.exclusions=**/zz_*.go (generated code, matches golangci generated:lax) - sonar.cpd.exclusions for the mirrored controllers/types (CPD only; they keep bug/security/reliability analysis) Clears the gate without loosening the 3% threshold, so genuine future duplication regressions still fail. --- .sonarcloud.properties | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .sonarcloud.properties diff --git a/.sonarcloud.properties b/.sonarcloud.properties new file mode 100644 index 0000000..4e7cf56 --- /dev/null +++ b/.sonarcloud.properties @@ -0,0 +1,32 @@ +# SPDX-FileCopyrightText: 2026 The Crossplane Authors +# +# SPDX-License-Identifier: CC0-1.0 + +# SonarCloud Automatic Analysis configuration. +# +# NOTE: Automatic Analysis reads THIS file (.sonarcloud.properties) and ignores +# any sonar-project.properties. See: +# https://docs.sonarsource.com/sonarqube-cloud/analyzing-source-code/automatic-analysis/ +# +# The new-code duplication gate (new_duplicated_lines_density <= 3%) was tripping +# at ~22.9% because Sonar's copy-paste detector counted two classes of code that +# are duplicated by design, not by neglect: +# +# 1. Upjet-generated `zz_*.go` (resolvers, deepcopy, generated types) — ~77% of +# the flagged lines. Machine-generated boilerplate; not ours to edit. Already +# treated as generated by golangci-lint (`generated: lax`) and ignored by +# codecov. +# 2. The intentional cluster/ <-> namespaced/ mirror of hand-written controllers +# and API types — a deliberate Crossplane v2 dual-scope architecture, so the +# two trees are near-identical twins by construction. +# +# Fix: drop generated code from all analysis, and exclude the mirrored hand-written +# controllers/types from duplication detection only (they still get bug/security/ +# reliability analysis). + +# Generated code — exclude from ALL analysis (mirrors golangci `generated: lax`). +sonar.exclusions=**/zz_*.go + +# Hand-written cluster/namespaced mirror — suppress the copy-paste flag only; +# these files still participate in every other rule. +sonar.cpd.exclusions=internal/controller/**/*.go,apis/**/*_types.go From 20d713aa71dfc6ca7b2b88add2e6f0d3427ccd95 Mon Sep 17 00:00:00 2001 From: Konrad Ferdinand Heimel Date: Mon, 3 Aug 2026 17:11:02 +0200 Subject: [PATCH 2/2] docs(changelog): regenerate for sonar-cpd-exclusions branch --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0f2ed6..84c461f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ Release notes are generated from [Conventional Commits](https://www.conventional (with a leading gitmoji token) on the default branch using [git-cliff](https://git-cliff.org/). +## [Unreleased] + +### Bug Fixes + +- **sonar:** Exclude generated + cluster/namespaced mirror from duplication gate [df8ae6f](https://github.com/platformrelay/provider-gridscale/commit/df8ae6ff928549dd37ffe6d3529b1641c53da09b) + ## [0.3.0](https://github.com/platformrelay/provider-gridscale/compare/v0.2.2..v0.3.0) - 2026-07-31 ### Bug Fixes