@codacy/tooling
v0.2.0
Published
Shared contracts, interfaces, and utilities for Codacy tool adapter development
Readme
@codacy/tooling
Table of Contents
Overview
Shared contracts, types, and utilities for the Codacy Analysis CLI monorepo. Every adapter and the runner depend on this package.
Exports
| Export | Purpose |
|--------|---------|
| Types (Issue, AnalysisError, ToolAdapter, etc.) | Shared interfaces for the entire pipeline |
| defineToolAdapter() | Type helper for defining adapters |
| buildPatternId() | Constructs pattern IDs from tool ID + rule ID |
| spawnTool() | Child process wrapper for CLI-strategy adapters |
| validateIssue() | Validates an Issue object at runtime |
| downloadFile() / downloadAndExtract() | HTTP download utilities for tool installation |
ToolAdapter contract
Every tool adapter must implement four methods:
checkAvailability → install → checkLocalConfigurationFile → analyze| Method | Purpose |
|--------|---------|
| checkAvailability(ctx) | Is the tool binary present and runnable? |
| install(ctx) | Download/install the binary (or return NotSupported) |
| checkLocalConfigurationFile(ctx) | Look for native config files in the repo |
| analyze(ctx, config) | Run the tool and return issues + errors |
Three execution strategies: CLI (child process), Library (Node.js API), Native (pure TypeScript).
Utilities
spawnTool(binary, args, options)
Spawns a child process, captures stdout/stderr/exitCode. Used by all CLI-strategy adapters.
downloadFile(url, destPath) / downloadAndExtract(url, destDir, options)
HTTP download helpers for tool installation. downloadAndExtract handles .tar.gz archives with optional stripComponents.
