cmd

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2022 License: MIT Imports: 34 Imported by: 4

Documentation

Index

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 AddEmbeddedRules(rset *rules.Set, filter func(r rules.Rule) bool) ([]*rules.Set, error)

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 FormatReport(r *linter.Report) string

func InitStubs added in v0.4.0

func InitStubs(l *linter.Linter) error

func LoadEmbeddedStubs added in v0.2.0

func LoadEmbeddedStubs(l *linter.Linter, filenames []string) error

func LoadMisspellDicts added in v0.3.0

func LoadMisspellDicts(config *linter.Config, dicts []string) error

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 ParseEmbeddedRules() ([]*rules.Set, error)

func ParseExternalRules added in v0.4.0

func ParseExternalRules(externalRules string) ([]*rules.Set, error)

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.

func TestRules added in v0.5.2

func TestRules(ctx *AppContext) (status int, err error)

Types

type App added in v0.4.0

type App struct {
	CLIName     string
	Name        string
	Description string

	Commands []*Command
	// contains filtered or unexported fields
}

func (*App) GetRawCommandByName added in v0.4.0

func (a *App) GetRawCommandByName(name string) *Command

func (*App) Run added in v0.4.0

func (a *App) Run(cfg *MainConfig) (int, error)

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 Argument added in v0.4.0

type Argument struct {
	Name        string
	Description 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 Example added in v0.4.0

type Example struct {
	Line        string
	Description string
}

type FlagsGroups added in v0.4.0

type FlagsGroups struct {
	Groups []string
	Map    map[string][]string
}

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 RegisterTestRulesFlags added in v0.5.2

func RegisterTestRulesFlags(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

type InitEnvironment struct {
	RuleSets []*rules.Set

	MetaInfo *meta.Info
}

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 messages after reports is not displayed.
	DisableAfterReportsLog 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
	}
}

type ReportsStat added in v0.5.2

type ReportsStat struct {
	// contains filtered or unexported fields
}

type RulesTestSuite added in v0.5.2

type RulesTestSuite struct {
	Rules string
	Tests string

	KPHP bool
}

func NewRulesTestSuite added in v0.5.2

func NewRulesTestSuite(rulesPaths string, tests string, kphp bool) *RulesTestSuite

func (*RulesTestSuite) ParseTestFile added in v0.5.2

func (s *RulesTestSuite) ParseTestFile(l *linter.Linter, filename, content string) linter.ParseResult

func (*RulesTestSuite) Run added in v0.5.2

func (s *RulesTestSuite) Run() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL