services/rfq/relayer/inventory/synapse.go
Method rebalanceManagerSynapseCCTP.listen
has 83 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *rebalanceManagerSynapseCCTP) listen(parentCtx context.Context, chainID int) (err error) {
listener, ok := c.chainListeners[chainID]
if !ok {
return fmt.Errorf("could not find listener for chain %d", chainID)
}
Method rebalanceManagerSynapseCCTP.listen
has 13 return statements (exceeds 4 allowed). Open
Open
func (c *rebalanceManagerSynapseCCTP) listen(parentCtx context.Context, chainID int) (err error) {
listener, ok := c.chainListeners[chainID]
if !ok {
return fmt.Errorf("could not find listener for chain %d", chainID)
}
Method rebalanceManagerSynapseCCTP.listen
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
Open
func (c *rebalanceManagerSynapseCCTP) listen(parentCtx context.Context, chainID int) (err error) {
listener, ok := c.chainListeners[chainID]
if !ok {
return fmt.Errorf("could not find listener for chain %d", chainID)
}
- 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
Function newRebalanceManagerSynapseCCTP
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func newRebalanceManagerSynapseCCTP(cfg relconfig.Config, handler metrics.Handler, chainClient submitter.ClientFetcher, txSubmitter submitter.TransactionSubmitter, relayerAddress common.Address, db reldb.Service) *rebalanceManagerSynapseCCTP {
Method rebalanceManagerSynapseCCTP.Execute
has 6 return statements (exceeds 4 allowed). Open
Open
func (c *rebalanceManagerSynapseCCTP) Execute(parentCtx context.Context, rebalance *RebalanceData) (err error) {
contract, ok := c.cctpContracts[rebalance.OriginMetadata.ChainID]
if !ok {
return fmt.Errorf("could not find cctp contract for chain %d", rebalance.OriginMetadata.ChainID)
}
Method rebalanceManagerSynapseCCTP.Start
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *rebalanceManagerSynapseCCTP) Start(ctx context.Context) (err error) {
err = c.initContracts(ctx)
if err != nil {
return fmt.Errorf("could not initialize contracts: %w", err)
}
Method rebalanceManagerSynapseCCTP.initListeners
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *rebalanceManagerSynapseCCTP) initListeners(ctx context.Context) (err error) {
for chainID := range c.cfg.GetChains() {
cctpAddr, err := c.cfg.GetSynapseCCTPAddress(chainID)
if err != nil {
return fmt.Errorf("could not get cctp address: %w", err)