config

package
v0.0.1-2019.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2019 License: MIT Imports: 8 Imported by: 84

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "config",
	Doc:  "loads configuration for the current package tree",
	Run: func(pass *analysis.Pass) (interface{}, error) {
		if len(pass.Files) == 0 {
			cfg := DefaultConfig
			return &cfg, nil
		}
		cache, err := os.UserCacheDir()
		if err != nil {
			cache = ""
		}
		var path string
		for _, f := range pass.Files {
			p := pass.Fset.PositionFor(f.Pos(), true).Filename

			if cache != "" && strings.HasPrefix(p, cache) {

				continue
			}
			path = p
			break
		}

		if path == "" {

			cfg := DefaultConfig
			return &cfg, nil
		}

		dir := filepath.Dir(path)
		cfg, err := Load(dir)
		if err != nil {
			return nil, fmt.Errorf("error loading staticcheck.conf: %s", err)
		}
		return &cfg, nil
	},
	RunDespiteErrors: true,
	ResultType:       reflect.TypeOf((*Config)(nil)),
}
View Source
var DefaultConfig = Config{
	Checks: []string{"all", "-ST1000", "-ST1003", "-ST1016"},
	Initialisms: []string{
		"ACL", "API", "ASCII", "CPU", "CSS", "DNS",
		"EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID",
		"IP", "JSON", "QPS", "RAM", "RPC", "SLA",
		"SMTP", "SQL", "SSH", "TCP", "TLS", "TTL",
		"UDP", "UI", "GID", "UID", "UUID", "URI",
		"URL", "UTF8", "VM", "XML", "XMPP", "XSRF",
		"XSS", "SIP", "RTP",
	},
	DotImportWhitelist:      []string{},
	HTTPStatusCodeWhitelist: []string{"200", "400", "404", "500"},
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Checks                  []string `toml:"checks"`
	Initialisms             []string `toml:"initialisms"`
	DotImportWhitelist      []string `toml:"dot_import_whitelist"`
	HTTPStatusCodeWhitelist []string `toml:"http_status_code_whitelist"`
}

func For

func For(pass *analysis.Pass) *Config

func Load

func Load(dir string) (Config, error)

func (Config) Merge

func (cfg Config) Merge(ocfg Config) Config

func (Config) String

func (c Config) String() string

Jump to

Keyboard shortcuts

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