Documentation
¶
Overview ¶
Package conformance checks rule implementations against annotated fixtures (see package markup for their format).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ParseMarkup strips the expectation tags of a fixture. ParseMarkup = markup.Parse // SortExpectations orders expectations by position. SortExpectations = markup.Sort )
Functions ¶
Types ¶
type CompareOptions ¶
type CompareOptions struct {
Messages bool // compare message text (own fixtures only; EA text is never compared)
// OnlyPrefixed keeps only expectations whose message has this prefix
// (EA: "[EA] "), dropping IDE syntax-error markers.
OnlyPrefixed string
// HideExpected suppresses expected fix text in diffs (EA fixtures).
HideExpected bool
// NoFixWithoutFixed requires a fixture without expected fix output to
// be left as it is by the fixes (own fixtures: a quick-fix is always
// shown by a .fixed file).
NoFixWithoutFixed bool
}
CompareOptions selects what is compared.
type EACase ¶
type EACase struct {
Test string `json:"test"`
Rules []string `json:"rules"`
Fixture string `json:"fixture"`
Fixed string `json:"fixed,omitempty"`
PHP string `json:"php,omitempty"`
ComparisonStyle string `json:"comparisonStyle,omitempty"`
Options map[string]string `json:"options,omitempty"`
Calls []string `json:"calls,omitempty"`
Companions []string `json:"companions,omitempty"`
}
EACase mirrors tools/extract's Case.
type EAIndex ¶
EAIndex mirrors the parts of tools/extract's Index the harness needs.
func LoadEAIndex ¶
LoadEAIndex reads the local-only index produced by `make extract`.
type Engine ¶
type Engine interface {
// Supports reports whether every given rule is implemented.
Supports(rules []string) bool
// Analyze returns findings for req.
Analyze(req Request) ([]Finding, error)
// Fix applies the available fixes in one pass and returns the result.
Fix(req Request) ([]byte, error)
}
Engine is implemented by the analysis engine adapter.
type Expectation ¶
type Expectation = markup.Expectation
Expectation is one expected finding of a fixture (see package markup).
type Request ¶
type Request struct {
Path string
Source []byte
Rules []string // rule IDs to enable (all others off)
PHP string // target PHP version, "" = default
ComparisonStyle string // "", "regular", "yoda"
Options map[string]string // "Rule.OPTION" -> raw value
Calls []string // raw option calls (EA list options)
// Companions are extra project files (path -> clean source) whose
// symbols are visible to the analyzed file.
Companions map[string][]byte
// CompleteWorld marks the indexed files as everything the project can
// load (see index.World).
CompleteWorld bool
// Vendor is the project's vendor directory (see index.World.Vendor).
Vendor string
// Assertions trusts assert() calls as guards (flow.assertions).
Assertions bool
}
Request is one analysis run over a fixture.
type Result ¶
type Result struct {
Missing []Expectation // expected but not reported
Unexpected []Expectation // reported but not expected
FixDiff string // non-empty when the fixed output differs
}
Result of checking one case.