orchestrator

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: MIT Imports: 11 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 analysis workflow:

  1. Load: Load previous report for comparison (if enabled)
  2. Parse: Discover and parse all Go source files
  3. Analyze: Apply metrics and quality checks
  4. Compare: Compare with previous report (if enabled)
  5. Report: Format and output results (including comparison)
  6. Save: Store report for historical tracking (if enabled)

Each stage is delegated to specialized components (Parser, Analyzer, Reporter, Storage, Comparator) 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)
  • Storage: for persistent storage (if enabled in Phase 3)
  • Comparator: for historical comparison (if enabled in Phase 3)

Returns an error if component creation fails.

func (*Orchestrator) Close added in v0.3.0

func (o *Orchestrator) Close() error

Close cleans up resources used by the orchestrator.

This should be called when the orchestrator is no longer needed, particularly to properly close storage backends.

func (*Orchestrator) Run

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

Run executes the complete analysis pipeline on the specified directory.

The pipeline workflow:

  1. Load Stage (Phase 3): - Load previous report for comparison (if enabled)

  2. 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

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

  4. Compare Stage (Phase 3): - Compare current results with previous report (if enabled) - Calculate deltas and detect trends - Categorize new and fixed issues

  5. Report Stage: - Formats results according to configured output format - Includes comparison results if available - Outputs to console or other configured destination

  6. Save Stage (Phase 3): - Save report to storage for historical tracking (if enabled)

Returns an error if:

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

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