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