psanalyzer

package
v0.44.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = errors.New("PowerShell analyzer unavailable")

ErrUnavailable marks local PowerShell analyzer startup as unavailable.

Functions

func IsUnavailable

func IsUnavailable(err error) bool

IsUnavailable reports whether err means the local PowerShell analyzer runtime is not available and callers should skip PowerShell analysis or formatting.

func SetUnavailableReporter

func SetUnavailableReporter(reporter UnavailableReporter) func()

SetUnavailableReporter installs a process-local reporter for expected local PowerShell analyzer availability skips. The returned function restores the previous reporter.

Types

type AnalyzeRequest

type AnalyzeRequest struct {
	Path             string
	ScriptDefinition string
	Settings         Settings
}

type Diagnostic

type Diagnostic struct {
	RuleName             string                `json:"ruleName"`
	Severity             int                   `json:"severity"`
	Line                 *int                  `json:"line"`
	Column               *int                  `json:"column"`
	EndLine              *int                  `json:"endLine"`
	EndColumn            *int                  `json:"endColumn"`
	Message              string                `json:"message"`
	ScriptPath           string                `json:"scriptPath"`
	SuggestedCorrections []SuggestedCorrection `json:"suggestedCorrections,omitempty"`
}

type FormatRequest

type FormatRequest struct {
	ScriptDefinition string
}

type Runner

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

func NewRunner

func NewRunner() *Runner

func SharedRunner

func SharedRunner() *Runner

SharedRunner returns the process-wide runner for callers that should share one lazy PowerShell sidecar.

func (*Runner) Analyze

func (r *Runner) Analyze(ctx context.Context, req AnalyzeRequest) ([]Diagnostic, error)

func (*Runner) Close

func (r *Runner) Close(ctx context.Context) error

func (*Runner) Format

func (r *Runner) Format(ctx context.Context, req FormatRequest) (string, error)

func (*Runner) FormatPowerShell

func (r *Runner) FormatPowerShell(ctx context.Context, script string) (string, error)

type Settings

type Settings struct {
	IncludeRules []string                  `json:"includeRules,omitempty"`
	ExcludeRules []string                  `json:"excludeRules,omitempty"`
	Severity     []string                  `json:"severity,omitempty"`
	Rules        map[string]map[string]any `json:"rules,omitempty"`
}

type SuggestedCorrection

type SuggestedCorrection struct {
	Description string `json:"description"`
	Line        int    `json:"line"`
	Column      int    `json:"column"`
	EndLine     int    `json:"endLine"`
	EndColumn   int    `json:"endColumn"`
	Text        string `json:"text"`
}

type UnavailableEvent

type UnavailableEvent struct {
	Operation string
	Err       error
}

UnavailableEvent describes a skipped PowerShell analyzer operation.

type UnavailableReporter

type UnavailableReporter func(UnavailableEvent)

UnavailableReporter receives non-diagnostic analyzer availability notices.

Jump to

Keyboard shortcuts

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