DeFiCh/jellyfish

View on GitHub

Showing 358 of 388 total issues

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

async function mintTokens (testing: Testing, symbol: string, amount: number): Promise<void> {
  await testing.token.mint({
    symbol: symbol,
    amount: amount
  })
apps/whale-api/src/module.indexer/model/dftx/place.auction.bid.spec.ts on lines 232..238

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

Avoid too many return statements within this function.
Open

    return this.withAlive('model', details)
Severity: Major
Found in apps/whale-api/src/module.model/_model.probes.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return
    Severity: Major
    Found in apps/whale-api/src/module.api/rawtx.controller.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return await this.getTotalLiquidityUsdByBestPath(info)
      Severity: Major
      Found in apps/whale-api/src/module.api/poolpair.service.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return true
        Severity: Major
        Found in apps/whale-api/src/module.indexer/model/dftx/active.price.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return
          Severity: Major
          Found in apps/whale-api/src/module.api/rawtx.controller.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

              return undefined
            Severity: Major
            Found in packages/jellyfish-address/src/script/index.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return
              Severity: Major
              Found in apps/whale-api/src/module.api/rawtx.controller.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return info.reserveB.multipliedBy(2).multipliedBy(USDT_PER_DFI)
                Severity: Major
                Found in apps/whale-api/src/module.api/poolpair.service.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                    return undefined
                  Severity: Major
                  Found in packages/jellyfish-address/src/script/index.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return true
                    Severity: Major
                    Found in apps/whale-api/src/module.indexer/model/dftx/active.price.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return dfiPair.reserveB.div(dfiPair.reserveA).times(usdPerDFI)
                      Severity: Major
                      Found in apps/whale-api/src/module.api/poolpair.service.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return swap
                        Severity: Major
                        Found in apps/whale-api/src/module.api/legacy.subgraph.service.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              return loanEmission.multipliedBy(split)
                                .times(60 * 60 * 24 / 30) // 30 seconds = 1 block
                                .times(365) // 1 year
                                .times(dfiPriceUSD)
                          Severity: Major
                          Found in apps/whale-api/src/module.api/poolpair.service.ts - About 30 mins to fix

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

                              await setMemberInfo(idETH, [{
                                id: '01',
                                name: 'alice',
                                ownerAddress: accountAlice,
                                backingId: '',
                            Severity: Minor
                            Found in apps/whale-api/src/module.api/consortium.controller.spec.ts and 1 other location - About 30 mins to fix
                            apps/whale-api/src/module.api/consortium.controller.spec.ts on lines 92..106

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

                            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

                              await setMemberInfo(idBTC, [{
                                id: '01',
                                name: 'alice',
                                ownerAddress: accountAlice,
                                backingId: 'abc',
                            Severity: Minor
                            Found in apps/whale-api/src/module.api/consortium.controller.spec.ts and 1 other location - About 30 mins to fix
                            apps/whale-api/src/module.api/consortium.controller.spec.ts on lines 108..122

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

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

                              async listAuction (query: PaginationQuery): Promise<ApiPagedResponse<LoanVaultLiquidated>> {
                                const next = query.next !== undefined ? String(query.next) : undefined
                                const size = query.size > 30 ? 30 : query.size
                                let pagination: AuctionPagination
                            
                            
                            Severity: Minor
                            Found in apps/whale-api/src/module.api/loan.vault.service.ts - About 25 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 createPoolPair has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                              async createPoolPair (options: TestingPoolPairCreateRequest): Promise<poolpair.PoolPairInfo> {
                                if (options.a.symbol !== 'DFI') {
                                  await this.testing.token.create({ symbol: options.a.symbol })
                                }
                                if (options.b.symbol !== 'DFI') {
                            Severity: Minor
                            Found in packages/jellyfish-testing/src/fixture.ts - About 25 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 toObject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                              toObject (): any {
                                function toObject (value: any): any {
                                  if (value instanceof ComposableBuffer) {
                                    return value.toObject()
                                  }
                            Severity: Minor
                            Found in packages/jellyfish-buffer/src/Composer.ts - About 25 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

                            Severity
                            Category
                            Status
                            Source
                            Language