vorteil/direktiv

View on GitHub
pkg/flow/engine.go

Summary

Maintainability
F
3 days
Test Coverage

File engine.go has 757 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package flow

import (
    "context"
    "encoding/base64"
Severity: Major
Found in pkg/flow/engine.go - About 1 day to fix

    Method engine.runState has a Cognitive Complexity of 54 (exceeds 20 allowed). Consider refactoring.
    Open

    func (engine *engine) runState(ctx context.Context, im *instanceMemory, wakedata []byte, err error) *states.Transition {
        loggingCtx := im.Namespace().WithTags(ctx)
        instanceTrackCtx := enginerefactor.WithTrack(loggingCtx, enginerefactor.BuildInstanceTrack(im.instance))
        slog.Debug("Starting state execution.", enginerefactor.GetSlogAttributesWithStatus(ctx, core.LogRunningStatus)...)
    
    
    Severity: Minor
    Found in pkg/flow/engine.go - About 5 hrs 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

    Method engine.NewInstance has 112 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (engine *engine) NewInstance(ctx context.Context, args *newInstanceArgs) (*instanceMemory, error) {
        slog.Debug("Initializing new instance creation.", "namespace", args.Namespace.Name, "workflow", args.CalledAs, "invoker", args.Invoker)
        file, data, err := engine.mux(ctx, args.Namespace, args.CalledAs)
        loggingCtx := args.Namespace.WithTags(ctx)
        loggingCtx = enginerefactor.AddTag(loggingCtx, "calledAs", args.CalledAs)
    Severity: Major
    Found in pkg/flow/engine.go - About 3 hrs to fix

      Method engine.runState has 95 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (engine *engine) runState(ctx context.Context, im *instanceMemory, wakedata []byte, err error) *states.Transition {
          loggingCtx := im.Namespace().WithTags(ctx)
          instanceTrackCtx := enginerefactor.WithTrack(loggingCtx, enginerefactor.BuildInstanceTrack(im.instance))
          slog.Debug("Starting state execution.", enginerefactor.GetSlogAttributesWithStatus(ctx, core.LogRunningStatus)...)
      
      
      Severity: Major
      Found in pkg/flow/engine.go - About 2 hrs to fix

        engine has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type engine struct {
            *server
        
            scheduled sync.Map
        }
        Severity: Minor
        Found in pkg/flow/engine.go - About 2 hrs to fix

          Method engine.Transition has 74 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (engine *engine) Transition(ctx context.Context, im *instanceMemory, nextState string, attempt int) *states.Transition {
              workflow, err := im.Model()
              if err != nil {
                  engine.CrashInstance(ctx, im, err)
                  return nil
          Severity: Minor
          Found in pkg/flow/engine.go - About 1 hr to fix

            Method engine.EventsInvoke has 56 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

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

              Method engine.NewInstance has 10 return statements (exceeds 4 allowed).
              Open

              func (engine *engine) NewInstance(ctx context.Context, args *newInstanceArgs) (*instanceMemory, error) {
                  slog.Debug("Initializing new instance creation.", "namespace", args.Namespace.Name, "workflow", args.CalledAs, "invoker", args.Invoker)
                  file, data, err := engine.mux(ctx, args.Namespace, args.CalledAs)
                  loggingCtx := args.Namespace.WithTags(ctx)
                  loggingCtx = enginerefactor.AddTag(loggingCtx, "calledAs", args.CalledAs)
              Severity: Major
              Found in pkg/flow/engine.go - About 1 hr to fix

                Method engine.Transition has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                Open

                func (engine *engine) Transition(ctx context.Context, im *instanceMemory, nextState string, attempt int) *states.Transition {
                    workflow, err := im.Model()
                    if err != nil {
                        engine.CrashInstance(ctx, im, err)
                        return nil
                Severity: Minor
                Found in pkg/flow/engine.go - About 55 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

                Method engine.NewInstance has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                Open

                func (engine *engine) NewInstance(ctx context.Context, args *newInstanceArgs) (*instanceMemory, error) {
                    slog.Debug("Initializing new instance creation.", "namespace", args.Namespace.Name, "workflow", args.CalledAs, "invoker", args.Invoker)
                    file, data, err := engine.mux(ctx, args.Namespace, args.CalledAs)
                    loggingCtx := args.Namespace.WithTags(ctx)
                    loggingCtx = enginerefactor.AddTag(loggingCtx, "calledAs", args.CalledAs)
                Severity: Minor
                Found in pkg/flow/engine.go - About 55 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

                Method engine.Transition has 8 return statements (exceeds 4 allowed).
                Open

                func (engine *engine) Transition(ctx context.Context, im *instanceMemory, nextState string, attempt int) *states.Transition {
                    workflow, err := im.Model()
                    if err != nil {
                        engine.CrashInstance(ctx, im, err)
                        return nil
                Severity: Major
                Found in pkg/flow/engine.go - About 50 mins to fix

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

                  func (engine *engine) EventsInvoke(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 engine.subflowInvoke has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    func (engine *engine) subflowInvoke(ctx context.Context, pi *enginerefactor.ParentInfo, instance *enginerefactor.Instance, name string, input []byte) (*instanceMemory, error) {
                    Severity: Minor
                    Found in pkg/flow/engine.go - About 35 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status