Files
skillshare/internal/audit/analyzer_static.go
T
9b5824806e feat(audit): detect whitespace padding that hides instructions (#755)
Long blank spans and repeated filler can move meaningful instructions out
of view during skill review. Add four padding signals under the static
analyzer with Markdown exemptions and original-source line mapping.

Reuse rule overlays so global and project toggles and severity/confidence
overrides also govern this file-level detector. Cover threshold boundaries,
benign examples, optimized scans, reports and CLI rule controls.

Implements item 17 of #746.

Co-authored-by: GPT-6.1 Sol <noreply@openai.com>
Co-authored-by: Willie <egg358358@gmail.com>
2026-11-05 14:31:23 +08:00

28 lines
1.0 KiB
Go

package audit
// staticAnalyzer wraps regex and whitespace-padding scanning for both content and markdown links.
type staticAnalyzer struct{}
func (a *staticAnalyzer) ID() string { return AnalyzerStatic }
func (a *staticAnalyzer) Scope() AnalyzerScope { return ScopeFile }
func (a *staticAnalyzer) Analyze(ctx *AnalyzeContext) ([]Finding, error) {
if ctx.IsMarkdown {
return ScanMarkdownContentWithRules(ctx.Content, ctx.FileName, ctx.MDContentRules), nil
}
return ScanContentWithRules(ctx.Content, ctx.FileName, ctx.Rules), nil
}
// markdownLinkAnalyzer runs markdown link rule checks (skill scope — needs all MD files).
type markdownLinkAnalyzer struct{}
func (a *markdownLinkAnalyzer) ID() string { return AnalyzerStatic }
func (a *markdownLinkAnalyzer) Scope() AnalyzerScope { return ScopeSkill }
func (a *markdownLinkAnalyzer) Analyze(ctx *AnalyzeContext) ([]Finding, error) {
if len(ctx.MDFiles) == 0 || len(ctx.MDLinkRules) == 0 {
return nil, nil
}
return checkMarkdownLinkRules(ctx.MDFiles, ctx.MDLinks, ctx.MDLinkRules), nil
}