DeFiCh/jellyfish

View on GitHub

Showing 358 of 388 total issues

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

  async getVins (txid: string, size: number = 30, next?: string): Promise<ApiPagedResponse<TransactionVin>> {
    return await this.client.requestList('GET', `transactions/${txid}/vins`, size, next)
  }
Severity: Major
Found in packages/whale-api-client/src/api/transactions.ts and 5 other locations - About 40 mins to fix
packages/whale-api-client/src/api/address.ts on lines 32..34
packages/whale-api-client/src/api/address.ts on lines 65..67
packages/whale-api-client/src/api/address.ts on lines 89..91
packages/whale-api-client/src/api/poolpairs.ts on lines 40..42
packages/whale-api-client/src/api/poolpairs.ts on lines 52..54

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 78.

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 6 locations. Consider refactoring.
Open

  async listAccountHistory (address: string, size: number = 30, next?: string): Promise<ApiPagedResponse<AddressHistory>> {
    return await this.client.requestList('GET', `address/${address}/history`, size, next)
  }
Severity: Major
Found in packages/whale-api-client/src/api/address.ts and 5 other locations - About 40 mins to fix
packages/whale-api-client/src/api/address.ts on lines 65..67
packages/whale-api-client/src/api/address.ts on lines 89..91
packages/whale-api-client/src/api/poolpairs.ts on lines 40..42
packages/whale-api-client/src/api/poolpairs.ts on lines 52..54
packages/whale-api-client/src/api/transactions.ts on lines 26..28

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 78.

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 6 locations. Consider refactoring.
Open

  async listTransaction (address: string, size: number = 30, next?: string): Promise<ApiPagedResponse<AddressActivity>> {
    return await this.client.requestList('GET', `address/${address}/transactions`, size, next)
  }
Severity: Major
Found in packages/whale-api-client/src/api/address.ts and 5 other locations - About 40 mins to fix
packages/whale-api-client/src/api/address.ts on lines 32..34
packages/whale-api-client/src/api/address.ts on lines 65..67
packages/whale-api-client/src/api/poolpairs.ts on lines 40..42
packages/whale-api-client/src/api/poolpairs.ts on lines 52..54
packages/whale-api-client/src/api/transactions.ts on lines 26..28

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 78.

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 put has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  async function put (hex: string, height: number, type: ScriptActivityType, txid: string, n: number): Promise<void> {
Severity: Minor
Found in apps/whale-api/src/module.model/script.activity.spec.ts - About 35 mins to fix

    Function placeAuctionBid has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    async function placeAuctionBid (testing: Testing, vaultId: string, index: number, addr: string, tokenAmt: string): Promise<void> {
    Severity: Minor
    Found in apps/whale-api/src/module.indexer/model/dftx/place.auction.bid.spec.ts - About 35 mins to fix

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

      function isBech32P2WPKH (decoded: DecodedBech32, network: NetworkName): boolean {
        return decoded.hrp === getNetwork(network).bech32.hrp &&
          decoded.version === 0x00 &&
          decoded.buffer.length === 20
      }
      Severity: Minor
      Found in packages/jellyfish-address/src/script/P2WPKH.ts and 1 other location - About 35 mins to fix
      packages/jellyfish-address/src/script/P2WSH.ts on lines 22..26

      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 77.

      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 requestData<T> (method: ApiMethod, path: string, object?: any): Promise<T> {
          const response = await this.requestAsApiResponse<T>(method, path, object)
          return response.data
        }
      Severity: Minor
      Found in packages/ocean-api-client/src/OceanApiClient.ts and 1 other location - About 35 mins to fix
      packages/whale-api-client/src/whale.api.client.ts on lines 156..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 77.

      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 requestData<T> (method: Method, path: string, object?: any): Promise<T> {
          const response = await this.requestAsApiResponse<T>(method, path, object)
          return response.data
        }
      Severity: Minor
      Found in packages/whale-api-client/src/whale.api.client.ts and 1 other location - About 35 mins to fix
      packages/ocean-api-client/src/OceanApiClient.ts on lines 106..109

      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 77.

      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

      function isBech32P2WSH (decoded: DecodedBech32, network: NetworkName): boolean {
        return decoded.hrp === getNetwork(network).bech32.hrp &&
          decoded.version === 0x00 &&
          decoded.buffer.length === 32
      }
      Severity: Minor
      Found in packages/jellyfish-address/src/script/P2WSH.ts and 1 other location - About 35 mins to fix
      packages/jellyfish-address/src/script/P2WPKH.ts on lines 22..26

      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 77.

      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 findAmountSymbol has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        private findAmountSymbol (history: AccountHistory, outgoing: boolean): LegacySubgraphSwapFromTo | undefined {
          for (const amount of history.amounts ?? []) {
            const [value, symbol] = amount.split('@')
            const isNegative = value.startsWith('-')
      
      
      Severity: Minor
      Found in apps/whale-api/src/module.api/legacy.subgraph.service.ts - About 35 mins 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 indexBlockStart has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        async indexBlockStart (block: RawBlock): Promise<void> {
          const poolPairs = await this.getPoolPairs(block)
      
          for (const interval of AggregatedIntervals) {
            for (const poolPair of poolPairs) {
      Severity: Minor
      Found in apps/whale-api/src/module.indexer/model/dftx/pool.swap.aggregated.ts - About 35 mins 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 getDexFeesPct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        public async getDexFeesPct (poolPair: PoolPairInfo, fromToken: string, toToken: string): Promise<EstimatedDexFeesInPct | undefined> {
          const { dexFeeInPctTokenA, dexFeeOutPctTokenA, dexFeeInPctTokenB, dexFeeOutPctTokenB } = poolPair
          const tokenADirection = poolPair.idTokenA === fromToken ? 'in' : 'out'
          const tokenBDirection = poolPair.idTokenB === toToken ? 'out' : 'in'
      
      
      Severity: Minor
      Found in apps/whale-api/src/module.api/poolpair.fees.service.ts - About 35 mins 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 listSwaps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        @Get('listswaps')
        async listSwaps (
          @Query('network', NetworkValidationPipe) network: SupportedNetwork = 'mainnet'
        ): Promise<LegacyListSwapsResponse> {
          const api = this.whaleApiClientProvider.getClient(network)
      Severity: Minor
      Found in apps/legacy-api/src/controllers/PoolPairController.ts - About 35 mins 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 listSwaps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        @Get('listswaps')
        async listSwaps (
          @Query('network', NetworkValidationPipe) network: SupportedNetwork = 'mainnet'
        ): Promise<LegacyListSwapsResponse> {
          const api = this.whaleApiClientProvider.getClient(network)
      Severity: Minor
      Found in apps/legacy-api/src/controllers/PoolPairController.ts - About 35 mins 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 waitForDeFiD has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        async waitForDeFiD (timeout = 45000): Promise<void> {
          const expiredAt = Date.now() + timeout
      
          while (expiredAt > Date.now()) {
            try {
      Severity: Minor
      Found in apps/playground-api/src/modules/PlaygroundModule.ts - About 35 mins 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 cycle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        @Interval(1000)
        async cycle (): Promise<void> {
          if (!this.running) {
            return
          }
      Severity: Minor
      Found in apps/whale-api/src/module.indexer/rpc.block.provider.ts - About 35 mins 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 findPoolSwapFromTo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      function findPoolSwapFromTo (history: AccountHistory | undefined, from: boolean, displaySymbol: string): PoolSwapFromToData | undefined {
        if (history?.amounts === undefined) {
          return undefined
        }
      
      
      Severity: Minor
      Found in apps/whale-api/src/module.api/poolpair.service.ts - About 35 mins 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

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

        async getTransactions (hash: string, size: number = 30, next?: string): Promise<ApiPagedResponse<Transaction>> {
          return await this.client.requestList('GET', `blocks/${hash}/transactions`, size, next)
        }
      Severity: Minor
      Found in packages/whale-api-client/src/api/blocks.ts and 2 other locations - About 35 mins to fix
      packages/whale-api-client/src/api/address.ts on lines 101..103
      packages/whale-api-client/src/api/transactions.ts on lines 38..40

      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 76.

      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 function dfi (testing: Testing, address: string, amount: number): Promise<void> {
        await testing.token.dfi({
          address: address,
          amount: amount
        })
      apps/whale-api/src/module.indexer/model/dftx/place.auction.bid.spec.ts on lines 246..252

      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 76.

      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

        async getVouts (txid: string, size: number = 30, next?: string): Promise<ApiPagedResponse<TransactionVout>> {
          return await this.client.requestList('GET', `transactions/${txid}/vouts`, size, next)
        }
      Severity: Minor
      Found in packages/whale-api-client/src/api/transactions.ts and 2 other locations - About 35 mins to fix
      packages/whale-api-client/src/api/address.ts on lines 101..103
      packages/whale-api-client/src/api/blocks.ts on lines 32..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 76.

      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

      Severity
      Category
      Status
      Source
      Language