diff --git a/cmd/blobstore/internal/blobstore/blobstore.go b/cmd/blobstore/internal/blobstore/blobstore.go index 7c26f3e2111..32fa38ec18e 100644 --- a/cmd/blobstore/internal/blobstore/blobstore.go +++ b/cmd/blobstore/internal/blobstore/blobstore.go @@ -136,8 +136,4 @@ var ( Name: "blobstore_service_running", Help: "Number of running blobstore requests.", }) - metricRequestTotal = promauto.NewCounterVec(prometheus.CounterOpts{ - Name: "blobstore_service_request_total", - Help: "Number of returned blobstore requests.", - }, []string{"code"}) ) diff --git a/cmd/frontend/graphqlbackend/slow_requests_tracer.go b/cmd/frontend/graphqlbackend/slow_requests_tracer.go index f5f27b0bfa2..15e285e2c45 100644 --- a/cmd/frontend/graphqlbackend/slow_requests_tracer.go +++ b/cmd/frontend/graphqlbackend/slow_requests_tracer.go @@ -20,9 +20,6 @@ import ( "github.com/sourcegraph/sourcegraph/lib/errors" ) -// slowRequestRedisFIFOListDefaultSize sets a default value for the FIFO list. -const slowRequestRedisFIFOListDefaultSize = 5000 - // slowRequestRedisFIFOListPerPage sets the default count of returned request. const slowRequestRedisFIFOListPerPage = 50 diff --git a/cmd/gitserver/server/vcs_syncer_ruby_packages.go b/cmd/gitserver/server/vcs_syncer_ruby_packages.go index 9a3679cc4c0..e9a9bb83445 100644 --- a/cmd/gitserver/server/vcs_syncer_ruby_packages.go +++ b/cmd/gitserver/server/vcs_syncer_ruby_packages.go @@ -38,8 +38,7 @@ func NewRubyPackagesSyncer( } type rubyDependencySource struct { - repositoryURL string - client *rubygems.Client + client *rubygems.Client } func (rubyDependencySource) ParseVersionedPackageFromNameAndVersion(name reposource.PackageName, version string) (reposource.VersionedPackage, error) { diff --git a/dev/sg/internal/bk/bk.go b/dev/sg/internal/bk/bk.go index 0cbd5ce2d52..68906521721 100644 --- a/dev/sg/internal/bk/bk.go +++ b/dev/sg/internal/bk/bk.go @@ -17,13 +17,9 @@ import ( "github.com/sourcegraph/sourcegraph/lib/output" ) -// https://buildkite.com/sourcegraph +// BuildkiteOrg is a Sourcegraph org in Buildkite. See: is https://buildkite.com/sourcegraph const BuildkiteOrg = "sourcegraph" -type buildkiteSecrets struct { - Token string `json:"token"` -} - type Build struct { buildkite.Build } diff --git a/enterprise/internal/codeintel/codenav/init.go b/enterprise/internal/codeintel/codenav/init.go index 7fe963f75e1..78b9796f1b1 100644 --- a/enterprise/internal/codeintel/codenav/init.go +++ b/enterprise/internal/codeintel/codenav/init.go @@ -27,14 +27,6 @@ func NewService( ) } -type serviceDependencies struct { - db database.DB - codeIntelDB codeintelshared.CodeIntelDB - uploadSvc UploadService - gitserver GitserverClient - observationCtx *observation.Context -} - func scopedContext(component string, parent *observation.Context) *observation.Context { return observation.ScopedContext("codeintel", "codenav", component, parent) } diff --git a/enterprise/internal/codeintel/policies/init.go b/enterprise/internal/codeintel/policies/init.go index 9a5a1019984..333e6591ed3 100644 --- a/enterprise/internal/codeintel/policies/init.go +++ b/enterprise/internal/codeintel/policies/init.go @@ -24,13 +24,6 @@ func NewService( ) } -type serviceDependencies struct { - db database.DB - uploadSvc UploadService - gitserver GitserverClient - observationCtx *observation.Context -} - func scopedContext(component string, parent *observation.Context) *observation.Context { return observation.ScopedContext("codeintel", "policies", component, parent) } diff --git a/internal/authz/sub_repo_perms.go b/internal/authz/sub_repo_perms.go index 570d93ea221..20e66c12a52 100644 --- a/internal/authz/sub_repo_perms.go +++ b/internal/authz/sub_repo_perms.go @@ -4,7 +4,6 @@ import ( "context" "io/fs" "strconv" - "strings" "time" "github.com/prometheus/client_golang/prometheus" @@ -63,11 +62,11 @@ var DefaultSubRepoPermsChecker SubRepoPermissionChecker = &noopPermsChecker{} type noopPermsChecker struct{} -func (*noopPermsChecker) Permissions(ctx context.Context, userID int32, content RepoContent) (Perms, error) { +func (*noopPermsChecker) Permissions(_ context.Context, _ int32, _ RepoContent) (Perms, error) { return None, nil } -func (*noopPermsChecker) FilePermissionsFunc(ctx context.Context, userID int32, repo api.RepoName) (FilePermissionFunc, error) { +func (*noopPermsChecker) FilePermissionsFunc(_ context.Context, _ int32, _ api.RepoName) (FilePermissionFunc, error) { return func(path string) (Perms, error) { return None, nil }, nil @@ -77,54 +76,14 @@ func (*noopPermsChecker) Enabled() bool { return false } -func (*noopPermsChecker) EnabledForRepoID(ctx context.Context, repoID api.RepoID) (bool, error) { +func (*noopPermsChecker) EnabledForRepoID(_ context.Context, _ api.RepoID) (bool, error) { return false, nil } -func (*noopPermsChecker) EnabledForRepo(ctx context.Context, repo api.RepoName) (bool, error) { +func (*noopPermsChecker) EnabledForRepo(_ context.Context, _ api.RepoName) (bool, error) { return false, nil } -// filePermissionsFuncAllRead is a FilePermissionFunc which _always_ returns -// Read. Only use in cases that sub repo permission checks should not be done. -func filePermissionsFuncAllRead(_ string) (Perms, error) { - return Read, nil -} - -// expandDirs will return a new set of rules that will match all directories -// above the supplied rule. As a special case, if the rule starts with a wildcard -// we return a rule to match all directories. -func expandDirs(rule string) []string { - dirs := make([]string, 0) - - // Make sure the rule starts with a slash - if !strings.HasPrefix(rule, "/") { - rule = "/" + rule - } - - // If a rule starts with a wildcard it can match at any level in the tree - // structure so there's no way of walking up the tree and expand out to the list - // of valid directories. Instead, we just return a rule that matches any - // directory - if strings.HasPrefix(rule, "/*") { - dirs = append(dirs, "**/") - return dirs - } - - for { - lastSlash := strings.LastIndex(rule, "/") - if lastSlash <= 0 { // we have to ignore the slash at index 0 - break - } - // Drop anything after the last slash - rule = rule[:lastSlash] - - dirs = append(dirs, rule+"/") - } - - return dirs -} - // ActorPermissions returns the level of access the given actor has for the requested // content. // diff --git a/internal/codeintel/dependencies/init.go b/internal/codeintel/dependencies/init.go index 77ba208805a..2d3045ddf7f 100644 --- a/internal/codeintel/dependencies/init.go +++ b/internal/codeintel/dependencies/init.go @@ -12,13 +12,8 @@ func NewService(observationCtx *observation.Context, db database.DB) *Service { return newService(scopedContext("service", observationCtx), store.New(scopedContext("store", observationCtx), db)) } -type serviceDependencies struct { - db database.DB - observationCtx *observation.Context -} - // TestService creates a new dependencies service with noop observation contexts. -func TestService(db database.DB, gitserver GitserverClient) *Service { +func TestService(db database.DB, _ GitserverClient) *Service { store := store.New(&observation.TestContext, db) return newService(&observation.TestContext, store) diff --git a/internal/extsvc/gitlab/client.go b/internal/extsvc/gitlab/client.go index 0fa8b3612bc..4e6d7927974 100644 --- a/internal/extsvc/gitlab/client.go +++ b/internal/extsvc/gitlab/client.go @@ -178,8 +178,6 @@ type Client struct { Auth auth.Authenticator rateLimitMonitor *ratelimit.Monitor rateLimiter *ratelimit.InstrumentedLimiter // Our internal rate limiter - - tokenRefresher oauthutil.TokenRefresher } // newClient creates a new GitLab API client with an optional personal access token to authenticate requests. diff --git a/internal/oauthutil/oauth2.go b/internal/oauthutil/oauth2.go index 179741cd3ab..583e8d6ed63 100644 --- a/internal/oauthutil/oauth2.go +++ b/internal/oauthutil/oauth2.go @@ -2,10 +2,7 @@ package oauthutil import ( "context" - "encoding/json" - "fmt" "net/http" - "strings" "golang.org/x/oauth2" @@ -32,32 +29,6 @@ type OAuthContext struct { Scopes []string } -type oauthError struct { - Err string `json:"error"` - ErrorDescription string `json:"error_description"` -} - -func (e oauthError) Error() string { - return fmt.Sprintf("OAuth response error %q description %q", e.Err, e.ErrorDescription) -} - -// getOAuthErrorDetails is a method that only returns OAuth errors. -// It is intended to be used in the oauth flow, when refreshing an expired token. -func getOAuthErrorDetails(body []byte) error { - var oe oauthError - if err := json.Unmarshal(body, &oe); err != nil { - // If we failed to unmarshal body with oauth error, it's not oauthError and we should return nil. - return nil - } - - // https://www.oauth.com/oauth2-servers/access-tokens/access-token-response/ - // {"error":"invalid_token","error_description":"Token is expired. You can either do re-authorization or token refresh."} - if oe.Err == "invalid_token" && strings.Contains(oe.ErrorDescription, "expired") { - return &oe - } - return nil -} - // TokenRefresher is a function to refresh and return the new OAuth token. type TokenRefresher func(ctx context.Context, doer httpcli.Doer, oauthCtx OAuthContext) (*auth.OAuthBearerToken, error) diff --git a/internal/repos/syncer.go b/internal/repos/syncer.go index f9b6c940576..e62094095ff 100644 --- a/internal/repos/syncer.go +++ b/internal/repos/syncer.go @@ -107,7 +107,7 @@ type syncHandler struct { minSyncInterval func() time.Duration } -func (s *syncHandler) Handle(ctx context.Context, logger log.Logger, sj *SyncJob) (err error) { +func (s *syncHandler) Handle(ctx context.Context, _ log.Logger, sj *SyncJob) (err error) { // Limit calls to progressRecorder as it will most likely hit the database progressLimiter := rate.NewLimiter(rate.Limit(1.0), 1) diff --git a/internal/search/repos/repos.go b/internal/search/repos/repos.go index 119a9b59f39..e57e6568ebf 100644 --- a/internal/search/repos/repos.go +++ b/internal/search/repos/repos.go @@ -944,22 +944,6 @@ func optimizeRepoPatternWithHeuristics(repoPattern string) string { return repoPattern } -type badRequestError struct { - err error -} - -func (e *badRequestError) BadRequest() bool { - return true -} - -func (e *badRequestError) Error() string { - return "bad request: " + e.err.Error() -} - -func (e *badRequestError) Cause() error { - return e.err -} - var ErrNoResolvedRepos = errors.New("no resolved repositories") type MissingRepoRevsError struct { diff --git a/lib/batches/changeset_specs.go b/lib/batches/changeset_specs.go index 9d3e38f34d3..bc0d364788f 100644 --- a/lib/batches/changeset_specs.go +++ b/lib/batches/changeset_specs.go @@ -12,8 +12,6 @@ import ( "github.com/sourcegraph/sourcegraph/lib/errors" ) -var errOptionalPublishedUnsupported = NewValidationError(errors.New(`This Sourcegraph version requires the "published" field to be specified in the batch spec; upgrade to version 3.30.0 or later to be able to omit the published field and control publication from the UI.`)) - // Repository is a repository in which the steps of a batch spec are executed. // // It is part of the cache.ExecutionKey, so changes to the names of fields here diff --git a/lib/codeintel/lsif/scip/document.go b/lib/codeintel/lsif/scip/document.go index a3382ab9888..469d42624a3 100644 --- a/lib/codeintel/lsif/scip/document.go +++ b/lib/codeintel/lsif/scip/document.go @@ -297,16 +297,3 @@ func extractLanguageFromIndexerName(indexerName string) string { return "" } - -// flattenNonEmptyMap returns an ordered slice of the keys from the given map, excluding the empty string. -func flattenNonEmptyMap(m map[string]struct{}) []string { - s := make([]string, 0, len(m)) - for k := range m { - if k != "" { - s = append(s, k) - } - } - sort.Strings(s) - - return s -}