rancher/opni-monitoring

View on GitHub

Showing 95 of 150 total issues

Method LabelSelectorRequirement.Validate has 5 return statements (exceeds 4 allowed).
Open

func (r *LabelSelectorRequirement) Validate() error {
    if r.Key == "" {
        return fmt.Errorf("%w: %s", validation.ErrMissingRequiredField, "key")
    }
    if r.Operator == "" {
Severity: Major
Found in pkg/core/validation.go - About 35 mins to fix

    Method CreateBootstrapTokenRequest.Validate has 5 return statements (exceeds 4 allowed).
    Open

    func (r *CreateBootstrapTokenRequest) Validate() error {
        if err := r.GetTtl().CheckValid(); err != nil {
            return fmt.Errorf("%w (ttl): %s", validation.ErrInvalidValue, err.Error())
        }
        if r.GetTtl().AsDuration() <= 0 {
    Severity: Major
    Found in pkg/management/validation.go - About 35 mins to fix

      Method Reconciler.configMap has 5 return statements (exceeds 4 allowed).
      Open

      func (r *Reconciler) configMap() (resources.Resource, error) {
          gatewayConf := &cfgv1beta1.GatewayConfig{
              TypeMeta: cfgmeta.TypeMeta{
                  Kind:       "GatewayConfig",
                  APIVersion: "v1beta1",
      Severity: Major
      Found in pkg/sdk/resources/gateway/configmap.go - About 35 mins to fix

        Function FetchUserInfo has 5 return statements (exceeds 4 allowed).
        Open

        func FetchUserInfo(endpoint, token string) (map[string]interface{}, error) {
            req, err := http.NewRequest("POST", endpoint, nil)
            if err != nil {
                return nil, err
            }
        Severity: Major
        Found in pkg/auth/openid/tokens.go - About 35 mins to fix

          Method Plugin.QueryRange has 5 return statements (exceeds 4 allowed).
          Open

          func (p *Plugin) QueryRange(
              ctx context.Context,
              in *cortexadmin.QueryRangeRequest,
          ) (*cortexadmin.QueryResponse, error) {
              lg := p.logger.With(
          Severity: Major
          Found in plugins/cortex/pkg/cortex/admin.go - About 35 mins to fix

            Method Agent.streamRulesToGateway has 5 return statements (exceeds 4 allowed).
            Open

            func (a *Agent) streamRulesToGateway(ctx context.Context) error {
                lg := a.logger
                updateC, err := a.streamRuleGroupUpdates(ctx)
                if err != nil {
                    a.logger.With(
            Severity: Major
            Found in pkg/agent/rules.go - About 35 mins to fix

              Function BuildDebugEtcdctlCmd has 5 return statements (exceeds 4 allowed).
              Open

              func BuildDebugEtcdctlCmd() *cobra.Command {
                  debugEtcdctlCmd := &cobra.Command{
                      Use:                "etcdctl",
                      Short:              "embedded auto-configured etcdctl",
                      Long:               "To specify a config location, use the OPNIM_CONFIG environment variable.",
              Severity: Major
              Found in pkg/opnim/commands/debug.go - About 35 mins to fix

                Method Plugin.AllUserStats has 5 return statements (exceeds 4 allowed).
                Open

                func (p *Plugin) AllUserStats(ctx context.Context, _ *emptypb.Empty) (*cortexadmin.UserIDStatsList, error) {
                    client := p.cortexHttpClient.Get()
                    req, err := http.NewRequestWithContext(ctx, "GET",
                        fmt.Sprintf("https://%s/distributor/all_user_stats", p.config.Get().Spec.Cortex.Distributor.HTTPAddress), nil)
                    if err != nil {
                Severity: Major
                Found in plugins/cortex/pkg/cortex/admin.go - About 35 mins to fix

                  Method BootstrapAuthRequest.Validate has 5 return statements (exceeds 4 allowed).
                  Open

                  func (h BootstrapAuthRequest) Validate() error {
                      if h.ClientID == "" {
                          return validation.Errorf("%w: %s", validation.ErrMissingRequiredField, "client_id")
                      }
                      if err := validation.ValidateID(h.ClientID); err != nil {
                  Severity: Major
                  Found in pkg/bootstrap/types.go - About 35 mins to fix

                    Method EtcdStore.GetRoleBinding has 5 return statements (exceeds 4 allowed).
                    Open

                    func (e *EtcdStore) GetRoleBinding(ctx context.Context, ref *core.Reference) (*core.RoleBinding, error) {
                        ctx, ca := context.WithTimeout(ctx, e.CommandTimeout)
                        defer ca()
                        resp, err := e.Client.Get(ctx, path.Join(e.Prefix, roleBindingKey, ref.Id))
                        if err != nil {
                    Severity: Major
                    Found in pkg/storage/etcd/rbac_store.go - About 35 mins to fix

                      Method Server.GetConfig has 5 return statements (exceeds 4 allowed).
                      Open

                      func (m *Server) GetConfig(
                          ctx context.Context,
                          _ *emptypb.Empty,
                      ) (*GatewayConfig, error) {
                          lg := m.logger
                      Severity: Major
                      Found in pkg/management/config.go - About 35 mins to fix

                        Method Plugin.Query has 5 return statements (exceeds 4 allowed).
                        Open

                        func (p *Plugin) Query(
                            ctx context.Context,
                            in *cortexadmin.QueryRequest,
                        ) (*cortexadmin.QueryResponse, error) {
                            lg := p.logger.With(
                        Severity: Major
                        Found in plugins/cortex/pkg/cortex/admin.go - About 35 mins to fix

                          Function CheckAvailability has 5 return statements (exceeds 4 allowed).
                          Open

                          func CheckAvailability(ctx context.Context, cc *grpc.ClientConn, id string) error {
                              ref := rpb.NewServerReflectionClient(cc)
                              stream, err := ref.ServerReflectionInfo(ctx)
                              if err != nil {
                                  return err
                          Severity: Major
                          Found in pkg/plugins/core.go - About 35 mins to fix

                            Method requestBuilder.Do has 5 return statements (exceeds 4 allowed).
                            Open

                            func (rb *requestBuilder) Do() (code int, body []byte, err error) {
                                nonce, mac, err := b2mac.New512([]byte(rb.gatewayClient.id),
                                    rb.req.Request().Body(), rb.gatewayClient.sharedKeys.ClientKey)
                                if err != nil {
                                    return 0, nil, err
                            Severity: Major
                            Found in pkg/clients/gateway_client.go - About 35 mins to fix

                              Function TLSConfig has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                              Open

                              func TLSConfig(pins []*PublicKeyPin) (*tls.Config, error) {
                                  if len(pins) == 0 {
                                      return nil, ErrNoPins
                                  }
                                  copiedPins := make([]*PublicKeyPin, len(pins))
                              Severity: Minor
                              Found in pkg/pkp/tls.go - About 25 mins to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              Severity
                              Category
                              Status
                              Source
                              Language