rules

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TypeIsCompatible added in v0.3.0

func TypeIsCompatible(dst, val phpdoc.TypeExpr) bool

TypesIsCompatible reports whether val type is compatible with dst type.

Types

type Filter

type Filter struct {
	Type   *phpdoc.Type
	Pure   bool
	Regexp *regexp.Regexp
}

Filter describes constraints that should be applied to a given phpgrep variable.

type Parser

type Parser struct{}

func NewParser

func NewParser() *Parser

func (*Parser) Parse

func (*Parser) Parse(filename string, r io.Reader) (*Set, error)

type Rule

type Rule struct {
	// Name tells whether this rule causes critical report.
	Name string

	// Matcher is an object that is used to check whether a given AST node
	// should trigger a warning that is associated with rule.
	Matcher *phpgrep.Matcher

	// Level is a severity level that is used during report generation.
	Level int

	// StrictSyntax determines whether phpgrep fuzzy search should not be used.
	StrictSyntax bool

	// Message is a report text that is printed when this rule matches.
	Message string

	// Fix is a quickfix template.
	Fix string

	// Location is a phpgrep variable name that should be used as a warning location.
	// WithDeprecationNote string selects the root node.
	Location string

	// Path is a filter-like rule switcher.
	// A rule is only applied to a file that contains a Path as a substring in its name.
	Path string

	// PathExcludes is a filter-like rule switcher.
	// A rule is not applied to a file that contains a PathExcludes as a substring in its name.
	PathExcludes map[string]bool

	// Filters is a list of OR-connected filter sets.
	// Every filter set is a mapping of phpgrep variable to a filter.
	Filters []map[string]Filter
	// contains filtered or unexported fields
}

Rule is a dynamically-loaded linter rule.

A rule is called unnamed if no @name attribute is given. Unnamed rules receive auto-generated name that includes a rule file name and a line that defines that rule.

func (*Rule) String

func (r *Rule) String() string

String returns a rule printer representation.

type RuleDoc added in v0.3.0

type RuleDoc struct {
	Comment  string
	Before   string
	After    string
	Fix      bool
	Extends  bool
	Disabled bool
}

type ScopedSet

type ScopedSet struct {
	RulesByKind [ir.NumKinds][]Rule
	CountRules  int
}

ScopedSet is a categorized rules collection. Categories help to assign a better execution strategy for a rule.

func (*ScopedSet) Add added in v0.4.0

func (s *ScopedSet) Add(kind ir.NodeKind, rule Rule)

func (*ScopedSet) Set added in v0.4.0

func (s *ScopedSet) Set(kind ir.NodeKind, rules []Rule)

type Set

type Set struct {
	Any     *ScopedSet // Anywhere
	Root    *ScopedSet // Only outside of functions
	Local   *ScopedSet // Only inside functions
	Builtin bool       // Whether this is a NoVerify builtin rule set

	Names     []string // All rule names
	DocByName map[string]RuleDoc
}

Set is a result of rule file parsing.

func NewSet

func NewSet() *Set

NewSet returns a new empty rules set.

Jump to

Keyboard shortcuts

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