DeFiCh/jellyfish

View on GitHub

Showing 358 of 388 total issues

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

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      export const TestNet: Network = {
        name: 'testnet',
        bech32: {
          hrp: 'tf'
        },
      Severity: Major
      Found in packages/jellyfish-network/src/Network.ts and 2 other locations - About 1 hr to fix
      packages/jellyfish-network/src/Network.ts on lines 61..78
      packages/jellyfish-network/src/Network.ts on lines 117..134

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 89.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      export const RegTest: Network = {
        name: 'regtest',
        bech32: {
          hrp: 'bcrt'
        },
      Severity: Major
      Found in packages/jellyfish-network/src/Network.ts and 2 other locations - About 1 hr to fix
      packages/jellyfish-network/src/Network.ts on lines 61..78
      packages/jellyfish-network/src/Network.ts on lines 83..100

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 89.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      export const MainNet: Network = {
        name: 'mainnet',
        bech32: {
          hrp: 'df'
        },
      Severity: Major
      Found in packages/jellyfish-network/src/Network.ts and 2 other locations - About 1 hr to fix
      packages/jellyfish-network/src/Network.ts on lines 83..100
      packages/jellyfish-network/src/Network.ts on lines 117..134

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 89.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        async getLatest (): Promise<MasternodeStats | undefined> {
          const stats = await this.database.query(MasternodeStatsMapping.index.height, {
            order: SortOrder.DESC,
            limit: 1
          })
      Severity: Major
      Found in apps/whale-api/src/module.model/masternode.stats.ts and 1 other location - About 1 hr to fix
      apps/whale-api/src/module.model/block.ts on lines 31..37

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 89.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        async getHighest (): Promise<Block | undefined> {
          const blocks = await this.database.query(BlockMapping.index.height, {
            order: SortOrder.DESC,
            limit: 1
          })
      Severity: Major
      Found in apps/whale-api/src/module.model/block.ts and 1 other location - About 1 hr to fix
      apps/whale-api/src/module.model/masternode.stats.ts on lines 24..30

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 89.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              if (isIndexModified(index, persisted, model)) {
                const subIndex = this.subIndex(index, index.partition.key(persisted))
                const key = index.sort !== undefined ? index.sort.key(persisted) : index.partition.key(persisted)
                await subIndex.del(key)
              }
      apps/whale-api/src/module.database/provider.level/level.database.ts on lines 179..183

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 89.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        @Post('/:method')
        @HttpCode(200)
        async call (@Param('method', MethodBlacklist) method: string, @Body() call?: CallRequest): Promise<any> {
          return await this.client.call(method, call?.params ?? [], 'lossless')
        }
      Severity: Major
      Found in apps/playground-api/src/controllers/RpcController.ts and 1 other location - About 1 hr to fix
      apps/whale-api/src/module.api/rpc.controller.ts on lines 98..102

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 89.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          for (const index of Object.values(mapping.index)) {
            const subIndex = this.subIndex(index, index.partition.key(model))
            const key = index.sort !== undefined ? index.sort.key(model) : index.partition.key(model)
            await subIndex.del(key)
          }
      apps/whale-api/src/module.database/provider.level/level.database.ts on lines 155..159

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 89.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        @Post('/:method')
        @HttpCode(200)
        async call (@Param('method', MethodWhitelist) method: string, @Body() callDto?: JSONRPCParams): Promise<any> {
          return await this.client.call(method, callDto?.params ?? [], 'lossless')
        }
      Severity: Major
      Found in apps/whale-api/src/module.api/rpc.controller.ts and 1 other location - About 1 hr to fix
      apps/playground-api/src/controllers/RpcController.ts on lines 79..83

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 89.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        export function fromBech32P2WPKH (decoded: DecodedBech32, network: NetworkName): Script | undefined {
          if (!isBech32P2WPKH(decoded, network)) {
            return undefined
          }
        
        
        Severity: Major
        Found in packages/jellyfish-address/src/script/P2WPKH.ts and 1 other location - About 1 hr to fix
        packages/jellyfish-address/src/script/P2WSH.ts on lines 28..39

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 88.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          async queryByBlockHash (hash: string, limit: number, gt?: number): Promise<Transaction[]> {
            return await this.database.query(TransactionMapping.index.block_order, {
              partitionKey: hash,
              limit: limit,
              order: SortOrder.ASC,
        Severity: Major
        Found in apps/whale-api/src/module.model/transaction.ts and 1 other location - About 1 hr to fix
        apps/whale-api/src/module.model/script.aggregation.ts on lines 37..44

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 88.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        export function fromBech32P2WSH (decoded: DecodedBech32, network: NetworkName): Script | undefined {
          if (!isBech32P2WSH(decoded, network)) {
            return undefined
          }
        
        
        Severity: Major
        Found in packages/jellyfish-address/src/script/P2WSH.ts and 1 other location - About 1 hr to fix
        packages/jellyfish-address/src/script/P2WPKH.ts on lines 28..39

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 88.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          async query (hid: string, limit: number, lt?: number): Promise<ScriptAggregation[]> {
            return await this.database.query(ScriptAggregationMapping.index.hid_height, {
              partitionKey: hid,
              limit: limit,
              order: SortOrder.DESC,
        Severity: Major
        Found in apps/whale-api/src/module.model/script.aggregation.ts and 1 other location - About 1 hr to fix
        apps/whale-api/src/module.model/transaction.ts on lines 27..34

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 88.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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
                Severity
                Category
                Status
                Source
                Language