opencode-sonarqube 1.2.26 → 1.2.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +15 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20494,7 +20494,7 @@ After fixing, I will re-run the analysis to verify.`;
|
|
|
20494
20494
|
}
|
|
20495
20495
|
};
|
|
20496
20496
|
const qualityGatePattern = /Quality Gate: \[(PASS|FAIL)\] (\w+)/;
|
|
20497
|
-
const issueCountPattern = /Blockers: (\d+), Critical: (\d+), Major: (\d+)/;
|
|
20497
|
+
const issueCountPattern = /Blockers: (\d+), Critical: (\d+), Major: (\d+), Minor: (\d+), Info: (\d+)/;
|
|
20498
20498
|
const parseAnalysisResult = (message) => {
|
|
20499
20499
|
const resultMatch = qualityGatePattern.exec(message);
|
|
20500
20500
|
const issueMatch = issueCountPattern.exec(message);
|
|
@@ -20506,7 +20506,9 @@ After fixing, I will re-run the analysis to verify.`;
|
|
|
20506
20506
|
issues: {
|
|
20507
20507
|
blocker: Number.parseInt(issueMatch[1], 10),
|
|
20508
20508
|
critical: Number.parseInt(issueMatch[2], 10),
|
|
20509
|
-
major: Number.parseInt(issueMatch[3], 10)
|
|
20509
|
+
major: Number.parseInt(issueMatch[3], 10),
|
|
20510
|
+
minor: Number.parseInt(issueMatch[4], 10),
|
|
20511
|
+
info: Number.parseInt(issueMatch[5], 10)
|
|
20510
20512
|
},
|
|
20511
20513
|
timestamp: new Date().toISOString()
|
|
20512
20514
|
};
|
|
@@ -20680,13 +20682,15 @@ Fix these issues before ${operationType === "commit" ? "committing" : "pushing"}
|
|
|
20680
20682
|
return { block: false };
|
|
20681
20683
|
await loadPluginConfig();
|
|
20682
20684
|
const sonarConfig = pluginConfig?.["sonarqube"];
|
|
20685
|
+
safeLog(`[handleGitOperationCheck] sonarConfig=${JSON.stringify(sonarConfig)}`);
|
|
20683
20686
|
const config2 = loadConfig(sonarConfig);
|
|
20684
|
-
safeLog(`[handleGitOperationCheck] ${operationType}: level=${config2?.level}`);
|
|
20687
|
+
safeLog(`[handleGitOperationCheck] ${operationType}: level=${config2?.level}, blockCommit=${config2?.blockCommit}, blockPush=${config2?.blockPush}`);
|
|
20685
20688
|
if (!config2 || config2.level === "off")
|
|
20686
20689
|
return { block: false };
|
|
20687
20690
|
const { analyzeBeforeCommit = true, blockCommit = false, blockPush = false } = config2;
|
|
20688
20691
|
const { fixBeforeCommit = false, blockingSeverity = "CRITICAL", autoFix = false } = config2;
|
|
20689
20692
|
const shouldBlock = operationType === "commit" ? blockCommit : blockPush;
|
|
20693
|
+
safeLog(`[handleGitOperationCheck] shouldBlock=${shouldBlock}, blockCommit=${blockCommit}, blockPush=${blockPush}, blockingSeverity=${blockingSeverity}`);
|
|
20690
20694
|
try {
|
|
20691
20695
|
const dir = getDirectory();
|
|
20692
20696
|
const state = await getProjectState(dir);
|
|
@@ -20700,7 +20704,9 @@ Fix these issues before ${operationType === "commit" ? "committing" : "pushing"}
|
|
|
20700
20704
|
await showToast("SonarQube: Running pre-commit analysis...", "info");
|
|
20701
20705
|
const analysisResult = await runAnalysis(config2, state, { projectKey: state.projectKey }, dir);
|
|
20702
20706
|
safeLog(`[handleGitOperationCheck] qualityGate=${analysisResult.qualityGateStatus}`);
|
|
20703
|
-
|
|
20707
|
+
const result = await processAnalysisResult(analysisResult, blockingSeverity, shouldBlock, fixBeforeCommit, autoFix);
|
|
20708
|
+
safeLog(`[handleGitOperationCheck] processResult block=${result.block}, message=${result.message}`);
|
|
20709
|
+
return result;
|
|
20704
20710
|
} catch (err) {
|
|
20705
20711
|
safeLog(`[handleGitOperationCheck] ERROR: ${err instanceof Error ? err.message : String(err)}`);
|
|
20706
20712
|
return { block: false };
|
|
@@ -20714,6 +20720,10 @@ Fix these issues before ${operationType === "commit" ? "committing" : "pushing"}
|
|
|
20714
20720
|
return issues.blocker > 0 || issues.critical > 0;
|
|
20715
20721
|
case "MAJOR":
|
|
20716
20722
|
return issues.blocker > 0 || issues.critical > 0 || issues.major > 0;
|
|
20723
|
+
case "MINOR":
|
|
20724
|
+
return issues.blocker > 0 || issues.critical > 0 || issues.major > 0 || issues.minor > 0;
|
|
20725
|
+
case "INFO":
|
|
20726
|
+
return issues.blocker > 0 || issues.critical > 0 || issues.major > 0 || issues.minor > 0 || issues.info > 0;
|
|
20717
20727
|
default:
|
|
20718
20728
|
return issues.blocker > 0 || issues.critical > 0;
|
|
20719
20729
|
}
|
|
@@ -20843,6 +20853,7 @@ Git operation completed with changes. Consider running:
|
|
|
20843
20853
|
if (/git\s+commit\b/.test(command) && !/--amend/.test(command)) {
|
|
20844
20854
|
safeLog(`[pre-check] Detected git commit, running quality check...`);
|
|
20845
20855
|
const result = await handleGitOperationCheck(output, "commit");
|
|
20856
|
+
safeLog(`[pre-check] commit check result: block=${result.block}, message=${result.message}`);
|
|
20846
20857
|
if (result.block && args) {
|
|
20847
20858
|
args.command = `echo "\uD83D\uDEAB BLOCKED BY SONARQUBE: ${result.message || "Quality gate failed"}" && exit 1`;
|
|
20848
20859
|
safeLog(`[pre-check] Commit BLOCKED - command replaced`);
|