Documentation
¶
Overview ¶
Package shellcheck provides shell script analysis operations for the operation graph.
Index ¶
- func CollectShellFiles(path string) ([]string, error)
- type ComplexityFile
- type ComplexityResult
- type FormatCheckResult
- type FormatFailedFile
- type FormatFixResult
- type FunctionComplexity
- type Hotspot
- type LintIssue
- type LintResult
- type ParseResult
- type ParsedFile
- type Provider
- type ShellFunction
- type ShellVariable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectShellFiles ¶
CollectShellFiles returns all shell files in a path.
Types ¶
type ComplexityFile ¶
type ComplexityFile struct {
Path string `starlark:"path"`
Functions []FunctionComplexity `starlark:"functions"`
TotalCyclo int `starlark:"total_cyclo"`
FunctionCount int `starlark:"function_count"`
}
ComplexityFile holds complexity metrics for a single shell file.
type ComplexityResult ¶
type ComplexityResult struct {
Files []ComplexityFile `starlark:"files"`
TotalCyclomatic int `starlark:"total_cyclomatic"`
TotalFunctions int `starlark:"total_functions"`
AvgCyclomatic float64 `starlark:"avg_cyclomatic"`
MaxCyclomatic int `starlark:"max_cyclomatic"`
MaxCycloFunc string `starlark:"max_cyclo_func"`
Hotspots []Hotspot `starlark:"hotspots"`
}
ComplexityResult holds complexity metrics for shell scripts.
type FormatCheckResult ¶
type FormatCheckResult struct {
Passed bool `starlark:"passed"`
FilesChecked int `starlark:"files_checked"`
FilesFailed []FormatFailedFile `starlark:"files_failed"`
}
FormatCheckResult holds the outcome of a shfmt check (fix=false).
type FormatFailedFile ¶
FormatFailedFile represents a file that failed formatting check.
type FormatFixResult ¶
type FormatFixResult struct {
FilesChecked int `starlark:"files_checked"`
FilesFormatted int `starlark:"files_formatted"`
}
FormatFixResult holds the outcome of a shfmt fix (fix=true).
type FunctionComplexity ¶
type FunctionComplexity struct {
Name string `starlark:"name"`
Line int `starlark:"line"`
Cyclomatic int `starlark:"cyclomatic"`
NestingDepth int `starlark:"nesting_depth"`
LOC int `starlark:"loc"`
ParameterRefs int `starlark:"parameter_refs"`
}
FunctionComplexity holds complexity metrics for a single function.
type Hotspot ¶
type Hotspot struct {
Name string `starlark:"name"`
File string `starlark:"file"`
Line int `starlark:"line"`
Cyclomatic int `starlark:"cyclomatic"`
NestingDepth int `starlark:"nesting_depth"`
LOC int `starlark:"loc"`
}
Hotspot represents a function exceeding complexity thresholds.
type LintIssue ¶
type LintIssue struct {
File string `json:"file" starlark:"file"`
Line int `json:"line" starlark:"line"`
EndLine int `json:"endLine" starlark:"end_line"`
Column int `json:"column" starlark:"column"`
EndColumn int `json:"endColumn" starlark:"end_column"`
Level string `json:"level" starlark:"level"`
Code int `json:"code" starlark:"code"`
Message string `json:"message" starlark:"message"`
}
LintIssue represents a single shellcheck finding.
type LintResult ¶
type LintResult struct {
Issues []LintIssue `starlark:"issues"`
ErrorCount int `starlark:"error_count"`
WarningCount int `starlark:"warning_count"`
InfoCount int `starlark:"info_count"`
StyleCount int `starlark:"style_count"`
TotalCount int `starlark:"total_count"`
Passed bool `starlark:"passed"`
}
LintResult holds the outcome of a shellcheck lint run.
type ParseResult ¶
type ParseResult struct {
Files []ParsedFile `starlark:"files"`
TotalFunctions int `starlark:"total_functions"`
TotalVariables int `starlark:"total_variables"`
TotalLOC int `starlark:"total_loc"`
TotalSLOC int `starlark:"total_sloc"`
}
ParseResult holds the parsed structure of shell scripts.
type ParsedFile ¶
type ParsedFile struct {
Path string `starlark:"path"`
Functions []ShellFunction `starlark:"functions"`
Variables []ShellVariable `starlark:"variables"`
Commands []string `starlark:"commands"`
Sources []string `starlark:"sources"`
LOC int `starlark:"loc"`
SLOC int `starlark:"sloc"`
Comments int `starlark:"comments"`
Blanks int `starlark:"blanks"`
}
ParsedFile holds the parsed structure of a single shell script.
type Provider ¶
type Provider struct {
op.ProviderBase
}
Provider provides shell script analysis operations: lint (shellcheck), format (shfmt), parse (structural extraction), and complexity (cyclomatic metrics).
+devlore:access=immediate
func NewProvider ¶
func NewProvider(ctx *op.RuntimeEnvironment) *Provider
NewProvider creates a shellcheck provider bound to the given context.
func (*Provider) Complexity ¶
func (p *Provider) Complexity(path string) (ComplexityResult, error)
Complexity calculates complexity metrics for shell scripts.
Parameters:
- `path`: file or directory to analyze
Returns:
- `ComplexityResult`: per-function cyclomatic complexity, nesting, and hotspots
- `error`: if path is invalid
func (*Provider) Format ¶
Format checks or fixes shell script formatting using shfmt.
+devlore:defaults indent=0,fix=false
Parameters:
- `path`: file or directory to check/format
- `indent`: indentation width (defaults to 4 when 0)
- `fix`: if true, rewrite files in place; if false, check only
Returns:
- `any`: FormatCheckResult (fix=false) or FormatFixResult (fix=true)
- `error`: if shfmt is not installed or path is invalid
func (*Provider) Lint ¶
func (p *Provider) Lint(path, severity string) (LintResult, error)
Lint runs shellcheck on shell scripts and returns structured issues.
+devlore:defaults severity="warning"
Parameters:
- `path`: file or directory to lint
- `severity`: minimum severity level (error, warning, info, style)
Returns:
- `LintResult`: issues grouped by severity with pass/fail
- `error`: if shellcheck is not installed or path is invalid
func (*Provider) Parse ¶
func (p *Provider) Parse(path string) (ParseResult, error)
Parse parses shell scripts and extracts structural information.
Parameters:
- `path`: file or directory to parse
Returns:
- `ParseResult`: functions, variables, commands, sources, and line counts
- `error`: if path is invalid
type ShellFunction ¶
type ShellFunction struct {
Name string `starlark:"name"`
Line int `starlark:"line"`
EndLine int `starlark:"end_line"`
BodyLines int `starlark:"body_lines"`
}
ShellFunction represents a function defined in a shell script.
type ShellVariable ¶
type ShellVariable struct {
Name string `starlark:"name"`
Line int `starlark:"line"`
Value string `starlark:"value"`
}
ShellVariable represents a variable assignment in a shell script.