orchestrator

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package orchestrator coordinates the code analysis pipeline.

The orchestrator integrates the parser, analyzer, and reporter to provide a complete code analysis workflow. It handles the execution flow and error propagation between components.

Pipeline

The orchestrator executes the following pipeline: 1. Parse - Extract metrics from Go source files 2. Analyze - Apply thresholds and detect issues 3. Report - Format and output results

Each stage can fail independently, and errors are propagated up.

Usage

Create and run the orchestrator:

cfg := config.Default()
orch, err := orchestrator.New(cfg)
if err != nil {
    log.Fatal(err)
}

err = orch.Run("/path/to/project")
if err != nil {
    log.Fatal(err)
}

The orchestrator automatically creates the parser, analyzer, and reporter based on the configuration and executes the full analysis pipeline.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Orchestrator

type Orchestrator struct {
	// contains filtered or unexported fields
}

Orchestrator coordinates the complete code analysis pipeline.

The orchestrator implements the three-stage analysis workflow:

  1. Parse: Discover and parse all Go source files
  2. Analyze: Apply metrics and quality checks
  3. Report: Format and output results

Each stage is delegated to specialized components (Parser, Analyzer, Reporter) that are configured and initialized based on the provided Config.

func New

func New(cfg *config.Config) (*Orchestrator, error)

New creates a new Orchestrator with the given configuration.

This function initializes all pipeline components:

  • Parser: for AST-based metrics extraction
  • Analyzer: for applying thresholds and detecting issues
  • Reporter: for formatted output (based on config.Output.Format)

Returns an error if reporter creation fails (e.g., unsupported format).

func (*Orchestrator) Run

func (o *Orchestrator) Run(targetPath string) error

Run executes the complete analysis pipeline on the specified directory.

The pipeline consists of three stages:

  1. Parse Stage: - Recursively discovers all .go files in targetPath - Applies exclude patterns (vendor/, testdata/, etc.) - Parses each file to extract metrics - Reports parse errors but continues with successful files

  2. Analyze Stage: - Applies thresholds to detect issues - Runs anti-pattern detectors - Executes test coverage analysis (if enabled) - Performs dependency analysis

  3. Report Stage: - Formats results according to configured output format - Outputs to console or other configured destination

Returns an error if:

  • No Go files are found in targetPath
  • Analysis fails (unexpected internal error)
  • Reporting fails (output error)

Parse errors for individual files are reported as warnings but don't fail the overall pipeline, allowing partial analysis when some files are malformed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL