services/explorer/backfill/chain.go
Method ChainBackfiller.backfillContractLogs
has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring. Open
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
- Read upRead up
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
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
Method ChainBackfiller.Backfill
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
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 {
- Read upRead up
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
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
Function NewChainBackfiller
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
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 {
Avoid deeply nested control flow statements. Open
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
Avoid deeply nested control flow statements. Open
Open
if err != nil {
timeout = b.Duration()
logger.Warnf("could not process logs for chain %d: %s", c.chainConfig.ChainID, err)
continue
}
Avoid deeply nested control flow statements. Open
Open
if len(parsedLogs) > 0 {
g.Go(func() error {
return c.storeParsedLogs(groupCtx, parsedLogs)
})
}
Method ChainBackfiller.Backfill
has 5 return statements (exceeds 4 allowed). Open
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 {