Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 // Message is a report text that is printed when this rule matches. Message string // Location is a phpgrep variable name that should be used as a warning location. // Empty 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 // 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.
type RuleKind ¶
type RuleKind int
const ( KindNone RuleKind = iota KindMethodCall KindFunctionCall KindStaticCall KindArray KindValueFetch KindCmp // All binary comparison ops KindBinOp // All binary ops except comparison ops KindUnaryOp // All unary-ish ops KindAssign // All assignments KindCondOp // All conditional expressions KindBranch // All conditional statements KindScalar // All scalar-like nodes KindConst // All const fetching ops KindRequire KindLoop KindCast KindOther // All remaining kinds that are not None KindOtherUnlikely // Second Other category, even less priority )
All kinds of node categories.
See CategorizeNode to see how they are connected with particular node types.
func CategorizeNode ¶
CategorizeNode tries to associate a node with one of the known categories. If node can't be (yet?) categorized, returns KindNone.
Note that for some nodes we *want* to return KindNone, since matching engine can have a hard time trying to match them.
We try to categorize nodes in a way that predict which rules have higher chances to be used by the users. For examples, it's likely that function calls could be the most important pattern out there. With some other groups it's more or less shot in the dark. A better algorithm can be found later. Maybe we'll assign categories dynamically or map them 1-to-1 with nodes kind in future.
type ScopedSet ¶
type ScopedSet struct {
RulesByKind [_KindCount][]Rule
}
ScopedSet is a categorized rules collection. Categories help to assign a better execution strategy for a rule.