Documentation ¶
Index ¶
- Constants
- Variables
- func AddEmbeddedRules(rset *rules.Set, filter func(r rules.Rule) bool) ([]*rules.Set, error)
- func Check(ctx *AppContext) (int, error)
- func Checkers(ctx *AppContext) (int, error)
- func CheckersDocumentation(ctx *AppContext) (int, error)
- func DefaultCacheDir() string
- func FormatReport(r *linter.Report) string
- func InitStubs(l *linter.Linter) error
- func LoadEmbeddedStubs(l *linter.Linter, filenames []string) error
- func LoadMisspellDicts(config *linter.Config, dicts []string) error
- func Main(cfg *MainConfig)
- func ParseEmbeddedRules() ([]*rules.Set, error)
- func ParseExternalRules(externalRules string) ([]*rules.Set, error)
- func Run(cfg *MainConfig) (int, error)
- type App
- type AppContext
- type Argument
- type Command
- type Example
- type FlagsGroups
- type InitEnvironment
- type LinterRunner
- type MainConfig
- type ParsedFlags
Constants ¶
View Source
const AllChecks = "<all>"
View Source
const AllNonNoticeChecks = "<all-non-notice>"
Variables ¶
View Source
var ( BuildVersion string BuildTime string BuildOSUname string BuildCommit string )
Build* are initialized during the build via -ldflags
Functions ¶
func AddEmbeddedRules ¶ added in v0.4.0
func Check ¶ added in v0.3.0
func Check(ctx *AppContext) (int, error)
func Checkers ¶ added in v0.4.0
func Checkers(ctx *AppContext) (int, error)
func CheckersDocumentation ¶ added in v0.4.0
func CheckersDocumentation(ctx *AppContext) (int, error)
func DefaultCacheDir ¶ added in v0.3.0
func DefaultCacheDir() string
func FormatReport ¶ added in v0.3.0
func LoadEmbeddedStubs ¶ added in v0.2.0
func LoadMisspellDicts ¶ added in v0.3.0
func Main ¶
func Main(cfg *MainConfig)
Main is like Run(), but it calls os.Exit() and does not return.
func ParseEmbeddedRules ¶ added in v0.4.0
func ParseExternalRules ¶ added in v0.4.0
func Run ¶ added in v0.3.0
func Run(cfg *MainConfig) (int, error)
Run executes linter main function.
It is separate from linter so that you can insert your own hooks before running Run().
It returns a status code to be used for os.Exit() and initialization error (if any).
Optionally, non-nil config can be passed to customize function behavior.
Types ¶
type App ¶ added in v0.4.0
type App struct { Name string Description string Commands []*Command // contains filtered or unexported fields }
func (*App) GetRawCommandByName ¶ added in v0.4.0
type AppContext ¶ added in v0.4.0
type AppContext struct { App *App MainConfig *MainConfig ParsedFlags ParsedFlags ParsedArgs []string FlagSet *flag.FlagSet CustomFlags interface{} // contains filtered or unexported fields }
func (*AppContext) CountDefinedFlags ¶ added in v0.4.0
func (ctx *AppContext) CountDefinedFlags() int
func (*AppContext) FormatFlags ¶ added in v0.4.0
func (ctx *AppContext) FormatFlags() (res string)
type Command ¶ added in v0.4.0
type Command struct { Name string Description string Action func(*AppContext) (int, error) Examples []Example Arguments []*Argument RegisterFlags func(*AppContext) (fs *flag.FlagSet, groups *FlagsGroups) // Pure flag defines the command, which itself is responsible // for registering flags and arguments. // For such a command, help subcommand is not automatically generated. Pure bool Commands []*Command // contains filtered or unexported fields }
type FlagsGroups ¶ added in v0.4.0
func NewFlagsGroups ¶ added in v0.4.0
func NewFlagsGroups() *FlagsGroups
func RegisterCheckFlags ¶ added in v0.4.0
func RegisterCheckFlags(ctx *AppContext) (*flag.FlagSet, *FlagsGroups)
func (*FlagsGroups) Add ¶ added in v0.4.0
func (fg *FlagsGroups) Add(group, name string)
func (*FlagsGroups) AddGroup ¶ added in v0.4.0
func (fg *FlagsGroups) AddGroup(group string)
type InitEnvironment ¶ added in v0.3.0
InitEnvironment passes the state that may be required to finish custom linters initialization.
type LinterRunner ¶ added in v0.4.0
type LinterRunner struct {
// contains filtered or unexported fields
}
func NewLinterRunner ¶ added in v0.4.0
func NewLinterRunner(lint *linter.Linter, checkersFilter *linter.CheckersFilter) *LinterRunner
func (*LinterRunner) Init ¶ added in v0.4.0
func (l *LinterRunner) Init(ruleSets []*rules.Set, flags *ParsedFlags) error
type MainConfig ¶
type MainConfig struct { // AfterFlagParse is called right after flag.Parse() returned. // Can be used to examine flags that were bound prior to the Main() call. // // If nil, behaves as a no-op function. AfterFlagParse func(InitEnvironment) // BeforeReport acts as both an on-report action and a filter. // // If false is returned, the given report will not be reported. BeforeReport func(*linter.Report) bool LinterVersion string LinterConfig *linter.Config // RegisterCheckers is used to register additional checkers. RegisterCheckers func() []linter.CheckerInfo // ModifyApp is a callback function into which a standard // application is passed to modify a command, name or description. ModifyApp func(app *App) // If true, then the message "No critical issues found. Your code is perfect." is not displayed. DisableCriticalIssuesLog bool // contains filtered or unexported fields }
MainConfig describes optional main function config. All zero field values have some defined behavior.
type ParsedFlags ¶ added in v0.4.0
type ParsedFlags struct { PHP7 bool PprofHost string CPUProfile string MemProfile string StrictMixed bool IgnoreVendor bool MaxFileSize int FullAnalysisFiles string IndexOnlyFiles string CheckAutoGenerated bool RulesList string Output string OutputJSON bool OutputBaseline bool Debug bool DebugParseDuration time.Duration MaxConcurrency int StubsDir string CacheDir string DisableCache bool IgnoreTriggerError bool ApplyQuickFixes bool KPHP bool Baseline string ConservativeBaseline bool MisspellList string UnusedVarPattern string AllowAll bool AllowChecks string AllowDisable string ReportsExclude string ReportsExcludeChecks string ReportsCritical string PhpExtensionsArg string Gitignore bool GitPushArg string GitAuthorsWhitelist string GitWorkTree string GitSkipFetch bool GitDisableCompensateMaster bool GitFullDiff bool GitIncludeUntracked bool GitRepo string // These two flags are mutated in prepareGitArgs. // This is bad, but it's easier for now than to fix this // without introducing other issues. Mutable struct { GitCommitFrom string GitCommitTo string } }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.