vorteil/direktiv

View on GitHub

Showing 1,235 of 1,235 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  await expect(
    page
      .getByTestId("consumer-table")
      .locator("tr")
      .getByRole("textbox")
Severity: Major
Found in ui/e2e/gateway/consumers/index.spec.ts and 2 other locations - About 40 mins to fix
ui/e2e/gateway/consumers/index.spec.ts on lines 136..143
ui/e2e/gateway/consumers/index.spec.ts on lines 173..180

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 49.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  await expect(
    page
      .getByTestId("consumer-table")
      .locator("tr")
      .getByRole("textbox")
Severity: Major
Found in ui/e2e/gateway/consumers/index.spec.ts and 2 other locations - About 40 mins to fix
ui/e2e/gateway/consumers/index.spec.ts on lines 73..80
ui/e2e/gateway/consumers/index.spec.ts on lines 136..143

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 49.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method uploader.createFileItem has 6 return statements (exceeds 4 allowed).
Open

func (u *uploader) createFileItem(path, method string, obj fileObject) error {
    parent := path
    parent = strings.ReplaceAll(parent, "\\", "/")

    if method == "POST" {
Severity: Major
Found in cmd/exec/cli/uploader.go - About 40 mins to fix

    Function fetchSecret has 6 return statements (exceeds 4 allowed).
    Open

    func fetchSecret(db *database.SQLStore, namespace string, callExpression string) (string, error) {
        callExpression = strings.TrimSpace(callExpression)
        if !strings.HasPrefix(callExpression, "fetchSecret") {
            return callExpression, nil
        }
    Severity: Major
    Found in pkg/gateway/fetch_secret.go - About 40 mins to fix

      Method forEachLogic.scheduleRetryAction has 6 return statements (exceeds 4 allowed).
      Open

      func (logic *forEachLogic) scheduleRetryAction(ctx context.Context, retry *actionRetryInfo) error {
          logic.Log(ctx, log.Info, "Retrying...")
      
          x, err := jqOne(logic.GetInstanceData(), logic.Array) //nolint:contextcheck
          if err != nil {
      Severity: Major
      Found in pkg/flow/states/foreach.go - About 40 mins to fix

        Method forEachLogic.scheduleFirstActions has 6 return statements (exceeds 4 allowed).
        Open

        func (logic *forEachLogic) scheduleFirstActions(ctx context.Context) (*Transition, error) {
            x, err := jqOne(logic.GetInstanceData(), logic.Array) //nolint:contextcheck
            if err != nil {
                return nil, err
            }
        Severity: Major
        Found in pkg/flow/states/foreach.go - About 40 mins to fix

          Method forEachLogic.scheduleAction has 6 return statements (exceeds 4 allowed).
          Open

          func (logic *forEachLogic) scheduleAction(ctx context.Context, inputSource interface{}, attempt, iterator int) (*ChildInfo, error) {
              action := logic.Action
          
              input, files, err := generateActionInput(ctx, &generateActionInputArgs{
                  Instance: logic.Instance,
          Severity: Major
          Found in pkg/flow/states/foreach.go - About 40 mins to fix

            Method parallelLogic.scheduleAction has 6 return statements (exceeds 4 allowed).
            Open

            func (logic *parallelLogic) scheduleAction(ctx context.Context, action *model.ActionDefinition, attempt int) (*ChildInfo, error) {
                input, files, err := generateActionInput(ctx, &generateActionInputArgs{
                    Instance: logic.Instance,
                    Source:   logic.GetInstanceData(),
                    Action:   action,
            Severity: Major
            Found in pkg/flow/states/parallel.go - About 40 mins to fix

              Method DirektivApplyer.copyFilesIntoRoot has 6 return statements (exceeds 4 allowed).
              Open

              func (o *DirektivApplyer) copyFilesIntoRoot(ctx context.Context) error {
                  paths, err := o.parser.ListFiles()
                  if err != nil {
                      return err
                  }
              Severity: Major
              Found in pkg/mirror/apply.go - About 40 mins to fix

                Method instanceMemory.flushUpdates has 6 return statements (exceeds 4 allowed).
                Open

                func (im *instanceMemory) flushUpdates(ctx context.Context) error {
                    data, err := json.Marshal(im.updateArgs)
                    if err != nil {
                        panic(err)
                    }
                Severity: Major
                Found in pkg/flow/memory.go - About 40 mins to fix

                  Method engine.EventsInvoke has 6 return statements (exceeds 4 allowed).
                  Open

                  func (engine *engine) EventsInvoke(tctx context.Context, workflowID uuid.UUID, events ...*cloudevents.Event) {
                      ctx := context.Background()
                  
                      tx, err := engine.flow.beginSQLTx(ctx)
                      if err != nil {
                  Severity: Major
                  Found in pkg/flow/engine.go - About 40 mins to fix

                    Method ACLPlugin.Execute has 6 return statements (exceeds 4 allowed).
                    Open

                    func (acl *ACLPlugin) Execute(w http.ResponseWriter, r *http.Request) *http.Request {
                        c := gateway.ExtractContextActiveConsumer(r)
                        if c == nil {
                            gateway.WriteInternalError(r, w, nil, "missing consumer")
                            return nil
                    Severity: Major
                    Found in pkg/gateway/plugins/inbound/acl-plugin.go - About 40 mins to fix

                      Function getVariableMetaFromFlow has 6 return statements (exceeds 4 allowed).
                      Open

                      func getVariableMetaFromFlow(ctx context.Context, flowToken string, flowAddr string, ir *functionRequest, scope, key string) (variable, int, error) {
                          var varResp *variablesResponse
                          var err error
                          var typ string
                          statusCode := http.StatusOK
                      Severity: Major
                      Found in cmd/sidecar/api_v2_clients.go - About 40 mins to fix

                        Method JSInboundPlugin.Execute has 6 return statements (exceeds 4 allowed).
                        Open

                        func (js *JSInboundPlugin) Execute(w http.ResponseWriter, r *http.Request) *http.Request {
                            var (
                                err error
                                b   []byte
                            )
                        Severity: Major
                        Found in pkg/gateway/plugins/inbound/js-inbound.go - About 40 mins to fix

                          Method instanceDataQuery.PopMessage has 6 return statements (exceeds 4 allowed).
                          Open

                          func (q *instanceDataQuery) PopMessage(ctx context.Context) (*instancestore.InstanceMessageData, error) {
                              columns := []string{fieldInstanceMessageID, fieldInstanceMessageInstanceID, fieldInstanceMessageCreatedAt, fieldInstanceMessagePayload}
                              query := fmt.Sprintf(`SELECT %s FROM %s WHERE %s = ? ORDER BY %s ASC LIMIT 1`, strings.Join(columns, ", "), messagesTable, fieldInstanceMessageInstanceID, fieldInstanceMessageCreatedAt)
                          
                              msg := &instancestore.InstanceMessageData{}
                          Severity: Major
                          Found in pkg/instancestore/instancestoresql/instance_data_query.go - About 40 mins to fix

                            Method actionLogic.processActionResults has 6 return statements (exceeds 4 allowed).
                            Open

                            func (logic *actionLogic) processActionResults(ctx context.Context, children []*ChildInfo, results *actionResultPayload) (*Transition, error) {
                                var err error
                            
                                sd := children[0]
                            
                            
                            Severity: Major
                            Found in pkg/flow/states/action.go - About 40 mins to fix

                              Method GenerateEventState.Validate has 6 return statements (exceeds 4 allowed).
                              Open

                              func (o *GenerateEventState) Validate() error {
                                  if err := o.commonValidate(); err != nil {
                                      return err
                                  }
                              
                              
                              Severity: Major
                              Found in pkg/model/state-generate-event.go - About 40 mins to fix

                                Function writeDataStoreError has 6 return statements (exceeds 4 allowed).
                                Open

                                func writeDataStoreError(w http.ResponseWriter, err error) {
                                    if errors.Is(err, datastore.ErrNotFound) {
                                        writeError(w, &Error{
                                            Code:    "resource_not_found",
                                            Message: "requested resource is not found",
                                Severity: Major
                                Found in pkg/api/errors.go - About 40 mins to fix

                                  Method knativeClient.createService has 6 return statements (exceeds 4 allowed).
                                  Open

                                  func (c *knativeClient) createService(sv *core.ServiceFileData) error {
                                      if sv.Image == "" {
                                          return errors.New("image field is empty or not set")
                                      }
                                  
                                  
                                  Severity: Major
                                  Found in pkg/service/knative_client.go - About 40 mins to fix

                                    Method sqlEventListenerStore.GetByID has 6 return statements (exceeds 4 allowed).
                                    Open

                                    func (s *sqlEventListenerStore) GetByID(ctx context.Context, id uuid.UUID) (*datastore.EventListener, error) {
                                        q := "SELECT id, namespace_id, namespace, created_at, updated_at, received_events, trigger_type, events_lifespan, event_types, trigger_info, metadata, event_context_filters FROM event_listeners WHERE id = $1 ;"
                                        var l gormEventListener
                                        tx := s.db.WithContext(ctx).Raw(q, id).First(&l)
                                        if tx.Error != nil {
                                    Severity: Major
                                    Found in pkg/datastore/datastoresql/eventstore_listener.go - About 40 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language