DeFiCh/jellyfish

View on GitHub

Showing 137 of 388 total issues

Function list has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  list (): SetLoanToken[] {
    return [
      {
        symbol: 'DUSD',
        name: 'Decentralized USD',
Severity: Minor
Found in apps/playground-api/src/setups/setup.loan.token.ts - About 1 hr to fix

    Function createVoc has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      async createVoc (createVoc: CreateVoc, changeScript: Script): Promise<TransactionSegWit> {
        if (!createVoc.nAmount.isEqualTo(new BigNumber(0))) {
          throw new TxnBuilderError(TxnBuilderErrorType.INVALID_VOC_AMOUNT,
            'CreateVoc amount should be 0'
          )

    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 31 lines of code (exceeds 25 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 1 hr to fix

      Function createVoc has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async createVoc (createVoc: CreateVoc, changeScript: Script): Promise<TransactionSegWit> {
          if (!createVoc.nAmount.isEqualTo(new BigNumber(0))) {
            throw new TxnBuilderError(TxnBuilderErrorType.INVALID_VOC_AMOUNT,
              'CreateVoc amount should be 0'
            )

        Function list has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          list (): Array<Record<string, any>> {
            return [
              {
                ATTRIBUTES: {
                  // dfi pay dtoken
        Severity: Minor
        Found in apps/playground-api/src/setups/setup.gov.ts - About 1 hr to fix

          Function dump has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async dump (): Promise<boolean> {
              let id = 0
              const maxSize = 500_000
              const dir = path.join(process.cwd(), 'dump')
              if (!fs.existsSync(dir)) {
          Severity: Minor
          Found in apps/whale-api/src/module.database/provider.level/level.database.ts - About 1 hr to fix

            Function shouldQueryPartitionPagination has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export async function shouldQueryPartitionPagination (database: Database): Promise<void> {
              const window43 = await database.query(PartitionMapping.index.partition_a, {
                limit: 2,
                order: SortOrder.DESC
              })
            Severity: Minor
            Found in apps/whale-api/src/module.database/database.spec/specifications.ts - About 1 hr to fix

              Function indexTransaction has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async indexTransaction (block: RawBlock, transaction: DfTxTransaction<AppointOracle>): Promise<void> {
                  const data = transaction.dftx.data
                  const txn = transaction.txn
                  const oracleId = txn.txid
              
              
              Severity: Minor
              Found in apps/whale-api/src/module.indexer/model/dftx/appoint.oracle.ts - About 1 hr to fix

                Function getMemberStats has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async getMemberStats (memberId: string): Promise<MemberStatsInfo> {
                    const attrs: Record<string, any> = (await this.rpcClient.masternode.getGov('ATTRIBUTES')).ATTRIBUTES
                    const keys: string[] = Object.keys(attrs)
                
                    const membersKeyRegex = /^v0\/consortium\/\d+\/members$/
                Severity: Minor
                Found in apps/whale-api/src/module.api/consortium.service.ts - About 1 hr to fix

                  Function validate has 28 lines of code (exceeds 25 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 1 hr to fix

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

                    function computeReturnLessDexFeesInDestinationToken (path: SwapPathPoolPair[], fromTokenId: string): {
                      estimatedReturn: BigNumber
                      estimatedReturnLessDexFees: BigNumber
                    } {
                      let estimatedReturnLessDexFees = new BigNumber(1)
                    Severity: Minor
                    Found in apps/whale-api/src/module.api/poolswap.pathfinding.service.ts - About 1 hr to fix

                      Function mapError has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function mapError (err: Error, url: string): ApiError {
                        if (err instanceof ApiException) {
                          return {
                            code: err.code,
                            type: err.type,
                      Severity: Minor
                      Found in apps/libs/filters/src/ErrorFilter.ts - About 1 hr to fix

                        Function getTokenUSDValue has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private async getTokenUSDValue (id: string): Promise<BigNumber | undefined> {
                            return await this.cache.get<BigNumber>(`PRICE_FOR_TOKEN_${id}`, async () => {
                              const tokenInfo = await this.deFiDCache.getTokenInfo(id)
                              const token = tokenInfo?.symbol
                        
                        
                        Severity: Minor
                        Found in apps/whale-api/src/module.api/poolpair.service.ts - About 1 hr to fix

                          Function maxPriceAsBigNumber has 27 lines of code (exceeds 25 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 1 hr to fix

                            Function pushToAssetBreakdownInfo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              private pushToAssetBreakdownInfo (assetBreakdownInfo: AssetBreakdownInfo[], memberId: string, memberDetail: MemberDetail, tokenId: string, tokens: TokenInfoWithId[]): void {
                                const backingAddresses: string[] = memberDetail.backingId.length > 0 ? memberDetail.backingId.split(',').map(a => a.trim()) : []
                            
                                const member: MemberWithTokenInfo = {
                                  id: memberId,
                            Severity: Minor
                            Found in apps/whale-api/src/module.api/consortium.service.ts - About 1 hr to fix

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

                                async readiness (): Promise<HealthIndicatorResult> {
                                  let highest: Block
                                  let index: number | undefined
                                  let defid: number | undefined
                              
                              
                              Severity: Minor
                              Found in apps/whale-api/src/module.model/_model.probes.ts - About 1 hr to fix

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

                                  private async findSwap (network: NetworkName, poolSwap: PoolSwap, transaction: Transaction): Promise<LegacySubgraphSwap | undefined> {
                                    const fromAddress = fromScript(poolSwap.fromScript, network)?.address
                                    const toAddress = fromScript(poolSwap.toScript, network)?.address
                                
                                    if (
                                Severity: Minor
                                Found in apps/whale-api/src/module.api/legacy.subgraph.service.ts - About 1 hr to fix

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

                                  function from<T extends Address> (net: NetworkName, address: string): T {
                                    const network = getNetwork(net)
                                    const possible: Map<AddressTypeDeprecated, Address> = new Map()
                                    possible.set('Unknown', new UnknownTypeAddress(network, address))
                                    possible.set('P2PKH', Base58Address.fromAddress<P2PKH>(network, address, P2PKH))
                                  Severity: Minor
                                  Found in packages/jellyfish-address/src/index.ts - About 1 hr to fix

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

                                      public async getUSDVolume (id: string): Promise<PoolPairData['volume'] | undefined> {
                                        return await this.cache.get<PoolPairData['volume']>(`POOLPAIR_VOLUME_${id}`, async () => {
                                          const gatherAmount = async (interval: PoolSwapAggregatedInterval, count: number): Promise<number> => {
                                            const aggregated: Record<string, number> = {}
                                            const swaps = await this.poolSwapAggregatedMapper.query(`${id}-${interval as number}`, count)
                                    Severity: Minor
                                    Found in apps/whale-api/src/module.api/poolpair.service.ts - About 1 hr to fix

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

                                        async indexSwap (block: RawBlock, transaction: DfTxTransaction<any>, poolPairId: string, fromTokenId: number, fromAmount: BigNumber): Promise<void> {
                                          await this.poolSwapMapper.put({
                                            id: `${poolPairId}-${transaction.txn.txid}`,
                                            txid: transaction.txn.txid,
                                            txno: transaction.txnNo,
                                      Severity: Minor
                                      Found in apps/whale-api/src/module.indexer/model/dftx/pool.swap.ts - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language