@codacy/analysis-runner 0.1.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/LICENSE +21 -0
- package/README.md +55 -0
- package/dist/index.d.ts +364 -0
- package/dist/index.js +4888 -0
- package/package.json +41 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,4888 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
analyze: () => analyze,
|
|
34
|
+
applyCodacyYamlExcludes: () => applyCodacyYamlExcludes,
|
|
35
|
+
buildToolConfig: () => buildToolConfig,
|
|
36
|
+
clearAdapters: () => clearAdapters,
|
|
37
|
+
configureApiToken: () => configureApiToken,
|
|
38
|
+
createCodacyConfig: () => createCodacyConfig,
|
|
39
|
+
createLogger: () => createLogger,
|
|
40
|
+
detectLanguages: () => detectLanguages,
|
|
41
|
+
formatOutput: () => formatOutput,
|
|
42
|
+
formatTextSummary: () => formatTextSummary,
|
|
43
|
+
getRegisteredAdapters: () => getRegisteredAdapters,
|
|
44
|
+
initContainerConfig: () => initContainerConfig,
|
|
45
|
+
initDefaultConfig: () => initDefaultConfig,
|
|
46
|
+
initLocalConfig: () => initLocalConfig,
|
|
47
|
+
initRemoteConfig: () => initRemoteConfig,
|
|
48
|
+
readCodacyConfig: () => readCodacyConfig,
|
|
49
|
+
readCodacyYaml: () => readCodacyYaml,
|
|
50
|
+
registerAdapter: () => registerAdapter,
|
|
51
|
+
resolveEngineToAdapter: () => resolveEngineToAdapter,
|
|
52
|
+
rotateLogFiles: () => rotateLogFiles,
|
|
53
|
+
validateApiToken: () => validateApiToken,
|
|
54
|
+
writeCodacyConfig: () => writeCodacyConfig
|
|
55
|
+
});
|
|
56
|
+
module.exports = __toCommonJS(index_exports);
|
|
57
|
+
|
|
58
|
+
// src/analyze.ts
|
|
59
|
+
var import_os = __toESM(require("os"));
|
|
60
|
+
var import_path3 = __toESM(require("path"));
|
|
61
|
+
|
|
62
|
+
// src/registry.ts
|
|
63
|
+
var adapters = /* @__PURE__ */ new Map();
|
|
64
|
+
function registerAdapter(adapter) {
|
|
65
|
+
adapters.set(adapter.id, adapter);
|
|
66
|
+
}
|
|
67
|
+
function resolveAdapter(input) {
|
|
68
|
+
const exact = adapters.get(input);
|
|
69
|
+
if (exact) return exact;
|
|
70
|
+
const needle = input.toLowerCase();
|
|
71
|
+
const matches = Array.from(adapters.values()).filter((a) => {
|
|
72
|
+
return a.id.toLowerCase().includes(needle) || a.displayName.toLowerCase().includes(needle);
|
|
73
|
+
});
|
|
74
|
+
return matches.length === 1 ? matches[0] : void 0;
|
|
75
|
+
}
|
|
76
|
+
function getRegisteredAdapters(toolIds) {
|
|
77
|
+
if (toolIds && toolIds.length > 0) {
|
|
78
|
+
return toolIds.map((id) => resolveAdapter(id)).filter((a) => a !== void 0);
|
|
79
|
+
}
|
|
80
|
+
return Array.from(adapters.values());
|
|
81
|
+
}
|
|
82
|
+
function clearAdapters() {
|
|
83
|
+
adapters.clear();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/config.ts
|
|
87
|
+
var import_promises = __toESM(require("fs/promises"));
|
|
88
|
+
var import_path = __toESM(require("path"));
|
|
89
|
+
var CODACY_DIR = ".codacy";
|
|
90
|
+
var CONFIG_FILE = "codacy.config.json";
|
|
91
|
+
async function readCodacyConfig(repositoryRoot) {
|
|
92
|
+
const configPath = import_path.default.join(repositoryRoot, CODACY_DIR, CONFIG_FILE);
|
|
93
|
+
try {
|
|
94
|
+
const raw = await import_promises.default.readFile(configPath, "utf-8");
|
|
95
|
+
return JSON.parse(raw);
|
|
96
|
+
} catch {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function writeCodacyConfig(repositoryRoot, config) {
|
|
101
|
+
const codacyDir = import_path.default.join(repositoryRoot, CODACY_DIR);
|
|
102
|
+
await import_promises.default.mkdir(codacyDir, { recursive: true });
|
|
103
|
+
await ensureGitignore(codacyDir);
|
|
104
|
+
const configPath = import_path.default.join(codacyDir, CONFIG_FILE);
|
|
105
|
+
await import_promises.default.writeFile(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
106
|
+
return configPath;
|
|
107
|
+
}
|
|
108
|
+
async function ensureGitignore(codacyDir) {
|
|
109
|
+
const gitignorePath = import_path.default.join(codacyDir, ".gitignore");
|
|
110
|
+
try {
|
|
111
|
+
const content = await import_promises.default.readFile(gitignorePath, "utf-8");
|
|
112
|
+
if (!content.includes("generated/")) {
|
|
113
|
+
await import_promises.default.writeFile(gitignorePath, content.trimEnd() + "\ngenerated/\n");
|
|
114
|
+
}
|
|
115
|
+
} catch {
|
|
116
|
+
await import_promises.default.writeFile(gitignorePath, "generated/\n");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function buildToolConfig(codacyConfig, adapter, configCheck) {
|
|
120
|
+
const existing = getToolConfig(codacyConfig, adapter.id);
|
|
121
|
+
const config = existing ? { ...existing } : { toolId: adapter.id, patterns: [] };
|
|
122
|
+
if (configCheck.found && configCheck.path) {
|
|
123
|
+
if (!existing || existing.useLocalConfigurationFile !== false) {
|
|
124
|
+
config.localConfigurationFile = configCheck.path;
|
|
125
|
+
config.useLocalConfigurationFile = true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return config;
|
|
129
|
+
}
|
|
130
|
+
function getToolConfig(codacyConfig, toolId) {
|
|
131
|
+
if (!codacyConfig) return void 0;
|
|
132
|
+
return codacyConfig.tools.find((t) => t.toolId === toolId);
|
|
133
|
+
}
|
|
134
|
+
function createCodacyConfig(params = {}) {
|
|
135
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
136
|
+
const config = {
|
|
137
|
+
version: 1,
|
|
138
|
+
metadata: {
|
|
139
|
+
source: params.source ?? "local",
|
|
140
|
+
provider: params.provider ?? null,
|
|
141
|
+
organization: params.organization ?? null,
|
|
142
|
+
repositoryId: params.repositoryId ?? null,
|
|
143
|
+
repositoryName: params.repositoryName ?? null,
|
|
144
|
+
createdAt: now,
|
|
145
|
+
updatedAt: now,
|
|
146
|
+
languages: params.languages ?? []
|
|
147
|
+
},
|
|
148
|
+
tools: params.tools ?? [],
|
|
149
|
+
exclude: []
|
|
150
|
+
};
|
|
151
|
+
if (params.includeFiles && params.includeFiles.length > 0) {
|
|
152
|
+
config.includeFiles = params.includeFiles;
|
|
153
|
+
}
|
|
154
|
+
return config;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// src/files.ts
|
|
158
|
+
var import_child_process = require("child_process");
|
|
159
|
+
var import_path2 = __toESM(require("path"));
|
|
160
|
+
var import_minimatch = require("minimatch");
|
|
161
|
+
function listRepoFiles(repositoryRoot) {
|
|
162
|
+
try {
|
|
163
|
+
const tracked = (0, import_child_process.execSync)("git ls-files", {
|
|
164
|
+
cwd: repositoryRoot,
|
|
165
|
+
encoding: "utf-8",
|
|
166
|
+
maxBuffer: 50 * 1024 * 1024
|
|
167
|
+
}).trim();
|
|
168
|
+
const untracked = (0, import_child_process.execSync)("git ls-files --others --exclude-standard", {
|
|
169
|
+
cwd: repositoryRoot,
|
|
170
|
+
encoding: "utf-8",
|
|
171
|
+
maxBuffer: 50 * 1024 * 1024
|
|
172
|
+
}).trim();
|
|
173
|
+
const files = /* @__PURE__ */ new Set();
|
|
174
|
+
for (const f of tracked.split("\n")) {
|
|
175
|
+
if (f) files.add(f);
|
|
176
|
+
}
|
|
177
|
+
for (const f of untracked.split("\n")) {
|
|
178
|
+
if (f) files.add(f);
|
|
179
|
+
}
|
|
180
|
+
return Array.from(files).sort();
|
|
181
|
+
} catch {
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function applyExclusions(files, globalExclude, toolExclude) {
|
|
186
|
+
const allExclusions = [...globalExclude, ...toolExclude];
|
|
187
|
+
if (allExclusions.length === 0) return files;
|
|
188
|
+
return files.filter((file) => {
|
|
189
|
+
const basename = import_path2.default.basename(file);
|
|
190
|
+
return !allExclusions.some((pattern) => {
|
|
191
|
+
if ((0, import_minimatch.minimatch)(file, pattern, { dot: true })) return true;
|
|
192
|
+
if (!pattern.includes("/") && (0, import_minimatch.minimatch)(basename, pattern, { dot: true })) return true;
|
|
193
|
+
return false;
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
function routeFilesToTool(files, adapter, toolConfig) {
|
|
198
|
+
const patterns = [...adapter.filePatterns];
|
|
199
|
+
if (toolConfig?.extraFilePatterns) {
|
|
200
|
+
patterns.push(...toolConfig.extraFilePatterns);
|
|
201
|
+
}
|
|
202
|
+
if (patterns.includes("*")) return files;
|
|
203
|
+
return files.filter((file) => {
|
|
204
|
+
const basename = import_path2.default.basename(file);
|
|
205
|
+
return patterns.some(
|
|
206
|
+
(pattern) => (0, import_minimatch.minimatch)(basename, pattern, { dot: true }) || (0, import_minimatch.minimatch)(file, pattern, { dot: true })
|
|
207
|
+
);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
function filterByTargetFiles(allFiles, targetPatterns) {
|
|
211
|
+
if (targetPatterns.length === 0) return allFiles;
|
|
212
|
+
const normalized = targetPatterns.map((p) => p.replace(/^\.\//, ""));
|
|
213
|
+
return allFiles.filter(
|
|
214
|
+
(f) => normalized.some(
|
|
215
|
+
(pattern) => (
|
|
216
|
+
// Exact match (fast path)
|
|
217
|
+
f === pattern || // Glob match
|
|
218
|
+
(0, import_minimatch.minimatch)(f, pattern, { dot: true, matchBase: false }) || // Directory prefix (e.g. "src/subdir/" matches all files under it)
|
|
219
|
+
pattern.endsWith("/") && f.startsWith(pattern)
|
|
220
|
+
)
|
|
221
|
+
)
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// src/executor.ts
|
|
226
|
+
async function runTool(adapter, ctx, codacyToolConfig, timeoutMs) {
|
|
227
|
+
const startTime = Date.now();
|
|
228
|
+
ctx.logger.debug("runTool started", { toolId: adapter.id, fileCount: ctx.targetFiles.length, timeoutMs });
|
|
229
|
+
try {
|
|
230
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
231
|
+
setTimeout(() => reject(new Error(`TIMEOUT: Tool ${adapter.id} exceeded ${timeoutMs}ms`)), timeoutMs);
|
|
232
|
+
});
|
|
233
|
+
const result = await Promise.race([
|
|
234
|
+
adapter.analyze(ctx, codacyToolConfig),
|
|
235
|
+
timeoutPromise
|
|
236
|
+
]);
|
|
237
|
+
ctx.logger.debug("runTool completed", { toolId: adapter.id, issueCount: result.summary.issueCount, durationMs: result.summary.durationMs });
|
|
238
|
+
return result;
|
|
239
|
+
} catch (err) {
|
|
240
|
+
const durationMs = Date.now() - startTime;
|
|
241
|
+
const isTimeout = err instanceof Error && err.message.includes("TIMEOUT");
|
|
242
|
+
if (isTimeout) {
|
|
243
|
+
ctx.logger.error("Tool timed out", { toolId: adapter.id, timeoutMs, elapsedMs: durationMs });
|
|
244
|
+
} else {
|
|
245
|
+
ctx.logger.error("Tool execution failed", { toolId: adapter.id, error: err instanceof Error ? err.message : String(err), durationMs });
|
|
246
|
+
}
|
|
247
|
+
const now = /* @__PURE__ */ new Date();
|
|
248
|
+
return {
|
|
249
|
+
metadata: {
|
|
250
|
+
startedAt: new Date(now.getTime() - durationMs).toISOString(),
|
|
251
|
+
completedAt: now.toISOString(),
|
|
252
|
+
durationMs
|
|
253
|
+
},
|
|
254
|
+
issues: [],
|
|
255
|
+
errors: [
|
|
256
|
+
{
|
|
257
|
+
toolId: adapter.id,
|
|
258
|
+
phase: "toolInvoke",
|
|
259
|
+
kind: isTimeout ? "Timeout" : "InvocationError",
|
|
260
|
+
message: isTimeout ? `Tool ${adapter.id} exceeded timeout of ${timeoutMs}ms` : `Tool ${adapter.id} failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
261
|
+
level: "error"
|
|
262
|
+
}
|
|
263
|
+
],
|
|
264
|
+
summary: {
|
|
265
|
+
toolId: adapter.id,
|
|
266
|
+
status: "failed",
|
|
267
|
+
issueCount: 0,
|
|
268
|
+
errorCount: 1,
|
|
269
|
+
durationMs,
|
|
270
|
+
filesAnalyzed: ctx.targetFiles.length
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
async function runToolsSequential(tools, timeoutMs, callbacks) {
|
|
276
|
+
const results = [];
|
|
277
|
+
for (const { adapter, ctx, codacyToolConfig } of tools) {
|
|
278
|
+
callbacks?.onToolStart?.(adapter.id, adapter.displayName);
|
|
279
|
+
const result = await runTool(adapter, ctx, codacyToolConfig, timeoutMs);
|
|
280
|
+
callbacks?.onToolComplete?.(adapter.id, adapter.displayName, result.summary.issueCount, result.summary.durationMs);
|
|
281
|
+
results.push(result);
|
|
282
|
+
}
|
|
283
|
+
return results;
|
|
284
|
+
}
|
|
285
|
+
async function runToolsParallel(tools, timeoutMs, concurrency, callbacks) {
|
|
286
|
+
const results = new Array(tools.length);
|
|
287
|
+
let nextIndex = 0;
|
|
288
|
+
async function worker() {
|
|
289
|
+
while (nextIndex < tools.length) {
|
|
290
|
+
const index = nextIndex++;
|
|
291
|
+
const { adapter, ctx, codacyToolConfig } = tools[index];
|
|
292
|
+
callbacks?.onToolStart?.(adapter.id, adapter.displayName);
|
|
293
|
+
results[index] = await runTool(adapter, ctx, codacyToolConfig, timeoutMs);
|
|
294
|
+
callbacks?.onToolComplete?.(adapter.id, adapter.displayName, results[index].summary.issueCount, results[index].summary.durationMs);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
const workers = Array.from({ length: Math.min(concurrency, tools.length) }, () => worker());
|
|
298
|
+
await Promise.all(workers);
|
|
299
|
+
return results;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// src/analyze.ts
|
|
303
|
+
var nullLogger = {
|
|
304
|
+
debug: () => {
|
|
305
|
+
},
|
|
306
|
+
info: () => {
|
|
307
|
+
},
|
|
308
|
+
warn: () => {
|
|
309
|
+
},
|
|
310
|
+
error: () => {
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
async function analyze(options) {
|
|
314
|
+
const startedAt = /* @__PURE__ */ new Date();
|
|
315
|
+
const mode = options.mode || "standard";
|
|
316
|
+
const toolTimeout = options.toolTimeout || 3e5;
|
|
317
|
+
const parallelTools = options.parallelTools || 1;
|
|
318
|
+
const logger = options.logger ?? nullLogger;
|
|
319
|
+
const adapters2 = getRegisteredAdapters(options.tools);
|
|
320
|
+
logger.info("Pipeline started", { mode, toolCount: adapters2.length, parallelTools, toolTimeout });
|
|
321
|
+
const globalDir = import_path3.default.join(import_os.default.homedir(), ".codacy");
|
|
322
|
+
const baseCtx = {
|
|
323
|
+
repositoryRoot: options.repositoryRoot,
|
|
324
|
+
globalDir,
|
|
325
|
+
platform: { os: import_os.default.platform(), arch: import_os.default.arch() },
|
|
326
|
+
logger,
|
|
327
|
+
runner: "local"
|
|
328
|
+
};
|
|
329
|
+
const ready = [];
|
|
330
|
+
const unavailable = [];
|
|
331
|
+
const availabilityTimeout = 6e4;
|
|
332
|
+
for (const adapter of adapters2) {
|
|
333
|
+
const ctx = makeToolContext(baseCtx, adapter, []);
|
|
334
|
+
const checkStart = Date.now();
|
|
335
|
+
logger.debug("Checking availability", { toolId: adapter.id });
|
|
336
|
+
try {
|
|
337
|
+
const availability = await Promise.race([
|
|
338
|
+
adapter.checkAvailability(ctx),
|
|
339
|
+
new Promise(
|
|
340
|
+
(_, reject) => setTimeout(() => reject(new Error(`checkAvailability timed out after ${availabilityTimeout}ms`)), availabilityTimeout)
|
|
341
|
+
)
|
|
342
|
+
]);
|
|
343
|
+
if (availability.available) {
|
|
344
|
+
logger.debug("Tool available", { toolId: adapter.id, version: availability.version, installation: availability.installation, durationMs: Date.now() - checkStart });
|
|
345
|
+
ready.push({
|
|
346
|
+
toolId: adapter.id,
|
|
347
|
+
displayName: adapter.displayName,
|
|
348
|
+
version: availability.version ?? adapter.preferredVersion,
|
|
349
|
+
installation: availability.installation ?? "global",
|
|
350
|
+
runner: "local"
|
|
351
|
+
});
|
|
352
|
+
} else {
|
|
353
|
+
logger.warn("Tool unavailable", { toolId: adapter.id, reason: availability.reason, durationMs: Date.now() - checkStart });
|
|
354
|
+
unavailable.push({
|
|
355
|
+
toolId: adapter.id,
|
|
356
|
+
displayName: adapter.displayName,
|
|
357
|
+
reason: availability.reason || "Tool is not available",
|
|
358
|
+
...availability.installHint ? { remediation: availability.installHint } : {}
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
} catch (err) {
|
|
362
|
+
logger.warn("Availability check failed", { toolId: adapter.id, error: err instanceof Error ? err.message : String(err), durationMs: Date.now() - checkStart });
|
|
363
|
+
unavailable.push({
|
|
364
|
+
toolId: adapter.id,
|
|
365
|
+
displayName: adapter.displayName,
|
|
366
|
+
reason: `Availability check failed: ${err instanceof Error ? err.message : String(err)}`
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const capability = {
|
|
371
|
+
ready,
|
|
372
|
+
unavailable,
|
|
373
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
374
|
+
};
|
|
375
|
+
const codacyConfig = await readCodacyConfig(options.repositoryRoot);
|
|
376
|
+
if (codacyConfig) {
|
|
377
|
+
const readyBefore = capability.ready.length;
|
|
378
|
+
const configuredIds = new Set(codacyConfig.tools.map((t) => t.toolId));
|
|
379
|
+
capability.ready = capability.ready.filter((t) => configuredIds.has(t.toolId));
|
|
380
|
+
capability.unavailable = capability.unavailable.filter((t) => configuredIds.has(t.toolId));
|
|
381
|
+
logger.debug("Filtered by config", { readyBefore, readyAfter: capability.ready.length, configuredToolCount: configuredIds.size });
|
|
382
|
+
} else {
|
|
383
|
+
logger.debug("No codacy config found, running all available tools");
|
|
384
|
+
}
|
|
385
|
+
if (mode === "auto-install" && capability.unavailable.length > 0) {
|
|
386
|
+
const installErrors = [];
|
|
387
|
+
for (let i = capability.unavailable.length - 1; i >= 0; i--) {
|
|
388
|
+
const status = capability.unavailable[i];
|
|
389
|
+
const adapter = adapters2.find((a) => a.id === status.toolId);
|
|
390
|
+
if (!adapter) continue;
|
|
391
|
+
const ctx = makeToolContext(baseCtx, adapter, []);
|
|
392
|
+
logger.info(`${adapter.displayName} is missing, attempting install...`);
|
|
393
|
+
try {
|
|
394
|
+
logger.info(`Downloading ${adapter.displayName}...`);
|
|
395
|
+
const installResult = await adapter.install(ctx);
|
|
396
|
+
if (installResult.success) {
|
|
397
|
+
logger.info(`Checking ${adapter.displayName} installation...`);
|
|
398
|
+
const recheck = await adapter.checkAvailability(ctx);
|
|
399
|
+
if (recheck.available) {
|
|
400
|
+
logger.info(`${adapter.displayName} is now available`);
|
|
401
|
+
capability.ready.push({
|
|
402
|
+
toolId: adapter.id,
|
|
403
|
+
displayName: adapter.displayName,
|
|
404
|
+
version: recheck.version ?? installResult.installedVersion ?? adapter.preferredVersion,
|
|
405
|
+
installation: recheck.installation ?? "codacy",
|
|
406
|
+
runner: "local"
|
|
407
|
+
});
|
|
408
|
+
capability.unavailable.splice(i, 1);
|
|
409
|
+
} else {
|
|
410
|
+
logger.error(`${adapter.displayName} post-install check failed: ${recheck.reason ?? "unknown"}`);
|
|
411
|
+
installErrors.push({
|
|
412
|
+
toolId: adapter.id,
|
|
413
|
+
phase: "toolInstall",
|
|
414
|
+
kind: "PostInstallCheckFailed",
|
|
415
|
+
message: `Installed ${adapter.id} but availability check still fails: ${recheck.reason ?? "unknown"}`,
|
|
416
|
+
level: "error"
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
} else if (installResult.error?.kind === "NotSupported") {
|
|
420
|
+
logger.info(`${adapter.displayName} does not support automated install, skipping.`);
|
|
421
|
+
capability.unavailable.splice(i, 1);
|
|
422
|
+
} else {
|
|
423
|
+
const errMsg = installResult.error?.message ?? `Failed to install ${adapter.id}`;
|
|
424
|
+
logger.error(`${adapter.displayName} install failed: ${errMsg}`);
|
|
425
|
+
installErrors.push(
|
|
426
|
+
installResult.error ?? {
|
|
427
|
+
toolId: adapter.id,
|
|
428
|
+
phase: "toolInstall",
|
|
429
|
+
kind: "InstallFailed",
|
|
430
|
+
message: errMsg,
|
|
431
|
+
level: "error"
|
|
432
|
+
}
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
} catch (err) {
|
|
436
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
437
|
+
logger.error(`${adapter.displayName} install failed: ${errMsg}`);
|
|
438
|
+
installErrors.push({
|
|
439
|
+
toolId: adapter.id,
|
|
440
|
+
phase: "toolInstall",
|
|
441
|
+
kind: "InstallError",
|
|
442
|
+
message: `Install failed for ${adapter.id}: ${errMsg}`,
|
|
443
|
+
level: "error"
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
if (installErrors.length > 0) {
|
|
448
|
+
return buildResult(startedAt, options.repositoryRoot, mode, capability, [], installErrors, []);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
if (mode === "inspect") {
|
|
452
|
+
for (const tool of capability.ready) {
|
|
453
|
+
const adapter = adapters2.find((a) => a.id === tool.toolId);
|
|
454
|
+
if (!adapter) continue;
|
|
455
|
+
const ctx = makeToolContext(baseCtx, adapter, []);
|
|
456
|
+
const availability = await adapter.checkAvailability(ctx).catch(() => null);
|
|
457
|
+
if (availability?.dependencies) {
|
|
458
|
+
tool.dependencies = availability.dependencies.filter((d) => d.available && d.version).map((d) => ({
|
|
459
|
+
name: d.name,
|
|
460
|
+
version: d.version,
|
|
461
|
+
installation: d.installation ?? "global"
|
|
462
|
+
}));
|
|
463
|
+
}
|
|
464
|
+
try {
|
|
465
|
+
const configCheck = await adapter.checkLocalConfigurationFile(ctx);
|
|
466
|
+
const toolCfg = buildToolConfig(codacyConfig, adapter, configCheck);
|
|
467
|
+
if (configCheck.found && toolCfg.useLocalConfigurationFile) {
|
|
468
|
+
tool.configSource = "local";
|
|
469
|
+
tool.configPath = configCheck.path;
|
|
470
|
+
} else {
|
|
471
|
+
tool.configSource = "codacy";
|
|
472
|
+
}
|
|
473
|
+
} catch {
|
|
474
|
+
tool.configSource = "codacy";
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
return buildResult(startedAt, options.repositoryRoot, mode, capability, [], [], []);
|
|
478
|
+
}
|
|
479
|
+
if (mode === "strict" && capability.unavailable.length > 0) {
|
|
480
|
+
const missingTools = capability.unavailable.map((u) => u.toolId).join(", ");
|
|
481
|
+
return buildResult(startedAt, options.repositoryRoot, mode, capability, [], [
|
|
482
|
+
{
|
|
483
|
+
toolId: "runner",
|
|
484
|
+
phase: "requirementCheck",
|
|
485
|
+
kind: "UnavailableTools",
|
|
486
|
+
message: `Strict mode: the following tools are unavailable: ${missingTools}`,
|
|
487
|
+
level: "error"
|
|
488
|
+
}
|
|
489
|
+
], []);
|
|
490
|
+
}
|
|
491
|
+
const globalExclude = codacyConfig?.exclude || [];
|
|
492
|
+
let allFiles = listRepoFiles(options.repositoryRoot);
|
|
493
|
+
logger.debug("File discovery", { totalFiles: allFiles.length });
|
|
494
|
+
if (options.files && options.files.length > 0) {
|
|
495
|
+
allFiles = filterByTargetFiles(allFiles, options.files);
|
|
496
|
+
logger.debug("Filtered by target files", { afterFilter: allFiles.length });
|
|
497
|
+
}
|
|
498
|
+
const readyAdapters = adapters2.filter((a) => capability.ready.some((r) => r.toolId === a.id));
|
|
499
|
+
const toolRuns = [];
|
|
500
|
+
for (const adapter of readyAdapters) {
|
|
501
|
+
const toolConfig = getToolConfig(codacyConfig, adapter.id);
|
|
502
|
+
if (codacyConfig && !toolConfig) continue;
|
|
503
|
+
const toolExclude = toolConfig?.exclude || [];
|
|
504
|
+
const filesAfterExclusion = applyExclusions(allFiles, globalExclude, toolExclude);
|
|
505
|
+
const toolFiles = routeFilesToTool(filesAfterExclusion, adapter, toolConfig);
|
|
506
|
+
const readyEntryForFiles = capability.ready.find((r) => r.toolId === adapter.id);
|
|
507
|
+
if (readyEntryForFiles) {
|
|
508
|
+
readyEntryForFiles.filesRouted = toolFiles.length;
|
|
509
|
+
}
|
|
510
|
+
if (toolFiles.length === 0) {
|
|
511
|
+
logger.debug("No files routed, skipping", { toolId: adapter.id });
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
514
|
+
logger.debug("Files routed to tool", { toolId: adapter.id, fileCount: toolFiles.length });
|
|
515
|
+
const ctx = makeToolContext(baseCtx, adapter, toolFiles);
|
|
516
|
+
const configCheck = await adapter.checkLocalConfigurationFile(ctx);
|
|
517
|
+
const codacyToolConfig = buildToolConfig(codacyConfig, adapter, configCheck);
|
|
518
|
+
logger.debug("Tool config resolved", { toolId: adapter.id, configSource: codacyToolConfig.useLocalConfigurationFile ? "local" : "codacy", patternCount: codacyToolConfig.patterns?.length ?? 0 });
|
|
519
|
+
const readyEntry = capability.ready.find((r) => r.toolId === adapter.id);
|
|
520
|
+
if (readyEntry) {
|
|
521
|
+
if (configCheck.found && codacyToolConfig.useLocalConfigurationFile) {
|
|
522
|
+
readyEntry.configSource = "local";
|
|
523
|
+
readyEntry.configPath = configCheck.path;
|
|
524
|
+
} else {
|
|
525
|
+
readyEntry.configSource = "codacy";
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
toolRuns.push({ adapter, ctx, codacyToolConfig });
|
|
529
|
+
}
|
|
530
|
+
logger.info("Starting tool execution", { toolCount: toolRuns.length, parallel: parallelTools > 1, parallelTools });
|
|
531
|
+
const callbacks = {
|
|
532
|
+
onToolStart: options.onToolStart,
|
|
533
|
+
onToolComplete: options.onToolComplete
|
|
534
|
+
};
|
|
535
|
+
let results;
|
|
536
|
+
if (parallelTools > 1 && toolRuns.length > 1) {
|
|
537
|
+
results = await runToolsParallel(toolRuns, toolTimeout, parallelTools, callbacks);
|
|
538
|
+
} else {
|
|
539
|
+
results = await runToolsSequential(toolRuns, toolTimeout, callbacks);
|
|
540
|
+
}
|
|
541
|
+
const allIssues = normalizeIssues(results.flatMap((r) => r.issues));
|
|
542
|
+
const allErrors = results.flatMap((r) => r.errors);
|
|
543
|
+
const allSummaries = results.map((r) => r.summary);
|
|
544
|
+
logger.info("Pipeline complete", { totalIssues: allIssues.length, totalErrors: allErrors.length, durationMs: Date.now() - startedAt.getTime() });
|
|
545
|
+
return buildResult(startedAt, options.repositoryRoot, mode, capability, allIssues, allErrors, allSummaries);
|
|
546
|
+
}
|
|
547
|
+
function makeToolContext(base, adapter, targetFiles) {
|
|
548
|
+
return {
|
|
549
|
+
...base,
|
|
550
|
+
targetFiles,
|
|
551
|
+
toolInstallDir: import_path3.default.join(base.globalDir, "tools", adapter.id),
|
|
552
|
+
generatedConfigDir: import_path3.default.join(base.repositoryRoot, ".codacy", "generated", adapter.id)
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
function normalizeIssues(issues) {
|
|
556
|
+
return issues.map((issue) => {
|
|
557
|
+
if (issue.endLine !== void 0 && issue.endLine === issue.line) {
|
|
558
|
+
const { endLine: _, ...rest } = issue;
|
|
559
|
+
return rest;
|
|
560
|
+
}
|
|
561
|
+
return issue;
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
function buildResult(startedAt, repositoryRoot, mode, capability, issues, errors, toolResults) {
|
|
565
|
+
const completedAt = /* @__PURE__ */ new Date();
|
|
566
|
+
return {
|
|
567
|
+
metadata: {
|
|
568
|
+
startedAt: startedAt.toISOString(),
|
|
569
|
+
completedAt: completedAt.toISOString(),
|
|
570
|
+
durationMs: completedAt.getTime() - startedAt.getTime(),
|
|
571
|
+
repositoryRoot,
|
|
572
|
+
executionMode: mode
|
|
573
|
+
},
|
|
574
|
+
capability,
|
|
575
|
+
issues,
|
|
576
|
+
errors,
|
|
577
|
+
toolResults
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// src/format.ts
|
|
582
|
+
var import_path4 = __toESM(require("path"));
|
|
583
|
+
var import_ansis = __toESM(require("ansis"));
|
|
584
|
+
var import_cli_table3 = __toESM(require("cli-table3"));
|
|
585
|
+
function formatOutput(result, format) {
|
|
586
|
+
switch (format) {
|
|
587
|
+
case "json":
|
|
588
|
+
return formatJson(result);
|
|
589
|
+
case "sarif":
|
|
590
|
+
return formatSarif(result);
|
|
591
|
+
case "container":
|
|
592
|
+
return formatContainer(result);
|
|
593
|
+
case "text":
|
|
594
|
+
return formatText(result);
|
|
595
|
+
default:
|
|
596
|
+
return formatJson(result);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
function formatJson(result) {
|
|
600
|
+
return JSON.stringify(result, null, 2);
|
|
601
|
+
}
|
|
602
|
+
function formatSarif(result) {
|
|
603
|
+
const issuesByTool = /* @__PURE__ */ new Map();
|
|
604
|
+
for (const issue of result.issues) {
|
|
605
|
+
const existing = issuesByTool.get(issue.toolId) || [];
|
|
606
|
+
existing.push(issue);
|
|
607
|
+
issuesByTool.set(issue.toolId, existing);
|
|
608
|
+
}
|
|
609
|
+
const runs = [];
|
|
610
|
+
for (const [toolId, issues] of issuesByTool) {
|
|
611
|
+
const toolResult = result.toolResults.find((t) => t.toolId === toolId);
|
|
612
|
+
const ruleMap = /* @__PURE__ */ new Map();
|
|
613
|
+
for (const issue of issues) {
|
|
614
|
+
if (!ruleMap.has(issue.patternId)) {
|
|
615
|
+
ruleMap.set(issue.patternId, {
|
|
616
|
+
id: issue.patternId,
|
|
617
|
+
shortDescription: issue.message,
|
|
618
|
+
severity: mapSeverityToSarif(issue.severity)
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
const rules = Array.from(ruleMap.values()).map((rule) => ({
|
|
623
|
+
id: rule.id,
|
|
624
|
+
shortDescription: { text: rule.shortDescription },
|
|
625
|
+
defaultConfiguration: { level: rule.severity }
|
|
626
|
+
}));
|
|
627
|
+
const ruleIndex = /* @__PURE__ */ new Map();
|
|
628
|
+
rules.forEach((r, i) => ruleIndex.set(r.id, i));
|
|
629
|
+
const results = issues.map((issue) => ({
|
|
630
|
+
ruleId: issue.patternId,
|
|
631
|
+
ruleIndex: ruleIndex.get(issue.patternId) ?? 0,
|
|
632
|
+
level: mapSeverityToSarif(issue.severity),
|
|
633
|
+
message: { text: issue.message },
|
|
634
|
+
locations: [
|
|
635
|
+
{
|
|
636
|
+
physicalLocation: {
|
|
637
|
+
artifactLocation: { uri: issue.filePath, uriBaseId: "%SRCROOT%" },
|
|
638
|
+
region: {
|
|
639
|
+
startLine: issue.line,
|
|
640
|
+
startColumn: issue.column,
|
|
641
|
+
...issue.endLine ? { endLine: issue.endLine } : {},
|
|
642
|
+
...issue.endColumn ? { endColumn: issue.endColumn } : {}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
]
|
|
647
|
+
}));
|
|
648
|
+
runs.push({
|
|
649
|
+
tool: {
|
|
650
|
+
driver: {
|
|
651
|
+
name: toolId,
|
|
652
|
+
version: toolResult?.toolId ? "0.0.1" : "0.0.1",
|
|
653
|
+
rules
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
results
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
if (runs.length === 0) {
|
|
660
|
+
runs.push({
|
|
661
|
+
tool: {
|
|
662
|
+
driver: {
|
|
663
|
+
name: "codacy-analysis",
|
|
664
|
+
version: "0.0.1",
|
|
665
|
+
rules: []
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
results: []
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
const sarif = {
|
|
672
|
+
$schema: "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
|
|
673
|
+
version: "2.1.0",
|
|
674
|
+
runs
|
|
675
|
+
};
|
|
676
|
+
return JSON.stringify(sarif, null, 2);
|
|
677
|
+
}
|
|
678
|
+
function mapSeverityToSarif(severity) {
|
|
679
|
+
switch (severity) {
|
|
680
|
+
case "Error":
|
|
681
|
+
return "error";
|
|
682
|
+
case "High":
|
|
683
|
+
case "Warning":
|
|
684
|
+
return "warning";
|
|
685
|
+
case "Info":
|
|
686
|
+
return "note";
|
|
687
|
+
default:
|
|
688
|
+
return "warning";
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
function formatContainer(result) {
|
|
692
|
+
return result.issues.map(
|
|
693
|
+
(issue) => JSON.stringify({
|
|
694
|
+
filename: issue.filePath,
|
|
695
|
+
patternId: issue.patternId,
|
|
696
|
+
line: issue.line,
|
|
697
|
+
message: issue.message,
|
|
698
|
+
suggestion: issue.suggestion
|
|
699
|
+
})
|
|
700
|
+
).join("\n");
|
|
701
|
+
}
|
|
702
|
+
function formatText(result) {
|
|
703
|
+
const lines = [];
|
|
704
|
+
const isInspect = result.metadata.executionMode === "inspect";
|
|
705
|
+
if (result.issues.length > 0) {
|
|
706
|
+
const byFile = /* @__PURE__ */ new Map();
|
|
707
|
+
for (const issue of result.issues) {
|
|
708
|
+
const existing = byFile.get(issue.filePath) || [];
|
|
709
|
+
existing.push(issue);
|
|
710
|
+
byFile.set(issue.filePath, existing);
|
|
711
|
+
}
|
|
712
|
+
for (const [filePath, issues] of byFile) {
|
|
713
|
+
lines.push("");
|
|
714
|
+
lines.push(import_ansis.default.bold.white(filePath));
|
|
715
|
+
for (const issue of issues) {
|
|
716
|
+
if (issue.multilineContent && issue.multilineContent.length > 1) {
|
|
717
|
+
formatMultilineIssue(lines, issue);
|
|
718
|
+
} else {
|
|
719
|
+
const truncated = truncateLine(issue.lineContent, MAX_LINE_LENGTH);
|
|
720
|
+
const endCol = issue.endLine === void 0 ? issue.endColumn : void 0;
|
|
721
|
+
const clampedEndCol = endCol !== void 0 ? Math.min(endCol, truncated.length + 1) : void 0;
|
|
722
|
+
const lineContent = highlightSpan(truncated, issue.column, clampedEndCol);
|
|
723
|
+
lines.push(` ${import_ansis.default.gray(String(issue.line))} | ${lineContent}`);
|
|
724
|
+
}
|
|
725
|
+
const sev = colorSeverity(issue.severity);
|
|
726
|
+
lines.push(` \u21B3 ${sev} | ${issue.category} | ${import_ansis.default.dim(issue.patternId)}`);
|
|
727
|
+
const message = issue.message.replace(/\n/g, " ").replace(/\s+/g, " ").trim();
|
|
728
|
+
lines.push(` ${message}`);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
lines.push("");
|
|
732
|
+
}
|
|
733
|
+
if (result.errors.length > 0) {
|
|
734
|
+
lines.push("");
|
|
735
|
+
lines.push("Errors:");
|
|
736
|
+
for (const error of result.errors) {
|
|
737
|
+
const prefix = `[${error.toolId}/${error.phase}]`;
|
|
738
|
+
const location = error.filePath ? ` ${error.filePath}:` : "";
|
|
739
|
+
lines.push(import_ansis.default.red(` ${prefix}${location} ${error.message}`));
|
|
740
|
+
}
|
|
741
|
+
lines.push("");
|
|
742
|
+
}
|
|
743
|
+
lines.push(formatTextSummary(result, isInspect));
|
|
744
|
+
return lines.join("\n");
|
|
745
|
+
}
|
|
746
|
+
function formatTextSummary(result, isInspect) {
|
|
747
|
+
const lines = [];
|
|
748
|
+
const inspect = isInspect ?? result.metadata.executionMode === "inspect";
|
|
749
|
+
const totalIssues = result.issues.length;
|
|
750
|
+
const totalErrors = result.errors.length;
|
|
751
|
+
const toolCount = result.toolResults.length;
|
|
752
|
+
const duration = result.metadata.durationMs;
|
|
753
|
+
if (inspect) {
|
|
754
|
+
const totalTools = result.capability.ready.length + result.capability.unavailable.length;
|
|
755
|
+
lines.push(
|
|
756
|
+
import_ansis.default.bold(`Inspection complete: ${totalTools} tool${totalTools !== 1 ? "s" : ""} found`)
|
|
757
|
+
);
|
|
758
|
+
} else {
|
|
759
|
+
const headerLine = `Analysis complete: ${totalIssues} issue${totalIssues !== 1 ? "s" : ""} found`;
|
|
760
|
+
lines.push(totalIssues > 0 ? import_ansis.default.bold.red(headerLine) : import_ansis.default.bold(headerLine));
|
|
761
|
+
lines.push(`${toolCount} tool${toolCount !== 1 ? "s" : ""} ran in ${duration}ms`);
|
|
762
|
+
}
|
|
763
|
+
if (totalErrors > 0) {
|
|
764
|
+
lines.push(import_ansis.default.red(`${totalErrors} error${totalErrors !== 1 ? "s" : ""} occurred`));
|
|
765
|
+
}
|
|
766
|
+
lines.push("");
|
|
767
|
+
const sortByName = (a, b) => (a.displayName ?? a.toolId).localeCompare(b.displayName ?? b.toolId);
|
|
768
|
+
const readyTools = [...result.capability.ready].sort(sortByName);
|
|
769
|
+
const unavailableTools = [...result.capability.unavailable].sort(sortByName);
|
|
770
|
+
const hasTools = readyTools.length > 0 || unavailableTools.length > 0;
|
|
771
|
+
if (hasTools) {
|
|
772
|
+
if (inspect) {
|
|
773
|
+
const table = new import_cli_table3.default({
|
|
774
|
+
head: ["Tool", "Version", "Install", "Configuration", "Files", "Prerequisites"],
|
|
775
|
+
style: { head: ["bold", "white"] }
|
|
776
|
+
});
|
|
777
|
+
for (const tool of readyTools) {
|
|
778
|
+
let prereqCell;
|
|
779
|
+
if (tool.dependencies && tool.dependencies.length > 0) {
|
|
780
|
+
prereqCell = tool.dependencies.map((d) => `${d.name} ${d.version} \u2713`).join(", ");
|
|
781
|
+
} else {
|
|
782
|
+
prereqCell = "-";
|
|
783
|
+
}
|
|
784
|
+
const filesCell = formatFilesCell(tool.filesRouted);
|
|
785
|
+
table.push([
|
|
786
|
+
import_ansis.default.cyan(tool.displayName ?? tool.toolId),
|
|
787
|
+
tool.version,
|
|
788
|
+
tool.installation,
|
|
789
|
+
formatConfigCell(tool, result.metadata.repositoryRoot),
|
|
790
|
+
filesCell,
|
|
791
|
+
prereqCell
|
|
792
|
+
]);
|
|
793
|
+
}
|
|
794
|
+
for (const tool of unavailableTools) {
|
|
795
|
+
table.push([import_ansis.default.dim.red(tool.displayName ?? tool.toolId), "-", "-", "-", "-", tool.reason]);
|
|
796
|
+
}
|
|
797
|
+
lines.push(table.toString());
|
|
798
|
+
} else {
|
|
799
|
+
const table = new import_cli_table3.default({
|
|
800
|
+
head: ["Tool", "Version", "Install", "Configuration", "Files", "Issues", "Duration"],
|
|
801
|
+
style: { head: ["bold", "white"] }
|
|
802
|
+
});
|
|
803
|
+
for (const tool of readyTools) {
|
|
804
|
+
const summary = result.toolResults.find((t) => t.toolId === tool.toolId);
|
|
805
|
+
const issueCount = summary?.issueCount ?? 0;
|
|
806
|
+
const durationMs = summary?.durationMs ?? 0;
|
|
807
|
+
const filesCell = formatFilesCell(tool.filesRouted);
|
|
808
|
+
table.push([
|
|
809
|
+
import_ansis.default.cyan(tool.displayName ?? tool.toolId),
|
|
810
|
+
tool.version,
|
|
811
|
+
tool.installation,
|
|
812
|
+
formatConfigCell(tool, result.metadata.repositoryRoot),
|
|
813
|
+
filesCell,
|
|
814
|
+
issueCount > 0 ? import_ansis.default.bold.red(String(issueCount)) : String(issueCount),
|
|
815
|
+
`${durationMs}ms`
|
|
816
|
+
]);
|
|
817
|
+
}
|
|
818
|
+
for (const tool of unavailableTools) {
|
|
819
|
+
table.push([
|
|
820
|
+
import_ansis.default.dim.red(tool.displayName ?? tool.toolId),
|
|
821
|
+
"-",
|
|
822
|
+
"-",
|
|
823
|
+
"-",
|
|
824
|
+
"-",
|
|
825
|
+
import_ansis.default.dim("missing binary"),
|
|
826
|
+
"-"
|
|
827
|
+
]);
|
|
828
|
+
}
|
|
829
|
+
lines.push(table.toString());
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
const toolsWithHints = result.capability.unavailable.filter((t) => t.remediation);
|
|
833
|
+
if (toolsWithHints.length > 0) {
|
|
834
|
+
lines.push("");
|
|
835
|
+
lines.push(import_ansis.default.bold("To install missing tools:"));
|
|
836
|
+
for (const tool of toolsWithHints) {
|
|
837
|
+
lines.push(import_ansis.default.cyan(` ${tool.displayName ?? tool.toolId}:`));
|
|
838
|
+
for (const line of tool.remediation.split("\n")) {
|
|
839
|
+
lines.push(` ${line}`);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
return lines.join("\n");
|
|
844
|
+
}
|
|
845
|
+
var MAX_LINE_LENGTH = 100;
|
|
846
|
+
var MAX_MULTILINE_DISPLAY = 10;
|
|
847
|
+
function formatMultilineIssue(output, issue) {
|
|
848
|
+
const contentLines = issue.multilineContent;
|
|
849
|
+
const startLine = issue.line;
|
|
850
|
+
const totalLines = contentLines.length;
|
|
851
|
+
let displayLines;
|
|
852
|
+
let collapsedCount = 0;
|
|
853
|
+
if (totalLines > MAX_MULTILINE_DISPLAY) {
|
|
854
|
+
const headCount = 8;
|
|
855
|
+
const tailCount = 2;
|
|
856
|
+
collapsedCount = totalLines - headCount - tailCount;
|
|
857
|
+
displayLines = [
|
|
858
|
+
...contentLines.slice(0, headCount).map((c, i) => ({ lineNum: startLine + i, content: c, index: i })),
|
|
859
|
+
...contentLines.slice(totalLines - tailCount).map((c, i) => ({
|
|
860
|
+
lineNum: startLine + totalLines - tailCount + i,
|
|
861
|
+
content: c,
|
|
862
|
+
index: totalLines - tailCount + i
|
|
863
|
+
}))
|
|
864
|
+
];
|
|
865
|
+
} else {
|
|
866
|
+
displayLines = contentLines.map((c, i) => ({ lineNum: startLine + i, content: c, index: i }));
|
|
867
|
+
}
|
|
868
|
+
for (const { lineNum, content, index } of displayLines) {
|
|
869
|
+
const truncated = truncateLine(content, MAX_LINE_LENGTH);
|
|
870
|
+
let formatted;
|
|
871
|
+
if (index === 0) {
|
|
872
|
+
formatted = highlightSpan(truncated, issue.column);
|
|
873
|
+
} else if (index === totalLines - 1) {
|
|
874
|
+
const clampedEnd = issue.endColumn !== void 0 ? Math.min(issue.endColumn, truncated.length + 1) : void 0;
|
|
875
|
+
formatted = highlightSpan(truncated, 1, clampedEnd);
|
|
876
|
+
} else {
|
|
877
|
+
formatted = import_ansis.default.bold(truncated);
|
|
878
|
+
}
|
|
879
|
+
output.push(` ${import_ansis.default.gray(String(lineNum))} | ${formatted}`);
|
|
880
|
+
if (collapsedCount > 0 && index === 7) {
|
|
881
|
+
output.push(` ${import_ansis.default.gray("...")} | ${import_ansis.default.dim(`${collapsedCount} more lines`)}`);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
function formatFilesCell(filesRouted) {
|
|
886
|
+
if (filesRouted === void 0) return "-";
|
|
887
|
+
if (filesRouted === 0) return import_ansis.default.dim("0");
|
|
888
|
+
return String(filesRouted);
|
|
889
|
+
}
|
|
890
|
+
function formatConfigCell(tool, repositoryRoot) {
|
|
891
|
+
if (tool.configSource === "local" && tool.configPath) {
|
|
892
|
+
const rawPath = import_path4.default.isAbsolute(tool.configPath) ? import_path4.default.relative(repositoryRoot, tool.configPath) : tool.configPath;
|
|
893
|
+
return rawPath.startsWith("./") ? rawPath : `./${rawPath}`;
|
|
894
|
+
}
|
|
895
|
+
if (tool.configSource === "codacy") return "Codacy";
|
|
896
|
+
return "-";
|
|
897
|
+
}
|
|
898
|
+
function truncateLine(line, maxLen) {
|
|
899
|
+
if (line.length <= maxLen) return line;
|
|
900
|
+
return line.slice(0, maxLen) + "...";
|
|
901
|
+
}
|
|
902
|
+
function highlightSpan(lineContent, column, endColumn) {
|
|
903
|
+
if (!lineContent || column < 1) return lineContent;
|
|
904
|
+
const start = column - 1;
|
|
905
|
+
const end = endColumn ? endColumn - 1 : lineContent.length;
|
|
906
|
+
const before = lineContent.slice(0, start);
|
|
907
|
+
const span = lineContent.slice(start, end);
|
|
908
|
+
const after = lineContent.slice(end);
|
|
909
|
+
return `${before}${import_ansis.default.bold(span)}${after}`;
|
|
910
|
+
}
|
|
911
|
+
function colorSeverity(severity) {
|
|
912
|
+
switch (severity) {
|
|
913
|
+
case "Error":
|
|
914
|
+
return import_ansis.default.hex("#ff6347")(`[${severity}]`);
|
|
915
|
+
case "High":
|
|
916
|
+
return import_ansis.default.hex("#ff8c00")(`[${severity}]`);
|
|
917
|
+
case "Warning":
|
|
918
|
+
return import_ansis.default.hex("#ffd700")(`[${severity}]`);
|
|
919
|
+
case "Info":
|
|
920
|
+
return import_ansis.default.cyan(`[${severity}]`);
|
|
921
|
+
default:
|
|
922
|
+
return `[${severity}]`;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// src/init.ts
|
|
927
|
+
var import_promises3 = __toESM(require("fs/promises"));
|
|
928
|
+
var import_path6 = __toESM(require("path"));
|
|
929
|
+
var import_child_process2 = require("child_process");
|
|
930
|
+
var import_tooling = require("@codacy/tooling");
|
|
931
|
+
|
|
932
|
+
// src/codacy-yaml.ts
|
|
933
|
+
var import_promises2 = __toESM(require("fs/promises"));
|
|
934
|
+
var import_path5 = __toESM(require("path"));
|
|
935
|
+
var import_yaml = require("yaml");
|
|
936
|
+
async function readCodacyYaml(repositoryRoot) {
|
|
937
|
+
const candidates = [".codacy.yaml", ".codacy.yml"];
|
|
938
|
+
let raw = null;
|
|
939
|
+
for (const filename of candidates) {
|
|
940
|
+
try {
|
|
941
|
+
raw = await import_promises2.default.readFile(import_path5.default.join(repositoryRoot, filename), "utf-8");
|
|
942
|
+
break;
|
|
943
|
+
} catch {
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
if (raw === null) return null;
|
|
947
|
+
const parsed = (0, import_yaml.parse)(raw);
|
|
948
|
+
if (parsed == null || typeof parsed !== "object") return null;
|
|
949
|
+
return extractCodacyYamlConfig(parsed);
|
|
950
|
+
}
|
|
951
|
+
function extractCodacyYamlConfig(raw) {
|
|
952
|
+
const excludePaths = extractStringArray(raw["exclude_paths"]);
|
|
953
|
+
const includePaths = extractStringArray(raw["include_paths"]);
|
|
954
|
+
const engines = /* @__PURE__ */ new Map();
|
|
955
|
+
const rawEngines = raw["engines"];
|
|
956
|
+
if (rawEngines != null && typeof rawEngines === "object" && !Array.isArray(rawEngines)) {
|
|
957
|
+
for (const [engineName, engineValue] of Object.entries(rawEngines)) {
|
|
958
|
+
if (engineValue != null && typeof engineValue === "object" && !Array.isArray(engineValue)) {
|
|
959
|
+
const eng = engineValue;
|
|
960
|
+
engines.set(engineName, {
|
|
961
|
+
excludePaths: extractStringArray(eng["exclude_paths"]),
|
|
962
|
+
includePaths: extractStringArray(eng["include_paths"])
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
return { excludePaths, includePaths, engines };
|
|
968
|
+
}
|
|
969
|
+
function extractStringArray(value) {
|
|
970
|
+
if (!Array.isArray(value)) return [];
|
|
971
|
+
return value.filter((v) => typeof v === "string");
|
|
972
|
+
}
|
|
973
|
+
function resolveEngineToAdapter(engineName, adapters2) {
|
|
974
|
+
const exact = adapters2.find((a) => a.id === engineName);
|
|
975
|
+
if (exact) return exact.id;
|
|
976
|
+
const needle = engineName.toLowerCase();
|
|
977
|
+
const matches = adapters2.filter((a) => {
|
|
978
|
+
return a.id.toLowerCase().includes(needle) || a.displayName.toLowerCase().includes(needle);
|
|
979
|
+
});
|
|
980
|
+
return matches.length === 1 ? matches[0].id : void 0;
|
|
981
|
+
}
|
|
982
|
+
function applyCodacyYamlExcludes(config, yamlConfig, adapters2, logger) {
|
|
983
|
+
const hasGlobalIncludes = yamlConfig.includePaths.length > 0;
|
|
984
|
+
const hasEngineIncludes = Array.from(yamlConfig.engines.values()).some(
|
|
985
|
+
(e) => e.includePaths.length > 0
|
|
986
|
+
);
|
|
987
|
+
if (hasGlobalIncludes || hasEngineIncludes) {
|
|
988
|
+
logger?.warn("include_paths in .codacy.yaml is not yet supported and will be ignored");
|
|
989
|
+
}
|
|
990
|
+
const globalExclude = deduplicateStrings([...config.exclude ?? [], ...yamlConfig.excludePaths]);
|
|
991
|
+
const tools = config.tools.map((tool) => ({ ...tool }));
|
|
992
|
+
for (const [engineName, engineConfig] of yamlConfig.engines) {
|
|
993
|
+
if (engineConfig.excludePaths.length === 0) continue;
|
|
994
|
+
const adapterId = resolveEngineToAdapter(engineName, adapters2);
|
|
995
|
+
if (!adapterId) {
|
|
996
|
+
logger?.warn(`Could not resolve .codacy.yaml engine "${engineName}" to a registered adapter`);
|
|
997
|
+
continue;
|
|
998
|
+
}
|
|
999
|
+
const toolEntry = tools.find((t) => t.toolId === adapterId);
|
|
1000
|
+
if (!toolEntry) {
|
|
1001
|
+
continue;
|
|
1002
|
+
}
|
|
1003
|
+
toolEntry.exclude = deduplicateStrings([
|
|
1004
|
+
...toolEntry.exclude ?? [],
|
|
1005
|
+
...engineConfig.excludePaths
|
|
1006
|
+
]);
|
|
1007
|
+
}
|
|
1008
|
+
return {
|
|
1009
|
+
...config,
|
|
1010
|
+
exclude: globalExclude,
|
|
1011
|
+
tools
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
function deduplicateStrings(arr) {
|
|
1015
|
+
return [...new Set(arr)];
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
// src/api/client/core/OpenAPI.ts
|
|
1019
|
+
var OpenAPI = {
|
|
1020
|
+
BASE: "https://app.codacy.com/api/v3",
|
|
1021
|
+
VERSION: "3.1.0",
|
|
1022
|
+
WITH_CREDENTIALS: false,
|
|
1023
|
+
CREDENTIALS: "include",
|
|
1024
|
+
TOKEN: void 0,
|
|
1025
|
+
USERNAME: void 0,
|
|
1026
|
+
PASSWORD: void 0,
|
|
1027
|
+
HEADERS: void 0,
|
|
1028
|
+
ENCODE_PATH: void 0
|
|
1029
|
+
};
|
|
1030
|
+
|
|
1031
|
+
// src/api/client/core/ApiError.ts
|
|
1032
|
+
var ApiError = class extends Error {
|
|
1033
|
+
url;
|
|
1034
|
+
status;
|
|
1035
|
+
statusText;
|
|
1036
|
+
body;
|
|
1037
|
+
request;
|
|
1038
|
+
constructor(request2, response, message) {
|
|
1039
|
+
super(message);
|
|
1040
|
+
this.name = "ApiError";
|
|
1041
|
+
this.url = response.url;
|
|
1042
|
+
this.status = response.status;
|
|
1043
|
+
this.statusText = response.statusText;
|
|
1044
|
+
this.body = response.body;
|
|
1045
|
+
this.request = request2;
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
|
|
1049
|
+
// src/api/client/core/CancelablePromise.ts
|
|
1050
|
+
var CancelError = class extends Error {
|
|
1051
|
+
constructor(message) {
|
|
1052
|
+
super(message);
|
|
1053
|
+
this.name = "CancelError";
|
|
1054
|
+
}
|
|
1055
|
+
get isCancelled() {
|
|
1056
|
+
return true;
|
|
1057
|
+
}
|
|
1058
|
+
};
|
|
1059
|
+
var CancelablePromise = class {
|
|
1060
|
+
#isResolved;
|
|
1061
|
+
#isRejected;
|
|
1062
|
+
#isCancelled;
|
|
1063
|
+
#cancelHandlers;
|
|
1064
|
+
#promise;
|
|
1065
|
+
#resolve;
|
|
1066
|
+
#reject;
|
|
1067
|
+
constructor(executor) {
|
|
1068
|
+
this.#isResolved = false;
|
|
1069
|
+
this.#isRejected = false;
|
|
1070
|
+
this.#isCancelled = false;
|
|
1071
|
+
this.#cancelHandlers = [];
|
|
1072
|
+
this.#promise = new Promise((resolve2, reject) => {
|
|
1073
|
+
this.#resolve = resolve2;
|
|
1074
|
+
this.#reject = reject;
|
|
1075
|
+
const onResolve = (value) => {
|
|
1076
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
this.#isResolved = true;
|
|
1080
|
+
if (this.#resolve) this.#resolve(value);
|
|
1081
|
+
};
|
|
1082
|
+
const onReject = (reason) => {
|
|
1083
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
this.#isRejected = true;
|
|
1087
|
+
if (this.#reject) this.#reject(reason);
|
|
1088
|
+
};
|
|
1089
|
+
const onCancel = (cancelHandler) => {
|
|
1090
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
this.#cancelHandlers.push(cancelHandler);
|
|
1094
|
+
};
|
|
1095
|
+
Object.defineProperty(onCancel, "isResolved", {
|
|
1096
|
+
get: () => this.#isResolved
|
|
1097
|
+
});
|
|
1098
|
+
Object.defineProperty(onCancel, "isRejected", {
|
|
1099
|
+
get: () => this.#isRejected
|
|
1100
|
+
});
|
|
1101
|
+
Object.defineProperty(onCancel, "isCancelled", {
|
|
1102
|
+
get: () => this.#isCancelled
|
|
1103
|
+
});
|
|
1104
|
+
return executor(onResolve, onReject, onCancel);
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
get [Symbol.toStringTag]() {
|
|
1108
|
+
return "Cancellable Promise";
|
|
1109
|
+
}
|
|
1110
|
+
then(onFulfilled, onRejected) {
|
|
1111
|
+
return this.#promise.then(onFulfilled, onRejected);
|
|
1112
|
+
}
|
|
1113
|
+
catch(onRejected) {
|
|
1114
|
+
return this.#promise.catch(onRejected);
|
|
1115
|
+
}
|
|
1116
|
+
finally(onFinally) {
|
|
1117
|
+
return this.#promise.finally(onFinally);
|
|
1118
|
+
}
|
|
1119
|
+
cancel() {
|
|
1120
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
this.#isCancelled = true;
|
|
1124
|
+
if (this.#cancelHandlers.length) {
|
|
1125
|
+
try {
|
|
1126
|
+
for (const cancelHandler of this.#cancelHandlers) {
|
|
1127
|
+
cancelHandler();
|
|
1128
|
+
}
|
|
1129
|
+
} catch (error) {
|
|
1130
|
+
console.warn("Cancellation threw an error", error);
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
this.#cancelHandlers.length = 0;
|
|
1135
|
+
if (this.#reject) this.#reject(new CancelError("Request aborted"));
|
|
1136
|
+
}
|
|
1137
|
+
get isCancelled() {
|
|
1138
|
+
return this.#isCancelled;
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
|
|
1142
|
+
// src/api/client/core/request.ts
|
|
1143
|
+
var isDefined = (value) => {
|
|
1144
|
+
return value !== void 0 && value !== null;
|
|
1145
|
+
};
|
|
1146
|
+
var isString = (value) => {
|
|
1147
|
+
return typeof value === "string";
|
|
1148
|
+
};
|
|
1149
|
+
var isStringWithValue = (value) => {
|
|
1150
|
+
return isString(value) && value !== "";
|
|
1151
|
+
};
|
|
1152
|
+
var isBlob = (value) => {
|
|
1153
|
+
return typeof value === "object" && typeof value.type === "string" && typeof value.stream === "function" && typeof value.arrayBuffer === "function" && typeof value.constructor === "function" && typeof value.constructor.name === "string" && /^(Blob|File)$/.test(value.constructor.name) && /^(Blob|File)$/.test(value[Symbol.toStringTag]);
|
|
1154
|
+
};
|
|
1155
|
+
var isFormData = (value) => {
|
|
1156
|
+
try {
|
|
1157
|
+
return value instanceof FormData;
|
|
1158
|
+
} catch (e) {
|
|
1159
|
+
return false;
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
var base64 = (str) => {
|
|
1163
|
+
try {
|
|
1164
|
+
return btoa(str);
|
|
1165
|
+
} catch (err) {
|
|
1166
|
+
return Buffer.from(str).toString("base64");
|
|
1167
|
+
}
|
|
1168
|
+
};
|
|
1169
|
+
var getQueryString = (params) => {
|
|
1170
|
+
const qs = [];
|
|
1171
|
+
const append = (key, value) => {
|
|
1172
|
+
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
1173
|
+
};
|
|
1174
|
+
const process2 = (key, value) => {
|
|
1175
|
+
if (isDefined(value)) {
|
|
1176
|
+
if (Array.isArray(value)) {
|
|
1177
|
+
value.forEach((v) => {
|
|
1178
|
+
process2(key, v);
|
|
1179
|
+
});
|
|
1180
|
+
} else if (typeof value === "object") {
|
|
1181
|
+
Object.entries(value).forEach(([k, v]) => {
|
|
1182
|
+
process2(`${key}[${k}]`, v);
|
|
1183
|
+
});
|
|
1184
|
+
} else {
|
|
1185
|
+
append(key, value);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
1190
|
+
process2(key, value);
|
|
1191
|
+
});
|
|
1192
|
+
if (qs.length > 0) {
|
|
1193
|
+
return `?${qs.join("&")}`;
|
|
1194
|
+
}
|
|
1195
|
+
return "";
|
|
1196
|
+
};
|
|
1197
|
+
var getUrl = (config, options) => {
|
|
1198
|
+
const encoder = config.ENCODE_PATH || encodeURI;
|
|
1199
|
+
const path8 = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
1200
|
+
if (options.path?.hasOwnProperty(group)) {
|
|
1201
|
+
return encoder(String(options.path[group]));
|
|
1202
|
+
}
|
|
1203
|
+
return substring;
|
|
1204
|
+
});
|
|
1205
|
+
const url = `${config.BASE}${path8}`;
|
|
1206
|
+
if (options.query) {
|
|
1207
|
+
return `${url}${getQueryString(options.query)}`;
|
|
1208
|
+
}
|
|
1209
|
+
return url;
|
|
1210
|
+
};
|
|
1211
|
+
var getFormData = (options) => {
|
|
1212
|
+
if (options.formData) {
|
|
1213
|
+
const formData = new FormData();
|
|
1214
|
+
const process2 = (key, value) => {
|
|
1215
|
+
if (isString(value) || isBlob(value)) {
|
|
1216
|
+
formData.append(key, value);
|
|
1217
|
+
} else {
|
|
1218
|
+
formData.append(key, JSON.stringify(value));
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
Object.entries(options.formData).filter(([_, value]) => isDefined(value)).forEach(([key, value]) => {
|
|
1222
|
+
if (Array.isArray(value)) {
|
|
1223
|
+
value.forEach((v) => process2(key, v));
|
|
1224
|
+
} else {
|
|
1225
|
+
process2(key, value);
|
|
1226
|
+
}
|
|
1227
|
+
});
|
|
1228
|
+
return formData;
|
|
1229
|
+
}
|
|
1230
|
+
return void 0;
|
|
1231
|
+
};
|
|
1232
|
+
var resolve = async (options, resolver) => {
|
|
1233
|
+
if (typeof resolver === "function") {
|
|
1234
|
+
return resolver(options);
|
|
1235
|
+
}
|
|
1236
|
+
return resolver;
|
|
1237
|
+
};
|
|
1238
|
+
var getHeaders = async (config, options) => {
|
|
1239
|
+
const [token, username, password, additionalHeaders] = await Promise.all([
|
|
1240
|
+
resolve(options, config.TOKEN),
|
|
1241
|
+
resolve(options, config.USERNAME),
|
|
1242
|
+
resolve(options, config.PASSWORD),
|
|
1243
|
+
resolve(options, config.HEADERS)
|
|
1244
|
+
]);
|
|
1245
|
+
const headers = Object.entries({
|
|
1246
|
+
Accept: "application/json",
|
|
1247
|
+
...additionalHeaders,
|
|
1248
|
+
...options.headers
|
|
1249
|
+
}).filter(([_, value]) => isDefined(value)).reduce((headers2, [key, value]) => ({
|
|
1250
|
+
...headers2,
|
|
1251
|
+
[key]: String(value)
|
|
1252
|
+
}), {});
|
|
1253
|
+
if (isStringWithValue(token)) {
|
|
1254
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
1255
|
+
}
|
|
1256
|
+
if (isStringWithValue(username) && isStringWithValue(password)) {
|
|
1257
|
+
const credentials = base64(`${username}:${password}`);
|
|
1258
|
+
headers["Authorization"] = `Basic ${credentials}`;
|
|
1259
|
+
}
|
|
1260
|
+
if (options.body) {
|
|
1261
|
+
if (options.mediaType) {
|
|
1262
|
+
headers["Content-Type"] = options.mediaType;
|
|
1263
|
+
} else if (isBlob(options.body)) {
|
|
1264
|
+
headers["Content-Type"] = options.body.type || "application/octet-stream";
|
|
1265
|
+
} else if (isString(options.body)) {
|
|
1266
|
+
headers["Content-Type"] = "text/plain";
|
|
1267
|
+
} else if (!isFormData(options.body)) {
|
|
1268
|
+
headers["Content-Type"] = "application/json";
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
return new Headers(headers);
|
|
1272
|
+
};
|
|
1273
|
+
var getRequestBody = (options) => {
|
|
1274
|
+
if (options.body !== void 0) {
|
|
1275
|
+
if (options.mediaType?.includes("/json")) {
|
|
1276
|
+
return JSON.stringify(options.body);
|
|
1277
|
+
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
|
1278
|
+
return options.body;
|
|
1279
|
+
} else {
|
|
1280
|
+
return JSON.stringify(options.body);
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
return void 0;
|
|
1284
|
+
};
|
|
1285
|
+
var sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
|
|
1286
|
+
const controller = new AbortController();
|
|
1287
|
+
const request2 = {
|
|
1288
|
+
headers,
|
|
1289
|
+
body: body ?? formData,
|
|
1290
|
+
method: options.method,
|
|
1291
|
+
signal: options.abortSignal ?? controller.signal
|
|
1292
|
+
};
|
|
1293
|
+
if (config.WITH_CREDENTIALS) {
|
|
1294
|
+
request2.credentials = config.CREDENTIALS;
|
|
1295
|
+
}
|
|
1296
|
+
onCancel(() => controller.abort());
|
|
1297
|
+
return await fetch(url, request2);
|
|
1298
|
+
};
|
|
1299
|
+
var getResponseHeader = (response, responseHeader) => {
|
|
1300
|
+
if (responseHeader) {
|
|
1301
|
+
const content = response.headers.get(responseHeader);
|
|
1302
|
+
if (isString(content)) {
|
|
1303
|
+
return content;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
return void 0;
|
|
1307
|
+
};
|
|
1308
|
+
var getResponseBody = async (response) => {
|
|
1309
|
+
if (response.status !== 204) {
|
|
1310
|
+
try {
|
|
1311
|
+
const contentType = response.headers.get("Content-Type");
|
|
1312
|
+
if (contentType) {
|
|
1313
|
+
const jsonTypes = ["application/json", "application/problem+json"];
|
|
1314
|
+
const isJSON = jsonTypes.some((type) => contentType.toLowerCase().startsWith(type));
|
|
1315
|
+
if (isJSON) {
|
|
1316
|
+
return await response.json();
|
|
1317
|
+
} else {
|
|
1318
|
+
return await response.text();
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
} catch (error) {
|
|
1322
|
+
console.error(error);
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
return void 0;
|
|
1326
|
+
};
|
|
1327
|
+
var catchErrorCodes = (options, result) => {
|
|
1328
|
+
const errors = {
|
|
1329
|
+
400: "Bad Request",
|
|
1330
|
+
401: "Unauthorized",
|
|
1331
|
+
403: "Forbidden",
|
|
1332
|
+
404: "Not Found",
|
|
1333
|
+
500: "Internal Server Error",
|
|
1334
|
+
502: "Bad Gateway",
|
|
1335
|
+
503: "Service Unavailable",
|
|
1336
|
+
...options.errors
|
|
1337
|
+
};
|
|
1338
|
+
const error = errors[result.status];
|
|
1339
|
+
if (error) {
|
|
1340
|
+
throw new ApiError(options, result, error);
|
|
1341
|
+
}
|
|
1342
|
+
if (!result.ok) {
|
|
1343
|
+
const errorStatus = result.status ?? "unknown";
|
|
1344
|
+
const errorStatusText = result.statusText ?? "unknown";
|
|
1345
|
+
const errorBody = (() => {
|
|
1346
|
+
try {
|
|
1347
|
+
return JSON.stringify(result.body, null, 2);
|
|
1348
|
+
} catch (e) {
|
|
1349
|
+
return void 0;
|
|
1350
|
+
}
|
|
1351
|
+
})();
|
|
1352
|
+
throw new ApiError(
|
|
1353
|
+
options,
|
|
1354
|
+
result,
|
|
1355
|
+
`Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`
|
|
1356
|
+
);
|
|
1357
|
+
}
|
|
1358
|
+
};
|
|
1359
|
+
var request = (config, options) => {
|
|
1360
|
+
return new CancelablePromise(async (resolve2, reject, onCancel) => {
|
|
1361
|
+
try {
|
|
1362
|
+
const url = getUrl(config, options);
|
|
1363
|
+
const formData = getFormData(options);
|
|
1364
|
+
const body = getRequestBody(options);
|
|
1365
|
+
const headers = await getHeaders(config, options);
|
|
1366
|
+
if (!onCancel.isCancelled) {
|
|
1367
|
+
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
|
|
1368
|
+
const responseBody = await getResponseBody(response);
|
|
1369
|
+
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
1370
|
+
const result = {
|
|
1371
|
+
url,
|
|
1372
|
+
ok: response.ok,
|
|
1373
|
+
status: response.status,
|
|
1374
|
+
statusText: response.statusText,
|
|
1375
|
+
body: responseHeader ?? responseBody
|
|
1376
|
+
};
|
|
1377
|
+
catchErrorCodes(options, result);
|
|
1378
|
+
resolve2(result.body);
|
|
1379
|
+
}
|
|
1380
|
+
} catch (error) {
|
|
1381
|
+
reject(error);
|
|
1382
|
+
}
|
|
1383
|
+
});
|
|
1384
|
+
};
|
|
1385
|
+
|
|
1386
|
+
// src/api/client/services/AccountService.ts
|
|
1387
|
+
var AccountService = class {
|
|
1388
|
+
/**
|
|
1389
|
+
* Get the authenticated user
|
|
1390
|
+
* @returns UserResponse Successful operation
|
|
1391
|
+
* @throws ApiError
|
|
1392
|
+
*/
|
|
1393
|
+
static getUser(abortSignal) {
|
|
1394
|
+
return request(OpenAPI, {
|
|
1395
|
+
method: "GET",
|
|
1396
|
+
url: "/user",
|
|
1397
|
+
abortSignal,
|
|
1398
|
+
errors: {
|
|
1399
|
+
401: `Unauthorized`,
|
|
1400
|
+
422: `Unprocessable Entity`,
|
|
1401
|
+
500: `Internal Server Error`
|
|
1402
|
+
}
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Delete the authenticated user
|
|
1407
|
+
* @returns void
|
|
1408
|
+
* @throws ApiError
|
|
1409
|
+
*/
|
|
1410
|
+
static deleteUser(abortSignal) {
|
|
1411
|
+
return request(OpenAPI, {
|
|
1412
|
+
method: "DELETE",
|
|
1413
|
+
url: "/user",
|
|
1414
|
+
abortSignal,
|
|
1415
|
+
errors: {
|
|
1416
|
+
401: `Unauthorized`,
|
|
1417
|
+
404: `Not Found`,
|
|
1418
|
+
409: `Conflict`,
|
|
1419
|
+
422: `Unprocessable Entity`,
|
|
1420
|
+
500: `Internal Server Error`
|
|
1421
|
+
}
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1424
|
+
/**
|
|
1425
|
+
* Update the authenticated user
|
|
1426
|
+
* @param requestBody * @returns UserResponse Successful operation
|
|
1427
|
+
* @throws ApiError
|
|
1428
|
+
*/
|
|
1429
|
+
static patchUser(requestBody, abortSignal) {
|
|
1430
|
+
return request(OpenAPI, {
|
|
1431
|
+
method: "PATCH",
|
|
1432
|
+
url: "/user",
|
|
1433
|
+
abortSignal,
|
|
1434
|
+
body: requestBody,
|
|
1435
|
+
mediaType: "application/json",
|
|
1436
|
+
errors: {
|
|
1437
|
+
400: `Bad Request`,
|
|
1438
|
+
401: `Unauthorized`,
|
|
1439
|
+
404: `Not Found`,
|
|
1440
|
+
422: `Unprocessable Entity`,
|
|
1441
|
+
500: `Internal Server Error`
|
|
1442
|
+
}
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
/**
|
|
1446
|
+
* List organizations for the authenticated user
|
|
1447
|
+
* List organizations for the authenticated user
|
|
1448
|
+
* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns OrganizationListResponse Successful operation
|
|
1449
|
+
* @throws ApiError
|
|
1450
|
+
*/
|
|
1451
|
+
static listUserOrganizations(cursor, limit = 100, abortSignal) {
|
|
1452
|
+
return request(OpenAPI, {
|
|
1453
|
+
method: "GET",
|
|
1454
|
+
url: "/user/organizations",
|
|
1455
|
+
query: {
|
|
1456
|
+
"cursor": cursor,
|
|
1457
|
+
"limit": limit
|
|
1458
|
+
},
|
|
1459
|
+
abortSignal,
|
|
1460
|
+
errors: {
|
|
1461
|
+
400: `Bad Request`,
|
|
1462
|
+
401: `Unauthorized`,
|
|
1463
|
+
422: `Unprocessable Entity`,
|
|
1464
|
+
500: `Internal Server Error`
|
|
1465
|
+
}
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* List organizations for the authenticated user
|
|
1470
|
+
* List organizations for the authenticated user
|
|
1471
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns OrganizationListResponse Successful operation
|
|
1472
|
+
* @throws ApiError
|
|
1473
|
+
*/
|
|
1474
|
+
static listOrganizations(provider, cursor, limit = 100, abortSignal) {
|
|
1475
|
+
return request(OpenAPI, {
|
|
1476
|
+
method: "GET",
|
|
1477
|
+
url: "/user/organizations/{provider}",
|
|
1478
|
+
path: {
|
|
1479
|
+
"provider": provider
|
|
1480
|
+
},
|
|
1481
|
+
query: {
|
|
1482
|
+
"cursor": cursor,
|
|
1483
|
+
"limit": limit
|
|
1484
|
+
},
|
|
1485
|
+
abortSignal,
|
|
1486
|
+
errors: {
|
|
1487
|
+
400: `Bad Request`,
|
|
1488
|
+
401: `Unauthorized`,
|
|
1489
|
+
422: `Unprocessable Entity`,
|
|
1490
|
+
500: `Internal Server Error`
|
|
1491
|
+
}
|
|
1492
|
+
});
|
|
1493
|
+
}
|
|
1494
|
+
/**
|
|
1495
|
+
* Get organization for the authenticated user
|
|
1496
|
+
* Get organization for the authenticated user
|
|
1497
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider * @returns OrganizationResponse Successful operation
|
|
1498
|
+
* @throws ApiError
|
|
1499
|
+
*/
|
|
1500
|
+
static getUserOrganization(provider, remoteOrganizationName, abortSignal) {
|
|
1501
|
+
return request(OpenAPI, {
|
|
1502
|
+
method: "GET",
|
|
1503
|
+
url: "/user/organizations/{provider}/{remoteOrganizationName}",
|
|
1504
|
+
path: {
|
|
1505
|
+
"provider": provider,
|
|
1506
|
+
"remoteOrganizationName": remoteOrganizationName
|
|
1507
|
+
},
|
|
1508
|
+
abortSignal,
|
|
1509
|
+
errors: {
|
|
1510
|
+
400: `Bad Request`,
|
|
1511
|
+
401: `Unauthorized`,
|
|
1512
|
+
404: `Not Found`,
|
|
1513
|
+
422: `Unprocessable Entity`,
|
|
1514
|
+
500: `Internal Server Error`
|
|
1515
|
+
}
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
/**
|
|
1519
|
+
* List emails for the authenticated user
|
|
1520
|
+
* @returns UserEmailsResponse Successful operation
|
|
1521
|
+
* @throws ApiError
|
|
1522
|
+
*/
|
|
1523
|
+
static listUserEmails(abortSignal) {
|
|
1524
|
+
return request(OpenAPI, {
|
|
1525
|
+
method: "GET",
|
|
1526
|
+
url: "/user/emails",
|
|
1527
|
+
abortSignal,
|
|
1528
|
+
errors: {
|
|
1529
|
+
400: `Bad Request`,
|
|
1530
|
+
401: `Unauthorized`,
|
|
1531
|
+
422: `Unprocessable Entity`,
|
|
1532
|
+
500: `Internal Server Error`
|
|
1533
|
+
}
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* Remove an email from user account
|
|
1538
|
+
* Removes the specified email address from the authenticated user's account. The primary/default email
|
|
1539
|
+
* cannot be removed. A user must always have at least one email address associated with their account.
|
|
1540
|
+
*
|
|
1541
|
+
* @param requestBody Email * @returns void
|
|
1542
|
+
* @throws ApiError
|
|
1543
|
+
*/
|
|
1544
|
+
static removeUserEmail(requestBody, abortSignal) {
|
|
1545
|
+
return request(OpenAPI, {
|
|
1546
|
+
method: "POST",
|
|
1547
|
+
url: "/user/emails/remove",
|
|
1548
|
+
abortSignal,
|
|
1549
|
+
body: requestBody,
|
|
1550
|
+
mediaType: "application/json",
|
|
1551
|
+
errors: {
|
|
1552
|
+
400: `Bad Request`,
|
|
1553
|
+
401: `Unauthorized`,
|
|
1554
|
+
422: `Unprocessable Entity`,
|
|
1555
|
+
500: `Internal Server Error`
|
|
1556
|
+
}
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
/**
|
|
1560
|
+
* Retrieve email notification settings
|
|
1561
|
+
* Returns the current email notification preferences, including per-commit notifications,
|
|
1562
|
+
* pull request notifications, and activity.
|
|
1563
|
+
*
|
|
1564
|
+
* @returns EmailNotificationSettingsResponse Successful operation
|
|
1565
|
+
* @throws ApiError
|
|
1566
|
+
*/
|
|
1567
|
+
static getEmailSettings(abortSignal) {
|
|
1568
|
+
return request(OpenAPI, {
|
|
1569
|
+
method: "GET",
|
|
1570
|
+
url: "/user/emails/settings",
|
|
1571
|
+
abortSignal,
|
|
1572
|
+
errors: {
|
|
1573
|
+
400: `Bad Request`,
|
|
1574
|
+
401: `Unauthorized`,
|
|
1575
|
+
422: `Unprocessable Entity`,
|
|
1576
|
+
500: `Internal Server Error`
|
|
1577
|
+
}
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
/**
|
|
1581
|
+
* Update email notification preferences
|
|
1582
|
+
* Modifies the user's email notification settings. Settings can be updated individually without affecting
|
|
1583
|
+
* other settings. This endpoint allows users to control which events trigger email notifications.
|
|
1584
|
+
*
|
|
1585
|
+
* @param requestBody Email notification preferences to update * @returns void
|
|
1586
|
+
* @throws ApiError
|
|
1587
|
+
*/
|
|
1588
|
+
static updateEmailSettings(requestBody, abortSignal) {
|
|
1589
|
+
return request(OpenAPI, {
|
|
1590
|
+
method: "PATCH",
|
|
1591
|
+
url: "/user/emails/settings",
|
|
1592
|
+
abortSignal,
|
|
1593
|
+
body: requestBody,
|
|
1594
|
+
mediaType: "application/json",
|
|
1595
|
+
errors: {
|
|
1596
|
+
400: `Bad Request`,
|
|
1597
|
+
401: `Unauthorized`,
|
|
1598
|
+
422: `Unprocessable Entity`,
|
|
1599
|
+
500: `Internal Server Error`
|
|
1600
|
+
}
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
/**
|
|
1604
|
+
* Set an email as default
|
|
1605
|
+
* Designates the specified email as the default email for the authenticated user. This operation will
|
|
1606
|
+
* automatically remove the default status from any previously default email.
|
|
1607
|
+
* Only one email can be default at any time.
|
|
1608
|
+
*
|
|
1609
|
+
* @param requestBody Email * @returns void
|
|
1610
|
+
* @throws ApiError
|
|
1611
|
+
*/
|
|
1612
|
+
static setDefaultEmail(requestBody, abortSignal) {
|
|
1613
|
+
return request(OpenAPI, {
|
|
1614
|
+
method: "POST",
|
|
1615
|
+
url: "/user/emails/set-default",
|
|
1616
|
+
abortSignal,
|
|
1617
|
+
body: requestBody,
|
|
1618
|
+
mediaType: "application/json",
|
|
1619
|
+
errors: {
|
|
1620
|
+
400: `Bad Request`,
|
|
1621
|
+
401: `Unauthorized`,
|
|
1622
|
+
422: `Unprocessable Entity`,
|
|
1623
|
+
500: `Internal Server Error`
|
|
1624
|
+
}
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* List integrations for the authenticated user
|
|
1629
|
+
* List integrations for the authenticated user
|
|
1630
|
+
* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns IntegrationListResponse Successful operation
|
|
1631
|
+
* @throws ApiError
|
|
1632
|
+
*/
|
|
1633
|
+
static listUserIntegrations(cursor, limit = 100, abortSignal) {
|
|
1634
|
+
return request(OpenAPI, {
|
|
1635
|
+
method: "GET",
|
|
1636
|
+
url: "/user/integrations",
|
|
1637
|
+
query: {
|
|
1638
|
+
"cursor": cursor,
|
|
1639
|
+
"limit": limit
|
|
1640
|
+
},
|
|
1641
|
+
abortSignal,
|
|
1642
|
+
errors: {
|
|
1643
|
+
400: `Bad Request`,
|
|
1644
|
+
401: `Unauthorized`,
|
|
1645
|
+
422: `Unprocessable Entity`,
|
|
1646
|
+
500: `Internal Server Error`
|
|
1647
|
+
}
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
/**
|
|
1651
|
+
* Delete an integration for the authenticated user
|
|
1652
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket) * @returns void
|
|
1653
|
+
* @throws ApiError
|
|
1654
|
+
*/
|
|
1655
|
+
static deleteIntegration(provider, abortSignal) {
|
|
1656
|
+
return request(OpenAPI, {
|
|
1657
|
+
method: "DELETE",
|
|
1658
|
+
url: "/user/integrations/{provider}",
|
|
1659
|
+
path: {
|
|
1660
|
+
"provider": provider
|
|
1661
|
+
},
|
|
1662
|
+
abortSignal,
|
|
1663
|
+
errors: {
|
|
1664
|
+
400: `Bad Request`,
|
|
1665
|
+
401: `Unauthorized`,
|
|
1666
|
+
404: `Not Found`,
|
|
1667
|
+
422: `Unprocessable Entity`,
|
|
1668
|
+
500: `Internal Server Error`
|
|
1669
|
+
}
|
|
1670
|
+
});
|
|
1671
|
+
}
|
|
1672
|
+
/**
|
|
1673
|
+
* Get organization by provider installation id
|
|
1674
|
+
* __Note__ Currently supports only `gh` as the `provider` parameter.
|
|
1675
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param installationId Identifier of the Codacy installation * @returns OrganizationResponse Successful operation
|
|
1676
|
+
* @throws ApiError
|
|
1677
|
+
*/
|
|
1678
|
+
static getOrganizationByInstallationId(provider, installationId, abortSignal) {
|
|
1679
|
+
return request(OpenAPI, {
|
|
1680
|
+
method: "GET",
|
|
1681
|
+
url: "/organizations/{provider}/installation/{installationId}",
|
|
1682
|
+
path: {
|
|
1683
|
+
"provider": provider,
|
|
1684
|
+
"installationId": installationId
|
|
1685
|
+
},
|
|
1686
|
+
abortSignal,
|
|
1687
|
+
errors: {
|
|
1688
|
+
400: `Bad Request`,
|
|
1689
|
+
401: `Unauthorized`,
|
|
1690
|
+
404: `Not Found`,
|
|
1691
|
+
422: `Unprocessable Entity`,
|
|
1692
|
+
500: `Internal Server Error`
|
|
1693
|
+
}
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1696
|
+
/**
|
|
1697
|
+
* List the [account API tokens](https://docs.codacy.com/codacy-api/api-tokens/) of the authenticated user
|
|
1698
|
+
* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns ApiTokenListResponse Successful operation
|
|
1699
|
+
* @throws ApiError
|
|
1700
|
+
*/
|
|
1701
|
+
static getUserApiTokens(cursor, limit = 100, abortSignal) {
|
|
1702
|
+
return request(OpenAPI, {
|
|
1703
|
+
method: "GET",
|
|
1704
|
+
url: "/user/tokens",
|
|
1705
|
+
query: {
|
|
1706
|
+
"cursor": cursor,
|
|
1707
|
+
"limit": limit
|
|
1708
|
+
},
|
|
1709
|
+
abortSignal,
|
|
1710
|
+
errors: {
|
|
1711
|
+
400: `Bad Request`,
|
|
1712
|
+
401: `Unauthorized`,
|
|
1713
|
+
422: `Unprocessable Entity`,
|
|
1714
|
+
500: `Internal Server Error`
|
|
1715
|
+
}
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
/**
|
|
1719
|
+
* Create a new [account API token](https://docs.codacy.com/codacy-api/api-tokens/) for the authenticated user
|
|
1720
|
+
* @param requestBody Optional token expiration timestamp * @returns ApiToken Successful operation
|
|
1721
|
+
* @throws ApiError
|
|
1722
|
+
*/
|
|
1723
|
+
static createUserApiToken(requestBody, abortSignal) {
|
|
1724
|
+
return request(OpenAPI, {
|
|
1725
|
+
method: "POST",
|
|
1726
|
+
url: "/user/tokens",
|
|
1727
|
+
abortSignal,
|
|
1728
|
+
body: requestBody,
|
|
1729
|
+
mediaType: "application/json",
|
|
1730
|
+
errors: {
|
|
1731
|
+
400: `Bad Request`,
|
|
1732
|
+
401: `Unauthorized`,
|
|
1733
|
+
422: `Unprocessable Entity`,
|
|
1734
|
+
500: `Internal Server Error`
|
|
1735
|
+
}
|
|
1736
|
+
});
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Delete an [account API token](https://docs.codacy.com/codacy-api/api-tokens/) for the authenticated user by ID
|
|
1740
|
+
* @param tokenId Unique identifier for the API token * @returns void
|
|
1741
|
+
* @throws ApiError
|
|
1742
|
+
*/
|
|
1743
|
+
static deleteUserApiToken(tokenId, abortSignal) {
|
|
1744
|
+
return request(OpenAPI, {
|
|
1745
|
+
method: "DELETE",
|
|
1746
|
+
url: "/user/tokens/{tokenId}",
|
|
1747
|
+
path: {
|
|
1748
|
+
"tokenId": tokenId
|
|
1749
|
+
},
|
|
1750
|
+
abortSignal,
|
|
1751
|
+
errors: {
|
|
1752
|
+
401: `Unauthorized`,
|
|
1753
|
+
404: `Not Found`,
|
|
1754
|
+
422: `Unprocessable Entity`,
|
|
1755
|
+
500: `Internal Server Error`
|
|
1756
|
+
}
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
};
|
|
1760
|
+
|
|
1761
|
+
// src/api/client/services/AnalysisService.ts
|
|
1762
|
+
var AnalysisService = class {
|
|
1763
|
+
/**
|
|
1764
|
+
* List organization repositories with analysis information for the authenticated user
|
|
1765
|
+
* For Bitbucket, you must URL encode the cursor before using it in subsequent API calls, as the pagination comes directly from the Git provider.
|
|
1766
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return* @param search Filter results by searching for this string* @param repositories **Deprecated:** Use [searchOrganizationRepositoriesWithAnalysis](#searchorganizationrepositorieswithanalysis) instead.* @param segments Filter by a comma-separated list of segment identifiers * @returns RepositoryWithAnalysisListResponse Successful operation
|
|
1767
|
+
* @throws ApiError
|
|
1768
|
+
*/
|
|
1769
|
+
static listOrganizationRepositoriesWithAnalysis(provider, remoteOrganizationName, cursor, limit = 100, search, repositories, segments, abortSignal) {
|
|
1770
|
+
return request(OpenAPI, {
|
|
1771
|
+
method: "GET",
|
|
1772
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories",
|
|
1773
|
+
path: {
|
|
1774
|
+
"provider": provider,
|
|
1775
|
+
"remoteOrganizationName": remoteOrganizationName
|
|
1776
|
+
},
|
|
1777
|
+
query: {
|
|
1778
|
+
"cursor": cursor,
|
|
1779
|
+
"limit": limit,
|
|
1780
|
+
"search": search,
|
|
1781
|
+
"repositories": repositories,
|
|
1782
|
+
"segments": segments
|
|
1783
|
+
},
|
|
1784
|
+
abortSignal,
|
|
1785
|
+
errors: {
|
|
1786
|
+
400: `Bad Request`,
|
|
1787
|
+
401: `Unauthorized`,
|
|
1788
|
+
404: `Not Found`,
|
|
1789
|
+
422: `Unprocessable Entity`,
|
|
1790
|
+
500: `Internal Server Error`,
|
|
1791
|
+
502: `Bad Gateway`
|
|
1792
|
+
}
|
|
1793
|
+
});
|
|
1794
|
+
}
|
|
1795
|
+
/**
|
|
1796
|
+
* Search organization repositories with analysis information for the authenticated user
|
|
1797
|
+
* For Bitbucket, you must URL encode the cursor before using it in subsequent API calls, as the pagination comes directly from the Git provider.
|
|
1798
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param requestBody Search query body* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns RepositoryWithAnalysisListResponse Successful operation
|
|
1799
|
+
* @throws ApiError
|
|
1800
|
+
*/
|
|
1801
|
+
static searchOrganizationRepositoriesWithAnalysis(provider, remoteOrganizationName, requestBody, cursor, limit = 100, abortSignal) {
|
|
1802
|
+
return request(OpenAPI, {
|
|
1803
|
+
method: "POST",
|
|
1804
|
+
url: "/search/analysis/organizations/{provider}/{remoteOrganizationName}/repositories",
|
|
1805
|
+
path: {
|
|
1806
|
+
"provider": provider,
|
|
1807
|
+
"remoteOrganizationName": remoteOrganizationName
|
|
1808
|
+
},
|
|
1809
|
+
query: {
|
|
1810
|
+
"cursor": cursor,
|
|
1811
|
+
"limit": limit
|
|
1812
|
+
},
|
|
1813
|
+
abortSignal,
|
|
1814
|
+
body: requestBody,
|
|
1815
|
+
mediaType: "application/json",
|
|
1816
|
+
errors: {
|
|
1817
|
+
400: `Bad Request`,
|
|
1818
|
+
401: `Unauthorized`,
|
|
1819
|
+
404: `Not Found`,
|
|
1820
|
+
422: `Unprocessable Entity`,
|
|
1821
|
+
500: `Internal Server Error`,
|
|
1822
|
+
502: `Bad Gateway`
|
|
1823
|
+
}
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
/**
|
|
1827
|
+
* Get a repository with analysis information for the authenticated user
|
|
1828
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param branch Name of a [repository branch enabled on Codacy](https://docs.codacy.com/repositories-configure/managing-branches/),
|
|
1829
|
+
* as returned by the endpoint [listRepositoryBranches](#listrepositorybranches).
|
|
1830
|
+
* By default, uses the main branch defined on the Codacy repository settings.
|
|
1831
|
+
* * @returns RepositoryWithAnalysisResponse Successful operation
|
|
1832
|
+
* @throws ApiError
|
|
1833
|
+
*/
|
|
1834
|
+
static getRepositoryWithAnalysis(provider, remoteOrganizationName, repositoryName, branch, abortSignal) {
|
|
1835
|
+
return request(OpenAPI, {
|
|
1836
|
+
method: "GET",
|
|
1837
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}",
|
|
1838
|
+
path: {
|
|
1839
|
+
"provider": provider,
|
|
1840
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
1841
|
+
"repositoryName": repositoryName
|
|
1842
|
+
},
|
|
1843
|
+
query: {
|
|
1844
|
+
"branch": branch
|
|
1845
|
+
},
|
|
1846
|
+
abortSignal,
|
|
1847
|
+
errors: {
|
|
1848
|
+
400: `Bad Request`,
|
|
1849
|
+
401: `Unauthorized`,
|
|
1850
|
+
404: `Not Found`,
|
|
1851
|
+
422: `Unprocessable Entity`,
|
|
1852
|
+
500: `Internal Server Error`
|
|
1853
|
+
}
|
|
1854
|
+
});
|
|
1855
|
+
}
|
|
1856
|
+
/**
|
|
1857
|
+
* Get analysis tools settings of a repository
|
|
1858
|
+
* **Note:** When applied to public repositories, this operation does not require authentication.
|
|
1859
|
+
*
|
|
1860
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns AnalysisToolsResponse Successful operation
|
|
1861
|
+
* @throws ApiError
|
|
1862
|
+
*/
|
|
1863
|
+
static listRepositoryTools(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
1864
|
+
return request(OpenAPI, {
|
|
1865
|
+
method: "GET",
|
|
1866
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/tools",
|
|
1867
|
+
path: {
|
|
1868
|
+
"provider": provider,
|
|
1869
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
1870
|
+
"repositoryName": repositoryName
|
|
1871
|
+
},
|
|
1872
|
+
abortSignal,
|
|
1873
|
+
errors: {
|
|
1874
|
+
400: `Bad Request`,
|
|
1875
|
+
401: `Unauthorized`,
|
|
1876
|
+
404: `Not Found`,
|
|
1877
|
+
422: `Unprocessable Entity`,
|
|
1878
|
+
500: `Internal Server Error`
|
|
1879
|
+
}
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1882
|
+
/**
|
|
1883
|
+
* Get tools with conflicts in a repository
|
|
1884
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns RepositoryConflictsResponse Successful operation
|
|
1885
|
+
* @throws ApiError
|
|
1886
|
+
*/
|
|
1887
|
+
static listRepositoryToolConflicts(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
1888
|
+
return request(OpenAPI, {
|
|
1889
|
+
method: "GET",
|
|
1890
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/tools/conflicts",
|
|
1891
|
+
path: {
|
|
1892
|
+
"provider": provider,
|
|
1893
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
1894
|
+
"repositoryName": repositoryName
|
|
1895
|
+
},
|
|
1896
|
+
abortSignal,
|
|
1897
|
+
errors: {
|
|
1898
|
+
400: `Bad Request`,
|
|
1899
|
+
401: `Unauthorized`,
|
|
1900
|
+
404: `Not Found`,
|
|
1901
|
+
422: `Unprocessable Entity`,
|
|
1902
|
+
500: `Internal Server Error`
|
|
1903
|
+
}
|
|
1904
|
+
});
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Configure an analysis tool by enabling and disabling its patterns for a repository.
|
|
1908
|
+
* This endpoint will apply the changes without verifying if the repository belongs to a coding standard.
|
|
1909
|
+
*
|
|
1910
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param toolUuid Unique identifier (UUID) for the tool* @param requestBody * @returns void
|
|
1911
|
+
* @throws ApiError
|
|
1912
|
+
*/
|
|
1913
|
+
static configureTool(provider, remoteOrganizationName, repositoryName, toolUuid, requestBody, abortSignal) {
|
|
1914
|
+
return request(OpenAPI, {
|
|
1915
|
+
method: "PATCH",
|
|
1916
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/tools/{toolUuid}",
|
|
1917
|
+
path: {
|
|
1918
|
+
"provider": provider,
|
|
1919
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
1920
|
+
"repositoryName": repositoryName,
|
|
1921
|
+
"toolUuid": toolUuid
|
|
1922
|
+
},
|
|
1923
|
+
abortSignal,
|
|
1924
|
+
body: requestBody,
|
|
1925
|
+
mediaType: "application/json",
|
|
1926
|
+
errors: {
|
|
1927
|
+
400: `Bad Request`,
|
|
1928
|
+
401: `Unauthorized`,
|
|
1929
|
+
404: `Not Found`,
|
|
1930
|
+
409: `Conflict`,
|
|
1931
|
+
422: `Unprocessable Entity`,
|
|
1932
|
+
500: `Internal Server Error`
|
|
1933
|
+
}
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1936
|
+
/**
|
|
1937
|
+
* Patterns configuration for (repository, tool). Uses standard if applied, repository settings otherwise.
|
|
1938
|
+
*
|
|
1939
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param toolUuid Unique identifier (UUID) for the tool* @param languages Comma-separated list of programming languages to filter results by* @param categories Filter by a comma-separated list of code pattern categories. Valid values are `Security`, `ErrorProne`, `CodeStyle`, `Compatibility`, `UnusedCode`, `Complexity`, `Comprehensibility`, `Documentation`, `BestPractice`, and `Performance`.
|
|
1940
|
+
* * @param severityLevels Filter by a comma-separated list of code pattern severity levels. Valid values are `Error`, `High`, `Warning`, and `Info`.* @param tags Filter by a comma-separated list of pattern tags* @param search Filter results by searching for this string* @param enabled Filter by pattern status. Set to `true` to return only enabled patterns, or `false` to return only disabled patterns* @param recommended Filter by recommended status. Set to `true` to return only recommended patterns, or `false` to return only non-recommended patterns* @param sort Field used to sort the tool's code patterns. Valid values are `category`, `recommended`, and `severity`.* @param direction Sort direction. Possible values are 'asc' (ascending) or 'desc' (descending).* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns ConfiguredPatternsListResponse Successful operation
|
|
1941
|
+
* @throws ApiError
|
|
1942
|
+
*/
|
|
1943
|
+
static listRepositoryToolPatterns(provider, remoteOrganizationName, repositoryName, toolUuid, languages, categories, severityLevels, tags, search, enabled, recommended, sort, direction, cursor, limit = 100, abortSignal) {
|
|
1944
|
+
return request(OpenAPI, {
|
|
1945
|
+
method: "GET",
|
|
1946
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/tools/{toolUuid}/patterns",
|
|
1947
|
+
path: {
|
|
1948
|
+
"provider": provider,
|
|
1949
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
1950
|
+
"repositoryName": repositoryName,
|
|
1951
|
+
"toolUuid": toolUuid
|
|
1952
|
+
},
|
|
1953
|
+
query: {
|
|
1954
|
+
"languages": languages,
|
|
1955
|
+
"categories": categories,
|
|
1956
|
+
"severityLevels": severityLevels,
|
|
1957
|
+
"tags": tags,
|
|
1958
|
+
"search": search,
|
|
1959
|
+
"enabled": enabled,
|
|
1960
|
+
"recommended": recommended,
|
|
1961
|
+
"sort": sort,
|
|
1962
|
+
"direction": direction,
|
|
1963
|
+
"cursor": cursor,
|
|
1964
|
+
"limit": limit
|
|
1965
|
+
},
|
|
1966
|
+
abortSignal,
|
|
1967
|
+
errors: {
|
|
1968
|
+
400: `Bad Request`,
|
|
1969
|
+
401: `Unauthorized`,
|
|
1970
|
+
403: `Forbidden`,
|
|
1971
|
+
404: `Not Found`,
|
|
1972
|
+
422: `Unprocessable Entity`,
|
|
1973
|
+
500: `Internal Server Error`
|
|
1974
|
+
}
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
/**
|
|
1978
|
+
* Bulk updates the code patterns of a tool in a repository.
|
|
1979
|
+
* Use filters to specify the code patterns to update, or omit the filters to update all code patterns.
|
|
1980
|
+
*
|
|
1981
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param toolUuid Unique identifier (UUID) for the tool* @param requestBody * @param languages Comma-separated list of programming languages to filter results by* @param categories Filter by a comma-separated list of code pattern categories. Valid values are `Security`, `ErrorProne`, `CodeStyle`, `Compatibility`, `UnusedCode`, `Complexity`, `Comprehensibility`, `Documentation`, `BestPractice`, and `Performance`.
|
|
1982
|
+
* * @param severityLevels Filter by a comma-separated list of code pattern severity levels. Valid values are `Error`, `High`, `Warning`, and `Info`.* @param tags Filter by a comma-separated list of pattern tags* @param search Filter results by searching for this string* @param recommended Filter by recommended status. Set to `true` to return only recommended patterns, or `false` to return only non-recommended patterns * @returns void
|
|
1983
|
+
* @throws ApiError
|
|
1984
|
+
*/
|
|
1985
|
+
static updateRepositoryToolPatterns(provider, remoteOrganizationName, repositoryName, toolUuid, requestBody, languages, categories, severityLevels, tags, search, recommended, abortSignal) {
|
|
1986
|
+
return request(OpenAPI, {
|
|
1987
|
+
method: "PATCH",
|
|
1988
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/tools/{toolUuid}/patterns",
|
|
1989
|
+
path: {
|
|
1990
|
+
"provider": provider,
|
|
1991
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
1992
|
+
"repositoryName": repositoryName,
|
|
1993
|
+
"toolUuid": toolUuid
|
|
1994
|
+
},
|
|
1995
|
+
query: {
|
|
1996
|
+
"languages": languages,
|
|
1997
|
+
"categories": categories,
|
|
1998
|
+
"severityLevels": severityLevels,
|
|
1999
|
+
"tags": tags,
|
|
2000
|
+
"search": search,
|
|
2001
|
+
"recommended": recommended
|
|
2002
|
+
},
|
|
2003
|
+
abortSignal,
|
|
2004
|
+
body: requestBody,
|
|
2005
|
+
mediaType: "application/json",
|
|
2006
|
+
errors: {
|
|
2007
|
+
400: `Bad Request`,
|
|
2008
|
+
401: `Unauthorized`,
|
|
2009
|
+
403: `Forbidden`,
|
|
2010
|
+
404: `Not Found`,
|
|
2011
|
+
409: `Conflict`,
|
|
2012
|
+
422: `Unprocessable Entity`,
|
|
2013
|
+
500: `Internal Server Error`
|
|
2014
|
+
}
|
|
2015
|
+
});
|
|
2016
|
+
}
|
|
2017
|
+
/**
|
|
2018
|
+
* Patterns configuration for (repository, tool, pattern). Uses standard if applied, repository settings otherwise.
|
|
2019
|
+
*
|
|
2020
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param toolUuid Unique identifier (UUID) for the tool* @param patternId Pattern identifier * @returns ConfiguredPatternResponse Successful operation
|
|
2021
|
+
* @throws ApiError
|
|
2022
|
+
*/
|
|
2023
|
+
static getRepositoryToolPattern(provider, remoteOrganizationName, repositoryName, toolUuid, patternId, abortSignal) {
|
|
2024
|
+
return request(OpenAPI, {
|
|
2025
|
+
method: "GET",
|
|
2026
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/tools/{toolUuid}/patterns/{patternId}",
|
|
2027
|
+
path: {
|
|
2028
|
+
"provider": provider,
|
|
2029
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2030
|
+
"repositoryName": repositoryName,
|
|
2031
|
+
"toolUuid": toolUuid,
|
|
2032
|
+
"patternId": patternId
|
|
2033
|
+
},
|
|
2034
|
+
abortSignal,
|
|
2035
|
+
errors: {
|
|
2036
|
+
400: `Bad Request`,
|
|
2037
|
+
401: `Unauthorized`,
|
|
2038
|
+
403: `Forbidden`,
|
|
2039
|
+
404: `Not Found`,
|
|
2040
|
+
422: `Unprocessable Entity`,
|
|
2041
|
+
500: `Internal Server Error`
|
|
2042
|
+
}
|
|
2043
|
+
});
|
|
2044
|
+
}
|
|
2045
|
+
/**
|
|
2046
|
+
* Patterns overview for tool. Uses standard if applied, repository settings otherwise.
|
|
2047
|
+
*
|
|
2048
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param toolUuid Unique identifier (UUID) for the tool* @param languages Comma-separated list of programming languages to filter results by* @param categories Filter by a comma-separated list of code pattern categories. Valid values are `Security`, `ErrorProne`, `CodeStyle`, `Compatibility`, `UnusedCode`, `Complexity`, `Comprehensibility`, `Documentation`, `BestPractice`, and `Performance`.
|
|
2049
|
+
* * @param severityLevels Filter by a comma-separated list of code pattern severity levels. Valid values are `Error`, `High`, `Warning`, and `Info`.* @param tags Filter by a comma-separated list of pattern tags* @param search Filter results by searching for this string* @param enabled Filter by pattern status. Set to `true` to return only enabled patterns, or `false` to return only disabled patterns* @param recommended Filter by recommended status. Set to `true` to return only recommended patterns, or `false` to return only non-recommended patterns * @returns ToolPatternsOverviewResponse Successful operation
|
|
2050
|
+
* @throws ApiError
|
|
2051
|
+
*/
|
|
2052
|
+
static toolPatternsOverview(provider, remoteOrganizationName, repositoryName, toolUuid, languages, categories, severityLevels, tags, search, enabled, recommended, abortSignal) {
|
|
2053
|
+
return request(OpenAPI, {
|
|
2054
|
+
method: "GET",
|
|
2055
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/tools/{toolUuid}/patterns/overview",
|
|
2056
|
+
path: {
|
|
2057
|
+
"provider": provider,
|
|
2058
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2059
|
+
"repositoryName": repositoryName,
|
|
2060
|
+
"toolUuid": toolUuid
|
|
2061
|
+
},
|
|
2062
|
+
query: {
|
|
2063
|
+
"languages": languages,
|
|
2064
|
+
"categories": categories,
|
|
2065
|
+
"severityLevels": severityLevels,
|
|
2066
|
+
"tags": tags,
|
|
2067
|
+
"search": search,
|
|
2068
|
+
"enabled": enabled,
|
|
2069
|
+
"recommended": recommended
|
|
2070
|
+
},
|
|
2071
|
+
abortSignal,
|
|
2072
|
+
errors: {
|
|
2073
|
+
400: `Bad Request`,
|
|
2074
|
+
401: `Unauthorized`,
|
|
2075
|
+
403: `Forbidden`,
|
|
2076
|
+
404: `Not Found`,
|
|
2077
|
+
422: `Unprocessable Entity`,
|
|
2078
|
+
500: `Internal Server Error`
|
|
2079
|
+
}
|
|
2080
|
+
});
|
|
2081
|
+
}
|
|
2082
|
+
/**
|
|
2083
|
+
* Patterns with Coding Standards conflicts for tool.
|
|
2084
|
+
*
|
|
2085
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param toolUuid Unique identifier (UUID) for the tool * @returns RepositoryToolConflictsResponse Successful operation
|
|
2086
|
+
* @throws ApiError
|
|
2087
|
+
*/
|
|
2088
|
+
static listRepositoryToolPatternConflicts(provider, remoteOrganizationName, repositoryName, toolUuid, abortSignal) {
|
|
2089
|
+
return request(OpenAPI, {
|
|
2090
|
+
method: "GET",
|
|
2091
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/tools/{toolUuid}/conflicts",
|
|
2092
|
+
path: {
|
|
2093
|
+
"provider": provider,
|
|
2094
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2095
|
+
"repositoryName": repositoryName,
|
|
2096
|
+
"toolUuid": toolUuid
|
|
2097
|
+
},
|
|
2098
|
+
abortSignal,
|
|
2099
|
+
errors: {
|
|
2100
|
+
400: `Bad Request`,
|
|
2101
|
+
401: `Unauthorized`,
|
|
2102
|
+
403: `Forbidden`,
|
|
2103
|
+
404: `Not Found`,
|
|
2104
|
+
422: `Unprocessable Entity`,
|
|
2105
|
+
500: `Internal Server Error`
|
|
2106
|
+
}
|
|
2107
|
+
});
|
|
2108
|
+
}
|
|
2109
|
+
/**
|
|
2110
|
+
* Get the analysis progress of a repository
|
|
2111
|
+
* **Note:** When applied to public repositories, this operation does not require authentication.
|
|
2112
|
+
*
|
|
2113
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param branch Name of a [repository branch enabled on Codacy](https://docs.codacy.com/repositories-configure/managing-branches/),
|
|
2114
|
+
* as returned by the endpoint [listRepositoryBranches](#listrepositorybranches).
|
|
2115
|
+
* By default, uses the main branch defined on the Codacy repository settings.
|
|
2116
|
+
* * @returns FirstAnalysisOverviewResponse Successful operation
|
|
2117
|
+
* @throws ApiError
|
|
2118
|
+
*/
|
|
2119
|
+
static getFirstAnalysisOverview(provider, remoteOrganizationName, repositoryName, branch, abortSignal) {
|
|
2120
|
+
return request(OpenAPI, {
|
|
2121
|
+
method: "GET",
|
|
2122
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/analysis-progress",
|
|
2123
|
+
path: {
|
|
2124
|
+
"provider": provider,
|
|
2125
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2126
|
+
"repositoryName": repositoryName
|
|
2127
|
+
},
|
|
2128
|
+
query: {
|
|
2129
|
+
"branch": branch
|
|
2130
|
+
},
|
|
2131
|
+
abortSignal,
|
|
2132
|
+
errors: {
|
|
2133
|
+
400: `Bad Request`,
|
|
2134
|
+
401: `Unauthorized`,
|
|
2135
|
+
404: `Not Found`,
|
|
2136
|
+
422: `Unprocessable Entity`,
|
|
2137
|
+
500: `Internal Server Error`
|
|
2138
|
+
}
|
|
2139
|
+
});
|
|
2140
|
+
}
|
|
2141
|
+
/**
|
|
2142
|
+
* List pull requests from a repository that the user has access to
|
|
2143
|
+
* You can search this endpoint for either `last-updated` (default), `impact` or `merged`
|
|
2144
|
+
*
|
|
2145
|
+
* **Note:** When applied to public repositories, this operation does not require authentication.
|
|
2146
|
+
*
|
|
2147
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param limit Maximum number of items to return* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param search Filter results by searching for this string* @param includeNotAnalyzed If true, also return pull requests that weren't analyzed * @returns PullRequestWithAnalysisListResponse Successful operation
|
|
2148
|
+
* @throws ApiError
|
|
2149
|
+
*/
|
|
2150
|
+
static listRepositoryPullRequests(provider, remoteOrganizationName, repositoryName, limit = 100, cursor, search, includeNotAnalyzed = false, abortSignal) {
|
|
2151
|
+
return request(OpenAPI, {
|
|
2152
|
+
method: "GET",
|
|
2153
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/pull-requests",
|
|
2154
|
+
path: {
|
|
2155
|
+
"provider": provider,
|
|
2156
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2157
|
+
"repositoryName": repositoryName
|
|
2158
|
+
},
|
|
2159
|
+
query: {
|
|
2160
|
+
"limit": limit,
|
|
2161
|
+
"cursor": cursor,
|
|
2162
|
+
"search": search,
|
|
2163
|
+
"includeNotAnalyzed": includeNotAnalyzed
|
|
2164
|
+
},
|
|
2165
|
+
abortSignal,
|
|
2166
|
+
errors: {
|
|
2167
|
+
400: `Bad Request`,
|
|
2168
|
+
401: `Unauthorized`,
|
|
2169
|
+
404: `Not Found`,
|
|
2170
|
+
422: `Unprocessable Entity`,
|
|
2171
|
+
500: `Internal Server Error`
|
|
2172
|
+
}
|
|
2173
|
+
});
|
|
2174
|
+
}
|
|
2175
|
+
/**
|
|
2176
|
+
* Get pull request from a repository
|
|
2177
|
+
* **Note:** When applied to public repositories, this operation does not require authentication.
|
|
2178
|
+
*
|
|
2179
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param pullRequestNumber Pull request number * @returns PullRequestWithAnalysis Successful operation
|
|
2180
|
+
* @throws ApiError
|
|
2181
|
+
*/
|
|
2182
|
+
static getRepositoryPullRequest(provider, remoteOrganizationName, repositoryName, pullRequestNumber, abortSignal) {
|
|
2183
|
+
return request(OpenAPI, {
|
|
2184
|
+
method: "GET",
|
|
2185
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/pull-requests/{pullRequestNumber}",
|
|
2186
|
+
path: {
|
|
2187
|
+
"provider": provider,
|
|
2188
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2189
|
+
"repositoryName": repositoryName,
|
|
2190
|
+
"pullRequestNumber": pullRequestNumber
|
|
2191
|
+
},
|
|
2192
|
+
abortSignal,
|
|
2193
|
+
errors: {
|
|
2194
|
+
400: `Bad Request`,
|
|
2195
|
+
401: `Unauthorized`,
|
|
2196
|
+
404: `Not Found`,
|
|
2197
|
+
422: `Unprocessable Entity`,
|
|
2198
|
+
500: `Internal Server Error`
|
|
2199
|
+
}
|
|
2200
|
+
});
|
|
2201
|
+
}
|
|
2202
|
+
/**
|
|
2203
|
+
* Return analysis results for the commits in a pull request
|
|
2204
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param pullRequestNumber Pull request number* @param limit Maximum number of items to return* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination) * @returns CommitWithAnalysisListResponse Successful operation
|
|
2205
|
+
* @throws ApiError
|
|
2206
|
+
*/
|
|
2207
|
+
static getPullRequestCommits(provider, remoteOrganizationName, repositoryName, pullRequestNumber, limit = 100, cursor, abortSignal) {
|
|
2208
|
+
return request(OpenAPI, {
|
|
2209
|
+
method: "GET",
|
|
2210
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/pull-requests/{pullRequestNumber}/commits",
|
|
2211
|
+
path: {
|
|
2212
|
+
"provider": provider,
|
|
2213
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2214
|
+
"repositoryName": repositoryName,
|
|
2215
|
+
"pullRequestNumber": pullRequestNumber
|
|
2216
|
+
},
|
|
2217
|
+
query: {
|
|
2218
|
+
"limit": limit,
|
|
2219
|
+
"cursor": cursor
|
|
2220
|
+
},
|
|
2221
|
+
abortSignal,
|
|
2222
|
+
errors: {
|
|
2223
|
+
400: `Bad Request`,
|
|
2224
|
+
401: `Unauthorized`,
|
|
2225
|
+
403: `Forbidden`,
|
|
2226
|
+
404: `Not Found`,
|
|
2227
|
+
422: `Unprocessable Entity`,
|
|
2228
|
+
500: `Internal Server Error`
|
|
2229
|
+
}
|
|
2230
|
+
});
|
|
2231
|
+
}
|
|
2232
|
+
/**
|
|
2233
|
+
* Bypass analysis status in a pull request
|
|
2234
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param pullRequestNumber Pull request number * @returns void
|
|
2235
|
+
* @throws ApiError
|
|
2236
|
+
*/
|
|
2237
|
+
static bypassPullRequestAnalysis(provider, remoteOrganizationName, repositoryName, pullRequestNumber, abortSignal) {
|
|
2238
|
+
return request(OpenAPI, {
|
|
2239
|
+
method: "POST",
|
|
2240
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/pull-requests/{pullRequestNumber}/bypass",
|
|
2241
|
+
path: {
|
|
2242
|
+
"provider": provider,
|
|
2243
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2244
|
+
"repositoryName": repositoryName,
|
|
2245
|
+
"pullRequestNumber": pullRequestNumber
|
|
2246
|
+
},
|
|
2247
|
+
abortSignal,
|
|
2248
|
+
errors: {
|
|
2249
|
+
400: `Bad Request`,
|
|
2250
|
+
401: `Unauthorized`,
|
|
2251
|
+
403: `Forbidden`,
|
|
2252
|
+
404: `Not Found`,
|
|
2253
|
+
422: `Unprocessable Entity`,
|
|
2254
|
+
500: `Internal Server Error`
|
|
2255
|
+
}
|
|
2256
|
+
});
|
|
2257
|
+
}
|
|
2258
|
+
/**
|
|
2259
|
+
* List all coverage reports uploaded for the common ancestor commit and head commit of a pull request branch
|
|
2260
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param pullRequestNumber Pull request number * @returns CoveragePullRequestResponse Successful operation
|
|
2261
|
+
* @throws ApiError
|
|
2262
|
+
*/
|
|
2263
|
+
static getPullRequestCoverageReports(provider, remoteOrganizationName, repositoryName, pullRequestNumber, abortSignal) {
|
|
2264
|
+
return request(OpenAPI, {
|
|
2265
|
+
method: "GET",
|
|
2266
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/pull-requests/{pullRequestNumber}/coverage/status",
|
|
2267
|
+
path: {
|
|
2268
|
+
"provider": provider,
|
|
2269
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2270
|
+
"repositoryName": repositoryName,
|
|
2271
|
+
"pullRequestNumber": pullRequestNumber
|
|
2272
|
+
},
|
|
2273
|
+
abortSignal,
|
|
2274
|
+
errors: {
|
|
2275
|
+
400: `Bad Request`,
|
|
2276
|
+
401: `Unauthorized`,
|
|
2277
|
+
404: `Not Found`,
|
|
2278
|
+
422: `Unprocessable Entity`,
|
|
2279
|
+
500: `Internal Server Error`
|
|
2280
|
+
}
|
|
2281
|
+
});
|
|
2282
|
+
}
|
|
2283
|
+
/**
|
|
2284
|
+
* List issues found in a pull request
|
|
2285
|
+
* Use the status parameter to filter by new or fixed issues
|
|
2286
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param pullRequestNumber Pull request number* @param status Filter issues by status. Valid values are `all`, `new`, or `fixed`.* @param onlyPotential Set to `true` to return only potential issues* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns PullRequestIssuesResponse Successful operation
|
|
2287
|
+
* @throws ApiError
|
|
2288
|
+
*/
|
|
2289
|
+
static listPullRequestIssues(provider, remoteOrganizationName, repositoryName, pullRequestNumber, status, onlyPotential, cursor, limit = 100, abortSignal) {
|
|
2290
|
+
return request(OpenAPI, {
|
|
2291
|
+
method: "GET",
|
|
2292
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/pull-requests/{pullRequestNumber}/issues",
|
|
2293
|
+
path: {
|
|
2294
|
+
"provider": provider,
|
|
2295
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2296
|
+
"repositoryName": repositoryName,
|
|
2297
|
+
"pullRequestNumber": pullRequestNumber
|
|
2298
|
+
},
|
|
2299
|
+
query: {
|
|
2300
|
+
"status": status,
|
|
2301
|
+
"onlyPotential": onlyPotential,
|
|
2302
|
+
"cursor": cursor,
|
|
2303
|
+
"limit": limit
|
|
2304
|
+
},
|
|
2305
|
+
abortSignal,
|
|
2306
|
+
errors: {
|
|
2307
|
+
400: `Bad Request`,
|
|
2308
|
+
401: `Unauthorized`,
|
|
2309
|
+
404: `Not Found`,
|
|
2310
|
+
422: `Unprocessable Entity`,
|
|
2311
|
+
500: `Internal Server Error`
|
|
2312
|
+
}
|
|
2313
|
+
});
|
|
2314
|
+
}
|
|
2315
|
+
/**
|
|
2316
|
+
* List duplicate code blocks found in a pull request
|
|
2317
|
+
* Use the status parameter to filter by new or removed duplicates
|
|
2318
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param pullRequestNumber Pull request number* @param status Filter issues by status. Valid values are `all`, `new`, or `fixed`.* @param onlyPotential Set to `true` to return only potential issues* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns ClonesResponse Successful operation
|
|
2319
|
+
* @throws ApiError
|
|
2320
|
+
*/
|
|
2321
|
+
static listPullRequestClones(provider, remoteOrganizationName, repositoryName, pullRequestNumber, status, onlyPotential, cursor, limit = 100, abortSignal) {
|
|
2322
|
+
return request(OpenAPI, {
|
|
2323
|
+
method: "GET",
|
|
2324
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/pull-requests/{pullRequestNumber}/clones",
|
|
2325
|
+
path: {
|
|
2326
|
+
"provider": provider,
|
|
2327
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2328
|
+
"repositoryName": repositoryName,
|
|
2329
|
+
"pullRequestNumber": pullRequestNumber
|
|
2330
|
+
},
|
|
2331
|
+
query: {
|
|
2332
|
+
"status": status,
|
|
2333
|
+
"onlyPotential": onlyPotential,
|
|
2334
|
+
"cursor": cursor,
|
|
2335
|
+
"limit": limit
|
|
2336
|
+
},
|
|
2337
|
+
abortSignal,
|
|
2338
|
+
errors: {
|
|
2339
|
+
400: `Bad Request`,
|
|
2340
|
+
401: `Unauthorized`,
|
|
2341
|
+
404: `Not Found`,
|
|
2342
|
+
422: `Unprocessable Entity`,
|
|
2343
|
+
500: `Internal Server Error`
|
|
2344
|
+
}
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2347
|
+
/**
|
|
2348
|
+
* List duplicate code blocks found in a commit
|
|
2349
|
+
* Use the status parameter to filter by new or removed duplicates
|
|
2350
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param commitUuid UUID or SHA identifier of the source commit* @param status Filter issues by status. Valid values are `all`, `new`, or `fixed`.* @param onlyPotential Set to `true` to return only potential issues* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns ClonesResponse Successful operation
|
|
2351
|
+
* @throws ApiError
|
|
2352
|
+
*/
|
|
2353
|
+
static listCommitClones(provider, remoteOrganizationName, repositoryName, commitUuid, status, onlyPotential, cursor, limit = 100, abortSignal) {
|
|
2354
|
+
return request(OpenAPI, {
|
|
2355
|
+
method: "GET",
|
|
2356
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/commits/{commitUuid}/clones",
|
|
2357
|
+
path: {
|
|
2358
|
+
"provider": provider,
|
|
2359
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2360
|
+
"repositoryName": repositoryName,
|
|
2361
|
+
"commitUuid": commitUuid
|
|
2362
|
+
},
|
|
2363
|
+
query: {
|
|
2364
|
+
"status": status,
|
|
2365
|
+
"onlyPotential": onlyPotential,
|
|
2366
|
+
"cursor": cursor,
|
|
2367
|
+
"limit": limit
|
|
2368
|
+
},
|
|
2369
|
+
abortSignal,
|
|
2370
|
+
errors: {
|
|
2371
|
+
400: `Bad Request`,
|
|
2372
|
+
401: `Unauthorized`,
|
|
2373
|
+
404: `Not Found`,
|
|
2374
|
+
422: `Unprocessable Entity`,
|
|
2375
|
+
500: `Internal Server Error`
|
|
2376
|
+
}
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2379
|
+
/**
|
|
2380
|
+
* Get analysis logs for a pull request
|
|
2381
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param pullRequestNumber Pull request number * @returns LogsResponse Successful operation
|
|
2382
|
+
* @throws ApiError
|
|
2383
|
+
*/
|
|
2384
|
+
static listPullRequestLogs(provider, remoteOrganizationName, repositoryName, pullRequestNumber, abortSignal) {
|
|
2385
|
+
return request(OpenAPI, {
|
|
2386
|
+
method: "GET",
|
|
2387
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/pull-requests/{pullRequestNumber}/logs",
|
|
2388
|
+
path: {
|
|
2389
|
+
"provider": provider,
|
|
2390
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2391
|
+
"repositoryName": repositoryName,
|
|
2392
|
+
"pullRequestNumber": pullRequestNumber
|
|
2393
|
+
},
|
|
2394
|
+
abortSignal,
|
|
2395
|
+
errors: {
|
|
2396
|
+
400: `Bad Request`,
|
|
2397
|
+
401: `Unauthorized`,
|
|
2398
|
+
404: `Not Found`,
|
|
2399
|
+
422: `Unprocessable Entity`,
|
|
2400
|
+
500: `Internal Server Error`
|
|
2401
|
+
}
|
|
2402
|
+
});
|
|
2403
|
+
}
|
|
2404
|
+
/**
|
|
2405
|
+
* Get analysis logs for a commit
|
|
2406
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param commitUuid UUID or SHA identifier of the source commit * @returns LogsResponse Successful operation
|
|
2407
|
+
* @throws ApiError
|
|
2408
|
+
*/
|
|
2409
|
+
static listCommitLogs(provider, remoteOrganizationName, repositoryName, commitUuid, abortSignal) {
|
|
2410
|
+
return request(OpenAPI, {
|
|
2411
|
+
method: "GET",
|
|
2412
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/commits/{commitUuid}/logs",
|
|
2413
|
+
path: {
|
|
2414
|
+
"provider": provider,
|
|
2415
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2416
|
+
"repositoryName": repositoryName,
|
|
2417
|
+
"commitUuid": commitUuid
|
|
2418
|
+
},
|
|
2419
|
+
abortSignal,
|
|
2420
|
+
errors: {
|
|
2421
|
+
400: `Bad Request`,
|
|
2422
|
+
401: `Unauthorized`,
|
|
2423
|
+
404: `Not Found`,
|
|
2424
|
+
422: `Unprocessable Entity`,
|
|
2425
|
+
500: `Internal Server Error`
|
|
2426
|
+
}
|
|
2427
|
+
});
|
|
2428
|
+
}
|
|
2429
|
+
/**
|
|
2430
|
+
* @deprecated
|
|
2431
|
+
* Get quality settings for the specific repository
|
|
2432
|
+
* **Deprecated:** Use [getQualitySettingsForRepository](#getqualitysettingsforrepository) instead.
|
|
2433
|
+
*
|
|
2434
|
+
* **Note:** When applied to public repositories, this operation does not require authentication.
|
|
2435
|
+
*
|
|
2436
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns DeprecatedRepositoryQualitySettingsResponse Successful operation
|
|
2437
|
+
* @throws ApiError
|
|
2438
|
+
*/
|
|
2439
|
+
static getRepositoryQualitySettings(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
2440
|
+
return request(OpenAPI, {
|
|
2441
|
+
method: "GET",
|
|
2442
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/quality-settings",
|
|
2443
|
+
path: {
|
|
2444
|
+
"provider": provider,
|
|
2445
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2446
|
+
"repositoryName": repositoryName
|
|
2447
|
+
},
|
|
2448
|
+
abortSignal,
|
|
2449
|
+
errors: {
|
|
2450
|
+
400: `Bad Request`,
|
|
2451
|
+
401: `Unauthorized`,
|
|
2452
|
+
404: `Not Found`,
|
|
2453
|
+
422: `Unprocessable Entity`,
|
|
2454
|
+
500: `Internal Server Error`
|
|
2455
|
+
}
|
|
2456
|
+
});
|
|
2457
|
+
}
|
|
2458
|
+
/**
|
|
2459
|
+
* List files of a commit with analysis results
|
|
2460
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param commitUuid UUID or SHA string that identifies the commit* @param branch Name of a [repository branch enabled on Codacy](https://docs.codacy.com/repositories-configure/managing-branches/),
|
|
2461
|
+
* as returned by the endpoint [listRepositoryBranches](#listrepositorybranches).
|
|
2462
|
+
* By default, uses the main branch defined on the Codacy repository settings.
|
|
2463
|
+
* * @param filter Optional field to filter the results. The possible values are empty (default, return files changed in the commit or with coverage changes) or `withCoverageChanges` (return files with coverage changes)
|
|
2464
|
+
* * @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return* @param search Filter files that include this string anywhere in their relative path* @param sortColumn Field used to sort the results. The possible values are `deltaCoverage` (to sort by the coverage variation value of the files), `totalCoverage` (to sort by the total coverage value of the files) or `filename` (default - to sort by the name of the files)
|
|
2465
|
+
* * @param columnOrder Sort direction. The possible values are `asc` (ascending - default) or `desc` (descending). * @returns FileAnalysisListResponse Successful operation
|
|
2466
|
+
* @throws ApiError
|
|
2467
|
+
*/
|
|
2468
|
+
static listCommitFiles(provider, remoteOrganizationName, repositoryName, commitUuid, branch, filter, cursor, limit = 100, search, sortColumn = "filename", columnOrder = "asc", abortSignal) {
|
|
2469
|
+
return request(OpenAPI, {
|
|
2470
|
+
method: "GET",
|
|
2471
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/commits/{commitUuid}/files",
|
|
2472
|
+
path: {
|
|
2473
|
+
"provider": provider,
|
|
2474
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2475
|
+
"repositoryName": repositoryName,
|
|
2476
|
+
"commitUuid": commitUuid
|
|
2477
|
+
},
|
|
2478
|
+
query: {
|
|
2479
|
+
"branch": branch,
|
|
2480
|
+
"filter": filter,
|
|
2481
|
+
"cursor": cursor,
|
|
2482
|
+
"limit": limit,
|
|
2483
|
+
"search": search,
|
|
2484
|
+
"sortColumn": sortColumn,
|
|
2485
|
+
"columnOrder": columnOrder
|
|
2486
|
+
},
|
|
2487
|
+
abortSignal,
|
|
2488
|
+
errors: {
|
|
2489
|
+
400: `Bad Request`,
|
|
2490
|
+
401: `Unauthorized`,
|
|
2491
|
+
404: `Not Found`,
|
|
2492
|
+
422: `Unprocessable Entity`,
|
|
2493
|
+
500: `Internal Server Error`
|
|
2494
|
+
}
|
|
2495
|
+
});
|
|
2496
|
+
}
|
|
2497
|
+
/**
|
|
2498
|
+
* List files of a pull request with analysis results
|
|
2499
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param pullRequestNumber Pull request number* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return* @param sortColumn Field used to sort the results. The possible values are `deltaCoverage` (to sort by the coverage variation value of the files), `totalCoverage` (to sort by the total coverage value of the files) or `filename` (default - to sort by the name of the files)
|
|
2500
|
+
* * @param columnOrder Sort direction. The possible values are `asc` (ascending - default) or `desc` (descending). * @returns FileAnalysisListResponse Successful operation
|
|
2501
|
+
* @throws ApiError
|
|
2502
|
+
*/
|
|
2503
|
+
static listPullRequestFiles(provider, remoteOrganizationName, repositoryName, pullRequestNumber, cursor, limit = 100, sortColumn = "filename", columnOrder = "asc", abortSignal) {
|
|
2504
|
+
return request(OpenAPI, {
|
|
2505
|
+
method: "GET",
|
|
2506
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/pull-requests/{pullRequestNumber}/files",
|
|
2507
|
+
path: {
|
|
2508
|
+
"provider": provider,
|
|
2509
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2510
|
+
"repositoryName": repositoryName,
|
|
2511
|
+
"pullRequestNumber": pullRequestNumber
|
|
2512
|
+
},
|
|
2513
|
+
query: {
|
|
2514
|
+
"cursor": cursor,
|
|
2515
|
+
"limit": limit,
|
|
2516
|
+
"sortColumn": sortColumn,
|
|
2517
|
+
"columnOrder": columnOrder
|
|
2518
|
+
},
|
|
2519
|
+
abortSignal,
|
|
2520
|
+
errors: {
|
|
2521
|
+
400: `Bad Request`,
|
|
2522
|
+
401: `Unauthorized`,
|
|
2523
|
+
404: `Not Found`,
|
|
2524
|
+
422: `Unprocessable Entity`,
|
|
2525
|
+
500: `Internal Server Error`
|
|
2526
|
+
}
|
|
2527
|
+
});
|
|
2528
|
+
}
|
|
2529
|
+
/**
|
|
2530
|
+
* List organization pull requests from repositories that the user has access to
|
|
2531
|
+
* You can sort by `last-updated` (default), `impact`, or `merged`
|
|
2532
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param limit Maximum number of items to return* @param search Filter results by searching for this string* @param repositories **Deprecated:** Use [searchOrganizationRepositoriesWithAnalysis](#searchorganizationrepositorieswithanalysis) instead. * @returns PullRequestWithAnalysisListResponse Successful operation
|
|
2533
|
+
* @throws ApiError
|
|
2534
|
+
*/
|
|
2535
|
+
static listOrganizationPullRequests(provider, remoteOrganizationName, limit = 100, search, repositories, abortSignal) {
|
|
2536
|
+
return request(OpenAPI, {
|
|
2537
|
+
method: "GET",
|
|
2538
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/pull-requests",
|
|
2539
|
+
path: {
|
|
2540
|
+
"provider": provider,
|
|
2541
|
+
"remoteOrganizationName": remoteOrganizationName
|
|
2542
|
+
},
|
|
2543
|
+
query: {
|
|
2544
|
+
"limit": limit,
|
|
2545
|
+
"search": search,
|
|
2546
|
+
"repositories": repositories
|
|
2547
|
+
},
|
|
2548
|
+
abortSignal,
|
|
2549
|
+
errors: {
|
|
2550
|
+
400: `Bad Request`,
|
|
2551
|
+
401: `Unauthorized`,
|
|
2552
|
+
404: `Not Found`,
|
|
2553
|
+
422: `Unprocessable Entity`,
|
|
2554
|
+
500: `Internal Server Error`
|
|
2555
|
+
}
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
/**
|
|
2559
|
+
* List commit analysis statistics for the last n days that have analysis data
|
|
2560
|
+
* Returns the last `n` days with available data. This means that the returned days may not match the last `n` calendar days.
|
|
2561
|
+
*
|
|
2562
|
+
* **Note:** When applied to public repositories, this operation does not require authentication.
|
|
2563
|
+
*
|
|
2564
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param branch Name of a [repository branch enabled on Codacy](https://docs.codacy.com/repositories-configure/managing-branches/),
|
|
2565
|
+
* as returned by the endpoint [listRepositoryBranches](#listrepositorybranches).
|
|
2566
|
+
* By default, uses the main branch defined on the Codacy repository settings.
|
|
2567
|
+
* * @param days Number of days of data to return (1-365, defaults to 31) * @returns CommitAnalysisStatsListResponse Successful operation
|
|
2568
|
+
* @throws ApiError
|
|
2569
|
+
*/
|
|
2570
|
+
static listCommitAnalysisStats(provider, remoteOrganizationName, repositoryName, branch, days = 31, abortSignal) {
|
|
2571
|
+
return request(OpenAPI, {
|
|
2572
|
+
method: "GET",
|
|
2573
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/commit-statistics",
|
|
2574
|
+
path: {
|
|
2575
|
+
"provider": provider,
|
|
2576
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2577
|
+
"repositoryName": repositoryName
|
|
2578
|
+
},
|
|
2579
|
+
query: {
|
|
2580
|
+
"branch": branch,
|
|
2581
|
+
"days": days
|
|
2582
|
+
},
|
|
2583
|
+
abortSignal,
|
|
2584
|
+
errors: {
|
|
2585
|
+
400: `Bad Request`,
|
|
2586
|
+
401: `Unauthorized`,
|
|
2587
|
+
404: `Not Found`,
|
|
2588
|
+
422: `Unprocessable Entity`,
|
|
2589
|
+
500: `Internal Server Error`
|
|
2590
|
+
}
|
|
2591
|
+
});
|
|
2592
|
+
}
|
|
2593
|
+
/**
|
|
2594
|
+
* List analysis category overviews for a repository that the user has access to
|
|
2595
|
+
* **Note:** When applied to public repositories, this operation does not require authentication.
|
|
2596
|
+
*
|
|
2597
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param branch Name of a [repository branch enabled on Codacy](https://docs.codacy.com/repositories-configure/managing-branches/),
|
|
2598
|
+
* as returned by the endpoint [listRepositoryBranches](#listrepositorybranches).
|
|
2599
|
+
* By default, uses the main branch defined on the Codacy repository settings.
|
|
2600
|
+
* * @returns CategoryOverviewListResponse Successful operation
|
|
2601
|
+
* @throws ApiError
|
|
2602
|
+
*/
|
|
2603
|
+
static listCategoryOverviews(provider, remoteOrganizationName, repositoryName, branch, abortSignal) {
|
|
2604
|
+
return request(OpenAPI, {
|
|
2605
|
+
method: "GET",
|
|
2606
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/category-overviews",
|
|
2607
|
+
path: {
|
|
2608
|
+
"provider": provider,
|
|
2609
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2610
|
+
"repositoryName": repositoryName
|
|
2611
|
+
},
|
|
2612
|
+
query: {
|
|
2613
|
+
"branch": branch
|
|
2614
|
+
},
|
|
2615
|
+
abortSignal,
|
|
2616
|
+
errors: {
|
|
2617
|
+
400: `Bad Request`,
|
|
2618
|
+
401: `Unauthorized`,
|
|
2619
|
+
404: `Not Found`,
|
|
2620
|
+
422: `Unprocessable Entity`,
|
|
2621
|
+
500: `Internal Server Error`
|
|
2622
|
+
}
|
|
2623
|
+
});
|
|
2624
|
+
}
|
|
2625
|
+
/**
|
|
2626
|
+
* List issues in a repository
|
|
2627
|
+
* Returns information about the issues that Codacy found in a repository as available on the [Issues page](https://docs.codacy.com/repositories/issues-view/).
|
|
2628
|
+
* Use [SearchRepositoryIssuesBody](#tocssearchrepositoryissuesbody) to filter the returned issues.
|
|
2629
|
+
*
|
|
2630
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return* @param requestBody Only return issues matching these filters * @returns SearchRepositoryIssuesListResponse List of issues in the repository
|
|
2631
|
+
* @throws ApiError
|
|
2632
|
+
*/
|
|
2633
|
+
static searchRepositoryIssues(provider, remoteOrganizationName, repositoryName, cursor, limit = 100, requestBody, abortSignal) {
|
|
2634
|
+
return request(OpenAPI, {
|
|
2635
|
+
method: "POST",
|
|
2636
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/issues/search",
|
|
2637
|
+
path: {
|
|
2638
|
+
"provider": provider,
|
|
2639
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2640
|
+
"repositoryName": repositoryName
|
|
2641
|
+
},
|
|
2642
|
+
query: {
|
|
2643
|
+
"cursor": cursor,
|
|
2644
|
+
"limit": limit
|
|
2645
|
+
},
|
|
2646
|
+
abortSignal,
|
|
2647
|
+
body: requestBody,
|
|
2648
|
+
mediaType: "application/json",
|
|
2649
|
+
errors: {
|
|
2650
|
+
400: `Bad Request`,
|
|
2651
|
+
401: `Unauthorized`,
|
|
2652
|
+
404: `Not Found`,
|
|
2653
|
+
422: `Unprocessable Entity`,
|
|
2654
|
+
500: `Internal Server Error`
|
|
2655
|
+
}
|
|
2656
|
+
});
|
|
2657
|
+
}
|
|
2658
|
+
/**
|
|
2659
|
+
* Bulk ignore issues in a repository
|
|
2660
|
+
* Receives a list of issue ids and ignores them in the specified repository. Limited to 50 issues at once
|
|
2661
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param requestBody List of issue ids to ignore * @returns void
|
|
2662
|
+
* @throws ApiError
|
|
2663
|
+
*/
|
|
2664
|
+
static bulkIgnoreIssues(provider, remoteOrganizationName, repositoryName, requestBody, abortSignal) {
|
|
2665
|
+
return request(OpenAPI, {
|
|
2666
|
+
method: "POST",
|
|
2667
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/issues/bulk-ignore",
|
|
2668
|
+
path: {
|
|
2669
|
+
"provider": provider,
|
|
2670
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2671
|
+
"repositoryName": repositoryName
|
|
2672
|
+
},
|
|
2673
|
+
abortSignal,
|
|
2674
|
+
body: requestBody,
|
|
2675
|
+
mediaType: "application/json",
|
|
2676
|
+
errors: {
|
|
2677
|
+
400: `Bad Request`,
|
|
2678
|
+
401: `Unauthorized`,
|
|
2679
|
+
404: `Not Found`,
|
|
2680
|
+
422: `Unprocessable Entity`,
|
|
2681
|
+
500: `Internal Server Error`
|
|
2682
|
+
}
|
|
2683
|
+
});
|
|
2684
|
+
}
|
|
2685
|
+
/**
|
|
2686
|
+
* Get an overview of the issues in a repository
|
|
2687
|
+
* Returns information about the number of issues that Codacy found in a repository as available on the [Issues page](https://docs.codacy.com/repositories/issues-view/).
|
|
2688
|
+
* Use [SearchRepositoryIssuesBody](#tocssearchrepositoryissuesbody) to filter the returned issues.
|
|
2689
|
+
*
|
|
2690
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param requestBody Only return issues matching these filters * @returns IssuesOverviewResponse Overview of the issues in the repository
|
|
2691
|
+
* @throws ApiError
|
|
2692
|
+
*/
|
|
2693
|
+
static issuesOverview(provider, remoteOrganizationName, repositoryName, requestBody, abortSignal) {
|
|
2694
|
+
return request(OpenAPI, {
|
|
2695
|
+
method: "POST",
|
|
2696
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/issues/overview",
|
|
2697
|
+
path: {
|
|
2698
|
+
"provider": provider,
|
|
2699
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2700
|
+
"repositoryName": repositoryName
|
|
2701
|
+
},
|
|
2702
|
+
abortSignal,
|
|
2703
|
+
body: requestBody,
|
|
2704
|
+
mediaType: "application/json",
|
|
2705
|
+
errors: {
|
|
2706
|
+
400: `Bad Request`,
|
|
2707
|
+
401: `Unauthorized`,
|
|
2708
|
+
404: `Not Found`,
|
|
2709
|
+
422: `Unprocessable Entity`,
|
|
2710
|
+
500: `Internal Server Error`
|
|
2711
|
+
}
|
|
2712
|
+
});
|
|
2713
|
+
}
|
|
2714
|
+
/**
|
|
2715
|
+
* Get information about an open issue in a repository
|
|
2716
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param issueId Identifier of an open issue * @returns GetIssueResponse An issue found in a repository.
|
|
2717
|
+
* @throws ApiError
|
|
2718
|
+
*/
|
|
2719
|
+
static getIssue(provider, remoteOrganizationName, repositoryName, issueId, abortSignal) {
|
|
2720
|
+
return request(OpenAPI, {
|
|
2721
|
+
method: "GET",
|
|
2722
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/issues/{issueId}",
|
|
2723
|
+
path: {
|
|
2724
|
+
"provider": provider,
|
|
2725
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2726
|
+
"repositoryName": repositoryName,
|
|
2727
|
+
"issueId": issueId
|
|
2728
|
+
},
|
|
2729
|
+
abortSignal,
|
|
2730
|
+
errors: {
|
|
2731
|
+
400: `Bad Request`,
|
|
2732
|
+
401: `Unauthorized`,
|
|
2733
|
+
404: `Not Found`,
|
|
2734
|
+
422: `Unprocessable Entity`,
|
|
2735
|
+
500: `Internal Server Error`
|
|
2736
|
+
}
|
|
2737
|
+
});
|
|
2738
|
+
}
|
|
2739
|
+
/**
|
|
2740
|
+
* Ignore or unignore an issue
|
|
2741
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param issueId Issue identifier* @param requestBody New ignored status of the issue * @returns void
|
|
2742
|
+
* @throws ApiError
|
|
2743
|
+
*/
|
|
2744
|
+
static updateIssueState(provider, remoteOrganizationName, repositoryName, issueId, requestBody, abortSignal) {
|
|
2745
|
+
return request(OpenAPI, {
|
|
2746
|
+
method: "PATCH",
|
|
2747
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/issues/{issueId}",
|
|
2748
|
+
path: {
|
|
2749
|
+
"provider": provider,
|
|
2750
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2751
|
+
"repositoryName": repositoryName,
|
|
2752
|
+
"issueId": issueId
|
|
2753
|
+
},
|
|
2754
|
+
abortSignal,
|
|
2755
|
+
body: requestBody,
|
|
2756
|
+
mediaType: "application/json",
|
|
2757
|
+
errors: {
|
|
2758
|
+
400: `Bad Request`,
|
|
2759
|
+
401: `Unauthorized`,
|
|
2760
|
+
404: `Not Found`,
|
|
2761
|
+
422: `Unprocessable Entity`,
|
|
2762
|
+
500: `Internal Server Error`
|
|
2763
|
+
}
|
|
2764
|
+
});
|
|
2765
|
+
}
|
|
2766
|
+
/**
|
|
2767
|
+
* Ignore the false positive result in an issue
|
|
2768
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param issueId Issue identifier * @returns void
|
|
2769
|
+
* @throws ApiError
|
|
2770
|
+
*/
|
|
2771
|
+
static ignoreFalsePositive(provider, remoteOrganizationName, repositoryName, issueId, abortSignal) {
|
|
2772
|
+
return request(OpenAPI, {
|
|
2773
|
+
method: "PATCH",
|
|
2774
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/issues/{issueId}/false-positive/ignore",
|
|
2775
|
+
path: {
|
|
2776
|
+
"provider": provider,
|
|
2777
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2778
|
+
"repositoryName": repositoryName,
|
|
2779
|
+
"issueId": issueId
|
|
2780
|
+
},
|
|
2781
|
+
abortSignal,
|
|
2782
|
+
errors: {
|
|
2783
|
+
400: `Bad Request`,
|
|
2784
|
+
401: `Unauthorized`,
|
|
2785
|
+
404: `Not Found`,
|
|
2786
|
+
409: `Conflict`,
|
|
2787
|
+
422: `Unprocessable Entity`,
|
|
2788
|
+
500: `Internal Server Error`
|
|
2789
|
+
}
|
|
2790
|
+
});
|
|
2791
|
+
}
|
|
2792
|
+
/**
|
|
2793
|
+
* List ignored issues in a repository
|
|
2794
|
+
* Ignored issues are issues that Codacy found but were marked as ignored on the Codacy UI. Use [SearchRepositoryIssuesBody](#tocssearchrepositoryissuesbody) to filter results.
|
|
2795
|
+
*
|
|
2796
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return* @param requestBody Only return issues matching these filters * @returns IgnoredIssuesListResponse List of ignored issues in the repository
|
|
2797
|
+
* @throws ApiError
|
|
2798
|
+
*/
|
|
2799
|
+
static searchRepositoryIgnoredIssues(provider, remoteOrganizationName, repositoryName, cursor, limit = 100, requestBody, abortSignal) {
|
|
2800
|
+
return request(OpenAPI, {
|
|
2801
|
+
method: "POST",
|
|
2802
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/ignoredIssues/search",
|
|
2803
|
+
path: {
|
|
2804
|
+
"provider": provider,
|
|
2805
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2806
|
+
"repositoryName": repositoryName
|
|
2807
|
+
},
|
|
2808
|
+
query: {
|
|
2809
|
+
"cursor": cursor,
|
|
2810
|
+
"limit": limit
|
|
2811
|
+
},
|
|
2812
|
+
abortSignal,
|
|
2813
|
+
body: requestBody,
|
|
2814
|
+
mediaType: "application/json",
|
|
2815
|
+
errors: {
|
|
2816
|
+
400: `Bad Request`,
|
|
2817
|
+
401: `Unauthorized`,
|
|
2818
|
+
404: `Not Found`,
|
|
2819
|
+
422: `Unprocessable Entity`,
|
|
2820
|
+
500: `Internal Server Error`
|
|
2821
|
+
}
|
|
2822
|
+
});
|
|
2823
|
+
}
|
|
2824
|
+
/**
|
|
2825
|
+
* Return analysis results for the commits in a branch
|
|
2826
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param branch Name of a [repository branch enabled on Codacy](https://docs.codacy.com/repositories-configure/managing-branches/),
|
|
2827
|
+
* as returned by the endpoint [listRepositoryBranches](#listrepositorybranches).
|
|
2828
|
+
* By default, uses the main branch defined on the Codacy repository settings.
|
|
2829
|
+
* * @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns CommitWithAnalysisListResponse List of commits with analysis results
|
|
2830
|
+
* @throws ApiError
|
|
2831
|
+
*/
|
|
2832
|
+
static listRepositoryCommits(provider, remoteOrganizationName, repositoryName, branch, cursor, limit = 100, abortSignal) {
|
|
2833
|
+
return request(OpenAPI, {
|
|
2834
|
+
method: "GET",
|
|
2835
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/commits",
|
|
2836
|
+
path: {
|
|
2837
|
+
"provider": provider,
|
|
2838
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2839
|
+
"repositoryName": repositoryName
|
|
2840
|
+
},
|
|
2841
|
+
query: {
|
|
2842
|
+
"branch": branch,
|
|
2843
|
+
"cursor": cursor,
|
|
2844
|
+
"limit": limit
|
|
2845
|
+
},
|
|
2846
|
+
abortSignal,
|
|
2847
|
+
errors: {
|
|
2848
|
+
400: `Bad Request`,
|
|
2849
|
+
401: `Unauthorized`,
|
|
2850
|
+
404: `Not Found`,
|
|
2851
|
+
422: `Unprocessable Entity`,
|
|
2852
|
+
500: `Internal Server Error`
|
|
2853
|
+
}
|
|
2854
|
+
});
|
|
2855
|
+
}
|
|
2856
|
+
/**
|
|
2857
|
+
* Get analysis results for a commit
|
|
2858
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param commitUuid UUID or SHA string that identifies the commit * @returns CommitWithAnalysis Successful operation
|
|
2859
|
+
* @throws ApiError
|
|
2860
|
+
*/
|
|
2861
|
+
static getCommit(provider, remoteOrganizationName, repositoryName, commitUuid, abortSignal) {
|
|
2862
|
+
return request(OpenAPI, {
|
|
2863
|
+
method: "GET",
|
|
2864
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/commits/{commitUuid}",
|
|
2865
|
+
path: {
|
|
2866
|
+
"provider": provider,
|
|
2867
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2868
|
+
"repositoryName": repositoryName,
|
|
2869
|
+
"commitUuid": commitUuid
|
|
2870
|
+
},
|
|
2871
|
+
abortSignal,
|
|
2872
|
+
errors: {
|
|
2873
|
+
400: `Bad Request`,
|
|
2874
|
+
401: `Unauthorized`,
|
|
2875
|
+
403: `Forbidden`,
|
|
2876
|
+
404: `Not Found`,
|
|
2877
|
+
422: `Unprocessable Entity`,
|
|
2878
|
+
500: `Internal Server Error`
|
|
2879
|
+
}
|
|
2880
|
+
});
|
|
2881
|
+
}
|
|
2882
|
+
/**
|
|
2883
|
+
* Get analysis statistics of a commit
|
|
2884
|
+
* Returns the quality metric deltas introduced by a commit. The values of the metrics are 0 or null if Codacy didn't analyze the commit yet.
|
|
2885
|
+
* To obtain the full analysis statistics for the repository use the endpoint [getRepositoryWithAnalysis](#getrepositorywithanalysis).
|
|
2886
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param commitUuid UUID or SHA string that identifies the commit * @returns CommitDeltaStatistics Successful operation
|
|
2887
|
+
* @throws ApiError
|
|
2888
|
+
*/
|
|
2889
|
+
static getCommitDeltaStatistics(provider, remoteOrganizationName, repositoryName, commitUuid, abortSignal) {
|
|
2890
|
+
return request(OpenAPI, {
|
|
2891
|
+
method: "GET",
|
|
2892
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/commits/{commitUuid}/deltaStatistics",
|
|
2893
|
+
path: {
|
|
2894
|
+
"provider": provider,
|
|
2895
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2896
|
+
"repositoryName": repositoryName,
|
|
2897
|
+
"commitUuid": commitUuid
|
|
2898
|
+
},
|
|
2899
|
+
abortSignal,
|
|
2900
|
+
errors: {
|
|
2901
|
+
400: `Bad Request`,
|
|
2902
|
+
401: `Unauthorized`,
|
|
2903
|
+
404: `Not Found`,
|
|
2904
|
+
422: `Unprocessable Entity`,
|
|
2905
|
+
500: `Internal Server Error`
|
|
2906
|
+
}
|
|
2907
|
+
});
|
|
2908
|
+
}
|
|
2909
|
+
/**
|
|
2910
|
+
* List the issues introduced or fixed by a commit
|
|
2911
|
+
* Returns a list of issues introduced or fixed given a source commit SHA. By default, Codacy will calculate the issues by creating a delta between the source commit and its parent commit. As an alternative, you can also provide a destination commit to calculate the deltas.
|
|
2912
|
+
* To list all issues in the repository, use [searchRepositoryIssues](#searchrepositoryissues).
|
|
2913
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param srcCommitUuid UUID or SHA string that identifies the source commit* @param targetCommitUuid UUID or SHA string that identifies the target commit* @param status Filter issues by status. Valid values are `all`, `new`, or `fixed`.* @param onlyPotential Set to `true` to return only potential issues* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns CommitDeltaIssuesResponse Successful operation
|
|
2914
|
+
* @throws ApiError
|
|
2915
|
+
*/
|
|
2916
|
+
static listCommitDeltaIssues(provider, remoteOrganizationName, repositoryName, srcCommitUuid, targetCommitUuid, status, onlyPotential, cursor, limit = 100, abortSignal) {
|
|
2917
|
+
return request(OpenAPI, {
|
|
2918
|
+
method: "GET",
|
|
2919
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/commits/{srcCommitUuid}/deltaIssues",
|
|
2920
|
+
path: {
|
|
2921
|
+
"provider": provider,
|
|
2922
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2923
|
+
"repositoryName": repositoryName,
|
|
2924
|
+
"srcCommitUuid": srcCommitUuid
|
|
2925
|
+
},
|
|
2926
|
+
query: {
|
|
2927
|
+
"targetCommitUuid": targetCommitUuid,
|
|
2928
|
+
"status": status,
|
|
2929
|
+
"onlyPotential": onlyPotential,
|
|
2930
|
+
"cursor": cursor,
|
|
2931
|
+
"limit": limit
|
|
2932
|
+
},
|
|
2933
|
+
abortSignal,
|
|
2934
|
+
errors: {
|
|
2935
|
+
400: `Bad Request`,
|
|
2936
|
+
401: `Unauthorized`,
|
|
2937
|
+
404: `Not Found`,
|
|
2938
|
+
422: `Unprocessable Entity`,
|
|
2939
|
+
500: `Internal Server Error`
|
|
2940
|
+
}
|
|
2941
|
+
});
|
|
2942
|
+
}
|
|
2943
|
+
/**
|
|
2944
|
+
* @deprecated
|
|
2945
|
+
* Get information about a commit
|
|
2946
|
+
* Use `/commits/{commitId}` instead.
|
|
2947
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param commitId Identifier of the commit * @returns CommitDetails Details about the commit.
|
|
2948
|
+
* @throws ApiError
|
|
2949
|
+
*/
|
|
2950
|
+
static getCommitDetails(provider, remoteOrganizationName, commitId, abortSignal) {
|
|
2951
|
+
return request(OpenAPI, {
|
|
2952
|
+
method: "GET",
|
|
2953
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/commit/{commitId}",
|
|
2954
|
+
path: {
|
|
2955
|
+
"provider": provider,
|
|
2956
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
2957
|
+
"commitId": commitId
|
|
2958
|
+
},
|
|
2959
|
+
abortSignal,
|
|
2960
|
+
errors: {
|
|
2961
|
+
400: `Bad Request`,
|
|
2962
|
+
401: `Unauthorized`,
|
|
2963
|
+
403: `Forbidden`,
|
|
2964
|
+
404: `Not Found`,
|
|
2965
|
+
422: `Unprocessable Entity`,
|
|
2966
|
+
500: `Internal Server Error`
|
|
2967
|
+
}
|
|
2968
|
+
});
|
|
2969
|
+
}
|
|
2970
|
+
/**
|
|
2971
|
+
* Get information about a commit
|
|
2972
|
+
* @param commitId Identifier of the commit * @returns CommitDetailsV2 Details about the commit.
|
|
2973
|
+
* @throws ApiError
|
|
2974
|
+
*/
|
|
2975
|
+
static getCommitDetailsByCommitId(commitId, abortSignal) {
|
|
2976
|
+
return request(OpenAPI, {
|
|
2977
|
+
method: "GET",
|
|
2978
|
+
url: "/commits/{commitId}",
|
|
2979
|
+
path: {
|
|
2980
|
+
"commitId": commitId
|
|
2981
|
+
},
|
|
2982
|
+
abortSignal,
|
|
2983
|
+
errors: {
|
|
2984
|
+
400: `Bad Request`,
|
|
2985
|
+
401: `Unauthorized`,
|
|
2986
|
+
403: `Forbidden`,
|
|
2987
|
+
404: `Not Found`,
|
|
2988
|
+
422: `Unprocessable Entity`,
|
|
2989
|
+
500: `Internal Server Error`
|
|
2990
|
+
}
|
|
2991
|
+
});
|
|
2992
|
+
}
|
|
2993
|
+
/**
|
|
2994
|
+
* Check if the repository has quick fix suggestions for a branch
|
|
2995
|
+
* If branch is not provided, the default branch is used.
|
|
2996
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param branch Name of a [repository branch enabled on Codacy](https://docs.codacy.com/repositories-configure/managing-branches/),
|
|
2997
|
+
* as returned by the endpoint [listRepositoryBranches](#listrepositorybranches).
|
|
2998
|
+
* By default, uses the main branch defined on the Codacy repository settings.
|
|
2999
|
+
* * @returns HasQuickfixSuggestionsResponse Successful operation
|
|
3000
|
+
* @throws ApiError
|
|
3001
|
+
*/
|
|
3002
|
+
static hasQuickfixSuggestions(provider, remoteOrganizationName, repositoryName, branch, abortSignal) {
|
|
3003
|
+
return request(OpenAPI, {
|
|
3004
|
+
method: "GET",
|
|
3005
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/issues/hasSuggestions",
|
|
3006
|
+
path: {
|
|
3007
|
+
"provider": provider,
|
|
3008
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3009
|
+
"repositoryName": repositoryName
|
|
3010
|
+
},
|
|
3011
|
+
query: {
|
|
3012
|
+
"branch": branch
|
|
3013
|
+
},
|
|
3014
|
+
abortSignal,
|
|
3015
|
+
errors: {
|
|
3016
|
+
400: `Bad Request`,
|
|
3017
|
+
401: `Unauthorized`,
|
|
3018
|
+
404: `Not Found`,
|
|
3019
|
+
422: `Unprocessable Entity`,
|
|
3020
|
+
500: `Internal Server Error`
|
|
3021
|
+
}
|
|
3022
|
+
});
|
|
3023
|
+
}
|
|
3024
|
+
/**
|
|
3025
|
+
* Get quickfixes for issues in patch format
|
|
3026
|
+
* If branch is not provided, the default branch is used.
|
|
3027
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param branch Name of a [repository branch enabled on Codacy](https://docs.codacy.com/repositories-configure/managing-branches/),
|
|
3028
|
+
* as returned by the endpoint [listRepositoryBranches](#listrepositorybranches).
|
|
3029
|
+
* By default, uses the main branch defined on the Codacy repository settings.
|
|
3030
|
+
* * @returns QuickfixPatchResponse Successful operation
|
|
3031
|
+
* @throws ApiError
|
|
3032
|
+
*/
|
|
3033
|
+
static getQuickfixesPatch(provider, remoteOrganizationName, repositoryName, branch, abortSignal) {
|
|
3034
|
+
return request(OpenAPI, {
|
|
3035
|
+
method: "GET",
|
|
3036
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/issues/patch",
|
|
3037
|
+
path: {
|
|
3038
|
+
"provider": provider,
|
|
3039
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3040
|
+
"repositoryName": repositoryName
|
|
3041
|
+
},
|
|
3042
|
+
query: {
|
|
3043
|
+
"branch": branch
|
|
3044
|
+
},
|
|
3045
|
+
abortSignal,
|
|
3046
|
+
errors: {
|
|
3047
|
+
400: `Bad Request`,
|
|
3048
|
+
401: `Unauthorized`,
|
|
3049
|
+
404: `Not Found`,
|
|
3050
|
+
422: `Unprocessable Entity`,
|
|
3051
|
+
500: `Internal Server Error`
|
|
3052
|
+
}
|
|
3053
|
+
});
|
|
3054
|
+
}
|
|
3055
|
+
/**
|
|
3056
|
+
* Get quickfixes for pull request issues in patch format
|
|
3057
|
+
* If branch is not provided, the default branch is used.
|
|
3058
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param pullRequestNumber Pull request number * @returns QuickfixPatchResponse Successful operation
|
|
3059
|
+
* @throws ApiError
|
|
3060
|
+
*/
|
|
3061
|
+
static getPullRequestQuickfixesPatch(provider, remoteOrganizationName, repositoryName, pullRequestNumber, abortSignal) {
|
|
3062
|
+
return request(OpenAPI, {
|
|
3063
|
+
method: "GET",
|
|
3064
|
+
url: "/analysis/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/pull-requests/{pullRequestNumber}/issues/patch",
|
|
3065
|
+
path: {
|
|
3066
|
+
"provider": provider,
|
|
3067
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3068
|
+
"repositoryName": repositoryName,
|
|
3069
|
+
"pullRequestNumber": pullRequestNumber
|
|
3070
|
+
},
|
|
3071
|
+
abortSignal,
|
|
3072
|
+
errors: {
|
|
3073
|
+
400: `Bad Request`,
|
|
3074
|
+
401: `Unauthorized`,
|
|
3075
|
+
404: `Not Found`,
|
|
3076
|
+
422: `Unprocessable Entity`,
|
|
3077
|
+
500: `Internal Server Error`
|
|
3078
|
+
}
|
|
3079
|
+
});
|
|
3080
|
+
}
|
|
3081
|
+
};
|
|
3082
|
+
|
|
3083
|
+
// src/api/client/services/RepositoryService.ts
|
|
3084
|
+
var RepositoryService = class {
|
|
3085
|
+
/**
|
|
3086
|
+
* Follow a repository that was already added to Codacy
|
|
3087
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns AddedStateResponse Successful operation
|
|
3088
|
+
* @throws ApiError
|
|
3089
|
+
*/
|
|
3090
|
+
static followAddedRepository(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3091
|
+
return request(OpenAPI, {
|
|
3092
|
+
method: "POST",
|
|
3093
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/follow",
|
|
3094
|
+
path: {
|
|
3095
|
+
"provider": provider,
|
|
3096
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3097
|
+
"repositoryName": repositoryName
|
|
3098
|
+
},
|
|
3099
|
+
abortSignal,
|
|
3100
|
+
errors: {
|
|
3101
|
+
400: `Bad Request`,
|
|
3102
|
+
401: `Unauthorized`,
|
|
3103
|
+
404: `Not Found`,
|
|
3104
|
+
422: `Unprocessable Entity`,
|
|
3105
|
+
500: `Internal Server Error`
|
|
3106
|
+
}
|
|
3107
|
+
});
|
|
3108
|
+
}
|
|
3109
|
+
/**
|
|
3110
|
+
* Unfollow a repository
|
|
3111
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns void
|
|
3112
|
+
* @throws ApiError
|
|
3113
|
+
*/
|
|
3114
|
+
static unfollowRepository(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3115
|
+
return request(OpenAPI, {
|
|
3116
|
+
method: "DELETE",
|
|
3117
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/follow",
|
|
3118
|
+
path: {
|
|
3119
|
+
"provider": provider,
|
|
3120
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3121
|
+
"repositoryName": repositoryName
|
|
3122
|
+
},
|
|
3123
|
+
abortSignal,
|
|
3124
|
+
errors: {
|
|
3125
|
+
400: `Bad Request`,
|
|
3126
|
+
401: `Unauthorized`,
|
|
3127
|
+
404: `Not Found`,
|
|
3128
|
+
422: `Unprocessable Entity`,
|
|
3129
|
+
500: `Internal Server Error`
|
|
3130
|
+
}
|
|
3131
|
+
});
|
|
3132
|
+
}
|
|
3133
|
+
/**
|
|
3134
|
+
* Get quality settings for the specific repository
|
|
3135
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns RepositoryQualitySettingsResponse Successful operation
|
|
3136
|
+
* @throws ApiError
|
|
3137
|
+
*/
|
|
3138
|
+
static getQualitySettingsForRepository(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3139
|
+
return request(OpenAPI, {
|
|
3140
|
+
method: "GET",
|
|
3141
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/quality/repository",
|
|
3142
|
+
path: {
|
|
3143
|
+
"provider": provider,
|
|
3144
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3145
|
+
"repositoryName": repositoryName
|
|
3146
|
+
},
|
|
3147
|
+
abortSignal,
|
|
3148
|
+
errors: {
|
|
3149
|
+
400: `Bad Request`,
|
|
3150
|
+
401: `Unauthorized`,
|
|
3151
|
+
404: `Not Found`,
|
|
3152
|
+
422: `Unprocessable Entity`,
|
|
3153
|
+
500: `Internal Server Error`
|
|
3154
|
+
}
|
|
3155
|
+
});
|
|
3156
|
+
}
|
|
3157
|
+
/**
|
|
3158
|
+
* Update quality goals settings for the specific repository
|
|
3159
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param requestBody The new value for the quality goals of the repository * @returns RepositoryQualitySettingsResponse Successful operation
|
|
3160
|
+
* @throws ApiError
|
|
3161
|
+
*/
|
|
3162
|
+
static updateRepositoryQualitySettings(provider, remoteOrganizationName, repositoryName, requestBody, abortSignal) {
|
|
3163
|
+
return request(OpenAPI, {
|
|
3164
|
+
method: "PUT",
|
|
3165
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/quality/repository",
|
|
3166
|
+
path: {
|
|
3167
|
+
"provider": provider,
|
|
3168
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3169
|
+
"repositoryName": repositoryName
|
|
3170
|
+
},
|
|
3171
|
+
abortSignal,
|
|
3172
|
+
body: requestBody,
|
|
3173
|
+
mediaType: "application/json",
|
|
3174
|
+
errors: {
|
|
3175
|
+
400: `Bad Request`,
|
|
3176
|
+
401: `Unauthorized`,
|
|
3177
|
+
404: `Not Found`,
|
|
3178
|
+
422: `Unprocessable Entity`,
|
|
3179
|
+
500: `Internal Server Error`
|
|
3180
|
+
}
|
|
3181
|
+
});
|
|
3182
|
+
}
|
|
3183
|
+
/**
|
|
3184
|
+
* Regenerate the user SSH key that Codacy uses to clone the repository
|
|
3185
|
+
* Codacy automatically adds the new public user SSH key to the user account on the Git provider. Using a user SSH key is recommended if your repository includes submodules.
|
|
3186
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns SshKeySettingResponse Successful operation
|
|
3187
|
+
* @throws ApiError
|
|
3188
|
+
*/
|
|
3189
|
+
static regenerateUserSshKey(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3190
|
+
return request(OpenAPI, {
|
|
3191
|
+
method: "POST",
|
|
3192
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/ssh-user-key",
|
|
3193
|
+
path: {
|
|
3194
|
+
"provider": provider,
|
|
3195
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3196
|
+
"repositoryName": repositoryName
|
|
3197
|
+
},
|
|
3198
|
+
abortSignal,
|
|
3199
|
+
errors: {
|
|
3200
|
+
400: `Bad Request`,
|
|
3201
|
+
401: `Unauthorized`,
|
|
3202
|
+
404: `Not Found`,
|
|
3203
|
+
422: `Unprocessable Entity`,
|
|
3204
|
+
500: `Internal Server Error`
|
|
3205
|
+
}
|
|
3206
|
+
});
|
|
3207
|
+
}
|
|
3208
|
+
/**
|
|
3209
|
+
* Regenerate the SSH key that Codacy uses to clone the repository
|
|
3210
|
+
* Codacy automatically adds the new public SSH key to the repository on the Git provider.
|
|
3211
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns SshKeySettingResponse Successful operation
|
|
3212
|
+
* @throws ApiError
|
|
3213
|
+
*/
|
|
3214
|
+
static regenerateRepositorySshKey(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3215
|
+
return request(OpenAPI, {
|
|
3216
|
+
method: "POST",
|
|
3217
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/ssh-repository-key",
|
|
3218
|
+
path: {
|
|
3219
|
+
"provider": provider,
|
|
3220
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3221
|
+
"repositoryName": repositoryName
|
|
3222
|
+
},
|
|
3223
|
+
abortSignal,
|
|
3224
|
+
errors: {
|
|
3225
|
+
400: `Bad Request`,
|
|
3226
|
+
401: `Unauthorized`,
|
|
3227
|
+
404: `Not Found`,
|
|
3228
|
+
422: `Unprocessable Entity`,
|
|
3229
|
+
500: `Internal Server Error`
|
|
3230
|
+
}
|
|
3231
|
+
});
|
|
3232
|
+
}
|
|
3233
|
+
/**
|
|
3234
|
+
* Get the public SSH key for the repository
|
|
3235
|
+
* The returned key is the most recently generated and can be either a user or repository SSH key.
|
|
3236
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns SshKeySettingResponse Successful operation
|
|
3237
|
+
* @throws ApiError
|
|
3238
|
+
*/
|
|
3239
|
+
static getRepositoryPublicSshKey(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3240
|
+
return request(OpenAPI, {
|
|
3241
|
+
method: "GET",
|
|
3242
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/stored-ssh-key",
|
|
3243
|
+
path: {
|
|
3244
|
+
"provider": provider,
|
|
3245
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3246
|
+
"repositoryName": repositoryName
|
|
3247
|
+
},
|
|
3248
|
+
abortSignal,
|
|
3249
|
+
errors: {
|
|
3250
|
+
400: `Bad Request`,
|
|
3251
|
+
401: `Unauthorized`,
|
|
3252
|
+
404: `Not Found`,
|
|
3253
|
+
422: `Unprocessable Entity`,
|
|
3254
|
+
500: `Internal Server Error`
|
|
3255
|
+
}
|
|
3256
|
+
});
|
|
3257
|
+
}
|
|
3258
|
+
/**
|
|
3259
|
+
* Synchronize repository name and visibility with Git provider
|
|
3260
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns SyncProviderSettingResponse Successful operation
|
|
3261
|
+
* @throws ApiError
|
|
3262
|
+
*/
|
|
3263
|
+
static syncRepositoryWithProvider(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3264
|
+
return request(OpenAPI, {
|
|
3265
|
+
method: "POST",
|
|
3266
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/sync",
|
|
3267
|
+
path: {
|
|
3268
|
+
"provider": provider,
|
|
3269
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3270
|
+
"repositoryName": repositoryName
|
|
3271
|
+
},
|
|
3272
|
+
abortSignal,
|
|
3273
|
+
errors: {
|
|
3274
|
+
400: `Bad Request`,
|
|
3275
|
+
401: `Unauthorized`,
|
|
3276
|
+
403: `Forbidden`,
|
|
3277
|
+
404: `Not Found`,
|
|
3278
|
+
422: `Unprocessable Entity`,
|
|
3279
|
+
500: `Internal Server Error`
|
|
3280
|
+
}
|
|
3281
|
+
});
|
|
3282
|
+
}
|
|
3283
|
+
/**
|
|
3284
|
+
* Get the status of the repository setting **Run analysis on your build server**
|
|
3285
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns BuildServerAnalysisSettingResponse Successful operation
|
|
3286
|
+
* @throws ApiError
|
|
3287
|
+
*/
|
|
3288
|
+
static getBuildServerAnalysisSetting(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3289
|
+
return request(OpenAPI, {
|
|
3290
|
+
method: "GET",
|
|
3291
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/analysis",
|
|
3292
|
+
path: {
|
|
3293
|
+
"provider": provider,
|
|
3294
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3295
|
+
"repositoryName": repositoryName
|
|
3296
|
+
},
|
|
3297
|
+
abortSignal,
|
|
3298
|
+
errors: {
|
|
3299
|
+
400: `Bad Request`,
|
|
3300
|
+
401: `Unauthorized`,
|
|
3301
|
+
404: `Not Found`,
|
|
3302
|
+
405: `Method Not Allowed`,
|
|
3303
|
+
422: `Unprocessable Entity`,
|
|
3304
|
+
500: `Internal Server Error`
|
|
3305
|
+
}
|
|
3306
|
+
});
|
|
3307
|
+
}
|
|
3308
|
+
/**
|
|
3309
|
+
* Update the status of the repository setting **Run analysis on your build server**
|
|
3310
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param requestBody New value for the repository setting **Run analysis on your build server** * @returns BuildServerAnalysisSettingResponse Successful operation
|
|
3311
|
+
* @throws ApiError
|
|
3312
|
+
*/
|
|
3313
|
+
static updateBuildServerAnalysisSetting(provider, remoteOrganizationName, repositoryName, requestBody, abortSignal) {
|
|
3314
|
+
return request(OpenAPI, {
|
|
3315
|
+
method: "PATCH",
|
|
3316
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/analysis",
|
|
3317
|
+
path: {
|
|
3318
|
+
"provider": provider,
|
|
3319
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3320
|
+
"repositoryName": repositoryName
|
|
3321
|
+
},
|
|
3322
|
+
abortSignal,
|
|
3323
|
+
body: requestBody,
|
|
3324
|
+
mediaType: "application/json",
|
|
3325
|
+
errors: {
|
|
3326
|
+
400: `Bad Request`,
|
|
3327
|
+
401: `Unauthorized`,
|
|
3328
|
+
404: `Not Found`,
|
|
3329
|
+
405: `Method Not Allowed`,
|
|
3330
|
+
422: `Unprocessable Entity`,
|
|
3331
|
+
500: `Internal Server Error`
|
|
3332
|
+
}
|
|
3333
|
+
});
|
|
3334
|
+
}
|
|
3335
|
+
/**
|
|
3336
|
+
* Get quality settings for the commits of a repository
|
|
3337
|
+
* `diffCoverageThreshold` is never returned because this threshold isn't currently supported for commits.
|
|
3338
|
+
*
|
|
3339
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns QualitySettingsResponse Successful operation
|
|
3340
|
+
* @throws ApiError
|
|
3341
|
+
*/
|
|
3342
|
+
static getCommitQualitySettings(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3343
|
+
return request(OpenAPI, {
|
|
3344
|
+
method: "GET",
|
|
3345
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/quality/commits",
|
|
3346
|
+
path: {
|
|
3347
|
+
"provider": provider,
|
|
3348
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3349
|
+
"repositoryName": repositoryName
|
|
3350
|
+
},
|
|
3351
|
+
abortSignal,
|
|
3352
|
+
errors: {
|
|
3353
|
+
400: `Bad Request`,
|
|
3354
|
+
401: `Unauthorized`,
|
|
3355
|
+
404: `Not Found`,
|
|
3356
|
+
422: `Unprocessable Entity`,
|
|
3357
|
+
500: `Internal Server Error`
|
|
3358
|
+
}
|
|
3359
|
+
});
|
|
3360
|
+
}
|
|
3361
|
+
/**
|
|
3362
|
+
* Update quality settings for the commits of a repository
|
|
3363
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param requestBody The new value for the quality settings of commits in a repository * @returns QualitySettingsResponse Successful operation
|
|
3364
|
+
* @throws ApiError
|
|
3365
|
+
*/
|
|
3366
|
+
static updateCommitQualitySettings(provider, remoteOrganizationName, repositoryName, requestBody, abortSignal) {
|
|
3367
|
+
return request(OpenAPI, {
|
|
3368
|
+
method: "PUT",
|
|
3369
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/quality/commits",
|
|
3370
|
+
path: {
|
|
3371
|
+
"provider": provider,
|
|
3372
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3373
|
+
"repositoryName": repositoryName
|
|
3374
|
+
},
|
|
3375
|
+
abortSignal,
|
|
3376
|
+
body: requestBody,
|
|
3377
|
+
mediaType: "application/json",
|
|
3378
|
+
errors: {
|
|
3379
|
+
400: `Bad Request`,
|
|
3380
|
+
401: `Unauthorized`,
|
|
3381
|
+
404: `Not Found`,
|
|
3382
|
+
422: `Unprocessable Entity`,
|
|
3383
|
+
500: `Internal Server Error`
|
|
3384
|
+
}
|
|
3385
|
+
});
|
|
3386
|
+
}
|
|
3387
|
+
/**
|
|
3388
|
+
* Reset quality settings for the commits of a repository to Codacy’s default values
|
|
3389
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns QualitySettingsResponse Successful operation
|
|
3390
|
+
* @throws ApiError
|
|
3391
|
+
*/
|
|
3392
|
+
static resetCommitsQualitySettings(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3393
|
+
return request(OpenAPI, {
|
|
3394
|
+
method: "POST",
|
|
3395
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/quality/commits/reset",
|
|
3396
|
+
path: {
|
|
3397
|
+
"provider": provider,
|
|
3398
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3399
|
+
"repositoryName": repositoryName
|
|
3400
|
+
},
|
|
3401
|
+
abortSignal,
|
|
3402
|
+
errors: {
|
|
3403
|
+
400: `Bad Request`,
|
|
3404
|
+
401: `Unauthorized`,
|
|
3405
|
+
404: `Not Found`,
|
|
3406
|
+
422: `Unprocessable Entity`,
|
|
3407
|
+
500: `Internal Server Error`
|
|
3408
|
+
}
|
|
3409
|
+
});
|
|
3410
|
+
}
|
|
3411
|
+
/**
|
|
3412
|
+
* Reset quality settings for the pull requests of a repository to Codacy’s default values
|
|
3413
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns QualitySettingsResponse Successful operation
|
|
3414
|
+
* @throws ApiError
|
|
3415
|
+
*/
|
|
3416
|
+
static resetPullRequestsQualitySettings(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3417
|
+
return request(OpenAPI, {
|
|
3418
|
+
method: "POST",
|
|
3419
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/quality/pull-requests/reset",
|
|
3420
|
+
path: {
|
|
3421
|
+
"provider": provider,
|
|
3422
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3423
|
+
"repositoryName": repositoryName
|
|
3424
|
+
},
|
|
3425
|
+
abortSignal,
|
|
3426
|
+
errors: {
|
|
3427
|
+
400: `Bad Request`,
|
|
3428
|
+
401: `Unauthorized`,
|
|
3429
|
+
404: `Not Found`,
|
|
3430
|
+
422: `Unprocessable Entity`,
|
|
3431
|
+
500: `Internal Server Error`
|
|
3432
|
+
}
|
|
3433
|
+
});
|
|
3434
|
+
}
|
|
3435
|
+
/**
|
|
3436
|
+
* Reset quality settings for the repository to Codacy’s default values
|
|
3437
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns RepositoryQualitySettingsResponse Successful operation
|
|
3438
|
+
* @throws ApiError
|
|
3439
|
+
*/
|
|
3440
|
+
static resetRepositoryQualitySettings(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3441
|
+
return request(OpenAPI, {
|
|
3442
|
+
method: "POST",
|
|
3443
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/quality/repository/reset",
|
|
3444
|
+
path: {
|
|
3445
|
+
"provider": provider,
|
|
3446
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3447
|
+
"repositoryName": repositoryName
|
|
3448
|
+
},
|
|
3449
|
+
abortSignal,
|
|
3450
|
+
errors: {
|
|
3451
|
+
400: `Bad Request`,
|
|
3452
|
+
401: `Unauthorized`,
|
|
3453
|
+
404: `Not Found`,
|
|
3454
|
+
422: `Unprocessable Entity`,
|
|
3455
|
+
500: `Internal Server Error`
|
|
3456
|
+
}
|
|
3457
|
+
});
|
|
3458
|
+
}
|
|
3459
|
+
/**
|
|
3460
|
+
* Get quality settings for the pull requests of a repository
|
|
3461
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns QualitySettingsResponse Successful operation
|
|
3462
|
+
* @throws ApiError
|
|
3463
|
+
*/
|
|
3464
|
+
static getPullRequestQualitySettings(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3465
|
+
return request(OpenAPI, {
|
|
3466
|
+
method: "GET",
|
|
3467
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/quality/pull-requests",
|
|
3468
|
+
path: {
|
|
3469
|
+
"provider": provider,
|
|
3470
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3471
|
+
"repositoryName": repositoryName
|
|
3472
|
+
},
|
|
3473
|
+
abortSignal,
|
|
3474
|
+
errors: {
|
|
3475
|
+
400: `Bad Request`,
|
|
3476
|
+
401: `Unauthorized`,
|
|
3477
|
+
404: `Not Found`,
|
|
3478
|
+
422: `Unprocessable Entity`,
|
|
3479
|
+
500: `Internal Server Error`
|
|
3480
|
+
}
|
|
3481
|
+
});
|
|
3482
|
+
}
|
|
3483
|
+
/**
|
|
3484
|
+
* Update quality settings for the pull requests of a repository
|
|
3485
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param requestBody The new value for the quality settings of pull requests in the repository * @returns QualitySettingsResponse Successful operation
|
|
3486
|
+
* @throws ApiError
|
|
3487
|
+
*/
|
|
3488
|
+
static updatePullRequestQualitySettings(provider, remoteOrganizationName, repositoryName, requestBody, abortSignal) {
|
|
3489
|
+
return request(OpenAPI, {
|
|
3490
|
+
method: "PUT",
|
|
3491
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/quality/pull-requests",
|
|
3492
|
+
path: {
|
|
3493
|
+
"provider": provider,
|
|
3494
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3495
|
+
"repositoryName": repositoryName
|
|
3496
|
+
},
|
|
3497
|
+
abortSignal,
|
|
3498
|
+
body: requestBody,
|
|
3499
|
+
mediaType: "application/json",
|
|
3500
|
+
errors: {
|
|
3501
|
+
400: `Bad Request`,
|
|
3502
|
+
401: `Unauthorized`,
|
|
3503
|
+
404: `Not Found`,
|
|
3504
|
+
422: `Unprocessable Entity`,
|
|
3505
|
+
500: `Internal Server Error`
|
|
3506
|
+
}
|
|
3507
|
+
});
|
|
3508
|
+
}
|
|
3509
|
+
/**
|
|
3510
|
+
* Get Git provider integration settings for a repository
|
|
3511
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns RepositoryIntegrationSettings Successful operation
|
|
3512
|
+
* @throws ApiError
|
|
3513
|
+
*/
|
|
3514
|
+
static getRepositoryIntegrationsSettings(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3515
|
+
return request(OpenAPI, {
|
|
3516
|
+
method: "GET",
|
|
3517
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/integrations/providerSettings",
|
|
3518
|
+
path: {
|
|
3519
|
+
"provider": provider,
|
|
3520
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3521
|
+
"repositoryName": repositoryName
|
|
3522
|
+
},
|
|
3523
|
+
abortSignal,
|
|
3524
|
+
errors: {
|
|
3525
|
+
400: `Bad Request`,
|
|
3526
|
+
401: `Unauthorized`,
|
|
3527
|
+
404: `Not Found`,
|
|
3528
|
+
422: `Unprocessable Entity`,
|
|
3529
|
+
500: `Internal Server Error`,
|
|
3530
|
+
502: `Bad Gateway`
|
|
3531
|
+
}
|
|
3532
|
+
});
|
|
3533
|
+
}
|
|
3534
|
+
/**
|
|
3535
|
+
* Update Git provider integration settings for a repository
|
|
3536
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param requestBody * @returns void
|
|
3537
|
+
* @throws ApiError
|
|
3538
|
+
*/
|
|
3539
|
+
static updateRepositoryIntegrationsSettings(provider, remoteOrganizationName, repositoryName, requestBody, abortSignal) {
|
|
3540
|
+
return request(OpenAPI, {
|
|
3541
|
+
method: "PATCH",
|
|
3542
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/integrations/providerSettings",
|
|
3543
|
+
path: {
|
|
3544
|
+
"provider": provider,
|
|
3545
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3546
|
+
"repositoryName": repositoryName
|
|
3547
|
+
},
|
|
3548
|
+
abortSignal,
|
|
3549
|
+
body: requestBody,
|
|
3550
|
+
mediaType: "application/json",
|
|
3551
|
+
errors: {
|
|
3552
|
+
400: `Bad Request`,
|
|
3553
|
+
401: `Unauthorized`,
|
|
3554
|
+
403: `Forbidden`,
|
|
3555
|
+
404: `Not Found`,
|
|
3556
|
+
422: `Unprocessable Entity`,
|
|
3557
|
+
500: `Internal Server Error`,
|
|
3558
|
+
502: `Bad Gateway`
|
|
3559
|
+
}
|
|
3560
|
+
});
|
|
3561
|
+
}
|
|
3562
|
+
/**
|
|
3563
|
+
* Create a [post-commit hook](https://docs.codacy.com/repositories-configure/integrations/post-commit-hooks/) for a repository
|
|
3564
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns void
|
|
3565
|
+
* @throws ApiError
|
|
3566
|
+
*/
|
|
3567
|
+
static createPostCommitHook(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3568
|
+
return request(OpenAPI, {
|
|
3569
|
+
method: "GET",
|
|
3570
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/integrations/postCommitHook",
|
|
3571
|
+
path: {
|
|
3572
|
+
"provider": provider,
|
|
3573
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3574
|
+
"repositoryName": repositoryName
|
|
3575
|
+
},
|
|
3576
|
+
abortSignal,
|
|
3577
|
+
errors: {
|
|
3578
|
+
400: `Bad Request`,
|
|
3579
|
+
401: `Unauthorized`,
|
|
3580
|
+
403: `Forbidden`,
|
|
3581
|
+
404: `Not Found`,
|
|
3582
|
+
422: `Unprocessable Entity`,
|
|
3583
|
+
500: `An unexpected error occurred while creating the post-commit hook`
|
|
3584
|
+
}
|
|
3585
|
+
});
|
|
3586
|
+
}
|
|
3587
|
+
/**
|
|
3588
|
+
* Refresh the Git provider integration for a repository (GitLab and Bitbucket only)
|
|
3589
|
+
* Codacy will use the authenticated user to create comments on new pull requests
|
|
3590
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns void
|
|
3591
|
+
* @throws ApiError
|
|
3592
|
+
*/
|
|
3593
|
+
static refreshProviderRepositoryIntegration(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3594
|
+
return request(OpenAPI, {
|
|
3595
|
+
method: "POST",
|
|
3596
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/integrations/refreshProvider",
|
|
3597
|
+
path: {
|
|
3598
|
+
"provider": provider,
|
|
3599
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3600
|
+
"repositoryName": repositoryName
|
|
3601
|
+
},
|
|
3602
|
+
abortSignal,
|
|
3603
|
+
errors: {
|
|
3604
|
+
400: `Bad Request`,
|
|
3605
|
+
401: `Unauthorized`,
|
|
3606
|
+
403: `Forbidden`,
|
|
3607
|
+
404: `Not Found`,
|
|
3608
|
+
422: `Unprocessable Entity`,
|
|
3609
|
+
500: `An unexpected error occurred while refreshing the repository Git provider integration`
|
|
3610
|
+
}
|
|
3611
|
+
});
|
|
3612
|
+
}
|
|
3613
|
+
/**
|
|
3614
|
+
* Reanalyze a specific commit in a repository
|
|
3615
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param requestBody UUID or SHA string that identifies the commit * @returns void
|
|
3616
|
+
* @throws ApiError
|
|
3617
|
+
*/
|
|
3618
|
+
static reanalyzeCommitById(provider, remoteOrganizationName, repositoryName, requestBody, abortSignal) {
|
|
3619
|
+
return request(OpenAPI, {
|
|
3620
|
+
method: "POST",
|
|
3621
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/reanalyzeCommit",
|
|
3622
|
+
path: {
|
|
3623
|
+
"provider": provider,
|
|
3624
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3625
|
+
"repositoryName": repositoryName
|
|
3626
|
+
},
|
|
3627
|
+
abortSignal,
|
|
3628
|
+
body: requestBody,
|
|
3629
|
+
mediaType: "application/json",
|
|
3630
|
+
errors: {
|
|
3631
|
+
400: `Bad Request`,
|
|
3632
|
+
401: `Unauthorized`,
|
|
3633
|
+
403: `Forbidden`,
|
|
3634
|
+
404: `Not Found`,
|
|
3635
|
+
422: `Unprocessable Entity`,
|
|
3636
|
+
500: `Internal Server Error`
|
|
3637
|
+
}
|
|
3638
|
+
});
|
|
3639
|
+
}
|
|
3640
|
+
/**
|
|
3641
|
+
* Fetch the specified repository
|
|
3642
|
+
* **Note:** When applied to public repositories, this operation does not require authentication.
|
|
3643
|
+
*
|
|
3644
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns RepositoryResponse Successful operation
|
|
3645
|
+
* @throws ApiError
|
|
3646
|
+
*/
|
|
3647
|
+
static getRepository(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3648
|
+
return request(OpenAPI, {
|
|
3649
|
+
method: "GET",
|
|
3650
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}",
|
|
3651
|
+
path: {
|
|
3652
|
+
"provider": provider,
|
|
3653
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3654
|
+
"repositoryName": repositoryName
|
|
3655
|
+
},
|
|
3656
|
+
abortSignal,
|
|
3657
|
+
errors: {
|
|
3658
|
+
400: `Bad Request`,
|
|
3659
|
+
401: `Unauthorized`,
|
|
3660
|
+
403: `Forbidden`,
|
|
3661
|
+
404: `Not Found`,
|
|
3662
|
+
422: `Unprocessable Entity`,
|
|
3663
|
+
500: `Internal Server Error`
|
|
3664
|
+
}
|
|
3665
|
+
});
|
|
3666
|
+
}
|
|
3667
|
+
/**
|
|
3668
|
+
* Delete the specified repository
|
|
3669
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns void
|
|
3670
|
+
* @throws ApiError
|
|
3671
|
+
*/
|
|
3672
|
+
static deleteRepository(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
3673
|
+
return request(OpenAPI, {
|
|
3674
|
+
method: "DELETE",
|
|
3675
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}",
|
|
3676
|
+
path: {
|
|
3677
|
+
"provider": provider,
|
|
3678
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3679
|
+
"repositoryName": repositoryName
|
|
3680
|
+
},
|
|
3681
|
+
abortSignal,
|
|
3682
|
+
errors: {
|
|
3683
|
+
400: `Bad Request`,
|
|
3684
|
+
401: `Unauthorized`,
|
|
3685
|
+
403: `Forbidden`,
|
|
3686
|
+
404: `Not Found`,
|
|
3687
|
+
422: `Unprocessable Entity`,
|
|
3688
|
+
500: `Internal Server Error`
|
|
3689
|
+
}
|
|
3690
|
+
});
|
|
3691
|
+
}
|
|
3692
|
+
/**
|
|
3693
|
+
* List repository branches
|
|
3694
|
+
* **Note:** When applied to public repositories, this operation does not require authentication.
|
|
3695
|
+
*
|
|
3696
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param enabled Filter by branch status. Set to `true` to return only enabled branches, or `false` to return only disabled branches* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return* @param search Filter results by searching for this string* @param sort Field used to sort the list of branches. The allowed values are 'name' and 'last-updated'.* @param direction Sort direction. Possible values are 'asc' (ascending) or 'desc' (descending). * @returns BranchListResponse Successful operation
|
|
3697
|
+
* @throws ApiError
|
|
3698
|
+
*/
|
|
3699
|
+
static listRepositoryBranches(provider, remoteOrganizationName, repositoryName, enabled, cursor, limit = 100, search, sort, direction, abortSignal) {
|
|
3700
|
+
return request(OpenAPI, {
|
|
3701
|
+
method: "GET",
|
|
3702
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/branches",
|
|
3703
|
+
path: {
|
|
3704
|
+
"provider": provider,
|
|
3705
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3706
|
+
"repositoryName": repositoryName
|
|
3707
|
+
},
|
|
3708
|
+
query: {
|
|
3709
|
+
"enabled": enabled,
|
|
3710
|
+
"cursor": cursor,
|
|
3711
|
+
"limit": limit,
|
|
3712
|
+
"search": search,
|
|
3713
|
+
"sort": sort,
|
|
3714
|
+
"direction": direction
|
|
3715
|
+
},
|
|
3716
|
+
abortSignal,
|
|
3717
|
+
errors: {
|
|
3718
|
+
400: `Bad Request`,
|
|
3719
|
+
401: `Unauthorized`,
|
|
3720
|
+
404: `Not Found`,
|
|
3721
|
+
422: `Unprocessable Entity`,
|
|
3722
|
+
500: `Internal Server Error`
|
|
3723
|
+
}
|
|
3724
|
+
});
|
|
3725
|
+
}
|
|
3726
|
+
/**
|
|
3727
|
+
* Update the settings for a repository branch
|
|
3728
|
+
* Toggle analysis for a branch.
|
|
3729
|
+
*
|
|
3730
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param branchName Repository branch name* @param requestBody * @returns void
|
|
3731
|
+
* @throws ApiError
|
|
3732
|
+
*/
|
|
3733
|
+
static updateRepositoryBranchConfiguration(provider, remoteOrganizationName, repositoryName, branchName, requestBody, abortSignal) {
|
|
3734
|
+
return request(OpenAPI, {
|
|
3735
|
+
method: "PATCH",
|
|
3736
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/branches/{branchName}",
|
|
3737
|
+
path: {
|
|
3738
|
+
"provider": provider,
|
|
3739
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3740
|
+
"repositoryName": repositoryName,
|
|
3741
|
+
"branchName": branchName
|
|
3742
|
+
},
|
|
3743
|
+
abortSignal,
|
|
3744
|
+
body: requestBody,
|
|
3745
|
+
mediaType: "application/json",
|
|
3746
|
+
errors: {
|
|
3747
|
+
400: `Bad Request`,
|
|
3748
|
+
401: `Unauthorized`,
|
|
3749
|
+
404: `Not Found`,
|
|
3750
|
+
422: `Unprocessable Entity`,
|
|
3751
|
+
500: `Internal Server Error`
|
|
3752
|
+
}
|
|
3753
|
+
});
|
|
3754
|
+
}
|
|
3755
|
+
/**
|
|
3756
|
+
* Set branch as default
|
|
3757
|
+
* Sets the default branch for a repository. The new default branch must already be enabled on Codacy.
|
|
3758
|
+
*
|
|
3759
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param branchName Repository branch name * @returns void
|
|
3760
|
+
* @throws ApiError
|
|
3761
|
+
*/
|
|
3762
|
+
static setRepositoryBranchAsDefault(provider, remoteOrganizationName, repositoryName, branchName, abortSignal) {
|
|
3763
|
+
return request(OpenAPI, {
|
|
3764
|
+
method: "POST",
|
|
3765
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/branches/{branchName}/setDefault",
|
|
3766
|
+
path: {
|
|
3767
|
+
"provider": provider,
|
|
3768
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3769
|
+
"repositoryName": repositoryName,
|
|
3770
|
+
"branchName": branchName
|
|
3771
|
+
},
|
|
3772
|
+
abortSignal,
|
|
3773
|
+
errors: {
|
|
3774
|
+
400: `Bad Request`,
|
|
3775
|
+
401: `Unauthorized`,
|
|
3776
|
+
404: `Not Found`,
|
|
3777
|
+
422: `Unprocessable Entity`,
|
|
3778
|
+
500: `Internal Server Error`
|
|
3779
|
+
}
|
|
3780
|
+
});
|
|
3781
|
+
}
|
|
3782
|
+
/**
|
|
3783
|
+
* Get branch required status checks
|
|
3784
|
+
* Get branch required status checks
|
|
3785
|
+
*
|
|
3786
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param branchName Repository branch name * @returns BranchRequiredChecksResponse Successful operation
|
|
3787
|
+
* @throws ApiError
|
|
3788
|
+
*/
|
|
3789
|
+
static getBranchRequiredChecks(provider, remoteOrganizationName, repositoryName, branchName, abortSignal) {
|
|
3790
|
+
return request(OpenAPI, {
|
|
3791
|
+
method: "GET",
|
|
3792
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/branches/{branchName}/required-checks",
|
|
3793
|
+
path: {
|
|
3794
|
+
"provider": provider,
|
|
3795
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3796
|
+
"repositoryName": repositoryName,
|
|
3797
|
+
"branchName": branchName
|
|
3798
|
+
},
|
|
3799
|
+
abortSignal,
|
|
3800
|
+
errors: {
|
|
3801
|
+
400: `Bad Request`,
|
|
3802
|
+
401: `Unauthorized`,
|
|
3803
|
+
403: `Forbidden`,
|
|
3804
|
+
404: `Not Found`,
|
|
3805
|
+
422: `Unprocessable Entity`,
|
|
3806
|
+
500: `Internal Server Error`
|
|
3807
|
+
}
|
|
3808
|
+
});
|
|
3809
|
+
}
|
|
3810
|
+
/**
|
|
3811
|
+
* Create a pull request adding the Codacy analysis badge to the repository
|
|
3812
|
+
* Creates a pull request adding the Codacy static code analysis badge
|
|
3813
|
+
* to the README of the GitHub repository if the repository is public
|
|
3814
|
+
* and doesn't already have a badge.
|
|
3815
|
+
*
|
|
3816
|
+
* **Note:** The pull request is created asynchronously and may fail
|
|
3817
|
+
* even if this endpoint responds successfully.
|
|
3818
|
+
*
|
|
3819
|
+
* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns void
|
|
3820
|
+
* @throws ApiError
|
|
3821
|
+
*/
|
|
3822
|
+
static createBadgePullRequest(remoteOrganizationName, repositoryName, abortSignal) {
|
|
3823
|
+
return request(OpenAPI, {
|
|
3824
|
+
method: "POST",
|
|
3825
|
+
url: "/organizations/gh/{remoteOrganizationName}/repositories/{repositoryName}/badge",
|
|
3826
|
+
path: {
|
|
3827
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3828
|
+
"repositoryName": repositoryName
|
|
3829
|
+
},
|
|
3830
|
+
abortSignal,
|
|
3831
|
+
errors: {
|
|
3832
|
+
400: `Bad Request`,
|
|
3833
|
+
401: `Unauthorized`,
|
|
3834
|
+
404: `Not Found`,
|
|
3835
|
+
422: `Unprocessable Entity`,
|
|
3836
|
+
500: `Internal Server Error`
|
|
3837
|
+
}
|
|
3838
|
+
});
|
|
3839
|
+
}
|
|
3840
|
+
/**
|
|
3841
|
+
* Add a repository to Codacy
|
|
3842
|
+
* Add a new repository to an existing organization on Codacy
|
|
3843
|
+
* @param requestBody Information of repository to add* @param caller Optional identifier for the calling application or service. * @returns Repository Successful operation
|
|
3844
|
+
* @throws ApiError
|
|
3845
|
+
*/
|
|
3846
|
+
static addRepository(requestBody, caller, abortSignal) {
|
|
3847
|
+
return request(OpenAPI, {
|
|
3848
|
+
method: "POST",
|
|
3849
|
+
url: "/repositories",
|
|
3850
|
+
headers: {
|
|
3851
|
+
"caller": caller
|
|
3852
|
+
},
|
|
3853
|
+
abortSignal,
|
|
3854
|
+
body: requestBody,
|
|
3855
|
+
mediaType: "application/json",
|
|
3856
|
+
errors: {
|
|
3857
|
+
400: `Bad Request`,
|
|
3858
|
+
401: `Unauthorized`,
|
|
3859
|
+
402: `PaymentRequired`,
|
|
3860
|
+
403: `Forbidden`,
|
|
3861
|
+
404: `Not Found`,
|
|
3862
|
+
409: `Conflict`,
|
|
3863
|
+
422: `Unprocessable Entity`,
|
|
3864
|
+
500: `Internal Server Error`
|
|
3865
|
+
}
|
|
3866
|
+
});
|
|
3867
|
+
}
|
|
3868
|
+
/**
|
|
3869
|
+
* List files in a repository
|
|
3870
|
+
* Returns the most recent analysis information for the files in a repository as available on the [Files page](https://docs.codacy.com/repositories/files-view/).
|
|
3871
|
+
* Files that are [ignored on Codacy](https://docs.codacy.com/repositories-configure/ignoring-files/) aren't returned.
|
|
3872
|
+
*
|
|
3873
|
+
* **Note:** When applied to public repositories, this operation does not require authentication.
|
|
3874
|
+
*
|
|
3875
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param branch Name of a [repository branch enabled on Codacy](https://docs.codacy.com/repositories-configure/managing-branches/),
|
|
3876
|
+
* as returned by the endpoint [listRepositoryBranches](#listrepositorybranches).
|
|
3877
|
+
* By default, uses the main branch defined on the Codacy repository settings.
|
|
3878
|
+
* * @param search Filter files that include this string anywhere in their relative path* @param sort Field used to sort the list of files. Valid values are `filename`, `issues`, `grade`, `duplication`, `complexity`, and `coverage`.* @param direction Sort direction. Possible values are 'asc' (ascending) or 'desc' (descending).* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns FileListResponse List of files in the repository
|
|
3879
|
+
* @throws ApiError
|
|
3880
|
+
*/
|
|
3881
|
+
static listFiles(provider, remoteOrganizationName, repositoryName, branch, search, sort, direction, cursor, limit = 100, abortSignal) {
|
|
3882
|
+
return request(OpenAPI, {
|
|
3883
|
+
method: "GET",
|
|
3884
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/files",
|
|
3885
|
+
path: {
|
|
3886
|
+
"provider": provider,
|
|
3887
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3888
|
+
"repositoryName": repositoryName
|
|
3889
|
+
},
|
|
3890
|
+
query: {
|
|
3891
|
+
"branch": branch,
|
|
3892
|
+
"search": search,
|
|
3893
|
+
"sort": sort,
|
|
3894
|
+
"direction": direction,
|
|
3895
|
+
"cursor": cursor,
|
|
3896
|
+
"limit": limit
|
|
3897
|
+
},
|
|
3898
|
+
abortSignal,
|
|
3899
|
+
errors: {
|
|
3900
|
+
400: `Bad Request`,
|
|
3901
|
+
401: `Unauthorized`,
|
|
3902
|
+
404: `Not Found`,
|
|
3903
|
+
422: `Unprocessable Entity`,
|
|
3904
|
+
500: `Internal Server Error`
|
|
3905
|
+
}
|
|
3906
|
+
});
|
|
3907
|
+
}
|
|
3908
|
+
/**
|
|
3909
|
+
* List ignored files in a repository
|
|
3910
|
+
* Returns the most recent ignored files information.
|
|
3911
|
+
*
|
|
3912
|
+
* **Note:** When the repository has a Codacy configuration file 'hasCodacyConfigurationFile', this list of files
|
|
3913
|
+
* are read-only, as they were ignored during the most recent analysis based on the configuration file
|
|
3914
|
+
*
|
|
3915
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param branch Name of a [repository branch enabled on Codacy](https://docs.codacy.com/repositories-configure/managing-branches/),
|
|
3916
|
+
* as returned by the endpoint [listRepositoryBranches](#listrepositorybranches).
|
|
3917
|
+
* By default, uses the main branch defined on the Codacy repository settings.
|
|
3918
|
+
* * @param search Filter files that include this string anywhere in their relative path* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns IgnoredFileListResponse List of ignored files in the repository
|
|
3919
|
+
* @throws ApiError
|
|
3920
|
+
*/
|
|
3921
|
+
static listIgnoredFiles(provider, remoteOrganizationName, repositoryName, branch, search, cursor, limit = 100, abortSignal) {
|
|
3922
|
+
return request(OpenAPI, {
|
|
3923
|
+
method: "GET",
|
|
3924
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/ignored-files",
|
|
3925
|
+
path: {
|
|
3926
|
+
"provider": provider,
|
|
3927
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3928
|
+
"repositoryName": repositoryName
|
|
3929
|
+
},
|
|
3930
|
+
query: {
|
|
3931
|
+
"branch": branch,
|
|
3932
|
+
"search": search,
|
|
3933
|
+
"cursor": cursor,
|
|
3934
|
+
"limit": limit
|
|
3935
|
+
},
|
|
3936
|
+
abortSignal,
|
|
3937
|
+
errors: {
|
|
3938
|
+
400: `Bad Request`,
|
|
3939
|
+
401: `Unauthorized`,
|
|
3940
|
+
404: `Not Found`,
|
|
3941
|
+
422: `Unprocessable Entity`,
|
|
3942
|
+
500: `Internal Server Error`
|
|
3943
|
+
}
|
|
3944
|
+
});
|
|
3945
|
+
}
|
|
3946
|
+
/**
|
|
3947
|
+
* Get analysis information and coverage metrics for a file in a repository
|
|
3948
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param fileId Identifier of a file in a specific commit * @returns FileInformationWithAnalysis File with analysis
|
|
3949
|
+
* @throws ApiError
|
|
3950
|
+
*/
|
|
3951
|
+
static getFileWithAnalysis(provider, remoteOrganizationName, repositoryName, fileId, abortSignal) {
|
|
3952
|
+
return request(OpenAPI, {
|
|
3953
|
+
method: "GET",
|
|
3954
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/files/{fileId}",
|
|
3955
|
+
path: {
|
|
3956
|
+
"provider": provider,
|
|
3957
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3958
|
+
"repositoryName": repositoryName,
|
|
3959
|
+
"fileId": fileId
|
|
3960
|
+
},
|
|
3961
|
+
abortSignal,
|
|
3962
|
+
errors: {
|
|
3963
|
+
400: `Bad Request`,
|
|
3964
|
+
401: `Unauthorized`,
|
|
3965
|
+
404: `Not Found`,
|
|
3966
|
+
422: `Unprocessable Entity`,
|
|
3967
|
+
500: `Internal Server Error`
|
|
3968
|
+
}
|
|
3969
|
+
});
|
|
3970
|
+
}
|
|
3971
|
+
/**
|
|
3972
|
+
* Get the list of duplicated code blocks for a file in a repository
|
|
3973
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param fileId Identifier of a file in a specific commit* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns FileClonesResponse File clones
|
|
3974
|
+
* @throws ApiError
|
|
3975
|
+
*/
|
|
3976
|
+
static getFileClones(provider, remoteOrganizationName, repositoryName, fileId, cursor, limit = 100, abortSignal) {
|
|
3977
|
+
return request(OpenAPI, {
|
|
3978
|
+
method: "GET",
|
|
3979
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/files/{fileId}/duplication",
|
|
3980
|
+
path: {
|
|
3981
|
+
"provider": provider,
|
|
3982
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
3983
|
+
"repositoryName": repositoryName,
|
|
3984
|
+
"fileId": fileId
|
|
3985
|
+
},
|
|
3986
|
+
query: {
|
|
3987
|
+
"cursor": cursor,
|
|
3988
|
+
"limit": limit
|
|
3989
|
+
},
|
|
3990
|
+
abortSignal,
|
|
3991
|
+
errors: {
|
|
3992
|
+
400: `Bad Request`,
|
|
3993
|
+
401: `Unauthorized`,
|
|
3994
|
+
404: `Not Found`,
|
|
3995
|
+
422: `Unprocessable Entity`,
|
|
3996
|
+
500: `Internal Server Error`
|
|
3997
|
+
}
|
|
3998
|
+
});
|
|
3999
|
+
}
|
|
4000
|
+
/**
|
|
4001
|
+
* Get the issue list for a file in a repository
|
|
4002
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param fileId Identifier of a file in a specific commit* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns SearchRepositoryIssuesListResponse File issues
|
|
4003
|
+
* @throws ApiError
|
|
4004
|
+
*/
|
|
4005
|
+
static getFileIssues(provider, remoteOrganizationName, repositoryName, fileId, cursor, limit = 100, abortSignal) {
|
|
4006
|
+
return request(OpenAPI, {
|
|
4007
|
+
method: "GET",
|
|
4008
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/files/{fileId}/issues",
|
|
4009
|
+
path: {
|
|
4010
|
+
"provider": provider,
|
|
4011
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
4012
|
+
"repositoryName": repositoryName,
|
|
4013
|
+
"fileId": fileId
|
|
4014
|
+
},
|
|
4015
|
+
query: {
|
|
4016
|
+
"cursor": cursor,
|
|
4017
|
+
"limit": limit
|
|
4018
|
+
},
|
|
4019
|
+
abortSignal,
|
|
4020
|
+
errors: {
|
|
4021
|
+
400: `Bad Request`,
|
|
4022
|
+
401: `Unauthorized`,
|
|
4023
|
+
404: `Not Found`,
|
|
4024
|
+
422: `Unprocessable Entity`,
|
|
4025
|
+
500: `Internal Server Error`
|
|
4026
|
+
}
|
|
4027
|
+
});
|
|
4028
|
+
}
|
|
4029
|
+
/**
|
|
4030
|
+
* List the [repository API tokens](https://docs.codacy.com/codacy-api/api-tokens/)
|
|
4031
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns ApiTokenListResponse Successful operation
|
|
4032
|
+
* @throws ApiError
|
|
4033
|
+
*/
|
|
4034
|
+
static listRepositoryApiTokens(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
4035
|
+
return request(OpenAPI, {
|
|
4036
|
+
method: "GET",
|
|
4037
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/tokens",
|
|
4038
|
+
path: {
|
|
4039
|
+
"provider": provider,
|
|
4040
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
4041
|
+
"repositoryName": repositoryName
|
|
4042
|
+
},
|
|
4043
|
+
abortSignal,
|
|
4044
|
+
errors: {
|
|
4045
|
+
400: `Bad Request`,
|
|
4046
|
+
401: `Unauthorized`,
|
|
4047
|
+
404: `Not Found`,
|
|
4048
|
+
422: `Unprocessable Entity`,
|
|
4049
|
+
500: `Internal Server Error`
|
|
4050
|
+
}
|
|
4051
|
+
});
|
|
4052
|
+
}
|
|
4053
|
+
/**
|
|
4054
|
+
* Create a new [repository API token](https://docs.codacy.com/codacy-api/api-tokens/)
|
|
4055
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization * @returns ApiTokenResponse Successful operation
|
|
4056
|
+
* @throws ApiError
|
|
4057
|
+
*/
|
|
4058
|
+
static createRepositoryApiToken(provider, remoteOrganizationName, repositoryName, abortSignal) {
|
|
4059
|
+
return request(OpenAPI, {
|
|
4060
|
+
method: "POST",
|
|
4061
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/tokens",
|
|
4062
|
+
path: {
|
|
4063
|
+
"provider": provider,
|
|
4064
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
4065
|
+
"repositoryName": repositoryName
|
|
4066
|
+
},
|
|
4067
|
+
abortSignal,
|
|
4068
|
+
errors: {
|
|
4069
|
+
400: `Bad Request`,
|
|
4070
|
+
401: `Unauthorized`,
|
|
4071
|
+
404: `Not Found`,
|
|
4072
|
+
422: `Unprocessable Entity`,
|
|
4073
|
+
500: `Internal Server Error`
|
|
4074
|
+
}
|
|
4075
|
+
});
|
|
4076
|
+
}
|
|
4077
|
+
/**
|
|
4078
|
+
* Delete a [repository API token](https://docs.codacy.com/codacy-api/api-tokens/) by ID
|
|
4079
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param tokenId Unique identifier for the API token * @returns void
|
|
4080
|
+
* @throws ApiError
|
|
4081
|
+
*/
|
|
4082
|
+
static deleteRepositoryApiToken(provider, remoteOrganizationName, repositoryName, tokenId, abortSignal) {
|
|
4083
|
+
return request(OpenAPI, {
|
|
4084
|
+
method: "DELETE",
|
|
4085
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/tokens/{tokenId}",
|
|
4086
|
+
path: {
|
|
4087
|
+
"provider": provider,
|
|
4088
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
4089
|
+
"repositoryName": repositoryName,
|
|
4090
|
+
"tokenId": tokenId
|
|
4091
|
+
},
|
|
4092
|
+
abortSignal,
|
|
4093
|
+
errors: {
|
|
4094
|
+
400: `Bad Request`,
|
|
4095
|
+
401: `Unauthorized`,
|
|
4096
|
+
404: `Not Found`,
|
|
4097
|
+
422: `Unprocessable Entity`,
|
|
4098
|
+
500: `Internal Server Error`
|
|
4099
|
+
}
|
|
4100
|
+
});
|
|
4101
|
+
}
|
|
4102
|
+
/**
|
|
4103
|
+
* List the most recent coverage reports and their status
|
|
4104
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param limit Maximum number of items to return * @returns CoverageReportResponse Successful operation
|
|
4105
|
+
* @throws ApiError
|
|
4106
|
+
*/
|
|
4107
|
+
static listCoverageReports(provider, remoteOrganizationName, repositoryName, limit = 100, abortSignal) {
|
|
4108
|
+
return request(OpenAPI, {
|
|
4109
|
+
method: "GET",
|
|
4110
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/coverage/status",
|
|
4111
|
+
path: {
|
|
4112
|
+
"provider": provider,
|
|
4113
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
4114
|
+
"repositoryName": repositoryName
|
|
4115
|
+
},
|
|
4116
|
+
query: {
|
|
4117
|
+
"limit": limit
|
|
4118
|
+
},
|
|
4119
|
+
abortSignal,
|
|
4120
|
+
errors: {
|
|
4121
|
+
400: `Bad Request`,
|
|
4122
|
+
401: `Unauthorized`,
|
|
4123
|
+
404: `Not Found`,
|
|
4124
|
+
422: `Unprocessable Entity`,
|
|
4125
|
+
500: `Internal Server Error`
|
|
4126
|
+
}
|
|
4127
|
+
});
|
|
4128
|
+
}
|
|
4129
|
+
/**
|
|
4130
|
+
* List coverage reports for a commit
|
|
4131
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param commitUuid UUID or SHA string that identifies the commit* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns CoverageReportEntryResponse Successful operation
|
|
4132
|
+
* @throws ApiError
|
|
4133
|
+
*/
|
|
4134
|
+
static listCommitCoverageReports(provider, remoteOrganizationName, repositoryName, commitUuid, cursor, limit = 100, abortSignal) {
|
|
4135
|
+
return request(OpenAPI, {
|
|
4136
|
+
method: "GET",
|
|
4137
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/commits/{commitUuid}/coverage/reports",
|
|
4138
|
+
path: {
|
|
4139
|
+
"provider": provider,
|
|
4140
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
4141
|
+
"repositoryName": repositoryName,
|
|
4142
|
+
"commitUuid": commitUuid
|
|
4143
|
+
},
|
|
4144
|
+
query: {
|
|
4145
|
+
"cursor": cursor,
|
|
4146
|
+
"limit": limit
|
|
4147
|
+
},
|
|
4148
|
+
abortSignal,
|
|
4149
|
+
errors: {
|
|
4150
|
+
400: `Bad Request`,
|
|
4151
|
+
401: `Unauthorized`,
|
|
4152
|
+
403: `Forbidden`,
|
|
4153
|
+
404: `Not Found`,
|
|
4154
|
+
422: `Unprocessable Entity`,
|
|
4155
|
+
500: `Internal Server Error`
|
|
4156
|
+
}
|
|
4157
|
+
});
|
|
4158
|
+
}
|
|
4159
|
+
/**
|
|
4160
|
+
* Get a coverage report with its contents
|
|
4161
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param commitUuid UUID or SHA string that identifies the commit* @param reportUuid UUID string that identifies the coverage report * @returns CoverageReportContentResponse Successful operation
|
|
4162
|
+
* @throws ApiError
|
|
4163
|
+
*/
|
|
4164
|
+
static getCoverageReport(provider, remoteOrganizationName, repositoryName, commitUuid, reportUuid, abortSignal) {
|
|
4165
|
+
return request(OpenAPI, {
|
|
4166
|
+
method: "GET",
|
|
4167
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/commits/{commitUuid}/coverage/reports/{reportUuid}",
|
|
4168
|
+
path: {
|
|
4169
|
+
"provider": provider,
|
|
4170
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
4171
|
+
"repositoryName": repositoryName,
|
|
4172
|
+
"commitUuid": commitUuid,
|
|
4173
|
+
"reportUuid": reportUuid
|
|
4174
|
+
},
|
|
4175
|
+
abortSignal,
|
|
4176
|
+
errors: {
|
|
4177
|
+
400: `Bad Request`,
|
|
4178
|
+
401: `Unauthorized`,
|
|
4179
|
+
403: `Forbidden`,
|
|
4180
|
+
404: `Not Found`,
|
|
4181
|
+
422: `Unprocessable Entity`,
|
|
4182
|
+
500: `Internal Server Error`
|
|
4183
|
+
}
|
|
4184
|
+
});
|
|
4185
|
+
}
|
|
4186
|
+
/**
|
|
4187
|
+
* Get coverage information for a file in the head commit of a repository branch.
|
|
4188
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param fileId Identifier of a file in a specific commit * @returns GetFileCoverageResponse File Coverage
|
|
4189
|
+
* @throws ApiError
|
|
4190
|
+
*/
|
|
4191
|
+
static getFileCoverage(provider, remoteOrganizationName, repositoryName, fileId, abortSignal) {
|
|
4192
|
+
return request(OpenAPI, {
|
|
4193
|
+
method: "GET",
|
|
4194
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/files/{fileId}/coverage",
|
|
4195
|
+
path: {
|
|
4196
|
+
"provider": provider,
|
|
4197
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
4198
|
+
"repositoryName": repositoryName,
|
|
4199
|
+
"fileId": fileId
|
|
4200
|
+
},
|
|
4201
|
+
abortSignal,
|
|
4202
|
+
errors: {
|
|
4203
|
+
400: `Bad Request`,
|
|
4204
|
+
401: `Unauthorized`,
|
|
4205
|
+
403: `Forbidden`,
|
|
4206
|
+
404: `Not Found`,
|
|
4207
|
+
422: `Unprocessable Entity`,
|
|
4208
|
+
500: `Internal Server Error`
|
|
4209
|
+
}
|
|
4210
|
+
});
|
|
4211
|
+
}
|
|
4212
|
+
/**
|
|
4213
|
+
* Ignore or unignore a file
|
|
4214
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param requestBody * @returns void
|
|
4215
|
+
* @throws ApiError
|
|
4216
|
+
*/
|
|
4217
|
+
static updateFileState(provider, remoteOrganizationName, repositoryName, requestBody, abortSignal) {
|
|
4218
|
+
return request(OpenAPI, {
|
|
4219
|
+
method: "PATCH",
|
|
4220
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/file",
|
|
4221
|
+
path: {
|
|
4222
|
+
"provider": provider,
|
|
4223
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
4224
|
+
"repositoryName": repositoryName
|
|
4225
|
+
},
|
|
4226
|
+
abortSignal,
|
|
4227
|
+
body: requestBody,
|
|
4228
|
+
mediaType: "application/json",
|
|
4229
|
+
errors: {
|
|
4230
|
+
400: `Bad Request`,
|
|
4231
|
+
401: `Unauthorized`,
|
|
4232
|
+
404: `Not Found`,
|
|
4233
|
+
422: `Unprocessable Entity`,
|
|
4234
|
+
500: `Internal Server Error`
|
|
4235
|
+
}
|
|
4236
|
+
});
|
|
4237
|
+
}
|
|
4238
|
+
/**
|
|
4239
|
+
* Get the human-readable Git diff of a pull request
|
|
4240
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param pullRequestNumber Pull request number * @returns DiffResponse Successful operation
|
|
4241
|
+
* @throws ApiError
|
|
4242
|
+
*/
|
|
4243
|
+
static getPullRequestDiff(provider, remoteOrganizationName, repositoryName, pullRequestNumber, abortSignal) {
|
|
4244
|
+
return request(OpenAPI, {
|
|
4245
|
+
method: "GET",
|
|
4246
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/pull-requests/{pullRequestNumber}/diff",
|
|
4247
|
+
path: {
|
|
4248
|
+
"provider": provider,
|
|
4249
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
4250
|
+
"repositoryName": repositoryName,
|
|
4251
|
+
"pullRequestNumber": pullRequestNumber
|
|
4252
|
+
},
|
|
4253
|
+
abortSignal,
|
|
4254
|
+
errors: {
|
|
4255
|
+
400: `Bad Request`,
|
|
4256
|
+
401: `Unauthorized`,
|
|
4257
|
+
403: `Forbidden`,
|
|
4258
|
+
404: `Not Found`,
|
|
4259
|
+
422: `Unprocessable Entity`,
|
|
4260
|
+
500: `Internal Server Error`
|
|
4261
|
+
}
|
|
4262
|
+
});
|
|
4263
|
+
}
|
|
4264
|
+
/**
|
|
4265
|
+
* Get the human-readable Git diff of a commit
|
|
4266
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param commitUuid UUID or SHA string that identifies the commit * @returns DiffResponse Successful operation
|
|
4267
|
+
* @throws ApiError
|
|
4268
|
+
*/
|
|
4269
|
+
static getCommitDiff(provider, remoteOrganizationName, repositoryName, commitUuid, abortSignal) {
|
|
4270
|
+
return request(OpenAPI, {
|
|
4271
|
+
method: "GET",
|
|
4272
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/commits/{commitUuid}/diff",
|
|
4273
|
+
path: {
|
|
4274
|
+
"provider": provider,
|
|
4275
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
4276
|
+
"repositoryName": repositoryName,
|
|
4277
|
+
"commitUuid": commitUuid
|
|
4278
|
+
},
|
|
4279
|
+
abortSignal,
|
|
4280
|
+
errors: {
|
|
4281
|
+
400: `Bad Request`,
|
|
4282
|
+
401: `Unauthorized`,
|
|
4283
|
+
403: `Forbidden`,
|
|
4284
|
+
404: `Not Found`,
|
|
4285
|
+
422: `Unprocessable Entity`,
|
|
4286
|
+
500: `Internal Server Error`
|
|
4287
|
+
}
|
|
4288
|
+
});
|
|
4289
|
+
}
|
|
4290
|
+
/**
|
|
4291
|
+
* Get the human-readable Git diff between a head commit and a base commit
|
|
4292
|
+
* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param repositoryName Repository name on the Git provider organization* @param baseCommitUuid UUID or SHA string that identifies the base commit for a comparison* @param headCommitUuid UUID or SHA string that identifies the head commit for a comparison * @returns DiffResponse Successful operation
|
|
4293
|
+
* @throws ApiError
|
|
4294
|
+
*/
|
|
4295
|
+
static getDiffBetweenCommits(provider, remoteOrganizationName, repositoryName, baseCommitUuid, headCommitUuid, abortSignal) {
|
|
4296
|
+
return request(OpenAPI, {
|
|
4297
|
+
method: "GET",
|
|
4298
|
+
url: "/organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/base/{baseCommitUuid}/head/{headCommitUuid}/diff",
|
|
4299
|
+
path: {
|
|
4300
|
+
"provider": provider,
|
|
4301
|
+
"remoteOrganizationName": remoteOrganizationName,
|
|
4302
|
+
"repositoryName": repositoryName,
|
|
4303
|
+
"baseCommitUuid": baseCommitUuid,
|
|
4304
|
+
"headCommitUuid": headCommitUuid
|
|
4305
|
+
},
|
|
4306
|
+
abortSignal,
|
|
4307
|
+
errors: {
|
|
4308
|
+
400: `Bad Request`,
|
|
4309
|
+
401: `Unauthorized`,
|
|
4310
|
+
403: `Forbidden`,
|
|
4311
|
+
404: `Not Found`,
|
|
4312
|
+
422: `Unprocessable Entity`,
|
|
4313
|
+
500: `Internal Server Error`
|
|
4314
|
+
}
|
|
4315
|
+
});
|
|
4316
|
+
}
|
|
4317
|
+
};
|
|
4318
|
+
|
|
4319
|
+
// src/api/client/services/ToolsService.ts
|
|
4320
|
+
var ToolsService = class {
|
|
4321
|
+
/**
|
|
4322
|
+
* Retrieve the list of tools
|
|
4323
|
+
* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns ToolListResponse Successful operation
|
|
4324
|
+
* @throws ApiError
|
|
4325
|
+
*/
|
|
4326
|
+
static listTools(cursor, limit = 100, abortSignal) {
|
|
4327
|
+
return request(OpenAPI, {
|
|
4328
|
+
method: "GET",
|
|
4329
|
+
url: "/tools",
|
|
4330
|
+
query: {
|
|
4331
|
+
"cursor": cursor,
|
|
4332
|
+
"limit": limit
|
|
4333
|
+
},
|
|
4334
|
+
abortSignal,
|
|
4335
|
+
errors: {
|
|
4336
|
+
400: `Bad Request`,
|
|
4337
|
+
422: `Unprocessable Entity`,
|
|
4338
|
+
500: `Internal Server Error`
|
|
4339
|
+
}
|
|
4340
|
+
});
|
|
4341
|
+
}
|
|
4342
|
+
/**
|
|
4343
|
+
* Retrieve the list of tool patterns
|
|
4344
|
+
* @param toolUuid Unique identifier (UUID) for the tool* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return* @param enabled Filter by enabled status. Set to `true` to return only enabled patterns, or `false` to return only disabled patterns. * @returns PatternListResponse Successful operations
|
|
4345
|
+
* @throws ApiError
|
|
4346
|
+
*/
|
|
4347
|
+
static listPatterns(toolUuid, cursor, limit = 100, enabled, abortSignal) {
|
|
4348
|
+
return request(OpenAPI, {
|
|
4349
|
+
method: "GET",
|
|
4350
|
+
url: "/tools/{toolUuid}/patterns",
|
|
4351
|
+
path: {
|
|
4352
|
+
"toolUuid": toolUuid
|
|
4353
|
+
},
|
|
4354
|
+
query: {
|
|
4355
|
+
"cursor": cursor,
|
|
4356
|
+
"limit": limit,
|
|
4357
|
+
"enabled": enabled
|
|
4358
|
+
},
|
|
4359
|
+
abortSignal,
|
|
4360
|
+
errors: {
|
|
4361
|
+
400: `Bad Request`,
|
|
4362
|
+
404: `Not Found`,
|
|
4363
|
+
422: `Unprocessable Entity`,
|
|
4364
|
+
500: `Internal Server Error`
|
|
4365
|
+
}
|
|
4366
|
+
});
|
|
4367
|
+
}
|
|
4368
|
+
/**
|
|
4369
|
+
* Add feedback relating to the tool pattern
|
|
4370
|
+
* Add feedback relating to the tool pattern.
|
|
4371
|
+
*
|
|
4372
|
+
* @param toolUuid Unique identifier (UUID) for the tool* @param patternId Pattern identifier* @param provider Git provider identifier (e.g., gh for GitHub, gl for GitLab, bb for Bitbucket)* @param remoteOrganizationName Organization name on the Git provider* @param requestBody * @returns any Successful operation
|
|
4373
|
+
* @throws ApiError
|
|
4374
|
+
*/
|
|
4375
|
+
static addPatternFeedback(toolUuid, patternId, provider, remoteOrganizationName, requestBody, abortSignal) {
|
|
4376
|
+
return request(OpenAPI, {
|
|
4377
|
+
method: "POST",
|
|
4378
|
+
url: "/tools/{toolUuid}/patterns/{patternId}/organizations/{provider}/{remoteOrganizationName}/feedback",
|
|
4379
|
+
path: {
|
|
4380
|
+
"toolUuid": toolUuid,
|
|
4381
|
+
"patternId": patternId,
|
|
4382
|
+
"provider": provider,
|
|
4383
|
+
"remoteOrganizationName": remoteOrganizationName
|
|
4384
|
+
},
|
|
4385
|
+
abortSignal,
|
|
4386
|
+
body: requestBody,
|
|
4387
|
+
mediaType: "application/json",
|
|
4388
|
+
errors: {
|
|
4389
|
+
400: `Bad Request`,
|
|
4390
|
+
401: `Unauthorized`,
|
|
4391
|
+
404: `Not Found`,
|
|
4392
|
+
422: `Unprocessable Entity`,
|
|
4393
|
+
500: `Internal Server Error`
|
|
4394
|
+
}
|
|
4395
|
+
});
|
|
4396
|
+
}
|
|
4397
|
+
/**
|
|
4398
|
+
* Retrieve a tool pattern
|
|
4399
|
+
* Get the definition of a specific pattern
|
|
4400
|
+
* @param toolUuid Unique identifier (UUID) for the tool* @param patternId Pattern identifier * @returns PatternResponse Successful operation
|
|
4401
|
+
* @throws ApiError
|
|
4402
|
+
*/
|
|
4403
|
+
static getPattern(toolUuid, patternId, abortSignal) {
|
|
4404
|
+
return request(OpenAPI, {
|
|
4405
|
+
method: "GET",
|
|
4406
|
+
url: "/tools/{toolUuid}/patterns/{patternId}",
|
|
4407
|
+
path: {
|
|
4408
|
+
"toolUuid": toolUuid,
|
|
4409
|
+
"patternId": patternId
|
|
4410
|
+
},
|
|
4411
|
+
abortSignal,
|
|
4412
|
+
errors: {
|
|
4413
|
+
400: `Bad Request`,
|
|
4414
|
+
404: `Not Found`,
|
|
4415
|
+
422: `Unprocessable Entity`,
|
|
4416
|
+
500: `Internal Server Error`
|
|
4417
|
+
}
|
|
4418
|
+
});
|
|
4419
|
+
}
|
|
4420
|
+
/**
|
|
4421
|
+
* Retrieve the list of duplication tools
|
|
4422
|
+
* @returns DuplicationToolListResponse Successful operation
|
|
4423
|
+
* @throws ApiError
|
|
4424
|
+
*/
|
|
4425
|
+
static listDuplicationTools(abortSignal) {
|
|
4426
|
+
return request(OpenAPI, {
|
|
4427
|
+
method: "GET",
|
|
4428
|
+
url: "/duplicationTools",
|
|
4429
|
+
abortSignal,
|
|
4430
|
+
errors: {
|
|
4431
|
+
422: `Unprocessable Entity`,
|
|
4432
|
+
500: `Internal Server Error`
|
|
4433
|
+
}
|
|
4434
|
+
});
|
|
4435
|
+
}
|
|
4436
|
+
/**
|
|
4437
|
+
* Retrieve the list of metrics tools
|
|
4438
|
+
* @returns MetricsToolListResponse Successful operation
|
|
4439
|
+
* @throws ApiError
|
|
4440
|
+
*/
|
|
4441
|
+
static listMetricsTools(abortSignal) {
|
|
4442
|
+
return request(OpenAPI, {
|
|
4443
|
+
method: "GET",
|
|
4444
|
+
url: "/metricsTools",
|
|
4445
|
+
abortSignal,
|
|
4446
|
+
errors: {
|
|
4447
|
+
422: `Unprocessable Entity`,
|
|
4448
|
+
500: `Internal Server Error`
|
|
4449
|
+
}
|
|
4450
|
+
});
|
|
4451
|
+
}
|
|
4452
|
+
};
|
|
4453
|
+
|
|
4454
|
+
// src/api/index.ts
|
|
4455
|
+
function configureApiToken(token) {
|
|
4456
|
+
OpenAPI.HEADERS = { "api-token": token };
|
|
4457
|
+
}
|
|
4458
|
+
async function fetchAllPages(fetcher) {
|
|
4459
|
+
const results = [];
|
|
4460
|
+
let cursor = void 0;
|
|
4461
|
+
while (true) {
|
|
4462
|
+
const page = await fetcher(cursor);
|
|
4463
|
+
results.push(...page.data);
|
|
4464
|
+
cursor = page.pagination?.cursor;
|
|
4465
|
+
if (!cursor || page.data.length === 0) break;
|
|
4466
|
+
}
|
|
4467
|
+
return results;
|
|
4468
|
+
}
|
|
4469
|
+
async function validateApiToken(token) {
|
|
4470
|
+
configureApiToken(token);
|
|
4471
|
+
const response = await AccountService.getUser();
|
|
4472
|
+
return { valid: true, name: response.data.name, email: response.data.mainEmail };
|
|
4473
|
+
}
|
|
4474
|
+
async function listTools() {
|
|
4475
|
+
return fetchAllPages((cursor) => ToolsService.listTools(cursor, 100));
|
|
4476
|
+
}
|
|
4477
|
+
async function listPatterns(toolUuid) {
|
|
4478
|
+
return fetchAllPages((cursor) => ToolsService.listPatterns(toolUuid, cursor, 100));
|
|
4479
|
+
}
|
|
4480
|
+
async function getRepository(provider, org, repo) {
|
|
4481
|
+
const response = await RepositoryService.getRepository(provider, org, repo);
|
|
4482
|
+
return response.data;
|
|
4483
|
+
}
|
|
4484
|
+
async function listRepositoryTools(provider, org, repo) {
|
|
4485
|
+
const response = await AnalysisService.listRepositoryTools(provider, org, repo);
|
|
4486
|
+
return response.data.filter((t) => t.settings.isEnabled);
|
|
4487
|
+
}
|
|
4488
|
+
async function listRepositoryToolPatterns(provider, org, repo, toolUuid) {
|
|
4489
|
+
const all = await fetchAllPages(
|
|
4490
|
+
(cursor) => AnalysisService.listRepositoryToolPatterns(
|
|
4491
|
+
provider,
|
|
4492
|
+
org,
|
|
4493
|
+
repo,
|
|
4494
|
+
toolUuid,
|
|
4495
|
+
void 0,
|
|
4496
|
+
// languages
|
|
4497
|
+
void 0,
|
|
4498
|
+
// categories
|
|
4499
|
+
void 0,
|
|
4500
|
+
// severityLevels
|
|
4501
|
+
void 0,
|
|
4502
|
+
// tags
|
|
4503
|
+
void 0,
|
|
4504
|
+
// search
|
|
4505
|
+
true,
|
|
4506
|
+
// enabled — fetch only enabled patterns
|
|
4507
|
+
void 0,
|
|
4508
|
+
// recommended
|
|
4509
|
+
void 0,
|
|
4510
|
+
// sort
|
|
4511
|
+
void 0,
|
|
4512
|
+
// direction
|
|
4513
|
+
cursor,
|
|
4514
|
+
100
|
|
4515
|
+
)
|
|
4516
|
+
);
|
|
4517
|
+
return all;
|
|
4518
|
+
}
|
|
4519
|
+
|
|
4520
|
+
// src/init.ts
|
|
4521
|
+
async function detectLanguages(repositoryRoot) {
|
|
4522
|
+
let files = [];
|
|
4523
|
+
try {
|
|
4524
|
+
const output = (0, import_child_process2.execSync)("git ls-files", {
|
|
4525
|
+
cwd: repositoryRoot,
|
|
4526
|
+
encoding: "utf-8",
|
|
4527
|
+
maxBuffer: 50 * 1024 * 1024
|
|
4528
|
+
}).trim();
|
|
4529
|
+
files = output ? output.split("\n") : [];
|
|
4530
|
+
} catch {
|
|
4531
|
+
return [];
|
|
4532
|
+
}
|
|
4533
|
+
const detected = /* @__PURE__ */ new Set();
|
|
4534
|
+
for (const file of files) {
|
|
4535
|
+
const basename = import_path6.default.basename(file);
|
|
4536
|
+
const ext = import_path6.default.extname(file).toLowerCase();
|
|
4537
|
+
for (const [lang, config] of Object.entries(import_tooling.LANGUAGE_CONFIG)) {
|
|
4538
|
+
if (config.extensions.includes(ext)) {
|
|
4539
|
+
detected.add(lang);
|
|
4540
|
+
} else if (config.files.includes(basename)) {
|
|
4541
|
+
detected.add(lang);
|
|
4542
|
+
}
|
|
4543
|
+
}
|
|
4544
|
+
}
|
|
4545
|
+
return Array.from(detected).sort();
|
|
4546
|
+
}
|
|
4547
|
+
async function detectLocalConfigFiles(repositoryRoot, adapters2) {
|
|
4548
|
+
const found = /* @__PURE__ */ new Map();
|
|
4549
|
+
const checks = await Promise.allSettled(
|
|
4550
|
+
adapters2.map(async (adapter) => {
|
|
4551
|
+
const result = await adapter.checkLocalConfigurationFile({
|
|
4552
|
+
repositoryRoot,
|
|
4553
|
+
generatedConfigDir: import_path6.default.join(repositoryRoot, ".codacy", "generated"),
|
|
4554
|
+
globalDir: import_path6.default.join(process.env.HOME ?? "~", ".codacy"),
|
|
4555
|
+
toolInstallDir: import_path6.default.join(process.env.HOME ?? "~", ".codacy", "tools", adapter.id),
|
|
4556
|
+
targetFiles: [],
|
|
4557
|
+
platform: { os: process.platform, arch: process.arch },
|
|
4558
|
+
logger: silentLogger,
|
|
4559
|
+
runner: "local"
|
|
4560
|
+
});
|
|
4561
|
+
return { toolId: adapter.id, result };
|
|
4562
|
+
})
|
|
4563
|
+
);
|
|
4564
|
+
for (const outcome of checks) {
|
|
4565
|
+
if (outcome.status === "fulfilled" && outcome.value.result.found && outcome.value.result.path) {
|
|
4566
|
+
found.set(outcome.value.toolId, outcome.value.result.path);
|
|
4567
|
+
}
|
|
4568
|
+
}
|
|
4569
|
+
return found;
|
|
4570
|
+
}
|
|
4571
|
+
var silentLogger = {
|
|
4572
|
+
debug: () => {
|
|
4573
|
+
},
|
|
4574
|
+
info: () => {
|
|
4575
|
+
},
|
|
4576
|
+
warn: () => {
|
|
4577
|
+
},
|
|
4578
|
+
error: () => {
|
|
4579
|
+
}
|
|
4580
|
+
};
|
|
4581
|
+
async function enrichWithCodacyYaml(config, repositoryRoot, adapters2) {
|
|
4582
|
+
const yamlConfig = await readCodacyYaml(repositoryRoot);
|
|
4583
|
+
if (!yamlConfig) return { config, codacyYamlApplied: false };
|
|
4584
|
+
return {
|
|
4585
|
+
config: applyCodacyYamlExcludes(config, yamlConfig, adapters2),
|
|
4586
|
+
codacyYamlApplied: true
|
|
4587
|
+
};
|
|
4588
|
+
}
|
|
4589
|
+
async function initLocalConfigBase(repositoryRoot, adapters2) {
|
|
4590
|
+
const languages = await detectLanguages(repositoryRoot);
|
|
4591
|
+
const localConfigs = await detectLocalConfigFiles(repositoryRoot, adapters2);
|
|
4592
|
+
const tools = [];
|
|
4593
|
+
for (const [toolId, configPath] of localConfigs.entries()) {
|
|
4594
|
+
tools.push({
|
|
4595
|
+
toolId,
|
|
4596
|
+
localConfigurationFile: configPath,
|
|
4597
|
+
useLocalConfigurationFile: true,
|
|
4598
|
+
patterns: []
|
|
4599
|
+
});
|
|
4600
|
+
}
|
|
4601
|
+
return createCodacyConfig({ source: "local", languages, tools });
|
|
4602
|
+
}
|
|
4603
|
+
async function initLocalConfig(repositoryRoot, adapters2) {
|
|
4604
|
+
const baseConfig = await initLocalConfigBase(repositoryRoot, adapters2);
|
|
4605
|
+
const { config, codacyYamlApplied } = await enrichWithCodacyYaml(baseConfig, repositoryRoot, adapters2);
|
|
4606
|
+
return { config, stats: { codacyYamlApplied } };
|
|
4607
|
+
}
|
|
4608
|
+
async function initDefaultConfig(repositoryRoot, adapters2) {
|
|
4609
|
+
const base = await initLocalConfigBase(repositoryRoot, adapters2);
|
|
4610
|
+
const toolsWithLocalConfig = new Set(
|
|
4611
|
+
base.tools.filter((t) => t.useLocalConfigurationFile).map((t) => t.toolId)
|
|
4612
|
+
);
|
|
4613
|
+
const apiTools = await listTools();
|
|
4614
|
+
const repoLanguages = new Set(base.metadata.languages);
|
|
4615
|
+
const updatedTools = [...base.tools];
|
|
4616
|
+
const coveredToolIds = new Set(updatedTools.map((t) => t.toolId));
|
|
4617
|
+
let addedTools = 0;
|
|
4618
|
+
for (const adapter of adapters2) {
|
|
4619
|
+
if (toolsWithLocalConfig.has(adapter.id)) continue;
|
|
4620
|
+
const apiTool = apiTools.find(
|
|
4621
|
+
(t) => t.prefix ? t.prefix.replace(/_$/, "") === adapter.id : t.name === adapter.id
|
|
4622
|
+
);
|
|
4623
|
+
if (!apiTool) continue;
|
|
4624
|
+
if (!apiTool.enabledByDefault) continue;
|
|
4625
|
+
if (apiTool.languages.length > 0 && repoLanguages.size > 0) {
|
|
4626
|
+
const hasOverlap = apiTool.languages.some((lang) => repoLanguages.has(lang));
|
|
4627
|
+
if (!hasOverlap) continue;
|
|
4628
|
+
}
|
|
4629
|
+
let patterns = [];
|
|
4630
|
+
try {
|
|
4631
|
+
const apiPatterns = await listPatterns(apiTool.uuid);
|
|
4632
|
+
patterns = apiPatterns.filter((p) => p.enabled).map((p) => ({ patternId: p.id }));
|
|
4633
|
+
} catch {
|
|
4634
|
+
}
|
|
4635
|
+
if (!coveredToolIds.has(adapter.id)) {
|
|
4636
|
+
updatedTools.push({
|
|
4637
|
+
toolId: adapter.id,
|
|
4638
|
+
patterns
|
|
4639
|
+
});
|
|
4640
|
+
coveredToolIds.add(adapter.id);
|
|
4641
|
+
addedTools++;
|
|
4642
|
+
}
|
|
4643
|
+
}
|
|
4644
|
+
const baseConfig = createCodacyConfig({ source: "default", languages: base.metadata.languages, tools: updatedTools });
|
|
4645
|
+
const { config, codacyYamlApplied } = await enrichWithCodacyYaml(baseConfig, repositoryRoot, adapters2);
|
|
4646
|
+
return { config, stats: { totalApiTools: apiTools.length, addedTools, codacyYamlApplied } };
|
|
4647
|
+
}
|
|
4648
|
+
async function initRemoteConfig(repositoryRoot, provider, organization, repositoryName, adapters2, apiToken, onRemoteToolsFound, onToolProcessed) {
|
|
4649
|
+
configureApiToken(apiToken);
|
|
4650
|
+
const repoInfo = await getRepository(provider, organization, repositoryName);
|
|
4651
|
+
const remoteTools = await listRepositoryTools(provider, organization, repositoryName);
|
|
4652
|
+
const adapterByName = /* @__PURE__ */ new Map();
|
|
4653
|
+
for (const adapter of adapters2) {
|
|
4654
|
+
adapterByName.set(adapter.id, adapter);
|
|
4655
|
+
adapterByName.set(adapter.displayName.toLowerCase(), adapter);
|
|
4656
|
+
}
|
|
4657
|
+
const localConfigs = await detectLocalConfigFiles(repositoryRoot, adapters2);
|
|
4658
|
+
const allApiTools = await listTools();
|
|
4659
|
+
const adapterByUuid = /* @__PURE__ */ new Map();
|
|
4660
|
+
for (const apiTool of allApiTools) {
|
|
4661
|
+
const adapter = apiTool.prefix ? adapterByName.get(apiTool.prefix.replace(/_$/, "")) : adapterByName.get(apiTool.name);
|
|
4662
|
+
if (adapter) {
|
|
4663
|
+
adapterByUuid.set(apiTool.uuid, adapter);
|
|
4664
|
+
}
|
|
4665
|
+
}
|
|
4666
|
+
const matchedAdapterCount = remoteTools.filter((t) => adapterByUuid.has(t.uuid)).length;
|
|
4667
|
+
onRemoteToolsFound?.(remoteTools.length, matchedAdapterCount);
|
|
4668
|
+
const tools = [];
|
|
4669
|
+
let matchedAdapters = 0;
|
|
4670
|
+
for (const remoteTool of remoteTools) {
|
|
4671
|
+
const adapter = adapterByUuid.get(remoteTool.uuid);
|
|
4672
|
+
if (!adapter) continue;
|
|
4673
|
+
matchedAdapters++;
|
|
4674
|
+
const usesLocalConfig = remoteTool.settings.usesConfigurationFile;
|
|
4675
|
+
const localConfigPath = localConfigs.get(adapter.id);
|
|
4676
|
+
let patterns = [];
|
|
4677
|
+
if (!usesLocalConfig) {
|
|
4678
|
+
try {
|
|
4679
|
+
const configuredPatterns = await listRepositoryToolPatterns(
|
|
4680
|
+
provider,
|
|
4681
|
+
organization,
|
|
4682
|
+
repositoryName,
|
|
4683
|
+
remoteTool.uuid
|
|
4684
|
+
);
|
|
4685
|
+
patterns = configuredPatterns.map((cp) => {
|
|
4686
|
+
const params = cp.parameters.length > 0 ? Object.fromEntries(cp.parameters.map((p) => [p.name, p.value])) : void 0;
|
|
4687
|
+
return {
|
|
4688
|
+
patternId: cp.patternDefinition.id,
|
|
4689
|
+
...params ? { parameters: params } : {}
|
|
4690
|
+
};
|
|
4691
|
+
});
|
|
4692
|
+
} catch {
|
|
4693
|
+
}
|
|
4694
|
+
}
|
|
4695
|
+
onToolProcessed?.(adapter.displayName, patterns.length, usesLocalConfig);
|
|
4696
|
+
tools.push({
|
|
4697
|
+
toolId: adapter.id,
|
|
4698
|
+
...localConfigPath ? { localConfigurationFile: localConfigPath } : {},
|
|
4699
|
+
// Honour local config when the API says usesConfigurationFile, OR when a
|
|
4700
|
+
// local config exists and no patterns were configured (backwards-compat).
|
|
4701
|
+
...usesLocalConfig || localConfigPath && patterns.length === 0 ? { useLocalConfigurationFile: true } : {},
|
|
4702
|
+
patterns
|
|
4703
|
+
});
|
|
4704
|
+
}
|
|
4705
|
+
const baseConfig = createCodacyConfig({
|
|
4706
|
+
source: "remote",
|
|
4707
|
+
provider,
|
|
4708
|
+
organization,
|
|
4709
|
+
languages: repoInfo.languages,
|
|
4710
|
+
tools,
|
|
4711
|
+
repositoryId: repoInfo.repositoryId != null ? String(repoInfo.repositoryId) : void 0,
|
|
4712
|
+
repositoryName
|
|
4713
|
+
});
|
|
4714
|
+
const { config, codacyYamlApplied } = await enrichWithCodacyYaml(baseConfig, repositoryRoot, adapters2);
|
|
4715
|
+
return { config, stats: { totalRemoteTools: remoteTools.length, matchedAdapters, codacyYamlApplied } };
|
|
4716
|
+
}
|
|
4717
|
+
async function initContainerConfig(repositoryRoot, adapters2) {
|
|
4718
|
+
const codacyrcPath = import_path6.default.join(repositoryRoot, ".codacyrc");
|
|
4719
|
+
let raw;
|
|
4720
|
+
try {
|
|
4721
|
+
raw = await import_promises3.default.readFile(codacyrcPath, "utf-8");
|
|
4722
|
+
} catch {
|
|
4723
|
+
throw new Error(`.codacyrc not found at ${codacyrcPath}`);
|
|
4724
|
+
}
|
|
4725
|
+
let parsed;
|
|
4726
|
+
try {
|
|
4727
|
+
parsed = JSON.parse(raw);
|
|
4728
|
+
} catch {
|
|
4729
|
+
try {
|
|
4730
|
+
const decoded = Buffer.from(raw.trim(), "base64").toString("utf-8");
|
|
4731
|
+
parsed = JSON.parse(decoded);
|
|
4732
|
+
} catch {
|
|
4733
|
+
throw new Error(`Failed to parse .codacyrc: not valid JSON or base64-encoded JSON`);
|
|
4734
|
+
}
|
|
4735
|
+
}
|
|
4736
|
+
const includeFiles = Array.isArray(parsed.files) ? parsed.files.filter((f) => typeof f === "string") : [];
|
|
4737
|
+
const adapterById = new Map(adapters2.map((a) => [a.id, a]));
|
|
4738
|
+
const tools = [];
|
|
4739
|
+
if (Array.isArray(parsed.tools)) {
|
|
4740
|
+
for (const toolEntry of parsed.tools) {
|
|
4741
|
+
if (typeof toolEntry !== "object" || toolEntry === null) continue;
|
|
4742
|
+
const entry = toolEntry;
|
|
4743
|
+
const toolId = typeof entry["toolId"] === "string" ? entry["toolId"] : void 0;
|
|
4744
|
+
if (!toolId || !adapterById.has(toolId)) continue;
|
|
4745
|
+
const patterns = [];
|
|
4746
|
+
if (Array.isArray(entry["patterns"])) {
|
|
4747
|
+
for (const p of entry["patterns"]) {
|
|
4748
|
+
if (typeof p === "object" && p !== null && typeof p["patternId"] === "string") {
|
|
4749
|
+
const pe = p;
|
|
4750
|
+
patterns.push({
|
|
4751
|
+
patternId: pe["patternId"],
|
|
4752
|
+
...pe["parameters"] && typeof pe["parameters"] === "object" ? { parameters: pe["parameters"] } : {}
|
|
4753
|
+
});
|
|
4754
|
+
}
|
|
4755
|
+
}
|
|
4756
|
+
}
|
|
4757
|
+
tools.push({ toolId, patterns });
|
|
4758
|
+
}
|
|
4759
|
+
}
|
|
4760
|
+
return createCodacyConfig({ source: "container", tools, includeFiles });
|
|
4761
|
+
}
|
|
4762
|
+
|
|
4763
|
+
// src/logger.ts
|
|
4764
|
+
var import_fs = __toESM(require("fs"));
|
|
4765
|
+
var import_path7 = __toESM(require("path"));
|
|
4766
|
+
var import_os2 = __toESM(require("os"));
|
|
4767
|
+
var LEVEL_ORDER = {
|
|
4768
|
+
debug: 0,
|
|
4769
|
+
info: 1,
|
|
4770
|
+
warning: 2,
|
|
4771
|
+
error: 3
|
|
4772
|
+
};
|
|
4773
|
+
function rotateLogFiles(logsDir, maxFiles) {
|
|
4774
|
+
let entries;
|
|
4775
|
+
try {
|
|
4776
|
+
entries = import_fs.default.readdirSync(logsDir).filter((f) => f.startsWith("analysis-") && f.endsWith(".log"));
|
|
4777
|
+
} catch {
|
|
4778
|
+
return;
|
|
4779
|
+
}
|
|
4780
|
+
if (entries.length <= maxFiles) return;
|
|
4781
|
+
entries.sort();
|
|
4782
|
+
const toRemove = entries.slice(0, entries.length - maxFiles);
|
|
4783
|
+
for (const f of toRemove) {
|
|
4784
|
+
try {
|
|
4785
|
+
import_fs.default.unlinkSync(import_path7.default.join(logsDir, f));
|
|
4786
|
+
} catch {
|
|
4787
|
+
}
|
|
4788
|
+
}
|
|
4789
|
+
}
|
|
4790
|
+
function fileTimestamp() {
|
|
4791
|
+
return (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
4792
|
+
}
|
|
4793
|
+
function enrichMessage(message, fields) {
|
|
4794
|
+
if (!fields) return message;
|
|
4795
|
+
const parts = [];
|
|
4796
|
+
if (fields.toolId) parts.push(String(fields.toolId));
|
|
4797
|
+
if (fields.version) parts.push(`v${fields.version}`);
|
|
4798
|
+
if (fields.installation) parts.push(String(fields.installation));
|
|
4799
|
+
if (fields.configSource) parts.push(String(fields.configSource));
|
|
4800
|
+
if (typeof fields.fileCount === "number") parts.push(`${fields.fileCount} files`);
|
|
4801
|
+
if (typeof fields.issueCount === "number") parts.push(`${fields.issueCount} issues`);
|
|
4802
|
+
if (typeof fields.errorCount === "number" && fields.errorCount > 0) parts.push(`${fields.errorCount} errors`);
|
|
4803
|
+
if (typeof fields.totalIssues === "number") parts.push(`${fields.totalIssues} issues`);
|
|
4804
|
+
if (typeof fields.totalErrors === "number" && fields.totalErrors > 0) parts.push(`${fields.totalErrors} errors`);
|
|
4805
|
+
if (typeof fields.durationMs === "number") parts.push(`${(fields.durationMs / 1e3).toFixed(1)}s`);
|
|
4806
|
+
if (fields.reason) parts.push(String(fields.reason));
|
|
4807
|
+
if (fields.error) parts.push(String(fields.error));
|
|
4808
|
+
if (typeof fields.found === "boolean") parts.push(fields.found ? "found" : "not found");
|
|
4809
|
+
if (fields.path && !fields.version) parts.push(String(fields.path));
|
|
4810
|
+
if (parts.length === 0) return message;
|
|
4811
|
+
return `${message} (${parts.join(", ")})`;
|
|
4812
|
+
}
|
|
4813
|
+
function createLogger(options = {}) {
|
|
4814
|
+
const minLevel = LEVEL_ORDER[options.level ?? "info"];
|
|
4815
|
+
const fileEnabled = options.fileEnabled ?? true;
|
|
4816
|
+
const logsDir = options.logsDir ?? import_path7.default.join(import_os2.default.homedir(), ".codacy", "logs");
|
|
4817
|
+
const maxFileSize = options.maxFileSize ?? 10 * 1024 * 1024;
|
|
4818
|
+
const maxFiles = options.maxFiles ?? 5;
|
|
4819
|
+
const onStderrMessage = options.onStderrMessage;
|
|
4820
|
+
let logFd = null;
|
|
4821
|
+
let bytesWritten = 0;
|
|
4822
|
+
if (fileEnabled) {
|
|
4823
|
+
import_fs.default.mkdirSync(logsDir, { recursive: true });
|
|
4824
|
+
rotateLogFiles(logsDir, maxFiles);
|
|
4825
|
+
const logFilePath = import_path7.default.join(logsDir, `analysis-${fileTimestamp()}.log`);
|
|
4826
|
+
logFd = import_fs.default.openSync(logFilePath, "a");
|
|
4827
|
+
}
|
|
4828
|
+
function log(level, message, fields) {
|
|
4829
|
+
const numLevel = LEVEL_ORDER[level];
|
|
4830
|
+
if (numLevel < minLevel) return;
|
|
4831
|
+
if (fileEnabled && logFd !== null) {
|
|
4832
|
+
const entry = JSON.stringify({
|
|
4833
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4834
|
+
level,
|
|
4835
|
+
message,
|
|
4836
|
+
...fields
|
|
4837
|
+
});
|
|
4838
|
+
const buf = Buffer.from(entry + "\n", "utf-8");
|
|
4839
|
+
import_fs.default.writeSync(logFd, buf);
|
|
4840
|
+
bytesWritten += buf.length;
|
|
4841
|
+
if (bytesWritten >= maxFileSize) {
|
|
4842
|
+
import_fs.default.closeSync(logFd);
|
|
4843
|
+
rotateLogFiles(logsDir, maxFiles);
|
|
4844
|
+
const newPath = import_path7.default.join(logsDir, `analysis-${fileTimestamp()}.log`);
|
|
4845
|
+
logFd = import_fs.default.openSync(newPath, "a");
|
|
4846
|
+
bytesWritten = 0;
|
|
4847
|
+
}
|
|
4848
|
+
}
|
|
4849
|
+
const enriched = enrichMessage(message, fields);
|
|
4850
|
+
if (onStderrMessage) {
|
|
4851
|
+
onStderrMessage(enriched, level);
|
|
4852
|
+
} else {
|
|
4853
|
+
process.stderr.write(` ${enriched}
|
|
4854
|
+
`);
|
|
4855
|
+
}
|
|
4856
|
+
}
|
|
4857
|
+
return {
|
|
4858
|
+
debug: (msg, fields) => log("debug", msg, fields),
|
|
4859
|
+
info: (msg, fields) => log("info", msg, fields),
|
|
4860
|
+
warn: (msg, fields) => log("warning", msg, fields),
|
|
4861
|
+
error: (msg, fields) => log("error", msg, fields)
|
|
4862
|
+
};
|
|
4863
|
+
}
|
|
4864
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
4865
|
+
0 && (module.exports = {
|
|
4866
|
+
analyze,
|
|
4867
|
+
applyCodacyYamlExcludes,
|
|
4868
|
+
buildToolConfig,
|
|
4869
|
+
clearAdapters,
|
|
4870
|
+
configureApiToken,
|
|
4871
|
+
createCodacyConfig,
|
|
4872
|
+
createLogger,
|
|
4873
|
+
detectLanguages,
|
|
4874
|
+
formatOutput,
|
|
4875
|
+
formatTextSummary,
|
|
4876
|
+
getRegisteredAdapters,
|
|
4877
|
+
initContainerConfig,
|
|
4878
|
+
initDefaultConfig,
|
|
4879
|
+
initLocalConfig,
|
|
4880
|
+
initRemoteConfig,
|
|
4881
|
+
readCodacyConfig,
|
|
4882
|
+
readCodacyYaml,
|
|
4883
|
+
registerAdapter,
|
|
4884
|
+
resolveEngineToAdapter,
|
|
4885
|
+
rotateLogFiles,
|
|
4886
|
+
validateApiToken,
|
|
4887
|
+
writeCodacyConfig
|
|
4888
|
+
});
|