Fantom-foundation/go-lachesis

View on GitHub

Showing 291 of 829 total issues

Function checkEventsFileHeader has 5 return statements (exceeds 4 allowed).
Open

func checkEventsFileHeader(reader io.Reader) error {
    headerAndVersion := make([]byte, len(eventsFileHeader)+len(eventsFileVersion))
    n, err := reader.Read(headerAndVersion)
    if err != nil {
        return err
Severity: Major
Found in cmd/lachesis/import.go - About 35 mins to fix

    Method Index.fetchSync has 5 return statements (exceeds 4 allowed).
    Open

    func (tt *Index) fetchSync(topics [][]common.Hash) (res []*types.Log, err error) {
        if len(topics) > MaxCount {
            err = ErrTooManyTopics
            return
        }
    Severity: Major
    Found in topicsdb/search_sync.go - About 35 mins to fix

      Method EthAPIBackend.GetFullEventID has 5 return statements (exceeds 4 allowed).
      Open

      func (b *EthAPIBackend) GetFullEventID(shortEventID string) (hash.Event, error) {
          s := strings.Split(shortEventID, ":")
          if len(s) == 1 {
              // it's a full hash
              return hash.HexToEventHash(shortEventID), nil
      Severity: Major
      Found in gossip/ethapi_backend.go - About 35 mins to fix

        Method Emitter.createEvent has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
        Open

        func (em *Emitter) createEvent(poolTxs map[common.Address]types.Transactions) *inter.Event {
            if em.myStakerID == 0 {
                // not a validator
                return nil
            }
        Severity: Minor
        Found in gossip/emitter.go - About 35 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 Emitter.isAllowedToEmit has 5 return statements (exceeds 4 allowed).
        Open

        func (em *Emitter) isAllowedToEmit(e *inter.Event, selfParent *inter.EventHeaderData) bool {
            passedTime := e.ClaimedTime.Time().Sub(em.prevEmittedTime)
            // Slow down emitting if power is low
            {
                threshold := em.config.NoTxsThreshold
        Severity: Major
        Found in gossip/emitter.go - About 35 mins to fix

          Method Emitter.maxGasPowerToUse has 5 return statements (exceeds 4 allowed).
          Open

          func (em *Emitter) maxGasPowerToUse(e *inter.Event) uint64 {
              // No txs in epoch tail, because tail events are unlikely to confirm
              {
                  if em.isEpochTail(e) {
                      return 0
          Severity: Major
          Found in gossip/emitter.go - About 35 mins to fix

            Method PublicFilterAPI.Logs has 5 return statements (exceeds 4 allowed).
            Open

            func (api *PublicFilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subscription, error) {
                notifier, supported := rpc.NotifierFromContext(ctx)
                if !supported {
                    return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported
                }
            Severity: Major
            Found in gossip/filters/api.go - About 35 mins to fix

              Function lachesisOperaMigrationMain has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
              Open

              func lachesisOperaMigrationMain(ctx *cli.Context) error {
                  if args := ctx.Args(); len(args) > 0 {
                      return fmt.Errorf("invalid command: %q", args[0])
                  }
              
              
              Severity: Minor
              Found in cmd/lachesis/opera_migration.go - About 25 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 TxPool.promoteExecutables has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
              Open

              func (pool *TxPool) promoteExecutables(accounts []common.Address) []*types.Transaction {
                  // Track the promoted transactions to broadcast them at once
                  var promoted []*types.Transaction
              
                  // Iterate over all accounts and promote any executable transactions
              Severity: Minor
              Found in evmcore/tx_pool.go - About 25 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

              Function Dir has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
              Open

              func Dir(src string, dst string) (err error) {
                  src = filepath.Clean(src)
                  dst = filepath.Clean(dst)
              
                  si, err := os.Stat(src)
              Severity: Minor
              Found in utils/iocopy/dir.go - About 25 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 Emitter.addTxs has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
              Open

              func (em *Emitter) addTxs(e *inter.Event, poolTxs map[common.Address]types.Transactions) *inter.Event {
                  if poolTxs == nil || len(poolTxs) == 0 {
                      return e
                  }
              
              
              Severity: Minor
              Found in gossip/emitter.go - About 25 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

              Severity
              Category
              Status
              Source
              Language