@codacy/analysis-runner 0.10.1 → 0.12.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +85 -59
  2. package/dist/index.js +653 -227
  3. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { OutputFormat, Logger, AnalysisResult, ToolAdapter, AdapterDescriptor, CodacyConfig, ConfigurationFileCheckResult, CodacyToolConfig, IssueSeverity, IssueCategory, Language, DiscoveryResult, Issue, PatternSummary, LogLevel } from '@codacy/tooling';
1
+ import { OutputFormat, Logger, AnalysisResult, ToolAdapter, AdapterDescriptor, CodacyConfig, ConfigurationFileCheckResult, CodacyToolConfig, IssueSeverity, IssueCategory, Language, DiscoveryResult, PatternEntry, Issue, PatternSummary, LogLevel } from '@codacy/tooling';
2
2
  export { AnalysisResult, OutputFormat } from '@codacy/tooling';
3
3
 
4
4
  /**
@@ -27,7 +27,7 @@ interface AnalyzeOptions {
27
27
  outputFormat?: OutputFormat;
28
28
  /** Execution mode. Defaults to "standard". */
29
29
  mode?: ExecutionMode;
30
- /** Maximum time in ms for each tool invocation. Defaults to 600000 (10 minutes). */
30
+ /** Maximum time in ms for each tool invocation. Defaults to 900000 (15 minutes). */
31
31
  toolTimeout?: number;
32
32
  /** Maximum number of tools to run in parallel. 1 = sequential. Defaults to 1. */
33
33
  parallelTools?: number;
@@ -94,6 +94,17 @@ declare function registerAdapter(adapter: Readonly<ToolAdapter>): void;
94
94
  * and inspect-mode metadata display without loading the full module.
95
95
  */
96
96
  declare function registerLazyAdapter(descriptor: AdapterDescriptor, factory: AdapterFactory): void;
97
+ /**
98
+ * Register an unsupported (cloud-only) tool by descriptor alone.
99
+ *
100
+ * These tools exist on Codacy Cloud but have no local analyzer in this CLI. They are
101
+ * registered so that `getRegisteredDescriptors()` (and therefore `info`, `init --auto`,
102
+ * and config generation) can see them, but they are intentionally excluded from
103
+ * `getRegisteredAdapters()`/`getAdapter()` since there is nothing to execute.
104
+ *
105
+ * The descriptor should have `unsupported: true`.
106
+ */
107
+ declare function registerUnsupportedTool(descriptor: AdapterDescriptor): void;
97
108
  /**
98
109
  * Returns all registered adapters, optionally filtered by tool ID list.
99
110
  *
@@ -309,6 +320,53 @@ declare function parseAutoFilters(raw: string): {
309
320
  unknown: string[];
310
321
  };
311
322
 
323
+ /**
324
+ * Codacy API client — thin wrappers around the generated OpenAPI client.
325
+ *
326
+ * The generated client (src/api/client/) is produced from the Codacy OpenAPI spec
327
+ * and should never be edited by hand. All API interactions go through this file.
328
+ *
329
+ * Authentication: Codacy uses an `api-token` header (not Bearer). We set it via
330
+ * `OpenAPI.HEADERS` before each call group. `configureApiToken()` must be called
331
+ * before any authenticated endpoint is used.
332
+ *
333
+ * Pagination: all list endpoints use cursor-based pagination. `fetchAllPages()`
334
+ * follows cursors until the response contains no next cursor.
335
+ */
336
+
337
+ /** Result of fetching cloud-ignored files, with pagination cap. */
338
+ interface IgnoredFilesResult {
339
+ /** File paths ignored in Codacy Cloud. */
340
+ files: string[];
341
+ /** Total number of files fetched (same as files.length). */
342
+ totalFetched: number;
343
+ /** Whether the fetch was stopped because it hit the 1000-file cap. */
344
+ capped: boolean;
345
+ }
346
+ /**
347
+ * Configures the API token used for authenticated requests.
348
+ * Must be called before `getRepository`, `listRepositoryTools`, or
349
+ * `listRepositoryToolPatterns`. Public endpoints (listTools, listPatterns)
350
+ * do not require a token.
351
+ */
352
+ declare function configureApiToken(token: string): void;
353
+ /**
354
+ * Validates an API token by calling the authenticated user endpoint.
355
+ * Returns user info on success; caller should catch errors for invalid tokens.
356
+ */
357
+ declare function validateApiToken(token: string): Promise<{
358
+ valid: boolean;
359
+ name?: string;
360
+ email?: string;
361
+ }>;
362
+ /**
363
+ * Fetches files individually ignored in Codacy Cloud for a repository.
364
+ * Uses cursor-based pagination capped at 10 pages (1000 files max) to avoid
365
+ * unbounded fetching for repositories with very large ignore lists.
366
+ * Requires `configureApiToken()` to have been called.
367
+ */
368
+ declare function listIgnoredFiles(provider: string, org: string, repo: string): Promise<IgnoredFilesResult>;
369
+
312
370
  /**
313
371
  * Init mode logic — builds a CodacyConfig from five distinct sources:
314
372
  *
@@ -348,8 +406,10 @@ declare function initLocalConfig(repositoryRoot: string, adapters: Readonly<Tool
348
406
  interface InitDefaultStats {
349
407
  /** Total number of tools listed by the Codacy API. */
350
408
  totalApiTools: number;
351
- /** Number of tool entries added to the config from API defaults. */
409
+ /** Number of supported (local-adapter) tool entries added from API defaults. */
352
410
  addedTools: number;
411
+ /** Number of unsupported (cloud-only) tool entries added from API defaults. */
412
+ addedUnsupported: number;
353
413
  /** Whether a .codacy.yaml file was found and its exclude paths were applied. */
354
414
  codacyYamlApplied: boolean;
355
415
  }
@@ -373,6 +433,8 @@ interface InitRemoteStats {
373
433
  totalRemoteTools: number;
374
434
  /** Number of those tools that have a registered local adapter. */
375
435
  matchedAdapters: number;
436
+ /** Number of those tools included as unsupported (cloud-only) entries. */
437
+ unsupportedTools: number;
376
438
  /** Whether a .codacy.yaml file was found and its exclude paths were applied. */
377
439
  codacyYamlApplied: boolean;
378
440
  /** Number of cloud-ignored files fetched from the Codacy API. */
@@ -383,8 +445,10 @@ interface InitRemoteStats {
383
445
  /**
384
446
  * `--remote <provider> <org> <repo>` mode.
385
447
  * Fetches the full tool/pattern configuration from the repository's Codacy settings.
386
- * The remote config is treated as the source of truth — only tools with a registered
387
- * adapter are included.
448
+ * The remote config is treated as the source of truth: tools with a registered adapter
449
+ * are included as supported tools, and enabled tools without a local adapter are tracked
450
+ * as unsupported (cloud-only) entries (subject to the trackability filter — deprecated and
451
+ * client-side/standalone-only tools are skipped).
388
452
  *
389
453
  * @param onRemoteToolsFound - Optional callback invoked once after the list of enabled
390
454
  * remote tools is fetched. Receives the total count of enabled tools and the count
@@ -418,8 +482,10 @@ interface InitAutoStats {
418
482
  detectedFrameworks: number;
419
483
  /** Number of libraries detected by discover. */
420
484
  detectedLibraries: number;
421
- /** Number of tool entries added to the config. */
485
+ /** Number of tool entries added to the config (supported + unsupported). */
422
486
  selectedTools: number;
487
+ /** Number of those entries that are unsupported (cloud-only) tools. */
488
+ selectedUnsupported: number;
423
489
  /** Whether a .codacy.yaml file was found and its exclude paths were applied. */
424
490
  codacyYamlApplied: boolean;
425
491
  }
@@ -440,8 +506,16 @@ interface InitAutoStats {
440
506
  * ESLint core rules and their `@typescript-eslint` equivalents may both be
441
507
  * enabled, potentially causing duplicate findings. This will be addressed in v2
442
508
  * via conflict-resolution metadata in the mapping files.
509
+ *
510
+ * Unsupported (cloud-only) tools — descriptors with `unsupported: true` — are
511
+ * also filled when their languages overlap the detected stack. Their patterns are
512
+ * loaded lazily via `loadUnsupportedPatterns`; when it is not provided they are
513
+ * skipped. Tools that ship framework-specific patterns (e.g. PHPCS, dartanalyzer,
514
+ * SonarCSharp, CodeNarc) carry curated `frameworkMappings` on their descriptor, so
515
+ * those patterns are gated on detected frameworks exactly like supported tools;
516
+ * tools without mappings have every committed pattern treated as universal.
443
517
  */
444
- declare function initAutoConfig(repositoryRoot: string, adapters: Readonly<ToolAdapter>[], descriptors: AdapterDescriptor[], filters?: AutoFilters, onDiscoveryComplete?: (result: DiscoveryResult) => void, rawFilterString?: string): Promise<{
518
+ declare function initAutoConfig(repositoryRoot: string, adapters: Readonly<ToolAdapter>[], descriptors: AdapterDescriptor[], filters?: AutoFilters, onDiscoveryComplete?: (result: DiscoveryResult) => void, rawFilterString?: string, loadUnsupportedPatterns?: (toolId: string) => readonly PatternEntry[]): Promise<{
445
519
  config: CodacyConfig;
446
520
  stats: InitAutoStats;
447
521
  }>;
@@ -527,11 +601,10 @@ interface PatternMetadataLookup {
527
601
  declare function computePatternSummary(issues: readonly Issue[], lookup: ReadonlyMap<string, PatternMetadataLookup>): PatternSummary;
528
602
 
529
603
  /**
530
- * File discovery and routing — finds files in a repository, applies exclusion
531
- * layers (.gitignore, global exclude, per-tool exclude), and routes files to
532
- * the appropriate tool adapters based on file patterns.
604
+ * Git-scope file resolution — resolves the set of files implied by the
605
+ * `--staged`, `--diff`, and `--pr` flags. Each helper returns paths relative
606
+ * to the repository root, excluding deleted files, sorted for stable output.
533
607
  */
534
-
535
608
  /**
536
609
  * Returns files changed in the git staging area (index), excluding deleted files.
537
610
  * Used by `--staged` to analyze only what's about to be committed.
@@ -552,53 +625,6 @@ declare function listDiffFiles(repositoryRoot: string, base?: string): string[];
552
625
  */
553
626
  declare function listPrFiles(repositoryRoot: string): string[];
554
627
 
555
- /**
556
- * Codacy API client — thin wrappers around the generated OpenAPI client.
557
- *
558
- * The generated client (src/api/client/) is produced from the Codacy OpenAPI spec
559
- * and should never be edited by hand. All API interactions go through this file.
560
- *
561
- * Authentication: Codacy uses an `api-token` header (not Bearer). We set it via
562
- * `OpenAPI.HEADERS` before each call group. `configureApiToken()` must be called
563
- * before any authenticated endpoint is used.
564
- *
565
- * Pagination: all list endpoints use cursor-based pagination. `fetchAllPages()`
566
- * follows cursors until the response contains no next cursor.
567
- */
568
-
569
- /** Result of fetching cloud-ignored files, with pagination cap. */
570
- interface IgnoredFilesResult {
571
- /** File paths ignored in Codacy Cloud. */
572
- files: string[];
573
- /** Total number of files fetched (same as files.length). */
574
- totalFetched: number;
575
- /** Whether the fetch was stopped because it hit the 1000-file cap. */
576
- capped: boolean;
577
- }
578
- /**
579
- * Configures the API token used for authenticated requests.
580
- * Must be called before `getRepository`, `listRepositoryTools`, or
581
- * `listRepositoryToolPatterns`. Public endpoints (listTools, listPatterns)
582
- * do not require a token.
583
- */
584
- declare function configureApiToken(token: string): void;
585
- /**
586
- * Validates an API token by calling the authenticated user endpoint.
587
- * Returns user info on success; caller should catch errors for invalid tokens.
588
- */
589
- declare function validateApiToken(token: string): Promise<{
590
- valid: boolean;
591
- name?: string;
592
- email?: string;
593
- }>;
594
- /**
595
- * Fetches files individually ignored in Codacy Cloud for a repository.
596
- * Uses cursor-based pagination capped at 10 pages (1000 files max) to avoid
597
- * unbounded fetching for repositories with very large ignore lists.
598
- * Requires `configureApiToken()` to have been called.
599
- */
600
- declare function listIgnoredFiles(provider: string, org: string, repo: string): Promise<IgnoredFilesResult>;
601
-
602
628
  /**
603
629
  * Structured file + stderr logger for the analysis pipeline.
604
630
  *
@@ -673,4 +699,4 @@ interface DiscoverOptions {
673
699
  */
674
700
  declare function discover(repositoryRoot: string, options?: DiscoverOptions): Promise<DiscoveryResult>;
675
701
 
676
- export { type AdapterFactory, type AnalyzeOptions, type AutoFilters, type CategoryFilter, type CodacyYamlConfig, type CodacyYamlEngineConfig, type ConfigOperation, type DiscoverOptions, type ExecutionMode, type IgnoredFilesResult, type InitAutoStats, type InitDefaultStats, type InitLocalStats, type InitRemoteStats, type LoggerOptions, type PatternMetadataLookup, type SeverityFilter, analyze, applyCodacyYamlExcludes, applyConfigOperation, buildToolConfig, clearAdapters, computePatternSummary, configureApiToken, createCodacyConfig, createLogger, detectLanguages, diffConfigs, discover, formatOutput, formatTextSummary, getAdapter, getRegisteredAdapters, getRegisteredDescriptors, initAutoConfig, initContainerConfig, initDefaultConfig, initLocalConfig, initRemoteConfig, intersectConfigs, listDiffFiles, listIgnoredFiles, listPrFiles, listStagedFiles, mergeConfigs, parseAutoFilters, readCodacyConfig, readCodacyYaml, registerAdapter, registerLazyAdapter, resolveConfigPath, resolveEngineToAdapter, rotateLogFiles, validateApiToken, writeCodacyConfig, writeCodacyConfigFile };
702
+ export { type AdapterFactory, type AnalyzeOptions, type AutoFilters, type CategoryFilter, type CodacyYamlConfig, type CodacyYamlEngineConfig, type ConfigOperation, type DiscoverOptions, type ExecutionMode, type IgnoredFilesResult, type InitAutoStats, type InitDefaultStats, type InitLocalStats, type InitRemoteStats, type LoggerOptions, type PatternMetadataLookup, type SeverityFilter, analyze, applyCodacyYamlExcludes, applyConfigOperation, buildToolConfig, clearAdapters, computePatternSummary, configureApiToken, createCodacyConfig, createLogger, detectLanguages, diffConfigs, discover, formatOutput, formatTextSummary, getAdapter, getRegisteredAdapters, getRegisteredDescriptors, initAutoConfig, initContainerConfig, initDefaultConfig, initLocalConfig, initRemoteConfig, intersectConfigs, listDiffFiles, listIgnoredFiles, listPrFiles, listStagedFiles, mergeConfigs, parseAutoFilters, readCodacyConfig, readCodacyYaml, registerAdapter, registerLazyAdapter, registerUnsupportedTool, resolveConfigPath, resolveEngineToAdapter, rotateLogFiles, validateApiToken, writeCodacyConfig, writeCodacyConfigFile };