polylint

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckContentHash

func CheckContentHash(expectedHash, content string) bool

func SHA256

func SHA256(content string) string

func ValidateConfigFile

func ValidateConfigFile(config ConfigFile) error

Types

type ConfigFile

type ConfigFile struct {
	Rules   []Rule
	Version string
}

func LoadConfigFile

func LoadConfigFile(content string) (ConfigFile, error)

type FileReport

type FileReport struct {
	Path     string
	Ignores  []Ignore
	Rules    []Rule
	Findings []Finding
}

func ProcessFile

func ProcessFile(content string, path string, cfg ConfigFile) (FileReport, error)

type Finding

type Finding struct {
	Path      string
	Line      string
	LineIndex int
	LineNo    int
	Rule      Rule
	RuleId    string
}

type Fn

type Fn struct {
	Type  string
	Scope Scope
	Name  string
	Args  []any
	Body  string
}

type Ignore

type Ignore struct {
	Id           string
	Scope        Scope
	SourceLineNo int
	LineNo       int
}

type IncludeRaw

type IncludeRaw struct {
	Path string `yaml:"path"`
	// Hash of the file contents prefixed with the algorithm
	Hash string `yaml:"hash"`
}

type RawConfig

type RawConfig struct {
	Version  string
	Includes []IncludeRaw
	Rules    []RawRule
}

type RawFn

type RawFn struct {
	Type  string
	Scope Scope
	Name  string
	Args  []any
	Body  string
}

type RawRule

type RawRule struct {
	Id             string
	Description    string
	Recommendation string
	Severity       string
	Link           string
	IncludePaths   *regexp.Regexp `yaml:"include_paths"`
	ExcludePaths   *regexp.Regexp `yaml:"exclude_paths"`
	Fn             RawFn
}

type Rule

type Rule struct {
	Fn             RuleFunc
	Id             string
	Description    string
	Recommendation string
	Severity       SeverityLevel
	// Link to the documentation for this Rule
	Link string
	// FilenameRegex is the regexp used to determine if this Rule should run on a given file
	IncludePaths *regexp.Regexp
	ExcludePaths *regexp.Regexp
	Scope        Scope
}

type RuleFunc

type RuleFunc func(string, int, string) bool

func BuildFileFnBuiltin

func BuildFileFnBuiltin(f RawFn) RuleFunc

func BuildFileFnJs

func BuildFileFnJs(f RawFn) RuleFunc

func BuildFileScopeFn

func BuildFileScopeFn(f RawFn) RuleFunc

func BuildFn

func BuildFn(f RawFn) RuleFunc

func BuildLineFn

func BuildLineFn(f RawFn) RuleFunc

func BuildPathFnBuiltin

func BuildPathFnBuiltin(f RawFn) RuleFunc

func BuildPathFnJs

func BuildPathFnJs(f RawFn) RuleFunc

func BuildPathScopeFn

func BuildPathScopeFn(f RawFn) RuleFunc

type Scope

type Scope string

type SeverityLevel

type SeverityLevel int

Jump to

Keyboard shortcuts

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