mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-11-21 14:48:37 +00:00
ci: exclude test code from SonarCloud duplication detection (#1207)
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.
This commit is contained in:
@@ -13,6 +13,17 @@ sonar.newCode.referenceBranch=main
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user