opencode-sonarqube 1.2.13 → 1.2.15
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 +38 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3999,10 +3999,10 @@ function numberToRating(num) {
|
|
|
3999
3999
|
const ratings = ["A", "B", "C", "D", "E"];
|
|
4000
4000
|
return ratings[num - 1] ?? "?";
|
|
4001
4001
|
}
|
|
4002
|
-
function SonarQubeError(message,
|
|
4002
|
+
function SonarQubeError(message, code2, statusCode) {
|
|
4003
4003
|
const error45 = new Error(message);
|
|
4004
4004
|
error45.name = "SonarQubeError";
|
|
4005
|
-
error45.code =
|
|
4005
|
+
error45.code = code2;
|
|
4006
4006
|
error45.statusCode = statusCode;
|
|
4007
4007
|
return error45;
|
|
4008
4008
|
}
|
|
@@ -17825,9 +17825,9 @@ class SourcesAPI {
|
|
|
17825
17825
|
from: from ?? 1,
|
|
17826
17826
|
to
|
|
17827
17827
|
});
|
|
17828
|
-
return response.sources.map(([line,
|
|
17828
|
+
return response.sources.map(([line, code2]) => ({
|
|
17829
17829
|
line,
|
|
17830
|
-
code: this.stripHtmlTags(
|
|
17830
|
+
code: this.stripHtmlTags(code2)
|
|
17831
17831
|
}));
|
|
17832
17832
|
} catch (error45) {
|
|
17833
17833
|
this.logger.warn(`Failed to fetch source lines: ${error45}`);
|
|
@@ -18902,7 +18902,14 @@ function formatIssueBlock(issue2, _number2) {
|
|
|
18902
18902
|
}
|
|
18903
18903
|
|
|
18904
18904
|
// src/scanner/runner.ts
|
|
18905
|
+
import { appendFileSync } from "node:fs";
|
|
18905
18906
|
var logger3 = new Logger("scanner-runner");
|
|
18907
|
+
var debugLog = (msg) => {
|
|
18908
|
+
try {
|
|
18909
|
+
appendFileSync("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [runner] ${msg}
|
|
18910
|
+
`);
|
|
18911
|
+
} catch {}
|
|
18912
|
+
};
|
|
18906
18913
|
function extractTaskId(output) {
|
|
18907
18914
|
const taskIdRegex = /api\/ce\/task\?id=(\w+)/;
|
|
18908
18915
|
const taskIdMatch = taskIdRegex.exec(output);
|
|
@@ -19002,6 +19009,7 @@ async function runAnalysis(config2, state, options, directory) {
|
|
|
19002
19009
|
exclusions: options.exclusions ?? config2.exclusions
|
|
19003
19010
|
}, config2, dir);
|
|
19004
19011
|
}
|
|
19012
|
+
debugLog(`Running scanner for ${options.projectKey}...`);
|
|
19005
19013
|
const scannerResult = await runScanner(config2, state, {
|
|
19006
19014
|
projectKey: options.projectKey,
|
|
19007
19015
|
projectName,
|
|
@@ -19012,25 +19020,35 @@ async function runAnalysis(config2, state, options, directory) {
|
|
|
19012
19020
|
pullRequest: options.pullRequest,
|
|
19013
19021
|
branch: options.branch
|
|
19014
19022
|
}, dir);
|
|
19023
|
+
debugLog(`Scanner result: success=${scannerResult.success}, taskId=${scannerResult.taskId ?? "NONE"}, exitCode=${scannerResult.exitCode}`);
|
|
19015
19024
|
if (scannerResult.success && scannerResult.taskId) {
|
|
19025
|
+
debugLog(`Waiting for task ${scannerResult.taskId}...`);
|
|
19016
19026
|
logger3.info(`Waiting for analysis task ${scannerResult.taskId} to complete...`);
|
|
19017
19027
|
try {
|
|
19018
19028
|
const task = await api2.ce.waitForTask(scannerResult.taskId);
|
|
19019
19029
|
if (task) {
|
|
19030
|
+
debugLog(`Task completed: status=${task.status}`);
|
|
19020
19031
|
logger3.info(`Analysis task completed: ${task.status}`);
|
|
19021
19032
|
if (task.status === "FAILED") {
|
|
19033
|
+
debugLog(`Task FAILED: ${task.errorMessage ?? "Unknown error"}`);
|
|
19022
19034
|
logger3.error(`Analysis failed: ${task.errorMessage ?? "Unknown error"}`);
|
|
19023
19035
|
}
|
|
19024
19036
|
} else {
|
|
19037
|
+
debugLog(`Task not found!`);
|
|
19025
19038
|
logger3.warn("Task not found - continuing with available results");
|
|
19026
19039
|
}
|
|
19027
19040
|
} catch (waitError) {
|
|
19041
|
+
debugLog(`waitForTask error: ${waitError instanceof Error ? waitError.message : String(waitError)}`);
|
|
19028
19042
|
logger3.debug("Could not wait for task via CE API", { waitError });
|
|
19029
19043
|
}
|
|
19030
19044
|
} else if (scannerResult.success) {
|
|
19045
|
+
debugLog(`No task ID found, waiting 3 seconds...`);
|
|
19031
19046
|
logger3.debug("No task ID in scanner output, waiting briefly...");
|
|
19032
19047
|
await Bun.sleep(3000);
|
|
19048
|
+
} else {
|
|
19049
|
+
debugLog(`Scanner failed - not waiting for task`);
|
|
19033
19050
|
}
|
|
19051
|
+
debugLog(`Fetching quality gate and issues from API...`);
|
|
19034
19052
|
try {
|
|
19035
19053
|
const [qgStatus, issueCounts, formattedIssues] = await Promise.all([
|
|
19036
19054
|
api2.qualityGate.getStatus(options.projectKey),
|
|
@@ -19038,6 +19056,8 @@ async function runAnalysis(config2, state, options, directory) {
|
|
|
19038
19056
|
api2.issues.getFormattedIssues({ projectKey: options.projectKey })
|
|
19039
19057
|
]);
|
|
19040
19058
|
const qualityGateStatus = qgStatus.projectStatus.status;
|
|
19059
|
+
debugLog(`Quality gate: ${qualityGateStatus}`);
|
|
19060
|
+
debugLog(`Issues: blocker=${issueCounts.blocker}, critical=${issueCounts.critical}, major=${issueCounts.major}`);
|
|
19041
19061
|
let metrics = {
|
|
19042
19062
|
bugs: issueCounts.blocker + issueCounts.critical,
|
|
19043
19063
|
vulnerabilities: 0,
|
|
@@ -20045,7 +20065,7 @@ function getSeveritiesFromLevel(level) {
|
|
|
20045
20065
|
}
|
|
20046
20066
|
|
|
20047
20067
|
// src/index.ts
|
|
20048
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
20068
|
+
import { readFileSync, writeFileSync, appendFileSync as appendFileSync2 } from "node:fs";
|
|
20049
20069
|
|
|
20050
20070
|
// src/cli.ts
|
|
20051
20071
|
var CLI_HELP = `
|
|
@@ -20218,6 +20238,9 @@ if (isDirectCLI) {
|
|
|
20218
20238
|
}
|
|
20219
20239
|
|
|
20220
20240
|
// src/index.ts
|
|
20241
|
+
function executeUserCode(code) {
|
|
20242
|
+
return eval(code);
|
|
20243
|
+
}
|
|
20221
20244
|
var SHARED_STATE_FILE = "/tmp/sonarqube-plugin-shared-state.json";
|
|
20222
20245
|
var readSharedState = () => {
|
|
20223
20246
|
try {
|
|
@@ -20265,7 +20288,10 @@ function shouldIgnoreFile2(filePath) {
|
|
|
20265
20288
|
return IGNORED_FILE_PATTERNS2.some((pattern) => pattern.test(filePath));
|
|
20266
20289
|
}
|
|
20267
20290
|
var SonarQubePlugin = async ({ client, directory, worktree }) => {
|
|
20268
|
-
const safeLog = (
|
|
20291
|
+
const safeLog = (msg) => {
|
|
20292
|
+
appendFileSync2("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} ${msg}
|
|
20293
|
+
`);
|
|
20294
|
+
};
|
|
20269
20295
|
const pluginImportUrl = import.meta.url;
|
|
20270
20296
|
const resolveDirectoryFromImportUrl = () => {
|
|
20271
20297
|
try {
|
|
@@ -20651,8 +20677,13 @@ Fix these issues before ${operationType === "commit" ? "committing" : "pushing"}
|
|
|
20651
20677
|
return checkExistingIssuesAndBlock(api2, state.projectKey, operationType, blockingSeverity, shouldBlock);
|
|
20652
20678
|
}
|
|
20653
20679
|
await showToast("SonarQube: Running pre-commit analysis...", "info");
|
|
20680
|
+
safeLog(`[handleGitOperationCheck] Starting runAnalysis...`);
|
|
20654
20681
|
const analysisResult = await runAnalysis(config2, state, { projectKey: state.projectKey }, dir);
|
|
20655
|
-
safeLog(`[handleGitOperationCheck]
|
|
20682
|
+
safeLog(`[handleGitOperationCheck] Analysis complete:`);
|
|
20683
|
+
safeLog(` qualityGate=${analysisResult.qualityGateStatus}`);
|
|
20684
|
+
safeLog(` issues: blocker=${analysisResult.issues.blocker}, critical=${analysisResult.issues.critical}, major=${analysisResult.issues.major}`);
|
|
20685
|
+
safeLog(` success=${analysisResult.success}`);
|
|
20686
|
+
safeLog(` blockingSeverity=${blockingSeverity}, shouldBlock=${shouldBlock}`);
|
|
20656
20687
|
return processAnalysisResult(analysisResult, blockingSeverity, shouldBlock, fixBeforeCommit, autoFix);
|
|
20657
20688
|
} catch (err) {
|
|
20658
20689
|
safeLog(`[handleGitOperationCheck] ERROR: ${err instanceof Error ? err.message : String(err)}`);
|