synapsecns/sanguine

View on GitHub
services/explorer/backfill/chain.go

Summary

Maintainability
D
1 day
Test Coverage

Method ChainBackfiller.backfillContractLogs has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring.
Open

func (c *ChainBackfiller) backfillContractLogs(parentCtx context.Context, contract indexerconfig.ContractConfig) (err error) {
    // make the event parser
    eventParser, err := c.makeEventParser(contract)
    if err != nil {
        return err
Severity: Minor
Found in services/explorer/backfill/chain.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 ChainBackfiller.backfillContractLogs has 87 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *ChainBackfiller) backfillContractLogs(parentCtx context.Context, contract indexerconfig.ContractConfig) (err error) {
    // make the event parser
    eventParser, err := c.makeEventParser(contract)
    if err != nil {
        return err
Severity: Major
Found in services/explorer/backfill/chain.go - About 2 hrs to fix

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

    func (c *ChainBackfiller) Backfill(ctx context.Context, livefill bool, refreshRate int) (err error) {
        chainCtx := context.WithValue(ctx, chainKey, fmt.Sprintf("%d", c.chainConfig.ChainID))
        contractsGroup, contractCtx := errgroup.WithContext(chainCtx)
    
        if !livefill {
    Severity: Minor
    Found in services/explorer/backfill/chain.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 ChainBackfiller.backfillContractLogs has 13 return statements (exceeds 4 allowed).
    Open

    func (c *ChainBackfiller) backfillContractLogs(parentCtx context.Context, contract indexerconfig.ContractConfig) (err error) {
        // make the event parser
        eventParser, err := c.makeEventParser(contract)
        if err != nil {
            return err
    Severity: Major
    Found in services/explorer/backfill/chain.go - About 1 hr to fix

      Function NewChainBackfiller has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func NewChainBackfiller(consumerDB db.ConsumerDB, bridgeParser *parser.BridgeParser, swapParsers map[common.Address]*parser.SwapParser, messageBusParser *parser.MessageBusParser, cctpParser *parser.CCTPParser, rfqParser *parser.RFQParser, fetcher fetcher.ScribeFetcher, chainConfig indexerconfig.ChainConfig) *ChainBackfiller {
      Severity: Major
      Found in services/explorer/backfill/chain.go - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                                if err != nil {
                                    timeout = b.Duration()
                                    logger.Warnf("could not fetch logs for chain %d: %v. Retrying in %s", c.chainConfig.ChainID, err, timeout)
        
                                    continue
        Severity: Major
        Found in services/explorer/backfill/chain.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if err != nil {
                                      timeout = b.Duration()
                                      logger.Warnf("could not process logs for chain %d: %s", c.chainConfig.ChainID, err)
                                      continue
                                  }
          Severity: Major
          Found in services/explorer/backfill/chain.go - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if len(parsedLogs) > 0 {
                                        g.Go(func() error {
                                            return c.storeParsedLogs(groupCtx, parsedLogs)
                                        })
                                    }
            Severity: Major
            Found in services/explorer/backfill/chain.go - About 45 mins to fix

              Method ChainBackfiller.Backfill has 5 return statements (exceeds 4 allowed).
              Open

              func (c *ChainBackfiller) Backfill(ctx context.Context, livefill bool, refreshRate int) (err error) {
                  chainCtx := context.WithValue(ctx, chainKey, fmt.Sprintf("%d", c.chainConfig.ChainID))
                  contractsGroup, contractCtx := errgroup.WithContext(chainCtx)
              
                  if !livefill {
              Severity: Major
              Found in services/explorer/backfill/chain.go - About 35 mins to fix

                There are no issues that match your filters.

                Category
                Status