synapsecns/sanguine

View on GitHub

Showing 1,971 of 13,422 total issues

Method Indexer.store has a Cognitive Complexity of 43 (exceeds 20 allowed). Consider refactoring.
Open

func (x *Indexer) store(parentCtx context.Context, log types.Log) (err error) {
    ctx, span := x.handler.Tracer().Start(parentCtx, "store", trace.WithAttributes(
        attribute.String("contract", x.addressesToString(x.indexerConfig.Addresses)),
        attribute.String("tx", log.TxHash.Hex()),
        attribute.String("block", fmt.Sprintf("%d", log.BlockNumber)),
Severity: Minor
Found in services/scribe/service/indexer/indexer.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

Function nest_results has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

const nest_results = (sqlResults: any[]) => {
  return sqlResults.map((transaction: any) => {
    const bridgeRequest: { [key: string]: any } = {}
    const bridgeRelay: { [key: string]: any } = {}
    const bridgeProof: { [key: string]: any } = {}
Severity: Minor
Found in packages/rfq-indexer/api/src/graphql/resolvers.ts - 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

Function nest_results has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

export const nest_results = (sqlResults: any[]) => {
  return sqlResults.map((transaction: any) => {
    const bridgeRequest: { [key: string]: any } = {}
    const bridgeRelay: { [key: string]: any } = {}
    const bridgeProof: { [key: string]: any } = {}
Severity: Minor
Found in packages/rfq-indexer/api/src/utils/nestResults.ts - 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

Function useGasEstimator has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const useGasEstimator = () => {
  const dispatch = useAppDispatch()
  const { address } = useAccount()
  const { synapseSDK } = useSynapseContext()
  const { balances } = usePortfolioState()
Severity: Major
Found in packages/synapse-interface/utils/hooks/useGasEstimator.ts - About 4 hrs to fix

    Function LandingNav has 99 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const LandingNav = () => {
      const topBarBtns = <TopBarButtons />
      const mobileBarBtns = <MobileBarButtons />
      const moreInfoBtns = <MoreInfoButtons />
      const socialBtns = <SocialButtons />
    Severity: Major
    Found in packages/explorer-ui/components/layouts/MainLayout/index.tsx - About 3 hrs to fix

      Method Bot.rfqRefund has 123 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (b *Bot) rfqRefund() *slacker.CommandDefinition {
          return &slacker.CommandDefinition{
              Command:     "refund <tx>",
              Description: "refund a quote request",
              Examples:    []string{"refund 0x1234"},
      Severity: Major
      Found in contrib/opbot/botmd/commands.go - About 3 hrs to fix

        File index.tsx has 330 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { Fragment } from 'react'
        import { useRouter } from 'next/router'
        import { Popover, Transition } from '@headlessui/react'
        import { MenuIcon, XIcon } from '@heroicons/react/outline'
        import { useTranslations } from 'next-intl'

          Method ExecutorSuite.TestSetMinimumTime has 121 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (e *ExecutorSuite) TestSetMinimumTime() {
              // TODO (joe and lex): FIX ME
              // e.T().Skip()
              testDone := false
              defer func() {
          Severity: Major
          Found in agents/agents/executor/executor_test.go - About 3 hrs to fix

            BackfillSuite has 31 methods (exceeds 20 allowed). Consider refactoring.
            Open

            func (b *BackfillSuite) TestBackfill() {
                testChainID := b.testBackend.GetBigChainID()
            
                bridgeContract, bridgeRef := b.testDeployManager.GetTestSynapseBridge(b.GetTestContext(), b.testBackend)
                bridgeV1Contract, bridgeV1Ref := b.testDeployManager.GetTestSynapseBridgeV1(b.GetTestContext(), b.testBackend)
            Severity: Minor
            Found in services/explorer/backfill/chain_test.go - About 3 hrs to fix

              Function executeSwap has 95 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const executeSwap = async () => {
                  const currentChainName = CHAINS_BY_ID[swapChainId]?.name
              
                  dispatch(setIsWalletPending(true))
              
              
              Severity: Major
              Found in packages/synapse-interface/pages/swap/index.tsx - About 3 hrs to fix

                File avSwapWrapper.ts has 323 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                export const AV_SWAP_WRAPPER_ABI = [
                  {
                    inputs: [
                      {
                        internalType: 'contract Swap',
                Severity: Minor
                Found in packages/synapse-interface/constants/abis/avSwapWrapper.ts - About 3 hrs to fix

                  Method executionContext._Query has 43 return statements (exceeds 4 allowed).
                  Open

                  func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
                      fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors)
                      ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
                          Object: "Query",
                      })
                  Severity: Major
                  Found in services/explorer/graphql/server/graph/resolver/server.go - About 3 hrs to fix

                    Function generateTheme has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function generateTheme(theme: CustomThemeVariables = {}) {
                      function str2hsl(color: string) {
                        // TODO: Support hex short codes
                        if (/^#?[\da-fA-F]{6,8}$/.test(color)) {
                          let [r, g, b, a] = color
                    Severity: Minor
                    Found in packages/widget/src/utils/generateTheme.ts - About 3 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 BridgeParser.ParseLog has 118 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (p *BridgeParser) ParseLog(log ethTypes.Log, chainID uint32) (*model.BridgeEvent, bridgeTypes.EventLog, error) {
                        logTopic := log.Topics[0]
                    
                        iFace, err := func(log ethTypes.Log) (bridgeTypes.EventLog, error) {
                            switch logTopic {
                    Severity: Major
                    Found in services/explorer/consumer/parser/bridgeparser.go - About 3 hrs to fix

                      Function useBridgeSelectionData has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const useBridgeSelectionData = (): BridgeSelections => {
                        const [originChain, setOriginChain] = useState('')
                        const [originToken, setOriginToken] = useState('')
                        const [destinationChain, setDestinationChain] = useState('')
                        const [destinationToken, setDestinationToken] = useState('')
                      Severity: Major
                      Found in packages/widget/src/hooks/useBridgeSelectionData.ts - About 3 hrs to fix

                        File index.tsx has 319 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import _ from 'lodash'
                        import { useRef, useState, useEffect } from 'react'
                        import { SynapseLogoSvg } from '@components/layouts/MainLayout/SynapseLogoSvg'
                        import { formatUSD } from '@utils/formatUSD'
                        import {
                        Severity: Minor
                        Found in packages/explorer-ui/components/ChainChart/index.tsx - About 3 hrs to fix

                          Method DBSuite.TestStoreRetrieveState has 116 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (t *DBSuite) TestStoreRetrieveState() {
                              t.RunOnAllDBs(func(testDB db.ExecutorDB) {
                                  rootA := common.BigToHash(big.NewInt(gofakeit.Int64()))
                                  originA := gofakeit.Uint32()
                                  nonceA := gofakeit.Uint32()
                          Severity: Major
                          Found in agents/agents/executor/db/state_test.go - About 3 hrs to fix

                            Function bridgeLimitsController has 91 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export const bridgeLimitsController = async (req, res) => {
                              const errors = validationResult(req)
                              if (!errors.isEmpty()) {
                                return res.status(400).json({ errors: errors.array() })
                              }
                            Severity: Major
                            Found in packages/rest-api/src/controllers/bridgeLimitsController.ts - About 3 hrs to fix

                              File manager.go has 567 lines of code (exceeds 500 allowed). Consider refactoring.
                              Open

                              package inventory
                              
                              import (
                                  "context"
                                  "errors"
                              Severity: Minor
                              Found in services/rfq/relayer/inventory/manager.go - About 3 hrs to fix

                                Function getAndSetSwapQuote has 90 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  const getAndSetSwapQuote = async () => {
                                    currentSDKRequestID.current += 1
                                    const thisRequestId = currentSDKRequestID.current
                                    try {
                                      dispatch(setIsLoading(true))
                                Severity: Major
                                Found in packages/synapse-interface/pages/swap/index.tsx - About 3 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language