DeFiCh/jellyfish

View on GitHub

Showing 137 of 388 total issues

Function setup has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function setup (): Promise<void> {
  accountAlice = await alice.generateAddress()
  accountBob = await bob.generateAddress()

  await alice.token.create({
Severity: Major
Found in apps/whale-api/src/module.api/consortium.controller.spec.ts - About 2 hrs to fix

    Function mapPoolPair has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async mapPoolPair (
        id: string,
        info: PoolPairInfo,
        totalLiquidityUsd?: BigNumber,
        apr?: PoolPairData['apr'],
    Severity: Major
    Found in apps/whale-api/src/module.api/poolpair.controller.ts - About 2 hrs to fix

      Function setupLoanToken has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function setupLoanToken (): Promise<void> {
        const oracleId = await testing.rpc.oracle.appointOracle(await testing.generateAddress(), [
          { token: 'DFI', currency: 'USD' },
          { token: 'LOAN', currency: 'USD' }
        ], { weightage: 1 })
      Severity: Major
      Found in apps/whale-api/src/module.api/address.controller.spec.ts - About 2 hrs to fix

        PoolPairService has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        @Injectable()
        export class PoolPairService {
          constructor (
            @Inject('NETWORK') protected readonly network: NetworkName,
            private readonly poolSwapPathfindingService: PoolSwapPathFindingService,
        Severity: Minor
        Found in apps/whale-api/src/module.api/poolpair.service.ts - About 2 hrs to fix

          File place.auction.bid.spec.ts has 258 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { NestFastifyApplication } from '@nestjs/platform-fastify'
          import { TestingGroup, Testing } from '@defichain/jellyfish-testing'
          import { MasterNodeRegTestContainer } from '@defichain/testcontainers'
          import { createTestingApp, stopTestingApp, waitForIndexedHeight } from '../../../e2e.module'
          import { VaultAuctionHistoryMapper } from '../../../module.model/vault.auction.batch.history'

            StatsController has 21 functions (exceeds 20 allowed). Consider refactoring.
            Open

            @Controller('/stats')
            export class StatsController {
              constructor (
                protected readonly blockMapper: BlockMapper,
                protected readonly priceTickerMapper: PriceTickerMapper,
            Severity: Minor
            Found in apps/whale-api/src/module.api/stats.controller.ts - About 2 hrs to fix

              Account has 21 functions (exceeds 20 allowed). Consider refactoring.
              Open

              export class Account {
                private readonly client: ApiClient
              
                constructor (client: ApiClient) {
                  this.client = client
              Severity: Minor
              Found in packages/jellyfish-api-core/src/category/account.ts - About 2 hrs to fix

                Blockchain has 21 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export class Blockchain {
                  private readonly client: ApiClient
                
                  constructor (client: ApiClient) {
                    this.client = client
                Severity: Minor
                Found in packages/jellyfish-api-core/src/category/blockchain.ts - About 2 hrs to fix

                  Function update has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async update (
                      updateMasternode: UpdateMasternode,
                      changeScript: Script,
                      collateral?: {
                        txid: string

                    File loan.ts has 255 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import { ApiClient, token } from '..'
                    import {
                      AuctionPagination,
                      CloseVault,
                      CreateVault,
                    Severity: Minor
                    Found in packages/jellyfish-api-core/src/category/loan.ts - About 2 hrs to fix

                      Function invalidate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                        async invalidate (block: RawBlock): Promise<void> {
                          const hidList = new Set<string>()
                      
                          for (const txn of block.tx) {
                            const isEvmTx = checkIfEvmTx(txn)
                      Severity: Minor
                      Found in apps/whale-api/src/module.indexer/model/script.aggregation.ts - About 2 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 checkSwapType has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                        public async checkSwapType (swap: PoolSwapData): Promise<SwapType | undefined> {
                          const dftx = await this.findCompositeSwapDfTx(swap.txid)
                          // if dftx is undefined, no composite swap is returned so check for swap
                          if (dftx === undefined || dftx.pools.length <= 1) {
                            const poolPairInfo = await this.deFiDCache.getPoolPairInfo(swap.poolPairId)
                      Severity: Minor
                      Found in apps/whale-api/src/module.api/poolpair.service.ts - About 2 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 index has a Cognitive Complexity of 15 (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.activity.ts - 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 listAccountHistory has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                        @Get('/history')
                        async listAccountHistory (
                          @Param('address') address: string,
                            @Query() query: PaginationQuery): Promise<ApiPagedResponse<AddressHistory>> {
                          if (address === 'mine') {
                      Severity: Minor
                      Found in apps/whale-api/src/module.api/address.controller.ts - 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 invalidate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                        async invalidate (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 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 accountToUtxos has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        async accountToUtxos (accountToUtxos: AccountToUtxos, destinationScript: Script): Promise<TransactionSegWit> {
                          if (accountToUtxos.balances.length !== 1) {
                            throw new TxnBuilderError(TxnBuilderErrorType.INVALID_ACCOUNT_TO_UTXOS_INPUT,
                              'Conversion output `accountToUtxos.balances` array length must be one'
                            )

                        Function listYieldFarming has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          @Get('listyieldfarming')
                          async listYieldFarming (
                            @Query('network', NetworkValidationPipe) network: SupportedNetwork = 'mainnet'
                          ): Promise<LegacyListYieldFarmingData> {
                            const api = this.whaleApiClientProvider.getClient(network)
                        Severity: Minor
                        Found in apps/legacy-api/src/controllers/PoolPairController.ts - About 1 hr to fix

                          Function fromAddress has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function fromAddress (address: string, network: NetworkName): DecodedAddress | undefined {
                            try {
                              const decodedBech32 = fromBech32(address)
                          
                              const p2wpkh = fromBech32P2WPKH(decodedBech32, network)
                          Severity: Minor
                          Found in packages/jellyfish-address/src/script/index.ts - About 1 hr to fix

                            Function index has a Cognitive Complexity of 14 (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/transaction.vin.ts - 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 index has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              async index (block: RawBlock): Promise<void> {
                                const records: Record<string, ScriptAggregation> = {}
                            
                                function findScriptAggregation (hex: string, type: string): ScriptAggregation {
                                  const hid = HexEncoder.asSHA256(hex)
                            Severity: Minor
                            Found in apps/whale-api/src/module.indexer/model/script.aggregation.ts - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language