mirror of
https://github.com/mgechev/revive.git
synced 2025-11-23 22:04:49 +02:00
Improvements
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user