Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions cmd/frontend/auth/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ func TestGetAndSaveUser(t *testing.T) {
userID, safeErr, err := GetAndSaveUser(ctx, db, op)
for _, v := range []struct {
label string
got interface{}
want interface{}
got any
want any
}{
{"userID", userID, c.expUserID},
{"safeErr", safeErr, c.expSafeErr},
Expand Down
2 changes: 1 addition & 1 deletion cmd/frontend/backend/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (s *repos) GetInventory(ctx context.Context, repo *types.Repo, commitID api
return Mocks.Repos.GetInventory(ctx, repo, commitID)
}

ctx, done := trace(ctx, "Repos", "GetInventory", map[string]interface{}{"repo": repo.Name, "commitID": commitID}, &err)
ctx, done := trace(ctx, "Repos", "GetInventory", map[string]any{"repo": repo.Name, "commitID": commitID}, &err)
defer done()

// Cap GetInventory operation to some reasonable time.
Expand Down
4 changes: 2 additions & 2 deletions cmd/frontend/backend/repos_vcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (s *repos) ResolveRev(ctx context.Context, repo *types.Repo, rev string) (c
return Mocks.Repos.ResolveRev(ctx, repo, rev)
}

ctx, done := trace(ctx, "Repos", "ResolveRev", map[string]interface{}{"repo": repo.Name, "rev": rev}, &err)
ctx, done := trace(ctx, "Repos", "ResolveRev", map[string]any{"repo": repo.Name, "rev": rev}, &err)
defer done()

return git.ResolveRevision(ctx, repo.Name, rev, git.ResolveRevisionOptions{})
Expand All @@ -35,7 +35,7 @@ func (s *repos) GetCommit(ctx context.Context, repo *types.Repo, commitID api.Co
return Mocks.Repos.GetCommit(ctx, repo, commitID)
}

ctx, done := trace(ctx, "Repos", "GetCommit", map[string]interface{}{"repo": repo.Name, "commitID": commitID}, &err)
ctx, done := trace(ctx, "Repos", "GetCommit", map[string]any{"repo": repo.Name, "commitID": commitID}, &err)
defer done()

log15.Debug("svc.local.repos.GetCommit", "repo", repo.Name, "commitID", commitID)
Expand Down
2 changes: 1 addition & 1 deletion cmd/frontend/backend/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var requestGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
Help: "Current number of requests running for a method.",
}, []string{"method"})

func trace(ctx context.Context, server, method string, arg interface{}, err *error) (context.Context, func()) {
func trace(ctx context.Context, server, method string, arg any, err *error) (context.Context, func()) {
requestGauge.WithLabelValues(server + "." + method).Inc()

span, ctx := ot.StartSpanFromContext(ctx, server+"."+method)
Expand Down
2 changes: 1 addition & 1 deletion cmd/frontend/graphqlbackend/access_tokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func TestMutation_CreateAccessToken(t *testing.T) {
ExpectedResult: `null`,
ExpectedErrors: []*gqlerrors.QueryError{
{
Path: []interface{}{"createAccessToken"},
Path: []any{"createAccessToken"},
Message: "Must be authenticated as user with id 1",
ResolverError: &backend.InsufficientAuthorizationError{Message: fmt.Sprintf("Must be authenticated as user with id %d", 1)},
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/frontend/graphqlbackend/bigint.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (v BigInt) MarshalJSON() ([]byte, error) {
return json.Marshal(strconv.FormatInt(v.Int, 10))
}

func (v *BigInt) UnmarshalGraphQL(input interface{}) error {
func (v *BigInt) UnmarshalGraphQL(input any) error {
s, ok := input.(string)
if !ok {
return errors.Errorf("invalid GraphQL BigInt scalar value input (got %T, expected string)", input)
Expand Down
2 changes: 1 addition & 1 deletion cmd/frontend/graphqlbackend/datetime.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (v DateTime) MarshalJSON() ([]byte, error) {
return json.Marshal(v.Time.Format(time.RFC3339))
}

func (v *DateTime) UnmarshalGraphQL(input interface{}) error {
func (v *DateTime) UnmarshalGraphQL(input any) error {
s, ok := input.(string)
if !ok {
return errors.Errorf("invalid GraphQL DateTime scalar value input (got %T, expected string)", input)
Expand Down
6 changes: 3 additions & 3 deletions cmd/frontend/graphqlbackend/default_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var builtinExtensions = map[string]bool{
"sourcegraph/vhdl": true,
}

func defaultSettings(db dbutil.DB) map[string]interface{} {
func defaultSettings(db dbutil.DB) map[string]any {
extensionIDs := []string{}
for id := range builtinExtensions {
extensionIDs = append(extensionIDs, id)
Expand All @@ -61,8 +61,8 @@ func defaultSettings(db dbutil.DB) map[string]interface{} {
extensions[id] = true
}

return map[string]interface{}{
"experimentalFeatures": map[string]interface{}{},
return map[string]any{
"experimentalFeatures": map[string]any{},
"extensions": extensions,
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/frontend/graphqlbackend/extension_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ type ExtensionRegistryMutationResult interface {

// NodeToRegistryExtension is called to convert GraphQL node values to values of type
// RegistryExtension. It is assigned at init time.
var NodeToRegistryExtension func(interface{}) (RegistryExtension, bool)
var NodeToRegistryExtension func(any) (RegistryExtension, bool)

// RegistryExtensionByID is called to look up values of GraphQL type RegistryExtension. It is
// assigned at init time.
Expand Down
2 changes: 1 addition & 1 deletion cmd/frontend/graphqlbackend/external_services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ func TestExternalServices(t *testing.T) {
`,
ExpectedErrors: []*gqlerrors.QueryError{
{
Path: []interface{}{"externalServices"},
Path: []any{"externalServices"},
Message: errNoAccessExternalService.Error(),
ResolverError: errNoAccessExternalService,
},
Expand Down
18 changes: 9 additions & 9 deletions cmd/frontend/graphqlbackend/git_commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,49 +46,49 @@ func TestGitCommitResolver(t *testing.T) {

for _, tc := range []struct {
name string
want interface{}
have func(*GitCommitResolver) (interface{}, error)
want any
have func(*GitCommitResolver) (any, error)
}{{
name: "author",
want: toSignatureResolver(db, &commit.Author, true),
have: func(r *GitCommitResolver) (interface{}, error) {
have: func(r *GitCommitResolver) (any, error) {
return r.Author(ctx)
},
}, {
name: "committer",
want: toSignatureResolver(db, commit.Committer, true),
have: func(r *GitCommitResolver) (interface{}, error) {
have: func(r *GitCommitResolver) (any, error) {
return r.Committer(ctx)
},
}, {
name: "message",
want: string(commit.Message),
have: func(r *GitCommitResolver) (interface{}, error) {
have: func(r *GitCommitResolver) (any, error) {
return r.Message(ctx)
},
}, {
name: "subject",
want: "subject: Changes things",
have: func(r *GitCommitResolver) (interface{}, error) {
have: func(r *GitCommitResolver) (any, error) {
return r.Subject(ctx)
},
}, {
name: "body",
want: "Body of changes",
have: func(r *GitCommitResolver) (interface{}, error) {
have: func(r *GitCommitResolver) (any, error) {
s, err := r.Body(ctx)
return *s, err
},
}, {
name: "url",
want: "/bob-repo/-/commit/c1",
have: func(r *GitCommitResolver) (interface{}, error) {
have: func(r *GitCommitResolver) (any, error) {
return r.URL(), nil
},
}, {
name: "canonical-url",
want: "/bob-repo/-/commit/c1",
have: func(r *GitCommitResolver) (interface{}, error) {
have: func(r *GitCommitResolver) (any, error) {
return r.CanonicalURL(), nil
},
}} {
Expand Down
2 changes: 1 addition & 1 deletion cmd/frontend/graphqlbackend/git_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (GitObjectID) ImplementsGraphQLType(name string) bool {
return name == "GitObjectID"
}

func (id *GitObjectID) UnmarshalGraphQL(input interface{}) error {
func (id *GitObjectID) UnmarshalGraphQL(input any) error {
if input, ok := input.(string); ok && git.IsAbsoluteRevision(input) {
*id = GitObjectID(input)
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/frontend/graphqlbackend/git_tree_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,4 @@ func (f fileInfo) Mode() os.FileMode {
return 0
}
func (f fileInfo) ModTime() time.Time { return time.Now() }
func (f fileInfo) Sys() interface{} { return interface{}(nil) }
func (f fileInfo) Sys() any { return any(nil) }
7 changes: 3 additions & 4 deletions cmd/frontend/graphqlbackend/graphqlbackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type prometheusTracer struct {
trace.OpenTracingTracer
}

func (t *prometheusTracer) TraceQuery(ctx context.Context, queryString string, operationName string, variables map[string]interface{}, varTypes map[string]*introspection.Type) (context.Context, trace.TraceQueryFinishFunc) {
func (t *prometheusTracer) TraceQuery(ctx context.Context, queryString string, operationName string, variables map[string]any, varTypes map[string]*introspection.Type) (context.Context, trace.TraceQueryFinishFunc) {
start := time.Now()
var finish trace.TraceQueryFinishFunc
if ot.ShouldTrace(ctx) {
Expand Down Expand Up @@ -121,7 +121,7 @@ VARIABLES
}
}

func (prometheusTracer) TraceField(ctx context.Context, label, typeName, fieldName string, trivial bool, args map[string]interface{}) (context.Context, trace.TraceFieldFinishFunc) {
func (prometheusTracer) TraceField(ctx context.Context, label, typeName, fieldName string, trivial bool, args map[string]any) (context.Context, trace.TraceFieldFinishFunc) {
start := time.Now()
return ctx, func(err *gqlerrors.QueryError) {
isErrStr := strconv.FormatBool(err != nil)
Expand Down Expand Up @@ -312,8 +312,7 @@ var blocklistedPrometheusTypeNames = map[string]struct{}{
// not worth tracking. You can find a complete list of the ones Prometheus is
// currently tracking via:
//
// sum by (type)(src_graphql_field_seconds_count)
//
// sum by (type)(src_graphql_field_seconds_count)
func prometheusTypeName(typeName string) string {
if _, ok := blocklistedPrometheusTypeNames[typeName]; ok {
return "other"
Expand Down
6 changes: 3 additions & 3 deletions cmd/frontend/graphqlbackend/graphqlbackend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestResolverTo(t *testing.T) {
// run. The To* resolvers are stored in a map in our graphql
// implementation => the order we call them is non deterministic =>
// codecov coverage reports are noisy.
resolvers := []interface{}{
resolvers := []any{
&FileMatchResolver{db: db},
&GitTreeEntryResolver{db: db},
&NamespaceResolver{},
Expand Down Expand Up @@ -301,7 +301,7 @@ func TestAffiliatedRepositories(t *testing.T) {
ExpectedResult: `null`,
ExpectedErrors: []*gqlerrors.QueryError{
{
Path: []interface{}{"affiliatedRepositories"},
Path: []any{"affiliatedRepositories"},
Message: "Must be authenticated as user with id 1",
ResolverError: &backend.InsufficientAuthorizationError{Message: fmt.Sprintf("Must be authenticated as user with id %d", 1)},
},
Expand Down Expand Up @@ -410,7 +410,7 @@ func TestAffiliatedRepositories(t *testing.T) {
ExpectedResult: `null`,
ExpectedErrors: []*gqlerrors.QueryError{
{
Path: []interface{}{"affiliatedRepositories", "nodes"},
Path: []any{"affiliatedRepositories", "nodes"},
Message: "failed to fetch from any code host",
ResolverError: errors.New("failed to fetch from any code host"),
},
Expand Down
6 changes: 3 additions & 3 deletions cmd/frontend/graphqlbackend/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (

// JSONValue implements the JSONValue scalar type. In GraphQL queries, it is represented the JSON
// representation of its Go value.
type JSONValue struct{ Value interface{} }
type JSONValue struct{ Value any }

func (JSONValue) ImplementsGraphQLType(name string) bool {
return name == "JSONValue"
}

func (v *JSONValue) UnmarshalGraphQL(input interface{}) error {
func (v *JSONValue) UnmarshalGraphQL(input any) error {
*v = JSONValue{Value: input}
return nil
}
Expand All @@ -34,7 +34,7 @@ func (JSONCString) ImplementsGraphQLType(name string) bool {
return name == "JSONCString"
}

func (j *JSONCString) UnmarshalGraphQL(input interface{}) error {
func (j *JSONCString) UnmarshalGraphQL(input any) error {
s, ok := input.(string)
if !ok {
return errors.Errorf("invalid GraphQL JSONCString scalar value input (got %T, expected string)", input)
Expand Down
2 changes: 1 addition & 1 deletion cmd/frontend/graphqlbackend/namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestNamespace(t *testing.T) {
`,
ExpectedErrors: []*gqlerrors.QueryError{
{
Path: []interface{}{"namespace"},
Path: []any{"namespace"},
Message: wantErr.Error(),
ResolverError: wantErr,
},
Expand Down
12 changes: 6 additions & 6 deletions cmd/frontend/graphqlbackend/parse_search_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ import (
"github.com/sourcegraph/sourcegraph/internal/search/query"
)

func toJSON(node query.Node) interface{} {
func toJSON(node query.Node) any {
switch n := node.(type) {
case query.Operator:
var jsons []interface{}
var jsons []any
for _, o := range n.Operands {
jsons = append(jsons, toJSON(o))
}

switch n.Kind {
case query.And:
return struct {
And []interface{} `json:"and"`
And []any `json:"and"`
}{
And: jsons,
}
case query.Or:
return struct {
Or []interface{} `json:"or"`
Or []any `json:"or"`
}{
Or: jsons,
}
Expand All @@ -33,7 +33,7 @@ func toJSON(node query.Node) interface{} {
// the original query expresses something that is not
// supported. We just return the parse tree anyway.
return struct {
Concat []interface{} `json:"concat"`
Concat []any `json:"concat"`
}{
Concat: jsons,
}
Expand Down Expand Up @@ -100,7 +100,7 @@ func (r *schemaResolver) ParseSearchQuery(ctx context.Context, args *struct {
return nil, err
}

var jsons []interface{}
var jsons []any
for _, node := range plan.ToParseTree() {
jsons = append(jsons, toJSON(node))
}
Expand Down
18 changes: 9 additions & 9 deletions cmd/frontend/graphqlbackend/rate_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type QueryCost struct {
// EstimateQueryCost estimates the cost of the query before it is actually
// executed. It is a worst cast estimate of the number of fields expected to be
// returned by the query and handles nested queries a well as fragments.
func EstimateQueryCost(query string, variables map[string]interface{}) (totalCost *QueryCost, err error) {
func EstimateQueryCost(query string, variables map[string]any) (totalCost *QueryCost, err error) {
// NOTE: When we encounter errors in our visit funcs we return
// visitor.ActionBreak to stop walking the tree and set the top level err
// variable so that it is returned
Expand All @@ -47,7 +47,7 @@ func EstimateQueryCost(query string, variables map[string]interface{}) (totalCos
}
}()
if variables == nil {
variables = make(map[string]interface{})
variables = make(map[string]any)
}

doc, err := parser.Parse(parser.ParseParams{
Expand Down Expand Up @@ -140,7 +140,7 @@ func EstimateQueryCost(query string, variables map[string]interface{}) (totalCos
return totalCost, nil
}

func calcNodeCost(def ast.Node, fragmentCosts map[string]int, variables map[string]interface{}) (*QueryCost, error) {
func calcNodeCost(def ast.Node, fragmentCosts map[string]int, variables map[string]any) (*QueryCost, error) {
// NOTE: When we encounter errors in our visit funcs we return
// visitor.ActionBreak to stop walking the tree and set the top level err
// variable so that it is returned
Expand Down Expand Up @@ -177,11 +177,11 @@ func calcNodeCost(def ast.Node, fragmentCosts map[string]int, variables map[stri
multiplier = multiplier / currentLimit
}

nonNullVariables := make(map[string]interface{})
defaultValues := make(map[string]interface{})
nonNullVariables := make(map[string]any)
defaultValues := make(map[string]any)

v := &visitor.VisitorOptions{
Enter: func(p visitor.VisitFuncParams) (string, interface{}) {
Enter: func(p visitor.VisitFuncParams) (string, any) {
switch node := p.Node.(type) {
case *ast.SelectionSet:
depth++
Expand Down Expand Up @@ -279,7 +279,7 @@ func calcNodeCost(def ast.Node, fragmentCosts map[string]int, variables map[stri
}
return visitor.ActionNoChange, nil
},
Leave: func(p visitor.VisitFuncParams) (string, interface{}) {
Leave: func(p visitor.VisitFuncParams) (string, any) {
switch p.Node.(type) {
case *ast.SelectionSet:
depth--
Expand Down Expand Up @@ -313,7 +313,7 @@ func getFragmentDependencies(node ast.Node) map[string]struct{} {
deps := make(map[string]struct{})

v := &visitor.VisitorOptions{
Enter: func(p visitor.VisitFuncParams) (string, interface{}) {
Enter: func(p visitor.VisitFuncParams) (string, any) {
switch node := p.Node.(type) {
case *ast.FragmentSpread:
deps[node.Name.Value] = struct{}{}
Expand All @@ -327,7 +327,7 @@ func getFragmentDependencies(node ast.Node) map[string]struct{} {
return deps
}

func extractInt(i interface{}) (int, error) {
func extractInt(i any) (int, error) {
switch v := i.(type) {
case int:
return v, nil
Expand Down
Loading