mesg-foundation/core

View on GitHub

Showing 56 of 208 total issues

Method executionServer.Stream has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
Open

func (s *executionServer) Stream(req *ExecutionStreamRequest, stream Execution_StreamServer) error {
    // check authorization
    if err := s.auth.IsAuthorized(stream.Context(), req); err != nil {
        return err
    }
Severity: Minor
Found in server/grpc/orchestrator/execution.go - About 1 hr 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 Server.Execution has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
Open

func (s *Server) Execution(req *ExecutionRequest, stream Runner_ExecutionServer) error {
    // check authorization and get runner hash
    runnerHash, err := s.isAuthorized(stream.Context())
    if err != nil {
        return err
Severity: Minor
Found in server/grpc/runner/runner.go - About 1 hr 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 runnerServer.Register has 60 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (s *runnerServer) Register(ctx context.Context, req *RunnerRegisterRequest) (*RunnerRegisterResponse, error) {
    // check authorization
    if err := s.auth.IsAuthorized(ctx, req); err != nil {
        return nil, err
    }
Severity: Minor
Found in server/grpc/orchestrator/runner.go - About 1 hr to fix

    Method Keeper.Create has 16 return statements (exceeds 6 allowed).
    Open

    func (k *Keeper) Create(ctx sdk.Context, msg types.MsgCreate) (*executionpb.Execution, error) {
        run, err := k.runnerKeeper.Get(ctx, msg.ExecutorHash)
        if err != nil {
            return nil, err
        }
    Severity: Major
    Found in x/execution/internal/keeper/keeper.go - About 1 hr to fix

      Method Service.validateData has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
      Open

      func (s *Service) validateData() error {
          var errs xerrors.Errors
          if err := s.areKeysUnique(); err != nil {
              errs = append(errs, err)
          }
      Severity: Minor
      Found in service/validate.go - About 1 hr 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 Container.Start has 15 return statements (exceeds 6 allowed).
      Open

      func (c *Container) Start(srv *service.Service, instanceHash, runnerHash, instanceEnvHash hash.Hash, instanceEnv []string, registerPayload []byte) (err error) {
          // delete the service's container on any error
          errorOccurred := true
          defer func() {
              if errorOccurred {
      Severity: Major
      Found in container/container.go - About 1 hr to fix

        Method Server.Execution has 52 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (s *Server) Execution(req *ExecutionRequest, stream Runner_ExecutionServer) error {
            // check authorization and get runner hash
            runnerHash, err := s.isAuthorized(stream.Context())
            if err != nil {
                return err
        Severity: Minor
        Found in server/grpc/runner/runner.go - About 1 hr to fix

          Method Keeper.Update has 12 return statements (exceeds 6 allowed).
          Open

          func (k *Keeper) Update(ctx sdk.Context, msg types.MsgUpdate) (*executionpb.Execution, error) {
              store := ctx.KVStore(k.storeKey)
              if !store.Has(msg.Hash) {
                  return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "execution %q doesn't exist", msg.Hash)
              }
          Severity: Major
          Found in x/execution/internal/keeper/keeper.go - About 1 hr to fix

            Method runnerServer.Register has 12 return statements (exceeds 6 allowed).
            Open

            func (s *runnerServer) Register(ctx context.Context, req *RunnerRegisterRequest) (*RunnerRegisterResponse, error) {
                // check authorization
                if err := s.auth.IsAuthorized(ctx, req); err != nil {
                    return nil, err
                }
            Severity: Major
            Found in server/grpc/orchestrator/runner.go - About 1 hr to fix

              Function AddGenesisAccountCmd has 12 return statements (exceeds 6 allowed).
              Open

              func AddGenesisAccountCmd(
                  ctx *server.Context, cdc *codec.Codec, defaultNodeHome, defaultClientHome string,
              ) *cobra.Command {
                  cmd := &cobra.Command{
                      Use:   "add-genesis-account [address_or_key_name] [coin][,[coin]]",
              Severity: Major
              Found in cmd/mesg-daemon/genaccounts.go - About 1 hr to fix

                Function NewInitApp has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
                    invCheckPeriod uint, skipUpgradeHeights map[int64]bool, baseAppOptions ...func(*bam.BaseApp),
                Severity: Major
                Found in app/app.go - About 50 mins to fix

                  Function NewKeeper has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      cdc *codec.Codec,
                      key sdk.StoreKey,
                      serviceKeeper types.ServiceKeeper,
                      instanceKeeper types.InstanceKeeper,
                      runnerKeeper types.RunnerKeeper,
                  Severity: Major
                  Found in x/execution/internal/keeper/keeper.go - About 50 mins to fix

                    Function IsDomainName has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func IsDomainName(s string) bool {
                        // See RFC 1035, RFC 3696.
                        // Presentation format has dots before every label except the first, and the
                        // terminal empty label is optional here because we assume fully-qualified
                        // (absolute) input. We must therefore reserve space for the first and last
                    Severity: Minor
                    Found in ext/xnet/dnsclient.go - About 45 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 Process_Node_Reference_Path.Resolve has 9 return statements (exceeds 6 allowed).
                    Open

                    func (path *Process_Node_Reference_Path) Resolve(data *types.Struct) (*types.Value, error) {
                        if path == nil {
                            return &types.Value{Kind: &types.Value_StructValue{StructValue: data}}, nil
                        }
                    
                    
                    Severity: Major
                    Found in process/ref.go - About 45 mins to fix

                      Function New has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      func New(sid, name, description string, configuration Service_Configuration, tasks []*Service_Task, events []*Service_Event, dependencies []*Service_Dependency, repository, source string) (*Service, error) {
                      Severity: Minor
                      Found in service/service.go - About 45 mins to fix

                        Method Orchestrator.processTask has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        func (s *Orchestrator) processTask(node *process.Process_Node, task *process.Process_Node_Task, wf *process.Process, exec *execution.Execution, event *event.Event, data *types.Struct) (hash.Hash, error) {
                        Severity: Minor
                        Found in orchestrator/orchestrator.go - About 45 mins to fix

                          Function exportAppStateAndTMValidators has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailWhiteList []string,
                          Severity: Minor
                          Found in cmd/mesg-daemon/main.go - About 45 mins to fix

                            Method Keeper.Create has 8 return statements (exceeds 6 allowed).
                            Open

                            func (k Keeper) Create(ctx sdk.Context, msg *types.MsgCreate) (*processpb.Process, error) {
                                store := ctx.KVStore(k.storeKey)
                            
                                p, err := process.New(msg.Name, msg.Nodes, msg.Edges, msg.Owner)
                                if err != nil {
                            Severity: Major
                            Found in x/process/internal/keeper/keeper.go - About 40 mins to fix

                              Method Server.Execution has 8 return statements (exceeds 6 allowed).
                              Open

                              func (s *Server) Execution(req *ExecutionRequest, stream Runner_ExecutionServer) error {
                                  // check authorization and get runner hash
                                  runnerHash, err := s.isAuthorized(stream.Context())
                                  if err != nil {
                                      return err
                              Severity: Major
                              Found in server/grpc/runner/runner.go - About 40 mins to fix

                                Function startOrchestratorCmd has 8 return statements (exceeds 6 allowed).
                                Open

                                func startOrchestratorCmd(cdc *codec.Codec) *cobra.Command {
                                    cmd := &cobra.Command{
                                        Use:   "start",
                                        Short: "Start the Orchestrator",
                                        RunE: func(cmd *cobra.Command, args []string) error {
                                Severity: Major
                                Found in cmd/mesg-cli/orchestrator.go - About 40 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language