Chapter 09Lesson 04~145 minutes

Rules, Rule Types, Severities, Quality Profiles, and Customization: Diagnostics, Failure Modes, and Production Practices

Diagnose surprising issue populations and policy drift without erasing evidence: determine whether source, scanner, analyzer, profile assignment, override, instance mode, Compute Engine or gate policy changed.

DiagnosticsPolicy driftDeprecated rulesProfile sprawlProduction practices

Learning objectives

  • Use an evidence-first sequence for rule/profile anomalies.
  • Diagnose reactive deactivation and severity misuse.
  • Identify default-profile blast radius and profile sprawl.
  • Reconcile analyzer upgrades, new/deprecated rules and inheritance.
  • Repair the smallest policy layer and rerun the same representative revision.

1. Evidence-first sequence

  1. Preserve scanner logs, report-task.txt, CE task, issue/gate state, profile exports/screens and change records.
  2. Confirm exact product edition/version, scanner, Java runtime, analyzer/plugin versions and instance mode.
  3. Confirm source revision, base directory, indexed files and SCM state.
  4. Confirm default versus explicit profile assignment for each language.
  5. Inspect exact rule key/repository/status, activation, inheritance/override and parameters.
  6. Confirm CE terminal status before interpreting results.
  7. Inspect gate/new-code policy only after analysis policy is proven.
  8. Inspect auth/network/database/search/JVM/container layers only when evidence points there.
  9. Apply the least-destructive correction and rerun the same representative revision.

2. Symptom → evidence, not guess

Symptom Likely layer Preserve Wrong shortcut
Issue count drops after profile edit activation/parameter/assignment profile diff, rule keys, same-revision tasks claim code improved
Issue count changes after upgrade analyzer rules/defaults/deprecations/inheritance old/new versions + profile backup suppress all new issues
Many projects change at once language default or parent profile default marker + affected-project inventory edit each project blindly
One project differs from peers explicit association or child override Project Settings + inheritance/override list copy peer profile without diagnosis
Scanner exits 0 but gate is red normal lifecycle/gate policy task/CE/gate separately call scanner failed or lower gate
Expected rule produces no issue file scope, inactive rule, wrong profile/language scope logs + rule/profile assignment activate every rule globally

3. Intentionally broken example: “green by removing the check”

The lab function raises S3776 under threshold 3. An operator deactivates S3776 in the child profile and points to the lower issue count as an improvement.

Same revision + S3776 active(threshold=3)   → issue present
Same revision + S3776 deactivated           → issue absent

The second line proves policy removal, not cleaner source.

Preserve both profile states and task IDs. Repair by restoring the rule/parent definition, then decide separately whether threshold 3 is justified. Never delete issue history to hide the experiment.

4. Failure: severity used as exploitability or developer grading

Sonar severity does not prove that a particular vulnerability is exploitable in your deployment and is not a developer score. Issue counts and severity can move because source scope, rule policy, analyzer versions and SCM attribution change. Keep security/business triage separate from rule-profile semantics.

5. Failure: uncontrolled profile sprawl

Red flags include nearly identical copies, unknown owners, stale rules, unexplained thresholds and projects pinned to obsolete profiles. Diagnose by inventorying/exporting profiles, parent relationships, overrides and project associations. Consolidate only after mapping blast radius.

6. Failure: changing a language default without ownership

A default-profile edit or replacement can affect every project without an explicit association. Production practice requires an affected-project inventory, owner, change window, representative before/after analyses, communication and rollback profile before making the change.

7. Failure: ignoring new/deprecated rules after analyzer upgrades

Analyzer upgrades can add rules, deprecate existing rules, change defaults or improve implementations. Sonar-way children can inherit parent evolution; copied/blank profiles do not automatically gain the same policy updates. Review new/deprecated rules and child overrides after every upgrade before interpreting trend changes as source-quality changes.

8. Keep failure layers separate

Scanner/build

Wrong base directory, missing bytecode, token/network failure, report not uploaded.

Compute Engine

Report uploaded but asynchronous processing failed.

Rule/profile

Wrong assignment, inactive rule, override, analyzer drift.

Gate/new code

Correct analysis creates a legitimate policy failure.

Platform

Database/search/JVM/container or edition/license failure.

Do not respond to a profile problem with direct DB/search edits, cache/log deletion, TLS disablement, admin tokens everywhere, unsupported downgrade or a new project key.

9. Production runbook

1. Freeze the representative source revision.
2. Preserve scanner/report-task/CE/issues/gate evidence.
3. Export/record old and new profile states.
4. Compare server + analyzer/plugin + mode changes.
5. Diff active rule keys, deprecated/new rules and overrides.
6. Restore only the incorrect profile/default/association change.
7. Rerun the same revision and preserve new task evidence.
8. Revisit issue/gate workflow only after analysis policy is correct.

10. Challenge: upgrade-driven issue spike

Forty projects gain maintainability issues after an analyzer upgrade. Revisions/scanners are unchanged. Half use Sonar-way children; half use old copied profiles. First compare analyzer versions and current Sonar way, then child inheritance versus copied-profile active rules/overrides. Do not mass-suppress findings before identifying the policy delta.

Knowledge check

What does issue disappearance after rule deactivation prove?

Why can an upgrade change issues on the same revision?

What must precede a default-profile change?

Why not edit database/search state for a profile problem?

What is the smallest verification rerun?

Next lesson

Prove a governed profile experiment end to end

Lesson 5 turns the S3776 experiment into a complete prediction, evidence, impact-analysis and rollback dossier.

Official references and version notes

Version and compatibility note

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.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this address.