shellcheck

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	File      string `json:"file"`
	Line      int    `json:"line"`
	EndLine   int    `json:"endLine"`
	Column    int    `json:"column"`
	EndColumn int    `json:"endColumn"`
	Level     string `json:"level"`
	Code      int    `json:"code"`
	Message   string `json:"message"`
	Fix       *Fix   `json:"fix"`
}

type Fix

type Fix struct {
	Replacements []Replacement `json:"replacements"`
}

type JSON1Output

type JSON1Output struct {
	Comments []Comment `json:"comments"`
}

JSON1Output is ShellCheck's -f json1 output schema. It is a JSON object with a single "comments" array.

type Options

type Options struct {
	// Dialect is the shell dialect for ShellCheck: sh, bash, dash, ksh, busybox.
	Dialect string

	// Severity is ShellCheck's minimum severity: error, warning, info, style.
	// Empty means use ShellCheck default.
	Severity string

	// Norc disables loading .shellcheckrc.
	Norc bool

	// ExtendedAnalysis sets --extended-analysis. Nil means use ShellCheck default.
	ExtendedAnalysis *bool

	// EnableOptional is passed via --enable=... (optional checks).
	EnableOptional []string

	// Include is passed via --include=... (consider only given codes).
	Include []string

	// Exclude is passed via --exclude=... (exclude given codes).
	Exclude []string
}

type Replacement

type Replacement struct {
	Line           int    `json:"line"`
	EndLine        int    `json:"endLine"`
	Column         int    `json:"column"`
	EndColumn      int    `json:"endColumn"`
	InsertionPoint string `json:"insertionPoint"`
	Precedence     int    `json:"precedence"`
	Replacement    string `json:"replacement"`
}

type Runner

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

Runner executes ShellCheck via a WASM reactor module.

The WASM binary is compiled once (expensive, cached on disk by wazero). A single reactor module instance is instantiated and initialized once (_initialize + hs_init). Each subsequent call uses sc_alloc/sc_check/sc_free with WASM linear memory buffers to avoid per-call instantiation overhead.

Note: WASI reactor modules export _initialize and require the host to call it exactly once after instantiation.

func NewRunner

func NewRunner() *Runner

func (*Runner) Close added in v0.28.0

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

Close releases the WASM runtime and compilation cache resources. Resources are closed in reverse init order: module → compiled → runtime → cache.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, script string, opts Options) (JSON1Output, string, error)

func (*Runner) Version added in v0.28.0

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

Version returns the ShellCheck version embedded in the WASM module. It initialises the runtime if needed (compilation is disk-cached by wazero).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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