forked from forgejo/forgejo
Rename scripts to build and add revive command as a new build tool command (#10942)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
4af7c47b38
commit
4f63f283c4
182 changed files with 15832 additions and 1226 deletions
39
vendor/github.com/mgechev/revive/rule/duplicated-imports.go
generated
vendored
Normal file
39
vendor/github.com/mgechev/revive/rule/duplicated-imports.go
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
package rule
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/mgechev/revive/lint"
|
||||
)
|
||||
|
||||
// DuplicatedImportsRule lints given else constructs.
|
||||
type DuplicatedImportsRule struct{}
|
||||
|
||||
// Apply applies the rule to given file.
|
||||
func (r *DuplicatedImportsRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
|
||||
var failures []lint.Failure
|
||||
|
||||
impPaths := map[string]struct{}{}
|
||||
for _, imp := range file.AST.Imports {
|
||||
path := imp.Path.Value
|
||||
_, ok := impPaths[path]
|
||||
if ok {
|
||||
failures = append(failures, lint.Failure{
|
||||
Confidence: 1,
|
||||
Failure: fmt.Sprintf("Package %s already imported", path),
|
||||
Node: imp,
|
||||
Category: "imports",
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
impPaths[path] = struct{}{}
|
||||
}
|
||||
|
||||
return failures
|
||||
}
|
||||
|
||||
// Name returns the rule name.
|
||||
func (r *DuplicatedImportsRule) Name() string {
|
||||
return "duplicated-imports"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue