opencode-sonarqube 0.1.22 → 0.2.0
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 +4 -76
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -16647,38 +16647,6 @@ async function deriveProjectKey(directory) {
|
|
|
16647
16647
|
}
|
|
16648
16648
|
return `project-${Date.now()}`;
|
|
16649
16649
|
}
|
|
16650
|
-
async function getProjectKey(config2, directory) {
|
|
16651
|
-
if (config2?.projectKey) {
|
|
16652
|
-
return config2.projectKey;
|
|
16653
|
-
}
|
|
16654
|
-
try {
|
|
16655
|
-
const packageJsonPath = directory ? `${directory}/package.json` : "./package.json";
|
|
16656
|
-
const packageJson = await Bun.file(packageJsonPath).json();
|
|
16657
|
-
if (packageJson.name) {
|
|
16658
|
-
return sanitizeProjectKey(packageJson.name);
|
|
16659
|
-
}
|
|
16660
|
-
} catch {}
|
|
16661
|
-
if (directory) {
|
|
16662
|
-
const dirName = directory.split("/").pop() ?? "project";
|
|
16663
|
-
return sanitizeProjectKey(dirName);
|
|
16664
|
-
}
|
|
16665
|
-
const cwd = process.cwd();
|
|
16666
|
-
const currentDirName = cwd.split("/").pop() ?? "project";
|
|
16667
|
-
return sanitizeProjectKey(currentDirName);
|
|
16668
|
-
}
|
|
16669
|
-
async function getProjectName(config2, directory) {
|
|
16670
|
-
if (config2?.projectName) {
|
|
16671
|
-
return config2.projectName;
|
|
16672
|
-
}
|
|
16673
|
-
try {
|
|
16674
|
-
const packageJsonPath = directory ? `${directory}/package.json` : "./package.json";
|
|
16675
|
-
const packageJson = await Bun.file(packageJsonPath).json();
|
|
16676
|
-
if (packageJson.name) {
|
|
16677
|
-
return packageJson.name;
|
|
16678
|
-
}
|
|
16679
|
-
} catch {}
|
|
16680
|
-
return await getProjectKey(config2, directory);
|
|
16681
|
-
}
|
|
16682
16650
|
function sanitizeProjectKey(input) {
|
|
16683
16651
|
return input.toLowerCase().replaceAll(/[^a-z0-9-_]/g, "-").replaceAll(/-+/g, "-").replaceAll(/(?:^-)|(?:-$)/g, "").slice(0, 400);
|
|
16684
16652
|
}
|
|
@@ -16766,9 +16734,6 @@ class Logger {
|
|
|
16766
16734
|
}
|
|
16767
16735
|
}
|
|
16768
16736
|
var logger = new Logger("opencode-sonarqube");
|
|
16769
|
-
function createLogger(service, client) {
|
|
16770
|
-
return new Logger(service, { client });
|
|
16771
|
-
}
|
|
16772
16737
|
|
|
16773
16738
|
// src/scanner/config.ts
|
|
16774
16739
|
var logger2 = new Logger("scanner-config");
|
|
@@ -18024,7 +17989,7 @@ class SourcesAPI {
|
|
|
18024
17989
|
this.formatFileLocation(filePath, issue2.line),
|
|
18025
17990
|
`**Rule:** \`${issue2.rule}\``
|
|
18026
17991
|
];
|
|
18027
|
-
const hasSourceContext = issue2.sourceContext
|
|
17992
|
+
const hasSourceContext = (issue2.sourceContext?.lines.length ?? 0) > 0;
|
|
18028
17993
|
if (hasSourceContext) {
|
|
18029
17994
|
lines.push(...this.formatSourceBlock(issue2.sourceContext, issue2.line));
|
|
18030
17995
|
}
|
|
@@ -18076,7 +18041,7 @@ class DuplicationsAPI {
|
|
|
18076
18041
|
});
|
|
18077
18042
|
const duplicatedComponents = components.components.filter((c) => {
|
|
18078
18043
|
const measure = c.measures.find((m) => m.metric === "duplicated_lines_density");
|
|
18079
|
-
return measure
|
|
18044
|
+
return measure ? Number.parseFloat(measure.value) > 0 : false;
|
|
18080
18045
|
}).slice(0, limit);
|
|
18081
18046
|
const allDuplications = [];
|
|
18082
18047
|
for (const component of duplicatedComponents) {
|
|
@@ -18876,10 +18841,6 @@ class SonarQubeAPI {
|
|
|
18876
18841
|
};
|
|
18877
18842
|
}
|
|
18878
18843
|
}
|
|
18879
|
-
function createSonarQubeAPIWithCredentials(url2, user, password, logger3) {
|
|
18880
|
-
const client = createClientWithCredentials(url2, user, password, logger3?.child("client"));
|
|
18881
|
-
return new SonarQubeAPI(client, logger3);
|
|
18882
|
-
}
|
|
18883
18844
|
function createSonarQubeAPIWithToken(url2, token, logger3) {
|
|
18884
18845
|
const client = createClientWithToken(url2, token, logger3?.child("client"));
|
|
18885
18846
|
return new SonarQubeAPI(client, logger3);
|
|
@@ -20146,7 +20107,6 @@ function getSeveritiesFromLevel(level) {
|
|
|
20146
20107
|
}
|
|
20147
20108
|
|
|
20148
20109
|
// src/index.ts
|
|
20149
|
-
init_types2();
|
|
20150
20110
|
import { appendFileSync as appendFileSync4 } from "node:fs";
|
|
20151
20111
|
try {
|
|
20152
20112
|
appendFileSync4("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [LOAD] Plugin module loaded! CWD=${process.cwd()}
|
|
@@ -20431,7 +20391,7 @@ After fixing, I will re-run the analysis to verify.`;
|
|
|
20431
20391
|
});
|
|
20432
20392
|
if (config2.autoFix && lastAnalysisResult) {
|
|
20433
20393
|
const state = await getProjectState(getDirectory());
|
|
20434
|
-
if (state
|
|
20394
|
+
if (state?.projectKey) {
|
|
20435
20395
|
const api2 = createSonarQubeAPI(config2, state);
|
|
20436
20396
|
const issues = await api2.issues.getFormattedIssues({
|
|
20437
20397
|
projectKey: state.projectKey,
|
|
@@ -20935,38 +20895,6 @@ if (isDirectCLI) {
|
|
|
20935
20895
|
await executeCLI();
|
|
20936
20896
|
}
|
|
20937
20897
|
export {
|
|
20938
|
-
writePropertiesFile,
|
|
20939
|
-
sortIssuesBySeverity,
|
|
20940
|
-
runScanner,
|
|
20941
|
-
runAnalysis,
|
|
20942
|
-
ratingToNumber,
|
|
20943
|
-
numberToRating,
|
|
20944
|
-
needsBootstrap,
|
|
20945
|
-
loadConfig,
|
|
20946
|
-
getThresholdsForLevel,
|
|
20947
|
-
getProjectState,
|
|
20948
|
-
getProjectName,
|
|
20949
|
-
getProjectKey,
|
|
20950
|
-
formatIssuesForAgent,
|
|
20951
|
-
formatAnalysisResult,
|
|
20952
|
-
detectProjectType,
|
|
20953
20898
|
src_default as default,
|
|
20954
|
-
|
|
20955
|
-
createSonarQubeAPI,
|
|
20956
|
-
createLogger,
|
|
20957
|
-
bootstrap,
|
|
20958
|
-
SonarQubePlugin,
|
|
20959
|
-
SonarQubeError,
|
|
20960
|
-
SonarQubeConfigSchema,
|
|
20961
|
-
SonarQubeAPI,
|
|
20962
|
-
SetupError,
|
|
20963
|
-
STANDARD_THRESHOLDS,
|
|
20964
|
-
RateLimitError,
|
|
20965
|
-
RELAXED_THRESHOLDS,
|
|
20966
|
-
ProjectStateSchema,
|
|
20967
|
-
ProjectNotFoundError,
|
|
20968
|
-
Logger,
|
|
20969
|
-
ENTERPRISE_THRESHOLDS,
|
|
20970
|
-
ConnectionError,
|
|
20971
|
-
AuthenticationError
|
|
20899
|
+
SonarQubePlugin
|
|
20972
20900
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-sonarqube",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "OpenCode Plugin for SonarQube integration - Enterprise-level code quality from the start",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"homepage": "https://github.com/mguttmann/opencode-sonarqube#readme",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@opencode-ai/plugin": "^1.1.34",
|
|
41
|
-
"opencode-sonarqube": "0.
|
|
41
|
+
"opencode-sonarqube": "0.2.0",
|
|
42
42
|
"zod": "^3.24.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|