mesg-foundation/core

View on GitHub

Showing 56 of 208 total issues

Function NewInitApp has 196 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func NewInitApp(
    logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
    invCheckPeriod uint, skipUpgradeHeights map[int64]bool, baseAppOptions ...func(*bam.BaseApp),
) (*NewApp, error) {
    // First define the top level codec that will be shared by the different modules
Severity: Major
Found in app/app.go - About 6 hrs to fix

    Method Keeper.Create has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
    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: Minor
    Found in x/execution/internal/keeper/keeper.go - About 4 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

    Function write has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring.
    Open

    func write(buf *bytes.Buffer, v reflect.Value) *bytes.Buffer {
        switch v.Kind() {
        case reflect.Bool:
            buf.WriteString(strconv.FormatBool(v.Bool()))
        case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
    Severity: Minor
    Found in hash/structhash/structhash.go - About 4 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 Keeper.Create has 134 lines of code (exceeds 50 allowed). Consider refactoring.
    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 4 hrs to fix

      Method Container.Start has 124 lines of code (exceeds 50 allowed). Consider refactoring.
      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 3 hrs to fix

        Function queryListHandlerFn has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
        Open

        func queryListHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
            return func(w http.ResponseWriter, r *http.Request) {
                cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
                if !ok {
                    return
        Severity: Minor
        Found in x/execution/client/rest/query.go - About 3 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 Process.Validate has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
        Open

        func (w *Process) Validate() error {
            if err := xvalidator.Struct(w); err != nil {
                return err
            }
            if err := w.validate(); err != nil {
        Severity: Minor
        Found in process/process.go - About 2 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

        Function write has 92 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func write(buf *bytes.Buffer, v reflect.Value) *bytes.Buffer {
            switch v.Kind() {
            case reflect.Bool:
                buf.WriteString(strconv.FormatBool(v.Bool()))
            case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
        Severity: Major
        Found in hash/structhash/structhash.go - About 2 hrs to fix

          Function AddGenesisAccountCmd has 92 lines of code (exceeds 50 allowed). Consider refactoring.
          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 2 hrs to fix

            Function New has 90 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func New(prefix string) (*validator.Validate, ut.Translator) {
                en := en.New()
                uni := ut.New(en, en)
                trans, _ := uni.GetTranslator("en")
                validate := validator.New()
            Severity: Major
            Found in ext/xvalidator/validator.go - About 2 hrs to fix

              Keybase has 23 methods (exceeds 20 allowed). Consider refactoring.
              Open

              type Keybase struct {
                  kb            keys.Keybase
                  mx            sync.Mutex
                  privKeysCache map[[sha256.Size]byte]crypto.PrivKey
              }
              Severity: Minor
              Found in cosmos/keybase.go - About 2 hrs to fix

                Function queryListHandlerFn has 83 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func queryListHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
                    return func(w http.ResponseWriter, r *http.Request) {
                        cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
                        if !ok {
                            return
                Severity: Major
                Found in x/execution/client/rest/query.go - About 2 hrs to fix

                  Method NewApp.prepForZeroHeightGenesis has 83 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (app *NewApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []string) {
                      applyWhiteList := false
                  
                      //Check if there is a whitelist
                      if len(jailWhiteList) > 0 {
                  Severity: Major
                  Found in app/export.go - About 2 hrs to fix

                    Function AddGenesisAccountCmd has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
                    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: Minor
                    Found in cmd/mesg-daemon/genaccounts.go - About 2 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 Orchestrator.startExecutionStream has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (s *Orchestrator) startExecutionStream(ctx context.Context) error {
                        subscriber := xstrings.RandASCIILetters(8)
                        query := fmt.Sprintf("%s.%s EXISTS AND %s.%s='%s'",
                            executionmodule.EventType, executionmodule.AttributeKeyHash,
                            executionmodule.EventType, sdk.AttributeKeyAction, executionmodule.AttributeActionCompleted,
                    Severity: Minor
                    Found in orchestrator/orchestrator.go - About 2 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

                    Function New has 25 return statements (exceeds 6 allowed).
                    Open

                    func New(prefix string) (*validator.Validate, ut.Translator) {
                        en := en.New()
                        uni := ut.New(en, en)
                        trans, _ := uni.GetTranslator("en")
                        validate := validator.New()
                    Severity: Major
                    Found in ext/xvalidator/validator.go - About 2 hrs to fix

                      Function processExec has 77 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func processExec(client runner.RunnerClient, token string, exec *execution.Execution) {
                          var outputs *types.Struct
                          if exec.TaskKey == "task_trigger" || exec.TaskKey == "task1" || exec.TaskKey == "task2" {
                              outputs = &types.Struct{
                                  Fields: map[string]*types.Value{
                      Severity: Major
                      Found in e2e/testdata/test-service/main.go - About 2 hrs to fix

                        Method Keeper.Update has 74 lines of code (exceeds 50 allowed). Consider refactoring.
                        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: Minor
                        Found in x/execution/internal/keeper/keeper.go - About 1 hr to fix

                          Method Container.Start has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
                          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: Minor
                          Found in container/container.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

                          Function startOrchestratorCmd has 71 lines of code (exceeds 50 allowed). Consider refactoring.
                          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: Minor
                          Found in cmd/mesg-cli/orchestrator.go - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language