DeFiCh/jellyfish

View on GitHub

Showing 137 of 388 total issues

Function getUSD_PER_DFI has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async getUSD_PER_DFI (): Promise<BigNumber | undefined> {
    return await this.cache.get<BigNumber>('USD_PER_DFI', async () => {
      const usdt = await this.getPoolPair('DFI', 'USDT')
      const usdc = await this.getPoolPair('DFI', 'USDC')
      // const dusd = await this.getPoolPair('DFI', 'DUSD')
Severity: Minor
Found in apps/whale-api/src/module.api/poolpair.service.ts - About 1 hr to fix

    Function maxPriceAsBigNumber has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      static maxPriceAsBigNumber (getter: () => BigNumber, setter: (data: BigNumber) => void): BufferComposer {
        return {
          fromBuffer: (buffer: SmartBuffer): void => {
            const integer = readBigNumberUInt64(buffer)
            const fraction = readBigNumberUInt64(buffer)
    Severity: Minor
    Found in packages/jellyfish-buffer/src/Composer.ts - About 55 mins 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 addTokensAndConnectionsToGraph has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      private async addTokensAndConnectionsToGraph (poolPairList: PoolPairInfoWithId[]): Promise<void> {
        for (const poolPair of poolPairList) {
          if (await this.isPoolPairIgnored(poolPair)) {
            continue
          }
    Severity: Minor
    Found in apps/whale-api/src/module.api/poolswap.pathfinding.service.ts - About 55 mins 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 computePathsBetweenTokens has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      private async computePathsBetweenTokens (
        fromTokenId: string,
        toTokenId: string
      ): Promise<SwapPathPoolPair[][]> {
        const poolPairPaths: SwapPathPoolPair[][] = []
    Severity: Minor
    Found in apps/whale-api/src/module.api/poolswap.pathfinding.service.ts - About 55 mins 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 index has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      async index (block: RawBlock): Promise<void> {
        for (const txn of block.tx) {
          const isEvmTx = checkIfEvmTx(txn)
    
          for (const vin of txn.vin) {
    Severity: Minor
    Found in apps/whale-api/src/module.indexer/model/script.unspent.ts - About 55 mins 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 compactSizeOptionalHex has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      static compactSizeOptionalHex (getter: () => string | undefined, setter: (data: string | undefined) => void): BufferComposer {
        return {
          fromBuffer: (buffer: SmartBuffer): void => {
            const length = readCompactSize(buffer)
            if (length > 0) {
    Severity: Minor
    Found in packages/jellyfish-buffer/src/Composer.ts - About 45 mins 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 catchUp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      private async catchUp (): Promise<void> {
        const lastBlock = await this.getCrawledTip()
        const nextBlockHeight = lastBlock === undefined ? 0 : lastBlock.data.height + 1
        const nextBlock = await this.getBlock(nextBlockHeight)
    
    
    Severity: Minor
    Found in packages/rich-list-core/src/RichListCore.ts - About 45 mins 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 validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      async validate (hex: string): Promise<void> {
        if (!hex.startsWith('040000000001')) {
          return
        }
    
    
    Severity: Minor
    Found in apps/whale-api/src/module.api/rawtx.controller.ts - About 45 mins 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 getGovernanceProposalVotes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      async getGovernanceProposalVotes (
        query: PaginationQuery = {
          size: 30
        },
        id: string,
    Severity: Minor
    Found in apps/whale-api/src/module.api/governance.service.ts - About 45 mins 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 mapPriceAggregated has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      private async mapPriceAggregated (block: RawBlock, token: string, currency: string): Promise<OraclePriceAggregated | undefined> {
        const oracles = await this.tokenCurrencyMapper.query(`${token}-${currency}`, Number.MAX_SAFE_INTEGER)
    
        const aggregated = {
          total: new BigNumber(0),
    Severity: Minor
    Found in apps/whale-api/src/module.indexer/model/dftx/set.oracle.data.ts - About 45 mins 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 getPoolPair has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      private async getPoolPair (a: string, b: string): Promise<PoolPairInfo | undefined> {
        try {
          const result = await this.rpcClient.poolpair.getPoolPair(`${a}-${b}`, true)
          if (Object.values(result).length > 0) {
            return Object.values(result)[0]
    Severity: Minor
    Found in apps/whale-api/src/module.api/poolpair.service.ts - About 45 mins 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 getBestPath has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      async getBestPath (fromTokenId: string, toTokenId: string): Promise<BestSwapPathResult> {
        const {
          fromToken,
          toToken,
          paths
    Severity: Minor
    Found in apps/whale-api/src/module.api/poolswap.pathfinding.service.ts - About 45 mins 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

    Consider simplifying this complex logical expression.
    Open

        if (masternode !== undefined) {
          await this.masternodeMapper.put({
            ...masternode,
            ownerAddress: updates.owner ?? masternode.ownerAddress,
            operatorAddress: updates.operator ?? masternode.operatorAddress,
    Severity: Major
    Found in apps/whale-api/src/module.indexer/model/dftx/update.masternode.ts - About 40 mins to fix

      Function put has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        async function put (hex: string, height: number, type: ScriptActivityType, txid: string, n: number): Promise<void> {
      Severity: Minor
      Found in apps/whale-api/src/module.model/script.activity.spec.ts - About 35 mins to fix

        Function placeAuctionBid has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        async function placeAuctionBid (testing: Testing, vaultId: string, index: number, addr: string, tokenAmt: string): Promise<void> {
        Severity: Minor
        Found in apps/whale-api/src/module.indexer/model/dftx/place.auction.bid.spec.ts - About 35 mins to fix

          Function findAmountSymbol has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            private findAmountSymbol (history: AccountHistory, outgoing: boolean): LegacySubgraphSwapFromTo | undefined {
              for (const amount of history.amounts ?? []) {
                const [value, symbol] = amount.split('@')
                const isNegative = value.startsWith('-')
          
          
          Severity: Minor
          Found in apps/whale-api/src/module.api/legacy.subgraph.service.ts - About 35 mins 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 indexBlockStart has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            async indexBlockStart (block: RawBlock): Promise<void> {
              const poolPairs = await this.getPoolPairs(block)
          
              for (const interval of AggregatedIntervals) {
                for (const poolPair of poolPairs) {
          Severity: Minor
          Found in apps/whale-api/src/module.indexer/model/dftx/pool.swap.aggregated.ts - About 35 mins 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 getDexFeesPct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            public async getDexFeesPct (poolPair: PoolPairInfo, fromToken: string, toToken: string): Promise<EstimatedDexFeesInPct | undefined> {
              const { dexFeeInPctTokenA, dexFeeOutPctTokenA, dexFeeInPctTokenB, dexFeeOutPctTokenB } = poolPair
              const tokenADirection = poolPair.idTokenA === fromToken ? 'in' : 'out'
              const tokenBDirection = poolPair.idTokenB === toToken ? 'out' : 'in'
          
          
          Severity: Minor
          Found in apps/whale-api/src/module.api/poolpair.fees.service.ts - About 35 mins 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 listSwaps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            @Get('listswaps')
            async listSwaps (
              @Query('network', NetworkValidationPipe) network: SupportedNetwork = 'mainnet'
            ): Promise<LegacyListSwapsResponse> {
              const api = this.whaleApiClientProvider.getClient(network)
          Severity: Minor
          Found in apps/legacy-api/src/controllers/PoolPairController.ts - About 35 mins 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 listSwaps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            @Get('listswaps')
            async listSwaps (
              @Query('network', NetworkValidationPipe) network: SupportedNetwork = 'mainnet'
            ): Promise<LegacyListSwapsResponse> {
              const api = this.whaleApiClientProvider.getClient(network)
          Severity: Minor
          Found in apps/legacy-api/src/controllers/PoolPairController.ts - About 35 mins 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

          Severity
          Category
          Status
          Source
          Language