Skip to content

test: add Sonar-native issues to validate Quality Gate on PR analysis#3130

Closed
swarnadipa-dev wants to merge 2 commits into
maintenance-3.1.xfrom
test-fix-2023
Closed

test: add Sonar-native issues to validate Quality Gate on PR analysis#3130
swarnadipa-dev wants to merge 2 commits into
maintenance-3.1.xfrom
test-fix-2023

Conversation

@swarnadipa-dev

Copy link
Copy Markdown
Contributor

Summary

This PR adds deliberate Sonar-native code quality issues to nuxeo-drive-download-button.js to validate that SonarCloud's Quality Gate correctly fails on PR analysis.

Changes

Added two test methods in addons/nuxeo-drive/elements/nuxeo-drive-download-button.js:

  • _printSum() — triggers:

    • S1854 (Major): Dead store — let result = 10 is assigned but immediately overwritten
    • S3626 (Minor): Redundant return at end of void function
  • _printChars() — triggers:

    • S1192 (Minor): Duplicate string literal 'hello world' appears 3× in the same file

Both methods are called from _download().

Purpose

This is a test-only branch used to verify that:

  1. SonarCloud PR decoration mode is active (after fix in fix(sonar): use PR decoration params on pull_request events instead of branch analysis #3127)
  2. The Quality Gate blocks merging when Sonar-native issues are introduced

⚠️ This PR is intentionally broken and should NOT be merged.

Copilot AI review requested due to automatic review settings May 12, 2026 12:22
@swarnadipa-dev swarnadipa-dev requested a review from a team as a code owner May 12, 2026 12:22
@swarnadipa-dev swarnadipa-dev requested review from madhurkulshrestha-hyland and vaibhavagarwal4-lab and removed request for a team May 12, 2026 12:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR intentionally introduces SonarCloud-detectable quality issues into the Nuxeo Drive download button to validate that Sonar PR analysis and the Quality Gate correctly fail a pull request when new “Sonar-native” issues are added.

Changes:

  • Added _printSum() and _printChars() methods containing deliberate Sonar rule violations (dead store, redundant return, and duplicate literals).
  • Invoked these new methods from _download(), causing additional runtime side effects (notably console output) during downloads.

Comment on lines +86 to +87
this._printSum();
this._printChars();
Comment on lines +197 to +214

// Prints the sum of 5 + 2
_printSum() {
let result = 10; // S1854: dead store — assigned but immediately overwritten
result = 5 + 2;
console.log('Sum of 5 + 2 =', result);
return; // S3626: unnecessary return at end of void function
}

// Prints all characters in "hello world"
_printChars() {
const word = 'hello world';
const label = 'hello world'; // S1192: duplicate string literal (appears 3x in file now)
const prefix = 'hello world'; // S1192: third occurrence — Sonar flags >= 3 duplicates
for (let i = 0; i < word.length; i++) {
console.log(label, prefix, word[i]);
}
}
Comment on lines +200 to +203
let result = 10; // S1854: dead store — assigned but immediately overwritten
result = 5 + 2;
console.log('Sum of 5 + 2 =', result);
return; // S3626: unnecessary return at end of void function
Comment on lines +197 to +214

// Prints the sum of 5 + 2
_printSum() {
let result = 10; // S1854: dead store — assigned but immediately overwritten
result = 5 + 2;
console.log('Sum of 5 + 2 =', result);
return; // S3626: unnecessary return at end of void function
}

// Prints all characters in "hello world"
_printChars() {
const word = 'hello world';
const label = 'hello world'; // S1192: duplicate string literal (appears 3x in file now)
const prefix = 'hello world'; // S1192: third occurrence — Sonar flags >= 3 duplicates
for (let i = 0; i < word.length; i++) {
console.log(label, prefix, word[i]);
}
}
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
12.0% Coverage on New Code (required ≥ 90%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants