1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-23 22:04:49 +02:00

Improvements

This commit is contained in:
mgechev
2018-01-27 16:37:30 -08:00
parent 8746067321
commit 1870854374
7 changed files with 20 additions and 10 deletions

View File

@@ -42,7 +42,8 @@ func isGenerated(src []byte) bool {
}
// Lint lints a set of files with the specified rule.
func (l *Linter) Lint(filenames []string, ruleSet []Rule, rulesConfig RulesConfig) (<-chan Failure, error) {
func (l *Linter) Lint(filenames []string, ruleSet []Rule, config Config) (<-chan Failure, error) {
rulesConfig := config.Rules
failures := make(chan Failure)
pkg := &Package{
fset: token.NewFileSet(),
@@ -54,7 +55,7 @@ func (l *Linter) Lint(filenames []string, ruleSet []Rule, rulesConfig RulesConfi
if err != nil {
return nil, err
}
if isGenerated(content) {
if isGenerated(content) && !config.IgnoreGeneratedHeader {
continue
}

View File

@@ -140,6 +140,10 @@ func receiverType(fn *ast.FuncDecl) string {
}
func (p *Package) lint(rules []Rule, config RulesConfig, failures chan Failure) {
if len(p.files) == 0 {
close(failures)
return
}
p.typeCheck()
p.scanSortable()
var wg sync.WaitGroup

View File

@@ -60,9 +60,10 @@ type RulesConfig = map[string]RuleConfig
// Config defines the config of the linter.
type Config struct {
Confidence float64
Severity Severity
Rules RulesConfig `toml:"rule"`
IgnoreGeneratedHeader bool `toml:"ignore-generated-header"`
Confidence float64
Severity Severity
Rules RulesConfig `toml:"rule"`
}
// Rule defines an abstract rule interaface