aergoio/aergo

View on GitHub
types/transaction.go

Summary

Maintainability
C
1 day
Test Coverage
F
31%

Method transaction.Validate has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
Open

func (tx *transaction) Validate(chainidhash []byte, isPublic bool) error {
    if tx.GetTx() == nil || tx.GetTx().GetBody() == nil {
        return ErrTxFormatInvalid
    }

Severity: Minor
Found in types/transaction.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 transaction.Validate has 72 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (tx *transaction) Validate(chainidhash []byte, isPublic bool) error {
    if tx.GetTx() == nil || tx.GetTx().GetBody() == nil {
        return ErrTxFormatInvalid
    }

Severity: Minor
Found in types/transaction.go - About 1 hr to fix

    Method transaction.Validate has 20 return statements (exceeds 4 allowed).
    Open

    func (tx *transaction) Validate(chainidhash []byte, isPublic bool) error {
        if tx.GetTx() == nil || tx.GetTx().GetBody() == nil {
            return ErrTxFormatInvalid
        }
    
    
    Severity: Major
    Found in types/transaction.go - About 1 hr to fix

      Function ValidateSystemTx has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
      Open

      func ValidateSystemTx(tx *TxBody) error {
          var ci CallInfo
          if err := json.Unmarshal(tx.Payload, &ci); err != nil {
              return ErrTxInvalidPayload
          }
      Severity: Minor
      Found in types/transaction.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 validateNameTx has 10 return statements (exceeds 4 allowed).
      Open

      func validateNameTx(tx *TxBody) error {
          var ci CallInfo
          if err := json.Unmarshal(tx.Payload, &ci); err != nil {
              return ErrTxInvalidPayload
          }
      Severity: Major
      Found in types/transaction.go - About 1 hr to fix

        Function ValidateSystemTx has 10 return statements (exceeds 4 allowed).
        Open

        func ValidateSystemTx(tx *TxBody) error {
            var ci CallInfo
            if err := json.Unmarshal(tx.Payload, &ci); err != nil {
                return ErrTxInvalidPayload
            }
        Severity: Major
        Found in types/transaction.go - About 1 hr to fix

          Method transaction.ValidateWithSenderState has 8 return statements (exceeds 4 allowed).
          Open

          func (tx *transaction) ValidateWithSenderState(senderState *State, gasPrice *big.Int, version int32) error {
              if (senderState.GetNonce() + 1) > tx.GetBody().GetNonce() {
                  return ErrTxNonceTooLow
              }
              amount := tx.GetBody().GetAmountBigInt()
          Severity: Major
          Found in types/transaction.go - About 50 mins to fix

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

            func _validateNameTx(tx *TxBody, ci *CallInfo) error {
                if len(ci.Args) < 1 {
                    return fmt.Errorf("invalid arguments in %s", ci)
                }
                nameParam, ok := ci.Args[0].(string)
            Severity: Major
            Found in types/transaction.go - About 40 mins to fix

              There are no issues that match your filters.

              Category
              Status