DeFiCh/jellyfish

View on GitHub

Showing 137 of 388 total issues

Function after has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async after (): Promise<void> {
    await this.generate(1)

    // separate the dfip2203 setgov as
    // set dfip2203 in the list above will throw
Severity: Minor
Found in apps/playground-api/src/setups/setup.gov.ts - About 1 hr to fix

    Function run has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      @Interval(6000)
      async run (): Promise<void> {
        if (this.vaultId === undefined) {
          this.vaultId = await this.client.loan.createVault({
            loanSchemeId: 'MIN150',
    Severity: Minor
    Found in apps/playground-api/src/bots/VaultBot.ts - About 1 hr to fix

      Function shouldQueryPartitionSortPagination has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export async function shouldQueryPartitionSortPagination (database: Database): Promise<void> {
        const window43 = await database.query(PartitionSortMapping.index.composite_a, {
          partitionKey: '1000',
          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 listAccountHistory has 41 lines of code (exceeds 25 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

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

            Function put has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              async put<M extends Model> (mapping: ModelMapping<M>, model: M): Promise<void> {
                const indexes = Object.values(mapping.index)
                const persisted = await this.get(mapping, model.id) as M
            
                if (persisted !== undefined) {
            Severity: Minor
            Found in apps/whale-api/src/module.database/provider.level/level.database.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 getStats has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async getStats (jsonPath?: string): Promise<LegacyStats | any> {
                const stats: StatsData = await this.api.stats.get()
            
                // Fire async requests at the same time and await results
                const [
            Severity: Minor
            Found in apps/legacy-api/src/controllers/stats/LegacyStatsProvider.ts - About 1 hr to fix

              Function shouldQueryWithAscDesc has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

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

                  Function fromScript has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function fromScript (script: Script, network: NetworkName): DecodedAddress | undefined {
                    const p2wpkh = fromScriptP2WPKH(script, network)
                    if (p2wpkh !== undefined) {
                      return {
                        type: AddressType.P2WPKH,
                  Severity: Minor
                  Found in packages/jellyfish-address/src/script/index.ts - About 1 hr to fix

                    Function getCmd has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      protected getCmd (opts: StartOptions): string[] {
                        const cmds = [...super.getCmd(opts),
                          '-regtest=1',
                          '-jellyfish_regtest=1',
                          '-txnotokens=0',
                    Severity: Minor
                    Found in packages/testcontainers/src/containers/RegTestContainer/index.ts - About 1 hr to fix

                      Function getDfTxTransactions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                        private getDfTxTransactions (block: RawBlock): Array<DfTxTransaction<any>> {
                          const transactions: Array<DfTxTransaction<any>> = []
                      
                          for (let i = 0; i < block.tx.length; i++) {
                            const txn = block.tx[i]
                      Severity: Minor
                      Found in apps/whale-api/src/module.indexer/model/dftx.indexer.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 12 (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.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 parse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                        async parse (txn: defid.Transaction): Promise<string[]> {
                          const result: string[] = []
                      
                          for (const vin of txn.vin) {
                            result.push(...(await this.utxo.extractFromVin(vin)))
                      Severity: Minor
                      Found in packages/rich-list-core/src/saga/AddressParser/index.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 createDeFiTx has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        async createDeFiTx (
                          opDeFiTx: OP_DEFI_TX,
                          changeScript: Script,
                          outValue: BigNumber = new BigNumber('0'),
                          utxos: Prevout[] = []
                      Severity: Minor
                      Found in packages/jellyfish-transaction-builder/src/txn/txn_builder.ts - About 1 hr to fix

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

                          Function Home has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export default function Home (): JSX.Element {
                            const siteConfig = useDocusaurusContext().siteConfig
                          
                            return (
                              <Layout description={siteConfig.tagline}>
                          Severity: Minor
                          Found in website/src/pages/index.tsx - About 1 hr to fix

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

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

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

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

                                  list (): CreateLoanScheme[] {
                                    return [
                                      {
                                        id: 'MIN150',
                                        interestRate: new BigNumber('5'),
                                Severity: Minor
                                Found in apps/playground-api/src/setups/setup.loan.scheme.ts - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language