analyzer

package
v0.0.0-...-cacfa07 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package analyzer implements complexity analysis for regex patterns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analyzer

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

Analyzer performs complexity analysis on regex patterns.

func NewAnalyzer

func NewAnalyzer(opts *Options) *Analyzer

NewAnalyzer creates a new analyzer with the given options.

func (*Analyzer) Analyze

func (a *Analyzer) Analyze(re *syntax.Regexp, pattern string) (*ComplexityScore, error)

Analyze performs comprehensive complexity analysis on a regex pattern.

func (*Analyzer) EstimateComplexity

func (a *Analyzer) EstimateComplexity(re *syntax.Regexp) string

EstimateComplexity provides a quick complexity estimate.

type ComplexityScore

type ComplexityScore struct {
	Score       int                    // 0-100 scale
	Complexity  string                 // O(1), O(n), O(n²), O(2^n)
	Description string                 // Human-readable description
	TimeClass   string                 // constant, linear, polynomial, exponential
	Degree      int                    // For polynomial: degree (2=quadratic, 3=cubic)
	Issues      []string               // List of contributing issues
	Metrics     map[string]interface{} // Detailed metrics
}

ComplexityScore contains complexity analysis results (internal format).

type Options

type Options struct {
	Timeout            time.Duration
	MaxComplexityScore int
}

Options contains configuration for analysis.

Jump to

Keyboard shortcuts

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