Documentation ¶
Overview ¶
Package rule contains functionality to create rules for evaluation by a linter
Index ¶
Constants ¶
const ( PersonFirstRuleName string = "People-first" RegexRuleName string = "Regex" )
const PhrasePattern string = `(\s|\\s|[ ]|-)`
Regex to identify patterns that match a phrase (rather than just a word) Determination made based on presence of whitespace or a hyphen in the pattern Double backslash escapes the whitespace token '\s'
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Book ¶
type Book struct { Name string RuleSets []*CategorySet }
Book is a collection of CategorySets
func NewBook ¶
NewBook is a factory that loads rule files (.yml) from a directory to create a new rule book
func (*Book) GetTotalRuleCount ¶
GetTotalRuleCount returns the total number of Rules from all RuleSets
func (*Book) NewCategorySet ¶
func (t *Book) NewCategorySet() *CategorySet
NewCategorySet creates a new set of rules and adds it to the book
type CategorySet ¶
type CategorySet struct { Category string `yaml:"Category"` Summary string `yaml:"Summary"` Detail string `yaml:"Detail"` Examples []Example `yaml:"Examples"` References []string `yaml:"References"` RuleConfigs []TypeInfo `yaml:"Rules"` Rules []Checker }
CategorySet is a collection of rules that share a common category and guidance
func NewCategorySet ¶
func NewCategorySet(file []byte) (*CategorySet, error)
NewCategorySet is a factory that returns a RuleSet loaded from a YAML file.
type CheckMatch ¶
type PersonFirstChecker ¶
type PersonFirstChecker struct { AdjectiveChecker RegexChecker // contains filtered or unexported fields }
PersonFirstChecker evaluates a source token for person first language
func (*PersonFirstChecker) Check ¶
func (t *PersonFirstChecker) Check(source *lex.Token) (match CheckMatch, isPass bool, advice string, err error)
Check implements RuleChecker
func (*PersonFirstChecker) Init ¶
func (t *PersonFirstChecker) Init() error
func (PersonFirstChecker) Kind ¶
func (t PersonFirstChecker) Kind() CheckKind
Kind implements RuleChecker
func (PersonFirstChecker) PatternString ¶
func (t PersonFirstChecker) PatternString() string
PatternString implements RuleChecker
func (PersonFirstChecker) String ¶
func (t PersonFirstChecker) String() string
Check implements String
type RegexChecker ¶
type RegexChecker struct { Pattern string Substitutes []string // contains filtered or unexported fields }
RegexChecker evaluates a source token against a regex pattern
func (*RegexChecker) Check ¶
func (t *RegexChecker) Check(source *lex.Token) (match CheckMatch, isPass bool, advice string, err error)
Check implements RuleChecker
func (RegexChecker) PatternString ¶
func (t RegexChecker) PatternString() string
Pattern implements RuleChecker