mesg-foundation/core

View on GitHub

Showing 207 of 208 total issues

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

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

    func GetCmdDelete(cdc *codec.Codec) *cobra.Command {
        return &cobra.Command{
            Use:   "delete [runnerHash]",
            Short: "Delete a runner",
            Args:  cobra.ExactArgs(1),
    Severity: Major
    Found in x/runner/client/cli/tx.go and 1 other location - About 3 hrs to fix
    x/process/client/cli/tx.go on lines 73..100

    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 291.

    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 2 locations. Consider refactoring.
    Open

    func GetCmdDelete(cdc *codec.Codec) *cobra.Command {
        return &cobra.Command{
            Use:   "delete [processHash]",
            Short: "Delete a process",
            Args:  cobra.ExactArgs(1),
    Severity: Major
    Found in x/process/client/cli/tx.go and 1 other location - About 3 hrs to fix
    x/runner/client/cli/tx.go on lines 81..108

    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 291.

    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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    func register() (string, error) {
        endpoint := os.Getenv(envMesgEndpoint)
        if endpoint == "" {
            return "", fmt.Errorf("env %q is empty", envMesgEndpoint)
        }
    Severity: Major
    Found in e2e/testdata/test-complex-service/main.go and 1 other location - About 3 hrs to fix
    e2e/testdata/test-service/main.go on lines 28..58

    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 276.

    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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    func register() (string, error) {
        endpoint := os.Getenv(envMesgEndpoint)
        if endpoint == "" {
            return "", fmt.Errorf("env %q is empty", envMesgEndpoint)
        }
    Severity: Major
    Found in e2e/testdata/test-service/main.go and 1 other location - About 3 hrs to fix
    e2e/testdata/test-complex-service/main.go on lines 29..59

    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 276.

    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

    package types
    
    import (
        sdk "github.com/cosmos/cosmos-sdk/types"
        sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
    Severity: Major
    Found in x/service/internal/types/msg.go and 2 other locations - About 3 hrs to fix
    x/credit/internal/types/msg.go on lines 1..35
    x/ownership/internal/types/msg.go on lines 1..35

    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 255.

    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

    package types
    
    import (
        sdk "github.com/cosmos/cosmos-sdk/types"
        sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
    Severity: Major
    Found in x/ownership/internal/types/msg.go and 2 other locations - About 3 hrs to fix
    x/credit/internal/types/msg.go on lines 1..35
    x/service/internal/types/msg.go on lines 1..35

    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 255.

    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

    package types
    
    import (
        sdk "github.com/cosmos/cosmos-sdk/types"
        sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
    Severity: Major
    Found in x/credit/internal/types/msg.go and 2 other locations - About 3 hrs to fix
    x/ownership/internal/types/msg.go on lines 1..35
    x/service/internal/types/msg.go on lines 1..35

    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 255.

    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 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

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

        func (k Keeper) Sub(ctx sdk.Context, address sdk.AccAddress, amount sdk.Int) (sdk.Int, error) {
            value, err := k.Get(ctx, address)
            if err != nil {
                return sdk.Int{}, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error())
            }
        Severity: Major
        Found in x/credit/internal/keeper/keeper.go and 1 other location - About 2 hrs to fix
        x/credit/internal/keeper/keeper.go on lines 38..54

        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 230.

        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 2 locations. Consider refactoring.
        Open

        func (k Keeper) Add(ctx sdk.Context, address sdk.AccAddress, amount sdk.Int) (sdk.Int, error) {
            value, err := k.Get(ctx, address)
            if err != nil {
                return sdk.Int{}, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error())
            }
        Severity: Major
        Found in x/credit/internal/keeper/keeper.go and 1 other location - About 2 hrs to fix
        x/credit/internal/keeper/keeper.go on lines 57..73

        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 230.

        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

        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

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

            func (k Keeper) List(ctx sdk.Context) ([]*runner.Runner, error) {
                var (
                    runners []*runner.Runner
                    iter    = ctx.KVStore(k.storeKey).Iterator(nil, nil)
                )
            Severity: Major
            Found in x/runner/internal/keeper/keeper.go and 2 other locations - About 2 hrs to fix
            x/process/internal/keeper/keeper.go on lines 139..154
            x/service/internal/keeper/keeper.go on lines 104..119

            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 211.

            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

            func (k Keeper) List(ctx sdk.Context) ([]*processpb.Process, error) {
                var (
                    processes []*processpb.Process
                    iter      = ctx.KVStore(k.storeKey).Iterator(nil, nil)
                )
            Severity: Major
            Found in x/process/internal/keeper/keeper.go and 2 other locations - About 2 hrs to fix
            x/runner/internal/keeper/keeper.go on lines 136..151
            x/service/internal/keeper/keeper.go on lines 104..119

            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 211.

            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

            func (k Keeper) List(ctx sdk.Context) ([]*servicepb.Service, error) {
                var (
                    services []*servicepb.Service
                    iter     = ctx.KVStore(k.storeKey).Iterator(nil, nil)
                )
            Severity: Major
            Found in x/service/internal/keeper/keeper.go and 2 other locations - About 2 hrs to fix
            x/process/internal/keeper/keeper.go on lines 139..154
            x/runner/internal/keeper/keeper.go on lines 136..151

            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 211.

            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

            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
              Severity
              Category
              Status
              Source
              Language