opencode-sonarqube 1.2.44 → 1.2.46

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/README.md CHANGED
@@ -4,7 +4,7 @@ OpenCode Plugin for SonarQube integration - Enterprise-level code quality from t
4
4
 
5
5
  [![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://sonarqube.example.com)
6
6
  [![Quality Gate](https://img.shields.io/badge/quality%20gate-passed-brightgreen)](https://sonarqube.example.com)
7
- [![Tests](https://img.shields.io/badge/tests-632%20passing-brightgreen)](https://sonarqube.example.com)
7
+ [![Tests](https://img.shields.io/badge/tests-612%20passing-brightgreen)](https://sonarqube.example.com)
8
8
  [![License](https://img.shields.io/badge/license-MIT-blue)](./LICENSE)
9
9
 
10
10
  ## Features
@@ -120,7 +120,6 @@ Create `.sonarqube/config.json` in your project root:
120
120
  {
121
121
  "level": "enterprise",
122
122
  "autoAnalyze": true,
123
- "autoFix": false,
124
123
  "newCodeDefinition": "previous_version"
125
124
  }
126
125
  ```
@@ -131,7 +130,6 @@ Create `.sonarqube/config.json` in your project root:
131
130
  |--------|------|---------|-------------|
132
131
  | `level` | `"enterprise"` \| `"standard"` \| `"relaxed"` \| `"off"` | `"enterprise"` | Analysis strictness level |
133
132
  | `autoAnalyze` | `boolean` | `true` | Auto-analyze when AI becomes idle |
134
- | `autoFix` | `boolean` | `false` | Automatically attempt to fix issues |
135
133
  | `projectKey` | `string` | auto | SonarQube project key (auto-generated from package.json or directory) |
136
134
  | `projectName` | `string` | auto | Display name on SonarQube |
137
135
  | `qualityGate` | `string` | `"Sonar way"` | Quality gate to use |
@@ -155,8 +153,7 @@ Create `.sonarqube/config.json` in your project root:
155
153
  ```json
156
154
  {
157
155
  "level": "enterprise",
158
- "autoAnalyze": true,
159
- "autoFix": false
156
+ "autoAnalyze": true
160
157
  }
161
158
  ```
162
159
 
@@ -480,7 +477,7 @@ This project maintains enterprise-level quality:
480
477
  | Metric | Value |
481
478
  |--------|-------|
482
479
  | Test Coverage | 96% |
483
- | Tests | 632 |
480
+ | Tests | 612 |
484
481
  | Bugs | 0 |
485
482
  | Vulnerabilities | 0 |
486
483
  | Code Smells | 0 |
package/dist/index.js CHANGED
@@ -4050,7 +4050,6 @@ var init_types2 = __esm(() => {
4050
4050
  password: exports_external2.string().min(1).describe("SonarQube password"),
4051
4051
  level: exports_external2.enum(["enterprise", "standard", "relaxed", "off"]).default("enterprise").describe("Analysis strictness level"),
4052
4052
  autoAnalyze: exports_external2.boolean().default(true).describe("Auto-analyze when agent becomes idle"),
4053
- autoFix: exports_external2.boolean().default(false).describe("Automatically attempt to fix issues"),
4054
4053
  projectKey: exports_external2.string().optional().describe("SonarQube project key (auto-generated if not set)"),
4055
4054
  projectName: exports_external2.string().optional().describe("SonarQube project display name"),
4056
4055
  qualityGate: exports_external2.string().optional().describe("Quality gate to use"),
@@ -16524,7 +16523,6 @@ var configLogger = {
16524
16523
  var DEFAULT_CONFIG = {
16525
16524
  level: "enterprise",
16526
16525
  autoAnalyze: true,
16527
- autoFix: false,
16528
16526
  newCodeDefinition: "previous_version",
16529
16527
  sources: "src"
16530
16528
  };
@@ -19099,20 +19097,6 @@ async function runAnalysis(config2, state, options, directory) {
19099
19097
  function formatAnalysisResult(result) {
19100
19098
  return formatIssuesForAgent(result.formattedIssues, result.qualityGateStatus);
19101
19099
  }
19102
- function shouldBlockOnResult(result, level) {
19103
- if (level === "off")
19104
- return false;
19105
- switch (level) {
19106
- case "enterprise":
19107
- return result.qualityGateStatus === "ERROR" || result.issues.blocker > 0 || result.issues.critical > 0;
19108
- case "standard":
19109
- return result.issues.blocker > 0 || result.issues.critical > 0;
19110
- case "relaxed":
19111
- return result.issues.blocker > 0;
19112
- default:
19113
- return false;
19114
- }
19115
- }
19116
19100
  // src/bootstrap/index.ts
19117
19101
  init_types2();
19118
19102
  init_state();
@@ -19354,23 +19338,17 @@ function formatAnalysisOutput(result, config2) {
19354
19338
  message += formatActionPrompt(result, config2);
19355
19339
  return message;
19356
19340
  }
19357
- function formatActionPrompt(result, config2) {
19341
+ function formatActionPrompt(result, _config) {
19358
19342
  const blockerCount = result.issues.blocker;
19359
19343
  const criticalCount = result.issues.critical;
19360
19344
  if (blockerCount === 0 && criticalCount === 0) {
19361
19345
  return "";
19362
19346
  }
19363
- let prompt = `
19347
+ return `
19364
19348
 
19365
19349
  ---
19366
19350
 
19367
- **Action Required:** Found ${blockerCount} blocker(s) and ${criticalCount} critical issue(s).`;
19368
- if (config2.autoFix) {
19369
- prompt += " I will now attempt to fix these issues.";
19370
- } else {
19371
- prompt += " Please review and fix these issues before continuing.";
19372
- }
19373
- return prompt;
19351
+ **Action Required:** Found ${blockerCount} blocker(s) and ${criticalCount} critical issue(s). Please review and fix these issues before continuing.`;
19374
19352
  }
19375
19353
  function createIdleHook(getConfig, getDirectory) {
19376
19354
  return async function handleSessionIdle() {
@@ -19574,7 +19552,6 @@ ${result.message}`;
19574
19552
  const defaultConfig = {
19575
19553
  level: config2.level || "enterprise",
19576
19554
  autoAnalyze: true,
19577
- autoFix: true,
19578
19555
  sources: config2.sources || "src",
19579
19556
  newCodeDefinition: "previous_version"
19580
19557
  };
@@ -19644,13 +19621,6 @@ async function handleAnalyze(config2, state, projectKey, args, directory) {
19644
19621
  }
19645
19622
  }
19646
19623
  }
19647
- if (shouldBlockOnResult(result, config2.level)) {
19648
- output += `
19649
-
19650
- ---
19651
-
19652
- **[BLOCKING]** Quality gate failed or critical issues found. Please fix before proceeding.`;
19653
- }
19654
19624
  return output;
19655
19625
  }
19656
19626
  async function handleIssues(config2, state, projectKey, args) {
@@ -20439,44 +20409,6 @@ ${blockerNote}Use \`sonarqube({ action: "issues" })\` to see details or \`sonarq
20439
20409
  });
20440
20410
  } catch {}
20441
20411
  };
20442
- const triggerAutoFix = async (issues) => {
20443
- if (!currentSessionId || issues.length === 0)
20444
- return;
20445
- const blockers = issues.filter((i) => i.severity === "BLOCKER");
20446
- const critical = issues.filter((i) => i.severity === "CRITICAL");
20447
- if (blockers.length === 0 && critical.length === 0)
20448
- return;
20449
- const issueList = [...blockers, ...critical].slice(0, 5).map((i) => `- ${i.file}:${i.line ?? "?"} - ${i.message}`).join(`
20450
- `);
20451
- const fixPrompt = `## SonarQube Auto-Fix Request
20452
-
20453
- The following critical issues were found and need to be fixed:
20454
-
20455
- ${issueList}
20456
-
20457
- Please fix these issues now. Focus on:
20458
- 1. Security vulnerabilities first (BLOCKER)
20459
- 2. Then reliability issues (CRITICAL)
20460
-
20461
- After fixing, I will re-run the analysis to verify.`;
20462
- try {
20463
- await client.session.prompt({
20464
- path: { id: currentSessionId },
20465
- body: {
20466
- parts: [{ type: "text", text: fixPrompt }]
20467
- }
20468
- });
20469
- } catch (error45) {
20470
- await client.app.log({
20471
- body: {
20472
- service: "opencode-sonarqube",
20473
- level: "error",
20474
- message: "Failed to trigger auto-fix",
20475
- extra: { error: String(error45) }
20476
- }
20477
- });
20478
- }
20479
- };
20480
20412
  const qualityGatePattern = /Quality Gate: \[(PASS|FAIL)\] (\w+)/;
20481
20413
  const issueCountPattern = /Blockers: (\d+), Critical: (\d+), Major: (\d+), Minor: (\d+), Info: (\d+)/;
20482
20414
  const parseAnalysisResult = (message) => {
@@ -20518,26 +20450,15 @@ After fixing, I will re-run the analysis to verify.`;
20518
20450
  hooks.fileEdited({ filePath: payload.path });
20519
20451
  }
20520
20452
  };
20521
- const injectAnalysisResults = async (message, config2, sessionId) => {
20453
+ const injectAnalysisResults = async (message, _config, sessionId) => {
20522
20454
  try {
20523
20455
  await client.session.prompt({
20524
20456
  path: { id: sessionId },
20525
20457
  body: {
20526
- noReply: !config2.autoFix,
20458
+ noReply: true,
20527
20459
  parts: [{ type: "text", text: message }]
20528
20460
  }
20529
20461
  });
20530
- if (config2.autoFix && lastAnalysisResult) {
20531
- const state = await getProjectState(getDirectory());
20532
- if (state?.projectKey) {
20533
- const api2 = createSonarQubeAPI(config2, state);
20534
- const issues = await api2.issues.getFormattedIssues({
20535
- projectKey: state.projectKey,
20536
- severities: ["BLOCKER", "CRITICAL"]
20537
- });
20538
- await triggerAutoFix(issues);
20539
- }
20540
- }
20541
20462
  } catch (error45) {
20542
20463
  await client.app.log({
20543
20464
  body: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-sonarqube",
3
- "version": "1.2.44",
3
+ "version": "1.2.46",
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,6 +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": "^1.2.45",
41
42
  "zod": "^3.24.0"
42
43
  },
43
44
  "devDependencies": {