DeFiCh/jellyfish

View on GitHub

Showing 137 of 388 total issues

File mapping.ts has 834 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { SmartBuffer } from 'smart-buffer'
import { readCompactSize, writeCompactSize } from '@defichain/jellyfish-buffer'
import { toBuffer, toOPCodes } from './_buffer'
import { OPCode, StaticCode } from './opcode'
import { OP_PUSHDATA } from './data'
Severity: Major
Found in packages/jellyfish-transaction/src/script/mapping.ts - About 2 days to fix

    OP_CODES has 60 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export const OP_CODES = {
      /**
       * Read SmartBuffer and create OPCode[] stack.
       *
       * Using P2WPKH redeem script as an example.
    Severity: Major
    Found in packages/jellyfish-transaction/src/script/mapping.ts - About 1 day to fix

      File Composer.ts has 416 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import BigNumber from 'bignumber.js'
      import { SmartBuffer } from 'smart-buffer'
      import { readCompactSize, writeCompactSize } from './CompactSize'
      import { readVarInt, writeVarInt } from './VarInt'
      import { getBitsFrom } from './BitMask'
      Severity: Minor
      Found in packages/jellyfish-buffer/src/Composer.ts - About 6 hrs to fix

        File poolpair.service.ts has 410 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { Inject, Injectable, NotFoundException } from '@nestjs/common'
        import { JsonRpcClient } from '@defichain/jellyfish-api-jsonrpc'
        import BigNumber from 'bignumber.js'
        import { PoolPairInfo } from '@defichain/jellyfish-api-core/dist/category/poolpair'
        import { SemaphoreCache } from '@defichain-apps/libs/caches'
        Severity: Minor
        Found in apps/whale-api/src/module.api/poolpair.service.ts - About 5 hrs to fix

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

            list (): TokenSetup[] {
              return [
                {
                  create: {
                    symbol: 'BTC',
          Severity: Major
          Found in apps/playground-api/src/setups/setup.token.ts - About 5 hrs to fix

            File TransactionSkipped.ts has 370 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { Network } from './Network'
            
            const MainNetSkippedTxIds = new Set([
              'ffcafd71820269ffe9cbecc12619154a3c5b272f1437d4e0242ff73d2bf09e4e',
              '4218d310d9a67b5e9a93d2a9ecf17bd70bda7a3670191efbc755b05c5fb8a6a4',
            Severity: Minor
            Found in packages/jellyfish-network/src/TransactionSkipped.ts - About 4 hrs to fix

              ComposableBuffer has 30 functions (exceeds 20 allowed). Consider refactoring.
              Open

              export abstract class ComposableBuffer<T> implements BufferComposer {
                protected readonly data: T
              
                abstract composers (data: T): BufferComposer[]
              
              
              Severity: Minor
              Found in packages/jellyfish-buffer/src/Composer.ts - About 3 hrs to fix

                Function getSwapsHistory has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                Open

                  async getSwapsHistory (
                    network: NetworkName,
                    limit: number,
                    nextToken: NextToken
                  ): Promise<{ swaps: LegacySubgraphSwap[], next: NextToken }> {
                Severity: Minor
                Found in apps/whale-api/src/module.api/legacy.subgraph.service.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

                File PoolPairController.ts has 315 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { Controller, DefaultValuePipe, Get, Inject, Logger, ParseIntPipe, Query } from '@nestjs/common'
                import { PoolPairData } from '@defichain/whale-api-client/dist/api/poolpairs'
                import { WhaleApiClientProvider } from '../providers/WhaleApiClientProvider'
                import { NetworkValidationPipe, SupportedNetwork } from '../pipes/NetworkValidationPipe'
                import BigNumber from 'bignumber.js'
                Severity: Minor
                Found in apps/legacy-api/src/controllers/PoolPairController.ts - About 3 hrs to fix

                  Loan has 29 functions (exceeds 20 allowed). Consider refactoring.
                  Open

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

                    File account.ts has 312 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import BigNumber from 'bignumber.js'
                    import { ApiClient } from '../.'
                    
                    /**
                     * Single account ID (CScript or address) or reserved words,
                    Severity: Minor
                    Found in packages/jellyfish-api-core/src/category/account.ts - About 3 hrs to fix

                      File stats.controller.ts has 304 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import { Controller, Get, Inject, NotFoundException } from '@nestjs/common'
                      import { BurnData, RewardDistributionData, StatsData, SupplyData } from '@defichain/whale-api-client/dist/api/stats'
                      import { SemaphoreCache } from '@defichain-apps/libs/caches'
                      import { JsonRpcClient } from '@defichain/jellyfish-api-jsonrpc'
                      import { BlockMapper } from '../module.model/block'
                      Severity: Minor
                      Found in apps/whale-api/src/module.api/stats.controller.ts - About 3 hrs to fix

                        File token.controller.spec.ts has 296 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import { Test, TestingModule } from '@nestjs/testing'
                        import { MasterNodeRegTestContainer } from '@defichain/testcontainers'
                        import { JsonRpcClient } from '@defichain/jellyfish-api-jsonrpc'
                        import { parseDATSymbol, TokenController } from './token.controller'
                        import { createPoolPair, createToken } from '@defichain/testing'
                        Severity: Minor
                        Found in apps/whale-api/src/module.api/token.controller.spec.ts - About 3 hrs to fix

                          File specifications.ts has 294 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import { Database, SortOrder } from '../database'
                          import { PartitionMapping, PartitionSortMapping } from './_model'
                          import { PARTITION_SORTS, PARTITIONS } from './_fixtures'
                          
                          /**
                          Severity: Minor
                          Found in apps/whale-api/src/module.database/database.spec/specifications.ts - About 3 hrs to fix

                            File blockchain.ts has 294 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import BigNumber from 'bignumber.js'
                            import { ApiClient } from '../.'
                            
                            /**
                             * Blockchain RPCs for DeFi Blockchain
                            Severity: Minor
                            Found in packages/jellyfish-api-core/src/category/blockchain.ts - About 3 hrs to fix

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

                                list (): SetCollateralToken[] {
                                  return [
                                    {
                                      token: 'DFI',
                                      fixedIntervalPriceId: 'DFI/USD',
                              Severity: Major
                              Found in apps/playground-api/src/setups/setup.loan.collateral.ts - About 2 hrs to fix

                                Function index has a Cognitive Complexity of 20 (exceeds 5 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 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

                                File dftx.ts has 280 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                import { SmartBuffer } from 'smart-buffer'
                                import { BufferComposer, ComposableBuffer } from '@defichain/jellyfish-buffer'
                                import {
                                  AccountToAccount,
                                  AccountToUtxos,
                                Severity: Minor
                                Found in packages/jellyfish-transaction/src/script/dftx/dftx.ts - About 2 hrs to fix

                                  File update.masternode.spec.ts has 272 lines of code (exceeds 250 allowed). Consider refactoring.
                                  Open

                                  import {
                                    createTestingApp,
                                    DelayedEunosPayaTestContainer,
                                    invalidateFromHeight,
                                    stopTestingApp,

                                    Function getSwapsHistory has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      async getSwapsHistory (
                                        network: NetworkName,
                                        limit: number,
                                        nextToken: NextToken
                                      ): Promise<{ swaps: LegacySubgraphSwap[], next: NextToken }> {
                                    Severity: Major
                                    Found in apps/whale-api/src/module.api/legacy.subgraph.service.ts - About 2 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language