codescan

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExpoConfigRule

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

ExpoConfigRule checks Expo app.json / app.config for common issues.

func (*ExpoConfigRule) Applies

func (r *ExpoConfigRule) Applies(fc FileContext) bool

func (*ExpoConfigRule) Check

func (r *ExpoConfigRule) Check(fc FileContext) []Finding

type FileContext

type FileContext struct {
	Path     string
	RelPath  string
	Lines    []string
	Language string // "swift", "objc", "typescript", "javascript", "json", "plist"
}

FileContext holds a scanned file and its lines for pattern matching.

type Finding

type Finding struct {
	Severity  Severity `json:"severity"`
	Guideline string   `json:"guideline"`
	Title     string   `json:"title"`
	Detail    string   `json:"detail"`
	Fix       string   `json:"fix,omitempty"`
	File      string   `json:"file"`
	Line      int      `json:"line"` // 1-indexed
	Code      string   `json:"code,omitempty"`
}

Finding is a single issue found in code.

type GlobalAntiPatternRule

type GlobalAntiPatternRule interface {
	Rule
	// HasGlobalAntiPatterns returns true if this rule uses project-wide anti-pattern suppression.
	HasGlobalAntiPatterns() bool
	// AntiPatternMatched returns true if any anti-pattern matches the given file.
	AntiPatternMatched(fc FileContext) bool
	// RuleID returns the rule identifier.
	RuleID() string
}

GlobalAntiPatternRule is implemented by rules that suppress findings when anti-patterns are found anywhere in the project (not just the current file).

type PatternRule

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

PatternRule matches regex patterns against file lines.

func (*PatternRule) AntiPatternMatched

func (r *PatternRule) AntiPatternMatched(fc FileContext) bool

func (*PatternRule) Applies

func (r *PatternRule) Applies(fc FileContext) bool

func (*PatternRule) Check

func (r *PatternRule) Check(fc FileContext) []Finding

func (*PatternRule) HasGlobalAntiPatterns

func (r *PatternRule) HasGlobalAntiPatterns() bool

func (*PatternRule) RuleID

func (r *PatternRule) RuleID() string

type PlistKeyRule

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

PlistKeyRule checks Info.plist for required privacy keys when certain frameworks are detected.

func (*PlistKeyRule) Applies

func (r *PlistKeyRule) Applies(fc FileContext) bool

func (*PlistKeyRule) Check

func (r *PlistKeyRule) Check(fc FileContext) []Finding

type Rule

type Rule interface {
	// Applies returns true if this rule should run on the given file.
	Applies(fc FileContext) bool
	// Check runs the rule and returns any findings.
	Check(fc FileContext) []Finding
}

Rule is a code pattern check.

func AllRules

func AllRules() []Rule

AllRules returns every registered code scan rule.

type Scanner

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

Scanner walks a project directory and runs pattern-based checks.

func NewScanner

func NewScanner(root string, verbose bool) *Scanner

func (*Scanner) Scan

func (s *Scanner) Scan() ([]Finding, error)

Scan walks the project and runs all rules against matching files.

type Severity

type Severity int

Severity levels matching the checks package.

const (
	SeverityInfo     Severity = iota // Best practice
	SeverityWarn                     // High risk
	SeverityCritical                 // Almost certain rejection
)

func (Severity) String

func (s Severity) String() string

type Summary

type Summary struct {
	Total     int  `json:"total"`
	Critical  int  `json:"critical"`
	Warns     int  `json:"warns"`
	Infos     int  `json:"infos"`
	FilesRead int  `json:"files_scanned"`
	Passed    bool `json:"passed"`
}

Summary holds aggregate results.

func ComputeSummary

func ComputeSummary(findings []Finding, filesScanned int) Summary

Jump to

Keyboard shortcuts

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