synapsecns/sanguine

View on GitHub
services/rfq/relayer/inventory/synapse.go

Summary

Maintainability
C
7 hrs
Test Coverage

Method rebalanceManagerSynapseCCTP.listen has 83 lines of code (exceeds 50 allowed). Consider refactoring.
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)
    }
Severity: Major
Found in services/rfq/relayer/inventory/synapse.go - About 2 hrs to fix

    Method rebalanceManagerSynapseCCTP.listen has 13 return statements (exceeds 4 allowed).
    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)
        }
    Severity: Major
    Found in services/rfq/relayer/inventory/synapse.go - About 1 hr to fix

      Method rebalanceManagerSynapseCCTP.listen has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
      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)
          }
      Severity: Minor
      Found in services/rfq/relayer/inventory/synapse.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 newRebalanceManagerSynapseCCTP has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func newRebalanceManagerSynapseCCTP(cfg relconfig.Config, handler metrics.Handler, chainClient submitter.ClientFetcher, txSubmitter submitter.TransactionSubmitter, relayerAddress common.Address, db reldb.Service) *rebalanceManagerSynapseCCTP {
      Severity: Minor
      Found in services/rfq/relayer/inventory/synapse.go - About 45 mins to fix

        Method rebalanceManagerSynapseCCTP.Execute has 6 return statements (exceeds 4 allowed).
        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)
            }
        Severity: Major
        Found in services/rfq/relayer/inventory/synapse.go - About 40 mins to fix

          Method rebalanceManagerSynapseCCTP.Start has 5 return statements (exceeds 4 allowed).
          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)
              }
          Severity: Major
          Found in services/rfq/relayer/inventory/synapse.go - About 35 mins to fix

            Method rebalanceManagerSynapseCCTP.initListeners has 5 return statements (exceeds 4 allowed).
            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)
            Severity: Major
            Found in services/rfq/relayer/inventory/synapse.go - About 35 mins to fix

              There are no issues that match your filters.

              Category
              Status