ci: exclude test code from SonarCloud duplication detection (#1207) (#1213)

Duplication is scored on new code only, so a PR adding cases to an already
repetitive test module inherits debt accrued across earlier PRs rather than
introducing it; tests/unit/modules/test_module_helm.py sits at 47.9% on main
before any change.

sonar.exclusions filters the source set, not the copy/paste detector, so test
code needs its own exclusion. Production code stays covered.

(cherry picked from commit f31ecce59c)

Co-authored-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
This commit is contained in:
patchback[bot]
2026-08-10 12:01:19 -04:00
committed by GitHub
co-authored by Yuriy Novostavskiy
parent 79e98c3d6e
commit da42348358
+11
View File
@@ -13,6 +13,17 @@ sonar.newCode.referenceBranch=stable-6
sonar.exclusions=tests/**,.tox/**
# Exclude test code from copy/paste detection. 'sonar.exclusions' above only
# filters the *source* set (it disambiguates 'sonar.sources=.' from
# 'sonar.tests'), so test files are still indexed as tests and still scored for
# duplication. Unit tests here are unittest.TestCase classes: every class needs
# its own setUp, and per-case arrange/assert blocks are deliberately repeated so
# a failing test reads on its own. Because SonarCloud scores only *new code* on
# a pull request, any PR adding cases to an already-repetitive test module
# inherits duplication accrued across earlier PRs. Production code under
# plugins/ stays fully covered by duplication analysis.
sonar.cpd.exclusions=tests/**
# Ansible module argument_spec is conventionally defined with the dict(...)
# constructor (not {...} literals) for readability and consistency across the
# collection. Suppress python:S7498 ("prefer literal syntax"), which conflicts