Rules, Rule Types, Severities, Quality Profiles, and Customization: Configuration, Design Patterns, and Trade-Offs
Design rule/profile policy for long-term maintainability: choose inheritance, copies, variants, parameter changes and analyzer/plugin boundaries without uncontrolled profile sprawl or hidden coverage loss.
Learning objectives
- Choose Extend, Copy, blank or import based on update behavior and governance needs.
- Design organization and team variants without profile sprawl.
- Distinguish parameter tuning, rule deactivation and issue-level exceptions.
- Assess analyzer/plugin provenance and compatibility risk.
- Document blast radius, owner and rollback for every policy change.
1. Decision table
| Choice | Use when | Trade-off | Evidence / rollback |
|---|---|---|---|
| Extend Sonar way | Need Sonar defaults plus explicit policy additions/overrides | Parent changes flow into child; overrides need review | parent/child graph, override list, backup, revert-to-parent |
| Copy profile | Need a deliberately independent snapshot | No inherited updates; higher maintenance | source/version/timestamp, scheduled diff, restore backup |
| Blank profile | Need tightly curated minimal policy | High risk of accidental omissions | approved rule manifest, owner, gap review |
| Tune parameter | Rule intent applies but threshold is domain-specific | Can create noise or weaken policy | same-revision before/after issues and rationale |
| Deactivate rule | Rule truly does not apply / validated false-positive burden | Removes coverage for all matching code | rule key, reason, affected projects, review date |
| Issue-level exception | Rule remains valid but one occurrence is exceptional | Creates exception debt, but narrow blast radius | issue lifecycle record + rationale + owner |
| Third-party plugin rules | Validated gap cannot be covered otherwise | Compatibility/security/license/upgrade risk | plugin provenance/version, test + uninstall plan |
2. Inheritance is an upgrade strategy
A child inherits parent rule activation/deactivation and parameter changes unless a rule is overridden. This is why extending Sonar way usually scales better than copying it: new analyzer rules and deprecation changes can flow into the child. The cost is review discipline after upgrades. A growing overridden-rule list is effectively a growing policy fork.
Current Community Build also has an instance-level control over whether inherited active rules may be deactivated in a child. Record that administrative setting before relying on child deactivation as a policy mechanism; do not assume every instance permits it.
3. Avoid profile sprawl
Quality profiles are language-specific, so variants are legitimate when technical requirements truly differ. Keep the hierarchy small: Sonar way → organization guardrails → rare domain-specific children. Every extra profile needs an owner, purpose, associated-project inventory, review cadence and retirement condition.
flowchart TD SW[Python Sonar way] --> O[Org Python Guardrails] O --> A[Payments Python] O --> B[Data Python] A --> P1[Payments projects] B --> P2[Data projects]
4. Rule severity/impact is not external risk scoring
Profile-level severity or impact customization changes Sonar issue classification and may affect downstream gate conditions. It does not create CVSS, exploitability probability, financial-risk score or developer performance grade. Security Hotspots remain review-oriented because their actual vulnerability status is unknown before review.
5. Parameter change, rule deactivation, issue exception and gate change are different
Parameter override → rule still applies; threshold/behavior changes for the profile.
Rule deactivation → rule no longer checks matching code in that profile.
Issue exception → one finding is accepted/false-positive; rule remains active.
Quality Gate edit → downstream pass/fail policy changes; active rules do not.
Choose the narrowest layer that expresses the real intent. Do not deactivate an organization-wide rule to handle one exceptional issue.
6. Analyzer and plugin rule provenance
The Rules page shows a repository identifier for the engine/analyzer contributing a rule. Commercial editions can add rules unavailable in Community Build; third-party plugins may add their own repositories. Treat plugin rule sets as executable server extensions with provenance, security, license, maintenance, compatibility and rollback implications. The mandatory course path installs no plugin.
7. Default profile versus explicit project association
Changing the language default can move policy for every project that relies on it implicitly. An explicit project association has a smaller blast radius and is the correct mechanism for experiments. Before a default change, inventory implicit default users and explicit exceptions; after it, verify which projects actually changed.
8. Product and edition boundaries
The mandatory path remains Community Build and local. Commercial SonarQube Server editions can expose additional rules or governance capabilities, and Data Center Edition changes deployment/availability topology rather than the basic profile mental model. SonarQube Cloud is a separate hosted product with organization/plan semantics and no self-managed server/plugin administration. Verify the current feature matrix before teaching an edition-specific rule or profile capability.
Also separate configuration owners: scanner/build parameters select analysis inputs, server/profile configuration selects rule policy, and project issues/gates are results. Do not move a scanner problem into profile policy or a profile problem into database/search state.
9. Minimum policy change record
Rule: key/repository/status and exact activation/parameter/severity change
Mode: MQR or Standard terminology
Versions: Community Build/Server + analyzer/plugin
Blast radius: project associations and default users
Rationale: evidence-based technical reason
Validation: same-revision before/after analysis + task IDs
Owner/reviewer: approval and upgrade-review responsibility
Rollback: revert-to-parent, profile restore or reassociation
10. Challenge: consolidate seven near-duplicate Python profiles
Seven profiles differ only by S3776 thresholds and several have no owner. A strong consolidation plan first inventories active project associations and issue deltas, chooses one organization parent, retains only evidence-backed domain variants, migrates projects deliberately, exports backups and retires old profiles only after proving no remaining association.
Knowledge check
When is Extend usually better than Copy?
When you want custom policy that continues to inherit Sonar way evolution.
What is the operational symptom of profile sprawl?
Many nearly identical policies with unclear owners, stale rules and inconsistent project behavior.
Is a Sonar severity a CVSS score?
No. It is Sonar analysis classification, not a universal business/security risk score.
Why prefer an issue-level exception for one exceptional finding?
It preserves the rule for the rest of the code and limits blast radius.
Why treat plugin-provided rules as an operational dependency?
Plugins add executable code plus compatibility, security, licensing and maintenance risk.
Official references and version notes
- Community Build — SonarQube rules — repositories, statuses, rule categories, custom/template rules and mode-dependent severity semantics.
- Community Build — Instance mode overview, including MQR Mode and Standard Experience.
- Community Build — Understanding quality profiles — built-in/default profiles, inheritance, overrides and project association.
- Community Build — Creating a quality profile — Extend, Copy, blank creation and import/export.
- Community Build — Editing a custom quality profile — activate/deactivate rules, customize parameters and Revert to Parent Definition.
- Community Build — Associating a quality profile with projects.
- Sonar Rules — Python S3776 — Cognitive Complexity rule used in the controlled parameter experiment.
- SonarQube releases — current Community Build and Server release identities.
Rechecked on 2026-09-07. Mandatory examples target private/local
SonarQube Community Build 26.9.0.129388 and
SonarScanner CLI 8.1.0.6389. Current Community
Build baseline is 26.9.0.129388; current commercial SonarQube
Server baseline is 2026 Release 4.1 with 2026.1.5 as the current
2026 LTA patch line. New Community Build instances use MQR Mode by
default, but every lab records the actual mode and never switches
it. MQR uses Blocker/High/Medium/Low/Info severities on
software-quality impacts; Standard Experience uses
Bug/Vulnerability/Code Smell/Security Hotspot types with
Blocker/Critical/Major/Minor/Info severity. Sonar way is built-in
and immutable. The hands-on experiment extends Python Sonar way
and tunes python:S3776; verify installed rule
metadata before changing it because analyzer behavior can evolve.
No third-party plugin, commercial edition, CI provider, enterprise
identity, SonarQube Cloud account, branch/PR analysis or
production source is required.
Keep the academy open
Support free, practical DevOps education.
Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this
address.