@codacy/analysis-runner 0.6.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +131 -7
- package/dist/index.js +1199 -32
- 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, Language, LogLevel } from '@codacy/tooling';
|
|
1
|
+
import { OutputFormat, Logger, AnalysisResult, ToolAdapter, AdapterDescriptor, CodacyConfig, ConfigurationFileCheckResult, CodacyToolConfig, IssueSeverity, IssueCategory, Language, DiscoveryResult, Issue, PatternSummary, LogLevel } from '@codacy/tooling';
|
|
2
2
|
export { AnalysisResult, OutputFormat } from '@codacy/tooling';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -179,26 +179,71 @@ declare function createCodacyConfig(params?: {
|
|
|
179
179
|
repositoryId?: string | null;
|
|
180
180
|
repositoryName?: string | null;
|
|
181
181
|
includeFiles?: string[];
|
|
182
|
+
autoFilters?: string;
|
|
182
183
|
}): CodacyConfig;
|
|
183
184
|
|
|
184
185
|
/**
|
|
185
|
-
*
|
|
186
|
+
* auto-filters.ts — Parses and applies --auto filter syntax.
|
|
187
|
+
*
|
|
188
|
+
* Filter syntax: comma-separated list of severity and category names.
|
|
189
|
+
* - Severity names: Info/Minor, Warning/Medium, High, Error/Critical (both accepted)
|
|
190
|
+
* - Category names: Security, ErrorProne, CodeStyle, etc.
|
|
191
|
+
* - `All` prefix on any token removes the `enabled: true` filter for that value.
|
|
192
|
+
* e.g. `AllCritical` includes ALL Critical patterns, not just default ones.
|
|
193
|
+
*
|
|
194
|
+
* Dimensions are ANDed (severity AND category). Values within a dimension are ORed.
|
|
195
|
+
* Omitting a dimension means "no restriction" for that dimension.
|
|
196
|
+
*/
|
|
197
|
+
|
|
198
|
+
/** A single severity filter with its All-prefix status. */
|
|
199
|
+
interface SeverityFilter {
|
|
200
|
+
level: IssueSeverity;
|
|
201
|
+
all: boolean;
|
|
202
|
+
}
|
|
203
|
+
/** A single category filter with its All-prefix status. */
|
|
204
|
+
interface CategoryFilter {
|
|
205
|
+
category: IssueCategory;
|
|
206
|
+
all: boolean;
|
|
207
|
+
}
|
|
208
|
+
/** Parsed result of the --auto filter string. */
|
|
209
|
+
interface AutoFilters {
|
|
210
|
+
severities: SeverityFilter[];
|
|
211
|
+
categories: CategoryFilter[];
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Parses a comma-separated auto-filter string into structured filters.
|
|
215
|
+
*
|
|
216
|
+
* Each token is classified as a severity or category by name lookup.
|
|
217
|
+
* The `All` prefix (case-insensitive) on a token removes the `enabled: true`
|
|
218
|
+
* constraint for that specific severity or category.
|
|
219
|
+
*
|
|
220
|
+
* Unrecognized tokens are collected and returned in the `unknown` array.
|
|
221
|
+
*/
|
|
222
|
+
declare function parseAutoFilters(raw: string): {
|
|
223
|
+
filters: AutoFilters;
|
|
224
|
+
unknown: string[];
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Init mode logic — builds a CodacyConfig from five distinct sources:
|
|
186
229
|
*
|
|
187
230
|
* - `initLocalConfig` — detect languages + tools with a local config file
|
|
231
|
+
* - `initAutoConfig` — discover stack, then select tools/patterns by framework match
|
|
188
232
|
* - `initDefaultConfig` — same as local, enriched with API-sourced pattern defaults
|
|
189
233
|
* - `initRemoteConfig` — fetch the full tool/pattern config from a remote Codacy repository
|
|
190
234
|
* - `initContainerConfig`— read .codacyrc file (container run input) and extract file list
|
|
191
235
|
*
|
|
192
|
-
* All
|
|
236
|
+
* All five functions return a `CodacyConfig` ready to be written by `writeCodacyConfig`.
|
|
193
237
|
* None of them write to disk — that is the caller's responsibility.
|
|
194
238
|
*/
|
|
195
239
|
|
|
196
240
|
/**
|
|
197
|
-
* Detects programming languages present in the repository by
|
|
198
|
-
*
|
|
241
|
+
* Detects programming languages present in the repository by matching file
|
|
242
|
+
* extensions/filenames against LANGUAGE_CONFIG. When `precomputedFiles` is
|
|
243
|
+
* provided, uses that list directly instead of running `git ls-files`.
|
|
199
244
|
* Returns languages sorted alphabetically for deterministic output.
|
|
200
245
|
*/
|
|
201
|
-
declare function detectLanguages(repositoryRoot: string): Promise<Language[]>;
|
|
246
|
+
declare function detectLanguages(repositoryRoot: string, precomputedFiles?: string[]): Promise<Language[]>;
|
|
202
247
|
/** Stats returned alongside the config from `initLocalConfig`. */
|
|
203
248
|
interface InitLocalStats {
|
|
204
249
|
/** Whether a .codacy.yaml file was found and its exclude paths were applied. */
|
|
@@ -280,6 +325,41 @@ declare function initRemoteConfig(repositoryRoot: string, provider: string, orga
|
|
|
280
325
|
* ```
|
|
281
326
|
*/
|
|
282
327
|
declare function initContainerConfig(repositoryRoot: string, adapters: Readonly<ToolAdapter>[]): Promise<CodacyConfig>;
|
|
328
|
+
/** Stats returned alongside the config from `initAutoConfig`. */
|
|
329
|
+
interface InitAutoStats {
|
|
330
|
+
/** Number of languages detected by discover. */
|
|
331
|
+
detectedLanguages: number;
|
|
332
|
+
/** Number of frameworks detected by discover. */
|
|
333
|
+
detectedFrameworks: number;
|
|
334
|
+
/** Number of libraries detected by discover. */
|
|
335
|
+
detectedLibraries: number;
|
|
336
|
+
/** Number of tool entries added to the config. */
|
|
337
|
+
selectedTools: number;
|
|
338
|
+
/** Whether a .codacy.yaml file was found and its exclude paths were applied. */
|
|
339
|
+
codacyYamlApplied: boolean;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* `--auto [filters]` mode.
|
|
343
|
+
*
|
|
344
|
+
* Runs `discover()` to detect the repository's tech stack, then selects tools
|
|
345
|
+
* by language overlap and filters patterns using per-tool framework mappings.
|
|
346
|
+
*
|
|
347
|
+
* Framework-specific patterns (those matching a mapping entry) are included only
|
|
348
|
+
* if the corresponding dependency was detected — and they bypass the `enabled`
|
|
349
|
+
* filter. Universal patterns (not in any mapping) are included only if
|
|
350
|
+
* `enabled: true`, unless an `All`-prefixed filter widens the gate.
|
|
351
|
+
*
|
|
352
|
+
* Severity and category filters are ANDed across dimensions, ORed within.
|
|
353
|
+
*
|
|
354
|
+
* **Known limitation (v1):** When both TypeScript and JavaScript are detected,
|
|
355
|
+
* ESLint core rules and their `@typescript-eslint` equivalents may both be
|
|
356
|
+
* enabled, potentially causing duplicate findings. This will be addressed in v2
|
|
357
|
+
* via conflict-resolution metadata in the mapping files.
|
|
358
|
+
*/
|
|
359
|
+
declare function initAutoConfig(repositoryRoot: string, adapters: Readonly<ToolAdapter>[], descriptors: AdapterDescriptor[], filters?: AutoFilters, onDiscoveryComplete?: (result: DiscoveryResult) => void, rawFilterString?: string): Promise<{
|
|
360
|
+
config: CodacyConfig;
|
|
361
|
+
stats: InitAutoStats;
|
|
362
|
+
}>;
|
|
283
363
|
|
|
284
364
|
/**
|
|
285
365
|
* .codacy.yaml ingestion — reads the standard Codacy configuration file from
|
|
@@ -339,6 +419,28 @@ declare function resolveEngineToAdapter(engineName: string, adapters: Readonly<T
|
|
|
339
419
|
*/
|
|
340
420
|
declare function applyCodacyYamlExcludes(config: CodacyConfig, yamlConfig: CodacyYamlConfig, adapters: Readonly<ToolAdapter>[], logger?: Logger): CodacyConfig;
|
|
341
421
|
|
|
422
|
+
/**
|
|
423
|
+
* Computes pattern-level summary statistics for analysis results.
|
|
424
|
+
*
|
|
425
|
+
* Groups issues by Severity → Category → Pattern, producing a PatternSummary
|
|
426
|
+
* that formatters can render. Called inside analyze() where adapter metadata
|
|
427
|
+
* (pattern titles, tool display names) is available.
|
|
428
|
+
*/
|
|
429
|
+
|
|
430
|
+
/** Resolved metadata for a pattern, built from adapter.patternsMetadata. */
|
|
431
|
+
interface PatternMetadataLookup {
|
|
432
|
+
title: string;
|
|
433
|
+
toolDisplayName: string;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Computes a PatternSummary from issues and a pattern metadata lookup.
|
|
437
|
+
*
|
|
438
|
+
* The lookup maps patternId → { title, toolDisplayName } and should be built
|
|
439
|
+
* from adapter.patternsMetadata before calling this function. Patterns not
|
|
440
|
+
* in the lookup fall back to patternId as the title and toolId as display name.
|
|
441
|
+
*/
|
|
442
|
+
declare function computePatternSummary(issues: readonly Issue[], lookup: ReadonlyMap<string, PatternMetadataLookup>): PatternSummary;
|
|
443
|
+
|
|
342
444
|
/**
|
|
343
445
|
* File discovery and routing — finds files in a repository, applies exclusion
|
|
344
446
|
* layers (.gitignore, global exclude, per-tool exclude), and routes files to
|
|
@@ -464,4 +566,26 @@ declare function rotateLogFiles(logsDir: string, maxFiles: number): void;
|
|
|
464
566
|
*/
|
|
465
567
|
declare function createLogger(options?: LoggerOptions): Logger;
|
|
466
568
|
|
|
467
|
-
|
|
569
|
+
/**
|
|
570
|
+
* Repository discovery — scans a codebase and identifies languages, file patterns,
|
|
571
|
+
* notable files, frameworks, and libraries.
|
|
572
|
+
*
|
|
573
|
+
* The discover() function is the main entry point. It runs a 4-phase pipeline:
|
|
574
|
+
* 1. File discovery (extensions, notable files)
|
|
575
|
+
* 2. Language detection (reuses detectLanguages)
|
|
576
|
+
* 3. Manifest parsing (dependency extraction)
|
|
577
|
+
* 4. Dependency classification (framework / library / platform / tool)
|
|
578
|
+
*/
|
|
579
|
+
|
|
580
|
+
/** Options for the discover function. */
|
|
581
|
+
interface DiscoverOptions {
|
|
582
|
+
/** Skip dependency extraction from manifests (only detect files and languages). */
|
|
583
|
+
skipDependencies?: boolean;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Scans a repository and returns a structured report of languages, file patterns,
|
|
587
|
+
* notable files, frameworks, and libraries.
|
|
588
|
+
*/
|
|
589
|
+
declare function discover(repositoryRoot: string, options?: DiscoverOptions): Promise<DiscoveryResult>;
|
|
590
|
+
|
|
591
|
+
export { type AdapterFactory, type AnalyzeOptions, type AutoFilters, type CategoryFilter, type CodacyYamlConfig, type CodacyYamlEngineConfig, type DiscoverOptions, type ExecutionMode, type IgnoredFilesResult, type InitAutoStats, type InitDefaultStats, type InitLocalStats, type InitRemoteStats, type LoggerOptions, type PatternMetadataLookup, type SeverityFilter, analyze, applyCodacyYamlExcludes, buildToolConfig, clearAdapters, computePatternSummary, configureApiToken, createCodacyConfig, createLogger, detectLanguages, discover, formatOutput, formatTextSummary, getAdapter, getRegisteredAdapters, getRegisteredDescriptors, initAutoConfig, initContainerConfig, initDefaultConfig, initLocalConfig, initRemoteConfig, listDiffFiles, listIgnoredFiles, listPrFiles, listStagedFiles, parseAutoFilters, readCodacyConfig, readCodacyYaml, registerAdapter, registerLazyAdapter, resolveEngineToAdapter, rotateLogFiles, validateApiToken, writeCodacyConfig };
|