Documentation
¶
Overview ¶
Package pattern compiles the custom rules a project declares in its configuration: PHP code patterns with metavariables, matched on resolved names, with an optional quick-fix template.
Index ¶
Constants ¶
const Group = "Custom"
Group is the rule group of every custom rule.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Definition ¶
type Definition struct {
ID string `json:"id"`
Match Patterns `json:"match"`
Where map[string]Where `json:"where,omitempty"`
// Inside lists code the match must lie within (one must match an
// enclosing node); NotInside, code it must not lie within.
Inside Patterns `json:"inside,omitempty"`
NotInside Patterns `json:"notInside,omitempty"`
Message string `json:"message"`
Severity string `json:"severity,omitempty"` // error | warning (default) | info
Enabled *bool `json:"enabled,omitempty"` // default true
Description string `json:"description,omitempty"`
PHP string `json:"php,omitempty"` // minimum target PHP version
Paths []string `json:"paths,omitempty"`
Exclude []string `json:"exclude,omitempty"`
Fix *string `json:"fix,omitempty"`
FixTitle string `json:"fixTitle,omitempty"`
}
Definition is the JSON shape of one custom rule.
type Patterns ¶
type Patterns []string
Patterns is one pattern or a list of them; JSON accepts both forms.
func (*Patterns) UnmarshalJSON ¶
UnmarshalJSON accepts a string or an array of strings.
type Where ¶
type Where struct {
// Type is a PHPDoc type the bound expression's inferred type must be
// accepted by, with fully qualified class names.
Type string `json:"type,omitempty"`
// Regex must match the bound source text.
Regex string `json:"regex,omitempty"`
// Not lists patterns the bound code must not match.
Not Patterns `json:"not,omitempty"`
}
Where constrains what a metavariable may bind.