Chapter 20Lesson 02~160 minutes

SonarQube for IDE Connected Mode and Developer Feedback Loops: Guided Hands-On Workflow

Install and inspect SonarQube for VS Code, compare standalone and Connected Mode, bind to a disposable Community Build project, synchronize one server rule parameter, and disconnect cleanly.

SonarQube for IDEConnected ModeDeveloper feedbackQuality profileGovernance

Learning objectives

  • Install or verify SonarQube for VS Code 5.9.1 in a disposable local workspace.
  • Create a small Community Build project and preserve a server-analysis baseline before binding the IDE.
  • Compare standalone local rule behavior with Connected Mode behavior.
  • Use separate credentials for Connected Mode (user token) and scanner/CI analysis (project-analysis token).
  • Change one safe server rule parameter in a disposable custom quality profile and observe the synchronized local effect.
  • Disconnect/revoke the IDE credential cleanly and prove that governed server analysis remains independent.

1. Local lab contract

Disposable and local. Use Community Build at http://localhost:9000, a synthetic repository, a disposable custom quality profile, and fake/non-sensitive source. Do not bind an employer/customer repository or use a production account/token for this exercise.
State Lab assumption
Server SonarQube Community Build 26.9.0.129388
IDE VS Code desktop with SonarQube for VS Code 5.9.1
IDE runtime JRE 17+; official platform-specific extension bundles include a runtime on common x86-64/Apple Silicon platforms
Scanner SonarScanner CLI 8.1.0.6389
Project sq-ch20-ide-lab
IDE credential Disposable user token owned by the lab user
Scanner credential Separate disposable project-analysis token

2. Create a fixture whose rule behavior is easy to observe

mkdir -p sq-ch20-ide-lab/src
cd sq-ch20-ide-lab
git init -b main
git config user.email "learner@example.invalid"
git config user.name "SQ IDE Learner"

cat > src/decision.py <<'PYCODE'
def classify(a, b, c, d):
    score = 0
    if a:
        score += 1
    if b:
        score += 1
    if c:
        score += 1
    if d:
        score += 1
    if score >= 3:
        return "high"
    if score == 2:
        return "medium"
    return "low"
PYCODE

cat > sonar-project.properties <<'EOF'
sonar.projectKey=sq-ch20-ide-lab
sonar.projectName=SQ Chapter 20 IDE Lab
sonar.sources=src
sonar.sourceEncoding=UTF-8
EOF

cat > .gitignore <<'EOF'
.scannerwork/
evidence/
EOF

git add .
git commit -m "baseline IDE feedback fixture"
git rev-parse HEAD

The fixture is intentionally small. The lab uses the Python Cognitive Complexity rule python:S3776 only if that rule is active in the current analyzer/profile; verify it before changing anything. If the exact rule key or parameter changes in a future release, choose another current locally supported parameterized rule and record that substitution.

3. Create the disposable server project and baseline analysis

Create sq-ch20-ide-lab in the local Community Build UI. Create a narrowly scoped project-analysis token for scanner execution and export it as SONAR_TOKEN. This credential is not the one you will use in the IDE.

export SONAR_HOST_URL="http://localhost:9000"
export SONAR_PROJECT_KEY="sq-ch20-ide-lab"
read -rsp "Project-analysis token: " SONAR_TOKEN; echo
export SONAR_TOKEN

mkdir -p evidence/baseline
git rev-parse HEAD | tee evidence/baseline/revision.txt
sonar-scanner -X 2>&1 | tee evidence/baseline/scanner.log
cp .scannerwork/report-task.txt evidence/baseline/report-task.txt

CE_TASK_ID="$(sed -n 's/^ceTaskId=//p' .scannerwork/report-task.txt)"
printf '%s\n' "$CE_TASK_ID" | tee evidence/baseline/ceTaskId.txt
curl -fsS -H "Authorization: Bearer $SONAR_TOKEN" \
  "$SONAR_HOST_URL/api/ce/task?id=$CE_TASK_ID" \
  | tee evidence/baseline/ce-task.json

Wait for a terminal Compute Engine state and record the baseline project profile, issue population, and Quality Gate. The purpose is to know what the server actually considers authoritative before the IDE is connected.

4. Verify/install the IDE extension

code --version
code --list-extensions --show-versions | grep -i "sonarsource.sonarlint-vscode" || true

# Optional install command when the VS Code CLI is available:
code --install-extension SonarSource.sonarlint-vscode

After installation, verify the version from the Extensions view or code --list-extensions --show-versions. Record the observed version in evidence/ide-version.txt. The course baseline is 5.9.1, but do not downgrade an already-supported later version solely to match the screenshot/menu wording.

5. Observe standalone state before binding

Open the repository folder in VS Code and let SonarQube for IDE analyze the Python file. Record:

  • whether the workspace is currently unbound/standalone;
  • the visible local issues for src/decision.py;
  • the locally active status/parameter of python:S3776 if exposed;
  • the extension Output/log pane;
  • the Git branch and working-tree state.

Do not change the server yet. This is the “before” observation that makes synchronization causal rather than anecdotal.

6. Create the Connected Mode credential correctly

In the local SonarQube account’s Security page, generate a disposable user token for the lab developer. Give the user only the project visibility/permissions it actually needs. Do not copy the scanner’s project-analysis token into the IDE.

Why two tokens? The scanner token authorizes analysis. The IDE user token represents a human user and carries that user’s Web API/project permissions. Their scopes, owners, lifecycle, and audit meaning are different.

7. Connect and bind explicitly

In VS Code, open SONARQUBE SETUP → CONNECTED MODE and add a SonarQube Server connection:

  1. Server URL: http://localhost:9000.
  2. Authentication: the disposable user token.
  3. Connection name: sq-ch20-local.
  4. Bind the open workspace explicitly to project sq-ch20-ide-lab.

Then record the binding in an evidence note. If the extension proposes an automatic match from sonar-project.properties, inspect the proposed project key before accepting it. Automation convenience must not replace identity verification.

8. Create one disposable profile change

In Community Build, create a child/custom Python quality profile for the lab rather than editing Sonar way. Assign it only to sq-ch20-ide-lab. Find python:S3776 (Cognitive Complexity) and record its current threshold. Lower the threshold only enough that the fixture becomes a predictable local finding.

Governed mutation. This is a disposable teaching project. In production, rule/profile changes require an owner, rationale, impact review, and rollback plan. Never lower/raise thresholds simply to make a dashboard look better.

After saving the rule parameter, use the IDE’s binding update/synchronization action (or restart the IDE if appropriate) and record the extension log showing synchronization.

9. Compare before/after local behavior

Without changing src/decision.py, compare:

  • standalone issue state;
  • Connected Mode issue state after the custom profile is assigned;
  • the exact rule key and synchronized threshold;
  • the server project/profile assignment;
  • the Git SHA, which should remain unchanged.

If the local issue changes while the source SHA is identical, the causal input was project policy synchronization. That is the effect this exercise is designed to prove.

10. Prove the server/CI handoff independently

Now run the scanner again on the same committed SHA using the separate project-analysis token. Preserve the new ceTaskId, Compute Engine state, issue result, and Quality Gate.

mkdir -p evidence/connected-server
git rev-parse HEAD | tee evidence/connected-server/revision.txt
sonar-scanner -X 2>&1 | tee evidence/connected-server/scanner.log
cp .scannerwork/report-task.txt evidence/connected-server/report-task.txt

CE_TASK_ID="$(sed -n 's/^ceTaskId=//p' .scannerwork/report-task.txt)"
curl -fsS -H "Authorization: Bearer $SONAR_TOKEN" \
  "$SONAR_HOST_URL/api/ce/task?id=$CE_TASK_ID" \
  | tee evidence/connected-server/ce-task.json

The IDE observation and server result may be related by profile synchronization, but they are still separate executions. The authoritative gate comes from the server analysis, not from the local squiggle disappearing or appearing.

11. Disconnect and clean up

  1. Preserve the connection/binding/profile evidence first.
  2. Remove the project binding and/or disposable connection from the IDE.
  3. Revoke the IDE user token in SonarQube.
  4. Revoke the project-analysis token.
  5. Restore/delete the disposable custom profile/project only after evidence is exported.
  6. Do not delete unrelated global profiles or credentials.

12. Challenge: choose the correct layer

The IDE still shows the old rule behavior after a server profile change. Before editing source, what should you inspect?

  1. Confirm the workspace is bound to the intended project key.
  2. Confirm the project is actually assigned the intended quality profile.
  3. Update/refresh the binding and inspect the SonarQube for IDE log.
  4. Confirm the changed rule is supported by local analysis.
  5. Only then decide whether source changes are relevant.

Knowledge check

Which credential belongs in Connected Mode?

Why keep the Git SHA unchanged while testing profile synchronization?

What should you do if the chosen server rule never appears locally?

Does changing a server quality profile prove CI passed?

What is the safest cleanup order?

Next lesson

Choose a developer-feedback design that preserves governance

Lesson 3 converts the workflow into repeatable team design choices and credential boundaries.

Official references and version notes

Version and compatibility note

Rechecked 2026-09-08. Mandatory examples target SonarQube Community Build 26.9.0.129388, SonarScanner CLI 8.1.0.6389, and SonarQube for VS Code 5.9.1 (published 2026-08-31). VS Code Connected Mode currently requires a user token; project/global analysis tokens do not function correctly for binding. Connected Mode applies the bound server quality profile/settings to supported local analysis, but architecture/injection and some advanced bug rules can remain server-only. Current VS Code Connected Mode has branch awareness but does not synchronize pull-request analysis. SonarQube for IDE compatibility follows active server/LTA support policy; recheck the IDE/server compatibility matrix, extension release, token rules, and locally supported analyzers before reproducing on a later release.

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.