opencode-sonarqube 0.2.1 → 0.2.2
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 +77 -67
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -85,36 +85,46 @@ Add these to your `~/.zshrc` or `~/.bashrc` to make them permanent.
|
|
|
85
85
|
|
|
86
86
|
## Configuration
|
|
87
87
|
|
|
88
|
-
###
|
|
88
|
+
### Environment Variables (Required)
|
|
89
|
+
|
|
90
|
+
Add these to your `~/.zshrc` or `~/.bashrc`:
|
|
89
91
|
|
|
90
92
|
```bash
|
|
91
|
-
|
|
93
|
+
export SONAR_HOST_URL="https://your-sonarqube-server.com"
|
|
94
|
+
export SONAR_USER="admin"
|
|
95
|
+
export SONAR_PASSWORD="your-password"
|
|
92
96
|
```
|
|
93
97
|
|
|
94
|
-
|
|
95
|
-
- Update SonarQube URL
|
|
96
|
-
- Change credentials
|
|
97
|
-
- Test connection
|
|
98
|
-
- Reset project state
|
|
99
|
-
|
|
100
|
-
### Environment Variables (Required)
|
|
101
|
-
|
|
102
|
-
| Variable | Description |
|
|
103
|
-
|----------|-------------|
|
|
104
|
-
| `SONAR_HOST_URL` | SonarQube server URL (e.g., `https://sonarqube.example.com`) |
|
|
105
|
-
| `SONAR_USER` | Username for authentication |
|
|
106
|
-
| `SONAR_PASSWORD` | Password for authentication |
|
|
98
|
+
### Plugin Configuration (Optional)
|
|
107
99
|
|
|
108
|
-
|
|
100
|
+
Create `.sonarqube/config.json` in your project root:
|
|
109
101
|
|
|
110
|
-
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"level": "enterprise",
|
|
105
|
+
"autoAnalyze": true,
|
|
106
|
+
"autoFix": false,
|
|
107
|
+
"sources": "src",
|
|
108
|
+
"tests": "tests",
|
|
109
|
+
"exclusions": "**/node_modules/**,**/dist/**",
|
|
110
|
+
"newCodeDefinition": "previous_version"
|
|
111
|
+
}
|
|
112
|
+
```
|
|
111
113
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
|
115
|
-
|
|
116
|
-
|
|
|
117
|
-
|
|
|
114
|
+
### All Configuration Options
|
|
115
|
+
|
|
116
|
+
| Option | Type | Default | Description |
|
|
117
|
+
|--------|------|---------|-------------|
|
|
118
|
+
| `level` | `"enterprise"` \| `"standard"` \| `"relaxed"` \| `"off"` | `"enterprise"` | Analysis strictness level |
|
|
119
|
+
| `autoAnalyze` | `boolean` | `true` | Auto-analyze when AI becomes idle |
|
|
120
|
+
| `autoFix` | `boolean` | `false` | Automatically attempt to fix issues |
|
|
121
|
+
| `projectKey` | `string` | auto | SonarQube project key (auto-generated from package.json or directory) |
|
|
122
|
+
| `projectName` | `string` | auto | Display name on SonarQube |
|
|
123
|
+
| `qualityGate` | `string` | `"Sonar way"` | Quality gate to use |
|
|
124
|
+
| `newCodeDefinition` | `"previous_version"` \| `"number_of_days"` \| `"reference_branch"` \| `"specific_analysis"` | `"previous_version"` | How to define 'new code' |
|
|
125
|
+
| `sources` | `string` | `"src"` | Source directories (comma-separated) |
|
|
126
|
+
| `tests` | `string` | - | Test directories (comma-separated) |
|
|
127
|
+
| `exclusions` | `string` | - | File exclusion patterns (glob) |
|
|
118
128
|
|
|
119
129
|
### Strictness Levels
|
|
120
130
|
|
|
@@ -125,6 +135,34 @@ The plugin uses these defaults (configurable in future versions):
|
|
|
125
135
|
| `relaxed` | Only blocker/critical, blocks on blocker |
|
|
126
136
|
| `off` | Plugin disabled |
|
|
127
137
|
|
|
138
|
+
### Example Configurations
|
|
139
|
+
|
|
140
|
+
**Enterprise (strictest)**:
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"level": "enterprise",
|
|
144
|
+
"autoAnalyze": true,
|
|
145
|
+
"autoFix": false
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Standard (balanced)**:
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"level": "standard",
|
|
153
|
+
"autoAnalyze": true,
|
|
154
|
+
"sources": "src,lib"
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**Relaxed (lenient)**:
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"level": "relaxed",
|
|
162
|
+
"autoAnalyze": false
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
128
166
|
## Tool Actions (15 total)
|
|
129
167
|
|
|
130
168
|
The plugin adds a `sonarqube` tool with these actions:
|
|
@@ -296,51 +334,23 @@ bun run src/index.ts --status --project-key=my-project
|
|
|
296
334
|
bun run src/index.ts --setup --force
|
|
297
335
|
```
|
|
298
336
|
|
|
299
|
-
##
|
|
337
|
+
## Project State
|
|
300
338
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
const api = createSonarQubeAPI(config, state);
|
|
314
|
-
|
|
315
|
-
// Health check
|
|
316
|
-
const health = await api.healthCheck();
|
|
317
|
-
console.log("Healthy:", health.healthy);
|
|
318
|
-
|
|
319
|
-
// Get issues
|
|
320
|
-
const issues = await api.issues.getFormattedIssues({
|
|
321
|
-
projectKey: "my-project",
|
|
322
|
-
severities: ["BLOCKER", "CRITICAL"],
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
// Get quality gate status
|
|
326
|
-
const status = await api.qualityGate.getStatus("my-project");
|
|
327
|
-
console.log("Status:", status.projectStatus.status);
|
|
328
|
-
|
|
329
|
-
// Get new code issues only
|
|
330
|
-
const newIssues = await api.issues.search({
|
|
331
|
-
projectKey: "my-project",
|
|
332
|
-
inNewCode: true,
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
// Get worst files for refactoring
|
|
336
|
-
const worstFiles = await api.components.getWorstFiles("my-project", 10);
|
|
337
|
-
|
|
338
|
-
// Run full analysis
|
|
339
|
-
const result = await runAnalysis(config, state, { projectKey: "my-project" }, "./");
|
|
340
|
-
console.log("Quality Gate:", result.qualityGateStatus);
|
|
339
|
+
The plugin stores project state in `.sonarqube/project.json`:
|
|
340
|
+
|
|
341
|
+
```json
|
|
342
|
+
{
|
|
343
|
+
"projectKey": "my-project",
|
|
344
|
+
"projectToken": "sqp_xxx...",
|
|
345
|
+
"tokenName": "opencode-my-project-...",
|
|
346
|
+
"initializedAt": "2024-01-01T00:00:00.000Z",
|
|
347
|
+
"languages": ["typescript", "javascript"],
|
|
348
|
+
"qualityGate": "Sonar way",
|
|
349
|
+
"setupComplete": true
|
|
350
|
+
}
|
|
341
351
|
```
|
|
342
352
|
|
|
343
|
-
|
|
353
|
+
**Important:** Add `.sonarqube/` to your `.gitignore` - it contains authentication tokens!
|
|
344
354
|
|
|
345
355
|
## Documentation
|
|
346
356
|
|
|
@@ -383,16 +393,16 @@ This project maintains enterprise-level quality:
|
|
|
383
393
|
|
|
384
394
|
| Metric | Value |
|
|
385
395
|
|--------|-------|
|
|
386
|
-
| Test Coverage |
|
|
396
|
+
| Test Coverage | 87.9% |
|
|
387
397
|
| Tests | 626 |
|
|
388
398
|
| Bugs | 0 |
|
|
389
399
|
| Vulnerabilities | 0 |
|
|
390
400
|
| Code Smells | 0 |
|
|
391
401
|
| Duplications | 0% |
|
|
392
|
-
| Quality Gate | Passed |
|
|
393
402
|
| Reliability Rating | A |
|
|
394
403
|
| Security Rating | A |
|
|
395
404
|
| Maintainability Rating | A |
|
|
405
|
+
| Lines of Code | ~6,000 |
|
|
396
406
|
|
|
397
407
|
## License
|
|
398
408
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-sonarqube",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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.2.
|
|
41
|
+
"opencode-sonarqube": "0.2.2",
|
|
42
42
|
"zod": "^3.24.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|