synapsecns/sanguine

View on GitHub

Showing 1,971 of 13,422 total issues

Method ScribeSuite.TestIndexToBlock has 53 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (s *ScribeSuite) TestIndexToBlock() {
    // Get simulated blockchain, deploy the test contract, and set up test variables.
    simulatedChain := geth.NewEmbeddedBackendForChainID(s.GetSuiteContext(), s.T(), big.NewInt(142))
    simulatedClient, err := backend.DialBackend(s.GetTestContext(), simulatedChain.RPCAddress(), s.nullMetrics)
    Nil(s.T(), err)
Severity: Minor
Found in services/scribe/service/chain_test.go - About 1 hr to fix

    Method Store.StoreLogsAtHead has 53 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (s Store) StoreLogsAtHead(ctx context.Context, chainID uint32, logs ...types.Log) error {
        var storeLogs []LogAtHead
        for _, log := range logs {
            var topics []sql.NullString
    
    
    Severity: Minor
    Found in services/scribe/db/datastore/sql/base/athead.go - About 1 hr to fix

      Function formatBigIntToString has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const formatBigIntToString = (
        bi: bigint,
        nativePrecision: number,
        decimalPlaces?: number
      ) => {
      Severity: Minor
      Found in packages/explorer-ui/utils/formatBigIntToString.ts - About 1 hr to fix

        Function getMenuItemStyleForChain has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const getMenuItemStyleForChain = (color: string): string => {
          switch (color) {
            case ColorOptions.ETH:
              return `hover:bg-opacity-20 hover:bg-[#3f4f8c] focus:bg-[#3f4f8c] active:bg-[#314367] active:bg-opacity-20 focus:bg-opacity-20`
            case ColorOptions.GRAY:
        Severity: Minor
        Found in packages/synapse-interface/styles/chains.ts - About 1 hr to fix

          Function useCurrentTokenBalance has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const useCurrentTokenBalance = () => {
            const web3Context = useContext(Web3Context)
            const { connectedAddress } = web3Context.web3Provider
            const { originChainId, originToken } = useBridgeState()
            const { balances } = useWalletState()
          Severity: Minor
          Found in packages/widget/src/hooks/useCurrentTokenBalance.ts - About 1 hr to fix

            Function checkElements has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                const checkElements = () => {
                  originChainSelect = document.getElementById('origin-chain-select')
                  destinationChainSelect = document.getElementById(
                    'destination-chain-select'
                  )
            Severity: Minor
            Found in packages/widget/src/hooks/useBridgeSelectionData.ts - About 1 hr to fix

              Function PageFooter has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const PageFooter = () => {
                return (
                  <footer>
                    <div className="max-w-md px-4 pt-4 pb-6 mx-auto sm:max-w-3xl sm:pt-6 sm:px-6 lg:max-w-7xl lg:px-8">
                      <Grid
              Severity: Minor
              Found in packages/explorer-ui/components/layouts/MainLayout/PageFooter.tsx - About 1 hr to fix

                Function payload has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      resp.map(async (quote) => {
                        const originQueryTokenOutInfo = tokenAddressToToken(
                          fromChain.toString(),
                          quote.originQuery.tokenOut
                        )
                Severity: Minor
                Found in packages/rest-api/src/controllers/bridgeController.ts - About 1 hr to fix

                  Function GasDropLabel has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const GasDropLabel = () => {
                    const { toChainId } = useBridgeState()
                    const {
                      bridgeQuote: { gasDropAmount },
                    } = useBridgeQuoteState()

                    Function useEventCountdownProgressBar has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export const useEventCountdownProgressBar = (
                      eventLabel: string,
                      startDate: Date,
                      endDate: Date | null,
                      hideProgress?: boolean
                    Severity: Minor
                    Found in packages/widget/src/hooks/useEventCountdownProgressBar.tsx - About 1 hr to fix

                      Method Guard.Start has 11 return statements (exceeds 4 allowed).
                      Open

                      func (g Guard) Start(parentCtx context.Context) error {
                          // First initialize a map to track what was the last state signed by this guard
                          g.loadSummitLatestStates(parentCtx)
                      
                          group, ctx := errgroup.WithContext(parentCtx)
                      Severity: Major
                      Found in agents/agents/guard/guard.go - About 1 hr to fix

                        Method parserImpl.ParseEvent has 11 return statements (exceeds 4 allowed).
                        Open

                        func (p parserImpl) ParseEvent(log ethTypes.Log) (_ EventType, event interface{}, ok bool) {
                            // return an unknown event to avoid cases where user failed to check the event type
                            // make it high enough to make it obvious (we start iotas at +1, see uber style guide for details)
                            noOpEvent := EventType(len(topicMap()) + 1)
                        
                        
                        Severity: Major
                        Found in services/rfq/contracts/l2gateway/parser.go - About 1 hr to fix

                          Method Manager.ShouldProcess has 11 return statements (exceeds 4 allowed).
                          Open

                          func (m *Manager) ShouldProcess(parentCtx context.Context, quote reldb.QuoteRequest) (res bool, err error) {
                              ctx, span := m.metricsHandler.Tracer().Start(parentCtx, "shouldProcess", trace.WithAttributes(
                                  attribute.String("transaction_id", hexutil.Encode(quote.TransactionID[:])),
                              ))
                          
                          
                          Severity: Major
                          Found in services/rfq/relayer/quoter/quoter.go - About 1 hr to fix

                            Method inventoryManagerImpl.initializeTokens has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                            Open

                            func (i *inventoryManagerImpl) initializeTokens(parentCtx context.Context, cfg relconfig.Config) (err error) {
                                i.mux.Lock()
                                defer i.mux.Unlock()
                            
                                ctx, span := i.handler.Tracer().Start(parentCtx, "initializeTokens", trace.WithAttributes(
                            Severity: Minor
                            Found in services/rfq/relayer/inventory/manager.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 filterLogs has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                            Open

                            func filterLogs(logs []*types.Log, fromBlock, toBlock *big.Int, addresses []common.Address, topics [][]common.Hash) []*types.Log {
                                var ret []*types.Log
                            Logs:
                                for _, currentLog := range logs {
                                    if fromBlock != nil && fromBlock.Int64() >= 0 && fromBlock.Uint64() > currentLog.BlockNumber {
                            Severity: Minor
                            Found in services/omnirpc/modules/harmonyproxy/harmonyproxy.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 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

                            Method parserImpl.ParseEvent has 11 return statements (exceeds 4 allowed).
                            Open

                            func (p parserImpl) ParseEvent(log ethTypes.Log) (_ EventType, event interface{}, ok bool) {
                                // return an unknown event to avoid cases where user failed to check the event type
                                // make it high enough to make it obvious (we start iotas at +1, see uber style guide for details)
                                noOpEvent := EventType(len(topicMap()) + 2)
                            
                            
                            Severity: Major
                            Found in services/rfq/contracts/l1gateway/parser.go - About 1 hr to fix

                              Function NewGuard has 11 return statements (exceeds 4 allowed).
                              Open

                              func NewGuard(ctx context.Context, metricHandler metrics.Handler, cfg guardconfig.Config, txSubmitter submitter.TransactionSubmitter) (*Guard, error) {
                                  omniClient := omniClient.NewOmnirpcClient(cfg.OmniRPCURL, metricHandler, omniClient.WithCaptureReqRes())
                                  chainListeners := make(map[int]listener.ContractListener)
                              
                                  dbType, err := dbcommon.DBTypeFromString(cfg.Database.Type)
                              Severity: Major
                              Found in services/rfq/guard/service/guard.go - About 1 hr to fix

                                Method Guard.handleProveCalled has 11 return statements (exceeds 4 allowed).
                                Open

                                func (g *Guard) handleProveCalled(parentCtx context.Context, proven *guarddb.PendingProven) (err error) {
                                    ctx, span := g.metrics.Tracer().Start(parentCtx, "handleProveCalled", trace.WithAttributes(
                                        attribute.String("transaction_id", hexutil.Encode(proven.TransactionID[:])),
                                    ))
                                    defer func() {
                                Severity: Major
                                Found in services/rfq/guard/service/handlers.go - About 1 hr to fix

                                  Function NewRelayerAPI has 11 return statements (exceeds 4 allowed).
                                  Open

                                  func NewRelayerAPI(
                                      ctx context.Context,
                                      cfg relconfig.Config,
                                      handler metrics.Handler,
                                      omniRPCClient omniClient.RPCClient,
                                  Severity: Major
                                  Found in services/rfq/relayer/relapi/server.go - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language