analyzer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabelGoAhead         = parser.LabelGoAhead
	LabelProceedWithCare = parser.LabelProceedWithCare
	LabelNeedsWork       = parser.LabelNeedsWork
	LabelStopRefactor    = parser.LabelStopRefactor
)

Variables

This section is empty.

Functions

func DetectedLanguage

func DetectedLanguage(ext string) string

func ReductionFactor added in v0.8.5

func ReductionFactor(score int) float64

ReductionFactor returns the estimated token reduction factor after refactoring to 80+. Based on current quality score:

  • 0-36: 50% reduction
  • 37-49: 50% reduction
  • 50-64: 45% reduction
  • 65-79: 40% reduction
  • 80+: 10% reduction (already clean)

func TestComputeOverallScoreHelper added in v0.8.5

func TestComputeOverallScoreHelper(results []QualityResult) int

TestComputeOverallScoreHelper is exported for testing.

func TestCountAllSmellsHelper added in v0.8.5

func TestCountAllSmellsHelper(results []QualityResult) int

TestCountAllSmellsHelper is exported for testing.

func TestDetectorStatusHelper added in v0.8.5

func TestDetectorStatusHelper(detector string, results []QualityResult) string

TestDetectorStatusHelper is exported for testing.

func TestIsBinaryFileHelper added in v0.8.5

func TestIsBinaryFileHelper(data []byte) bool

TestIsBinaryFileHelper is exported for testing.

func TestIsGitignoredReportHelper added in v0.8.5

func TestIsGitignoredReportHelper(path, root string, patterns []string) bool

TestIsGitignoredReportHelper is exported for testing.

func TestIsSourceFileReportHelper added in v0.8.5

func TestIsSourceFileReportHelper(path string) bool

TestIsSourceFileReportHelper is exported for testing.

func TestLoadGitignoreSimpleHelper added in v0.8.5

func TestLoadGitignoreSimpleHelper(root string) []string

TestLoadGitignoreSimpleHelper is exported for testing.

func TestScoreEmojiHelper added in v0.8.5

func TestScoreEmojiHelper(score int) string

TestScoreEmojiHelper is exported for testing.

Types

type CohesionResult

type CohesionResult = parser.CohesionResult

Re-export parser types for backward compatibility.

type DuplicationPair

type DuplicationPair = parser.DuplicationPair

Re-export parser types for backward compatibility.

type FunctionBloat

type FunctionBloat = parser.FunctionBloat

Re-export parser types for backward compatibility.

type GitHotspotResult

type GitHotspotResult = parser.GitHotspotResult

Re-export parser types for backward compatibility.

func AnalyzeGitHotspots

func AnalyzeGitHotspots(repoPath string, maxDepth int) GitHotspotResult

type HotspotEntry

type HotspotEntry = parser.HotspotEntry

Re-export parser types for backward compatibility.

type ModelPricing added in v0.8.5

type ModelPricing struct {
	Name           string
	CostPerMTokens float64 // USD per million input tokens
}

ModelPricing holds pricing info for an AI model.

type QualityResult

type QualityResult = parser.QualityResult

Re-export parser types for backward compatibility.

func Analyze

func Analyze(src SourceInput, t Thresholds) QualityResult

Analyze runs all detectors on source and returns a QualityResult. Score is 0-100.

type ReportData added in v0.8.5

type ReportData struct {
	Target       string
	Timestamp    string
	Results      []QualityResult
	Secrets      []secrets.SecretFinding
	Vulns        []vulnerability.Finding
	OverallScore int
	OverallLabel string
}

ReportData holds all the data needed to render a markdown quality report.

func GenerateReport added in v0.8.5

func GenerateReport(target string, respectGitignore bool) (*ReportData, error)

GenerateReport runs a full scan and returns rendered markdown.

func (*ReportData) RenderMarkdown added in v0.8.5

func (rd *ReportData) RenderMarkdown() string

RenderMarkdown generates the full markdown report string.

type Smell

type Smell = parser.Smell

Re-export parser types for backward compatibility.

type SourceInput added in v0.8.5

type SourceInput struct {
	FilePath string
	Source   string
	Lang     string
}

SourceInput bundles the source file identity for analysis.

type Thresholds

type Thresholds = parser.Thresholds

Re-export parser types for backward compatibility.

func DefaultThresholds

func DefaultThresholds(lang string) Thresholds

type TokenEstimator added in v0.8.5

type TokenEstimator struct {
	FilePath     string
	CurrentScore int
	FileBytes    int64
}

TokenEstimator estimates token counts and cost savings for AI interactions.

func NewTokenEstimator added in v0.8.5

func NewTokenEstimator(filePath string, currentScore int) *TokenEstimator

NewTokenEstimator creates an estimator for a given file.

func (*TokenEstimator) CostForModel added in v0.8.5

func (t *TokenEstimator) CostForModel(modelName string) float64

CostForModel returns the per-interaction cost for a specific model.

func (*TokenEstimator) CurrentTokens added in v0.8.5

func (t *TokenEstimator) CurrentTokens() int

CurrentTokens estimates the number of tokens in the current file. Approx 1 token per 4 characters (standard LLM approximation).

func (*TokenEstimator) EstimatedTokensAfterRefactor added in v0.8.5

func (t *TokenEstimator) EstimatedTokensAfterRefactor() int

EstimatedTokensAfterRefactor estimates tokens after refactoring to score 80+.

func (*TokenEstimator) FormatEstimateOutput added in v0.8.5

func (t *TokenEstimator) FormatEstimateOutput() string

FormatEstimateOutput returns the formatted token estimate string.

func (*TokenEstimator) InteractionCost added in v0.8.5

func (t *TokenEstimator) InteractionCost(model ModelPricing) float64

InteractionCost returns the cost of reading the file once with a given model.

func (*TokenEstimator) IterationReductionSavings added in v0.8.5

func (t *TokenEstimator) IterationReductionSavings(model ModelPricing) float64

IterationReductionSavings calculates total savings including ~40% fewer iterations from clean code.

func (*TokenEstimator) MonthlyEnterpriseSavings added in v0.8.5

func (t *TokenEstimator) MonthlyEnterpriseSavings(model ModelPricing) float64

MonthlyEnterpriseSavings calculates monthly savings for 20 devs, 50 AI calls/day, 6 files read per call.

func (*TokenEstimator) SavingsPerRead added in v0.8.5

func (t *TokenEstimator) SavingsPerRead(model ModelPricing) float64

SavingsPerRead returns per-interaction savings for a given model.

func (*TokenEstimator) TokenSavingsPerRead added in v0.8.5

func (t *TokenEstimator) TokenSavingsPerRead() int

TokenSavingsPerRead returns the number of tokens saved per single read of the file.

Jump to

Keyboard shortcuts

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