Documentation ¶
Index ¶
- Constants
- func Name(name string, whitelist, blacklist []string) (should string)
- type AbstractRule
- type Arguments
- type Config
- type DirectiveConfig
- type DirectivesConfig
- type DisabledInterval
- type Failure
- type FailurePosition
- type File
- type FileFilter
- type FileFilters
- type Formatter
- type FormatterMetadata
- type Linter
- type Package
- type ReadFile
- type Rule
- type RuleConfig
- type RulesConfig
- type Severity
Constants ¶
const ( // SeverityWarning declares failures of type warning SeverityWarning = "warning" // SeverityError declares failures of type error. SeverityError = "error" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AbstractRule ¶
type AbstractRule struct {
Failures []Failure
}
AbstractRule defines an abstract rule.
type Config ¶
type Config struct { IgnoreGeneratedHeader bool `toml:"ignoreGeneratedHeader"` Confidence float64 Severity Severity EnableAllRules bool `toml:"enableAllRules"` Rules RulesConfig `toml:"rule"` ErrorCode int `toml:"errorCode"` WarningCode int `toml:"warningCode"` Directives DirectivesConfig `toml:"directive"` Exclude []string `toml:"exclude"` }
Config defines the config of the linter.
type DirectiveConfig ¶
type DirectiveConfig struct {
Severity Severity
}
DirectiveConfig is type used for the linter directive configuration.
type DirectivesConfig ¶
type DirectivesConfig = map[string]DirectiveConfig
DirectivesConfig defines the config for all directives.
type DisabledInterval ¶
DisabledInterval contains a single disabled interval and the associated rule name.
type Failure ¶
type Failure struct { Failure string RuleName string Category string Position FailurePosition Node ast.Node `json:"-"` Confidence float64 // For future use ReplacementLine string }
Failure defines a struct for a linting failure.
func (*Failure) GetFilename ¶
GetFilename returns the filename.
type FailurePosition ¶
FailurePosition returns the failure position
func ToFailurePosition ¶
func ToFailurePosition(start, end token.Pos, file *File) FailurePosition
ToFailurePosition returns the failure position.
type File ¶
type File struct { Name string Pkg *Package AST *ast.File // contains filtered or unexported fields }
File abstraction used for representing files.
func (*File) CommentMap ¶
func (f *File) CommentMap() ast.CommentMap
CommentMap builds a comment map for the file.
func (*File) IsUntypedConst ¶
IsUntypedConst reports whether expr is an untyped constant, and indicates what its default type is. scope may be nil.
type FileFilter ¶
type FileFilter struct {
// contains filtered or unexported fields
}
FileFilter - file filter to exclude some files for rule supports whole 1. file/dir names : pkg/mypkg/my.go, 2. globs: **/*.pb.go, 3. regexes (~ prefix) ~-tmp\.\d+\.go 4. special test marker `TEST` - treats as `~_test\.go`
func ParseFileFilter ¶
func ParseFileFilter(rawFilter string) (*FileFilter, error)
ParseFileFilter - creates FileFilter for given raw filter if empty string, it matches nothing if `*`, or `~`, it matches everything while regexp could be invalid, it could return it's compilation error
func (*FileFilter) MatchFileName ¶
func (ff *FileFilter) MatchFileName(name string) bool
MatchFileName - checks if file name matches filter
func (*FileFilter) String ¶
func (ff *FileFilter) String() string
type FileFilters ¶
type FileFilters = []*FileFilter
type FormatterMetadata ¶
FormatterMetadata configuration of a formatter
type Linter ¶
type Linter struct {
// contains filtered or unexported fields
}
Linter is used for linting set of files.
type Package ¶
Package represents a package in the project.
type RuleConfig ¶
type RuleConfig struct { Arguments Arguments Severity Severity Disabled bool // Exclude - rule-level file excludes, TOML related (strings) Exclude []string // contains filtered or unexported fields }
RuleConfig is type used for the rule configuration.
func (*RuleConfig) Initialize ¶
func (rc *RuleConfig) Initialize() error
Initialize - should be called after reading from TOML file
func (*RuleConfig) MustExclude ¶
func (rcfg *RuleConfig) MustExclude(name string) bool
MustExclude - checks if given filename `name` must be excluded
type RulesConfig ¶
type RulesConfig = map[string]RuleConfig
RulesConfig defines the config for all rules.