golangci-lint/pkg/config/config.go

131 lines
2.5 KiB
Go
Raw Normal View History

package config
2018-05-06 19:08:34 +03:00
import (
"time"
)
2018-05-06 09:41:48 +03:00
2018-05-05 09:24:37 +03:00
type OutFormat string
const (
OutFormatJSON = "json"
OutFormatLineNumber = "line-number"
OutFormatColoredLineNumber = "colored-line-number"
)
var OutFormats = []string{OutFormatColoredLineNumber, OutFormatLineNumber, OutFormatJSON}
var DefaultExcludePatterns = []string{
// errcheck
2018-05-08 22:28:29 +03:00
"Error return value of .((os\\.)?std(out|err)\\..*|.*Close|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked",
// golint
"should have comment",
"comment on exported method",
// gas
"G103:", // Use of unsafe calls should be audited
"G104:", // disable what errcheck does: it reports on Close etc
"G204:", // Subprocess launching should be audited: too lot false positives
2018-05-08 22:28:29 +03:00
"G301:", // Expect directory permissions to be 0750 or less
"G302:", // Expect file permissions to be 0600 or less
"G304:", // Potential file inclusion via variable: `src, err := ioutil.ReadFile(filename)`
// govet
"possible misuse of unsafe.Pointer",
2018-05-08 22:28:29 +03:00
"should have signature",
// megacheck
"ineffective break statement. Did you mean to break out of the outer loop", // developers tend to write in C-style with break in switch
}
2018-05-06 13:41:42 +03:00
2018-05-05 09:24:37 +03:00
type Common struct {
2018-05-05 19:43:18 +03:00
IsVerbose bool
CPUProfilePath string
2018-05-06 12:08:57 +03:00
Concurrency int
2018-05-05 09:24:37 +03:00
}
type Run struct { // nolint:maligned
2018-05-06 19:08:34 +03:00
Args []string
2018-05-05 19:43:18 +03:00
BuildTags []string
OutFormat string
PrintIssuedLine bool
PrintLinterName bool
PrintWelcomeMessage bool
2018-05-08 11:54:30 +03:00
2018-05-05 11:08:14 +03:00
ExitCodeIfIssuesFound int
2018-05-05 19:43:18 +03:00
Errcheck struct {
CheckTypeAssertions bool
CheckAssignToBlank bool
}
2018-05-05 22:22:21 +03:00
Govet struct {
CheckShadowing bool
}
2018-05-06 07:20:12 +03:00
Golint struct {
MinConfidence float64
}
2018-05-06 09:41:48 +03:00
Gofmt struct {
Simplify bool
}
2018-05-06 15:24:45 +03:00
Gocyclo struct {
MinComplexity int
}
2018-05-06 20:28:59 +03:00
Varcheck struct {
CheckExportedFields bool
}
Structcheck struct {
CheckExportedFields bool
}
2018-05-06 21:08:53 +03:00
Maligned struct {
SuggestNewOrder bool
}
2018-05-06 22:58:04 +03:00
Megacheck struct {
EnableStaticcheck bool
EnableUnused bool
EnableGosimple bool
}
2018-05-07 09:09:10 +03:00
Dupl struct {
Threshold int
}
2018-05-07 12:43:52 +03:00
Goconst struct {
MinStringLen int
MinOccurrencesCount int
}
EnabledLinters []string
DisabledLinters []string
EnableAllLinters bool
DisableAllLinters bool
2018-05-06 13:41:42 +03:00
Presets []string
ExcludePatterns []string
UseDefaultExcludes bool
2018-05-06 19:08:34 +03:00
Deadline time.Duration
MaxIssuesPerLinter int
MaxSameIssues int
2018-05-08 09:55:38 +03:00
DiffFromRevision string
DiffPatchFilePath string
Diff bool
2018-05-08 12:28:36 +03:00
AnalyzeTests bool
2018-05-05 09:24:37 +03:00
}
type Config struct {
2018-05-05 09:24:37 +03:00
Common Common
Run Run
}
func NewDefault() *Config {
return &Config{
Run: Run{
OutFormat: OutFormatColoredLineNumber,
},
}
}