1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 10:18:38 +00:00

update revive lint to latest commit (#12921)

* update revive lint to latest commit

* make fmt

* change import
This commit is contained in:
techknowlogick
2020-09-22 13:02:16 -04:00
committed by GitHub
parent 63e8bdaf73
commit 1c3278c2fa
154 changed files with 5965 additions and 8502 deletions

View File

@@ -402,14 +402,14 @@ func equivalentTypes(want, got types.Type) bool {
func FindBestMatch(pattern string, idents []*ast.Ident) ast.Expr {
fuzz := fuzzy.NewMatcher(pattern)
var bestFuzz ast.Expr
highScore := float32(-1) // minimum score is -1 (no match)
highScore := float32(0) // minimum score is 0 (no match)
for _, ident := range idents {
// TODO: Improve scoring algorithm.
score := fuzz.Score(ident.Name)
if score > highScore {
highScore = score
bestFuzz = ident
} else if score == -1 {
} else if score == 0 {
// Order matters in the fuzzy matching algorithm. If we find no match
// when matching the target to the identifier, try matching the identifier
// to the target.

View File

@@ -615,7 +615,7 @@ func getCandidatePkgs(ctx context.Context, wrappedCallback *scanCallback, filena
packageName: path.Base(importPath),
relevance: MaxRelevance,
}
if notSelf(p) && wrappedCallback.packageNameLoaded(p) {
if notSelf(p) && wrappedCallback.dirFound(p) && wrappedCallback.packageNameLoaded(p) {
wrappedCallback.exportsLoaded(p, exports)
}
}
@@ -827,7 +827,11 @@ func (e *ProcessEnv) goEnv() (map[string]string, error) {
}
func (e *ProcessEnv) matchFile(dir, name string) (bool, error) {
return build.Default.MatchFile(dir, name)
bctx, err := e.buildContext()
if err != nil {
return false, err
}
return bctx.MatchFile(dir, name)
}
// CopyConfig copies the env's configuration into a new env.
@@ -920,15 +924,21 @@ func (e *ProcessEnv) buildContext() (*build.Context, error) {
// Populate it only if present.
rc := reflect.ValueOf(&ctx).Elem()
dir := rc.FieldByName("Dir")
if !dir.IsValid() {
// Working drafts of Go 1.14 named the field "WorkingDir" instead.
// TODO(bcmills): Remove this case after the Go 1.14 beta has been released.
dir = rc.FieldByName("WorkingDir")
}
if dir.IsValid() && dir.Kind() == reflect.String {
dir.SetString(e.WorkingDir)
}
// Since Go 1.11, go/build.Context.Import may invoke 'go list' depending on
// the value in GO111MODULE in the process's environment. We always want to
// run in GOPATH mode when calling Import, so we need to prevent this from
// happening. In Go 1.16, GO111MODULE defaults to "on", so this problem comes
// up more frequently.
//
// HACK: setting any of the Context I/O hooks prevents Import from invoking
// 'go list', regardless of GO111MODULE. This is undocumented, but it's
// unlikely to change before GOPATH support is removed.
ctx.ReadDir = ioutil.ReadDir
return &ctx, nil
}

View File

@@ -135,7 +135,7 @@ func (m *Matcher) Score(candidate string) float32 {
}
m.lastCandidateMatched = false
return -1
return 0
}
const minScore = -10000